forked from lualiliu/esp32-gameboy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
44 lines (32 loc) · 611 Bytes
/
main.cpp
File metadata and controls
44 lines (32 loc) · 611 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include "cpu.h"
#include "lcd.h"
#include "mem.h"
#include "rom.h"
#include "sdl.h"
#include "timer.h"
int main(int argc, char *argv[]) {
#ifdef BUILD_FOR_PC
int r;
const char usage[] = "Usage: %s <rom>\n";
if (argc != 2) {
fprintf(stderr, usage, argv[0]);
return 0;
}
r = rom_load(argv[1]);
if (!r) return 0;
sdl_init();
printf("ROM OK!\n");
gameboy_mem_init();
printf("Mem OK!\n");
cpu_init();
printf("CPU OK!\n");
while (1) {
if (!cpu_cycle()) break;
if (!lcd_cycle()) break;
timer_cycle();
}
sdl_quit();
#endif
return 0;
}