nesemu/main.c

63 lines
1.1 KiB
C
Raw Normal View History

2023-09-21 23:53:14 -04:00
/*
* =====================================================================================
*
* Filename: main.c
*
* Description: Emulator main loop
*
* Version: 1.0
* Created: 2023-09-21 09:50:34 PM
* Revision: none
* Compiler: gcc
*
* Author: William Nolin,
* Organization:
*
* =====================================================================================
*/
#include <stdlib.h>
2024-04-30 12:28:43 -04:00
#include "log.h"
2023-09-21 23:53:14 -04:00
2023-12-03 00:27:07 -05:00
#include "include/rom.h"
2024-01-06 14:27:09 -05:00
#include "include/system.h"
2024-05-17 00:33:37 -04:00
#include "gui.h"
2023-09-21 23:53:14 -04:00
2024-01-07 16:20:37 -05:00
int main() {
2024-07-12 18:52:54 -04:00
char *rom_path = "./test_roms/dk_japan.nes";
2024-01-07 16:20:37 -05:00
log_set_level(LOG_INFO);
2023-12-23 16:35:23 -05:00
2024-06-16 19:22:40 -04:00
if (!gui_init()) {
return EXIT_FAILURE;
}
2024-05-17 00:33:37 -04:00
system_init();
2024-01-07 16:20:37 -05:00
2024-05-06 20:23:44 -04:00
if (!rom_load(rom_path)) {
system_uninit();
2024-06-16 19:22:40 -04:00
gui_uninit();
2024-01-06 14:27:09 -05:00
return EXIT_FAILURE;
}
2023-09-21 23:53:14 -04:00
2024-06-16 19:22:40 -04:00
gui_post_sysinit();
2024-05-06 20:23:44 -04:00
system_start();
2024-05-17 00:33:37 -04:00
bool stop = false;
while (!stop) {
if (gui_input() < 0) {
stop = true;
}
system_next_frame();
gui_render();
2024-06-16 19:22:40 -04:00
2024-05-17 00:33:37 -04:00
gui_present();
2024-05-17 13:16:21 -04:00
gui_delay();
2024-05-17 00:33:37 -04:00
}
2024-01-07 16:20:37 -05:00
2024-05-06 20:23:44 -04:00
system_uninit();
2024-05-23 22:44:52 -04:00
rom_unload();
2024-05-17 00:33:37 -04:00
gui_uninit();
2024-01-16 15:46:22 -05:00
return EXIT_SUCCESS;
2024-01-06 14:27:09 -05:00
}