SayoriOS
0.3.3
main.c
1
#include "lib/stdio.h"
2
#include "timer.h"
3
#include "rom.h"
4
#include "mem.h"
5
#include "cpu.h"
6
#include "lcd.h"
7
#include "sdl.h"
8
#include "drv/input/keyboard.h"
9
#include "io/tty.h"
10
11
int
gb_main(
int
argc,
char
*argv[]) {
12
int
r;
13
const
char
usage[] =
"Usage: %s <rom>\n"
;
14
15
if
(argc != 2) {
16
printf(usage, argv[0]);
17
return
0;
18
}
19
20
r = rom_load(argv[1]);
21
if
(!r)
22
return
0;
23
24
printf(
"ROM OK!\n"
);
25
26
r = lcd_init();
27
if
(r)
28
return
0;
29
30
printf(
"LCD OK!\n"
);
31
32
mem_init();
33
printf(
"Mem OK!\n"
);
34
35
cpu_init();
36
printf(
"CPU OK!\n"
);
37
38
keyboardctl(KEYBOARD_ECHO,
false
);
39
set_cursor_enabled(
false
);
40
41
r = 0;
42
43
while
(1)
44
{
45
int
now;
46
47
if
(!cpu_cycle())
48
break
;
49
50
now = cpu_get_cycles();
51
52
while
(now != r)
53
{
54
int
i;
55
56
for
(i = 0; i < 4; i++)
57
if
(!lcd_cycle())
58
goto
out;
59
60
r++;
61
}
62
63
timer_cycle();
64
65
r = now;
66
}
67
out:
68
sdl_quit();
69
70
keyboardctl(KEYBOARD_ECHO,
true
);
71
set_cursor_enabled(
true
);
72
73
return
0;
74
}
kernel
src
ports
gameboy
main.c
Документация по SayoriOS. Последние изменения: Вс 8 Дек 2024 11:15:22. Создано системой
1.9.1