-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
95 lines (74 loc) · 1.4 KB
/
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <stdlib.h>
#include <time.h>
#include <timer.h>
#include <string.h>
#include <kernel.h>
#include <graph.h>
#include "system.h"
#include "game.h"
#include "resources.h"
#include "maths.h"
static volatile uint32_t vblank;
int vblank_handler()
{
++vblank;
return 0;
}
int main(int argc, char **argv)
{
StartTimerSystemTime();
srand(time(NULL));
bool interlaced = true;
bool ntsc = true;
bool debug = true;
/*for (int i = 0; i < argc; i++) {
LOG_DEBUG("arg%u: %s", i, argv[i]);
switch(*(uint16_t *)argv[i]) {
case 'p-':
interlaced = false;
break;
case 'P-':
ntsc = false;
break;
case 'D-':
debug = true;
break;
}
}*/
if (debug) {
assDebugInit();
}
// print early welcome message
LOG_DEBUG("Assteroids PS2 remastered director's cut version");
assGsInit(interlaced, ntsc);
assInputInit();
assRestartLevel();
graph_add_vsync_handler(vblank_handler);
LOG_DEBUG("Entering main loop");
io_t io;
float tick = 0.0f;
uint32_t last_vblank = 0;
memset(&io, 0, sizeof(io));
while (1) {
assUpdateIO(&io);
if (io.exit) {
break;
}
assGsBeginFrame();
assGsClear(&g_color_black);
assGameUpdate(&io);
assGameDrawOsd(&io);
uint32_t qwords = assGsEndFrame();
while (1) {
uint32_t vb = vblank;
if (vb != last_vblank) {
last_vblank = vb;
break;
}
}
assGsWait();
assGsExecute();
}
LOG_DEBUG("Main loop exit");
return 0;
}