added delay function that regularly updates the screen (to redraw toons)
authorHolger Schemel <info@artsoft.org>
Wed, 27 Jun 2018 21:16:24 +0000 (23:16 +0200)
committerHolger Schemel <info@artsoft.org>
Wed, 27 Jun 2018 21:16:24 +0000 (23:16 +0200)
src/libgame/sdl.c
src/libgame/sdl.h

index 47ad26237b32ab1186c6a059152f038c69655b96..eee5d59ac56cee2d054f4ecbd79fa788982569c5 100644 (file)
@@ -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;
index b6fad4414798ec050ba6aa759a450bc1212989e3..d7c6243c1305fd4aa16e9a7a07c7c5a32ae0cf6e 100644 (file)
@@ -503,4 +503,6 @@ void SDLCloseJoystick(int);
 
 void PrepareFadeBitmap(int);
 
+void Delay_WithScreenUpdates(unsigned int);
+
 #endif /* SDL_H */