From f5e1ad6aa532d3dd68b23eb6488f4f5c40858805 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sat, 16 Jan 2010 08:56:15 +0000 Subject: [PATCH] Same delay as Frodo --- main.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 09d0d90..a077fd4 100644 --- a/main.cpp +++ b/main.cpp @@ -8,11 +8,16 @@ SDL_Surface *screen; C64 *TheC64; +#define MS_PER_FRAME 28 + static void run(void) { + Uint32 last_frame = SDL_GetTicks(); + while(1) { SDL_Event ev; + Uint32 now = SDL_GetTicks(); while (SDL_PollEvent(&ev)) { if (ev.type == SDL_QUIT) @@ -24,7 +29,9 @@ static void run(void) Gui::gui->draw(screen); SDL_Flip(screen); - SDL_Delay(50); + + if ( (now - last_frame) < MS_PER_FRAME) + SDL_Delay( MS_PER_FRAME - (now - last_frame)); } }