X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fsdl%2Fmain.c;h=3165e314001dd32ccb042365c40fa999477a2f55;hb=1442212ba0ff24b868dd29facc2278a26c8a9a18;hp=09645aafcd22c1368dd3f116c4537e4416ba2cc8;hpb=1723e332319e7732473814dfc168a13d0bafccb4;p=dosdemo diff --git a/src/sdl/main.c b/src/sdl/main.c index 09645aa..3165e31 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -4,12 +4,13 @@ #include #include "demo.h" #include "tinyfps.h" +#include "timer.h" +#include "cfgopt.h" static void handle_event(SDL_Event *ev); static void toggle_fullscreen(void); static int quit; -static long start_time; static SDL_Surface *fbsurf; static int fbscale = 2; @@ -52,7 +53,7 @@ int main(int argc, char **argv) SDL_Quit(); return 1; } - start_time = SDL_GetTicks(); + reset_timer(); while(!quit) { SDL_Event ev; @@ -61,7 +62,7 @@ int main(int argc, char **argv) if(quit) goto break_evloop; } - time_msec = SDL_GetTicks() - start_time; + time_msec = get_msec(); demo_draw(); drawFps(fb_pixels); @@ -103,9 +104,19 @@ void demo_quit(void) quit = 1; } +void wait_vsync(void) +{ + unsigned long start = SDL_GetTicks(); + unsigned long until = (start | 0xf) + 1; + while(SDL_GetTicks() <= until); +} + void swap_buffers(void *pixels) { /* do nothing, all pointers point to the same buffer */ + if(opt.vsync) { + wait_vsync(); + } } static void handle_event(SDL_Event *ev) @@ -117,10 +128,9 @@ static void handle_event(SDL_Event *ev) case SDL_KEYDOWN: case SDL_KEYUP: - if(ev->key.keysym.sym == 'f') { - if(ev->key.state == SDL_PRESSED) { - toggle_fullscreen(); - } + if(ev->key.keysym.sym == SDLK_RETURN && (SDL_GetModState() & KMOD_ALT) && + ev->key.state == SDL_PRESSED) { + toggle_fullscreen(); break; } demo_keyboard(ev->key.keysym.sym, ev->key.state == SDL_PRESSED ? 1 : 0);