-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.c
67 lines (49 loc) · 745 Bytes
/
main.c
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include "timer.h"
#include "rom.h"
#include "mem.h"
#include "cpu.h"
#include "lcd.h"
#include "sdl.h"
int main(int argc, char *argv[])
{
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;
printf("ROM OK!\n");
r = lcd_init();
if(r)
return 0;
printf("LCD OK!\n");
mem_init();
printf("Mem OK!\n");
cpu_init();
printf("CPU OK!\n");
r = 0;
while(1)
{
int now;
if(!cpu_cycle())
break;
now = cpu_get_cycles();
while(now != r)
{
int i;
for(i = 0; i < 4; i++)
if(!lcd_cycle())
goto out;
r++;
}
timer_cycle();
r = now;
}
out:
sdl_quit();
return 0;
}