mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
Simplify the main loop
This commit is contained in:
+17
-26
@@ -187,41 +187,32 @@ void nact_main() {
|
||||
reset_counter_high(SYSTEMCOUNTER_MSEC, 1, 0);
|
||||
reset_counter_high(SYSTEMCOUNTER_MAINLOOP, MAINLOOP_EVENTCHECK_INTERVAL, 0);
|
||||
int cnt = 0;
|
||||
#ifdef ENABLE_SDL
|
||||
|
||||
nact->frame_count = 0;
|
||||
nact->cmd_count = 0;
|
||||
nact->wait_vsync = FALSE;
|
||||
#endif
|
||||
|
||||
while (!nact->is_quit) {
|
||||
DEBUG_MESSAGE("%d:%x\n", sl_getPage(), sl_getIndex());
|
||||
if (!nact->popupmenu_opened) {
|
||||
int c0 = checkMessage();
|
||||
check_command(c0);
|
||||
#ifdef ENABLE_SDL
|
||||
nact->cmd_count++;
|
||||
#endif
|
||||
}
|
||||
for (int cnt = 0; !nact->wait_vsync && cnt < 10000; cnt++) {
|
||||
DEBUG_MESSAGE("%d:%x\n", sl_getPage(), sl_getIndex());
|
||||
if (!nact->popupmenu_opened) {
|
||||
int c0 = checkMessage();
|
||||
check_command(c0);
|
||||
nact->cmd_count++;
|
||||
}
|
||||
#ifndef __EMSCRIPTEN__
|
||||
if (!nact->is_message_locked) {
|
||||
if (get_high_counter(SYSTEMCOUNTER_MAINLOOP)) {
|
||||
sys_getInputInfo();
|
||||
reset_counter_high(SYSTEMCOUNTER_MAINLOOP, MAINLOOP_EVENTCHECK_INTERVAL, 0);
|
||||
if (!nact->is_message_locked) {
|
||||
if (get_high_counter(SYSTEMCOUNTER_MAINLOOP)) {
|
||||
sys_getInputInfo();
|
||||
reset_counter_high(SYSTEMCOUNTER_MAINLOOP, MAINLOOP_EVENTCHECK_INTERVAL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (++cnt == 10000) {
|
||||
Sleep(1); /* XXXX */
|
||||
cnt = 0;
|
||||
nact->callback();
|
||||
}
|
||||
nact->callback();
|
||||
#ifdef ENABLE_SDL
|
||||
if (nact->wait_vsync) {
|
||||
nact->frame_count++;
|
||||
nact->wait_vsync = FALSE;
|
||||
WaitVsync();
|
||||
}
|
||||
#endif
|
||||
WaitVsync();
|
||||
nact->frame_count++;
|
||||
nact->wait_vsync = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,11 +142,9 @@ typedef struct {
|
||||
char *alk[10];
|
||||
} files;
|
||||
|
||||
#ifdef ENABLE_SDL
|
||||
int frame_count;
|
||||
int cmd_count;
|
||||
boolean wait_vsync;
|
||||
#endif
|
||||
|
||||
} NACTINFO;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user