From db63673f22dc3107dfdb431c2881235039285e07 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 27 Jun 2018 23:16:24 +0200 Subject: [PATCH] added delay function that regularly updates the screen (to redraw toons) --- src/libgame/sdl.c | 29 +++++++++++++++-------------- src/libgame/sdl.h | 2 ++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 47ad2623..eee5d59a 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -245,6 +245,20 @@ static void UpdateScreen_WithoutFrameDelay(SDL_Rect *rect) UpdateScreenExt(rect, FALSE); } +void Delay_WithScreenUpdates(unsigned int delay) +{ + unsigned int time_current = SDL_GetTicks(); + unsigned int time_delayed = time_current + delay; + + while (time_current < time_delayed) + { + // updating the screen contains waiting for frame delay (non-busy) + UpdateScreen_WithFrameDelay(NULL); + + time_current = SDL_GetTicks(); + } +} + static void SDLSetWindowIcon(char *basename) { /* (setting the window icon on Mac OS X would replace the high-quality @@ -1389,20 +1403,7 @@ void SDLFadeRectangle(int x, int y, int width, int height, } if (post_delay > 0) - { - unsigned int time_post_delay; - - time_current = SDL_GetTicks(); - time_post_delay = time_current + post_delay; - - while (time_current < time_post_delay) - { - // updating the screen contains waiting for frame delay (non-busy) - UpdateScreen_WithFrameDelay(NULL); - - time_current = SDL_GetTicks(); - } - } + Delay_WithScreenUpdates(post_delay); // restore function for drawing global masked border gfx.draw_global_border_function = draw_global_border_function; diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index b6fad441..d7c6243c 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -503,4 +503,6 @@ void SDLCloseJoystick(int); void PrepareFadeBitmap(int); +void Delay_WithScreenUpdates(unsigned int); + #endif /* SDL_H */ -- 2.34.1