File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626#include < stdio.h>
2727#include < stdlib.h>
2828#include < string.h>
29+ #include < math.h>
2930/*
3031*/
3132#include " SDL.h"
@@ -122,7 +123,7 @@ int FlcCheckHeader(const char *filename)
122123 Log (LOG_INFO ) << " Playing flx, " << flc.screen_w << " x" << flc.screen_h << " , " << flc.HeaderFrames << " frames" ;
123124 flc.screen_depth =8 ;
124125 if (flc.HeaderCheck ==0x0AF11 ) {
125- flc.HeaderSpeed *=1000 /70 ;
126+ flc.HeaderSpeed *=1000.0 /70 ;
126127 }
127128 return (0 );
128129 }
@@ -419,17 +420,24 @@ void FlcDoOneFrame()
419420} /* FlcDoOneFrame */
420421
421422void SDLWaitFrame (void )
422- { static Uint32 oldTick=0 ;
423+ { static double oldTick=0. 0 ;
423424 Uint32 currentTick;
424- Sint32 waitTicks;
425+ double waitTicks;
425426
426- currentTick=SDL_GetTicks ();
427- if (oldTick == 0 ) oldTick = currentTick;
428- waitTicks=(oldTick+=(flc.HeaderSpeed ))-currentTick;
427+ if (oldTick == 0.0 ) oldTick = SDL_GetTicks ();
429428
430- if (waitTicks>0 ) {
431- SDL_Delay (waitTicks);
432- }
429+ currentTick=SDL_GetTicks ();
430+ waitTicks=(oldTick+=(flc.HeaderSpeed ))-currentTick;
431+
432+
433+ do {
434+ waitTicks = (oldTick + flc.HeaderSpeed - SDL_GetTicks ());
435+
436+ if (waitTicks > 0.0 ) {
437+ // SDL_Delay(floor(waitTicks + 0.5)); // biased rounding? mehhh?
438+ SDL_Delay (1 );
439+ }
440+ } while (waitTicks > 0.0 );
433441} /* SDLWaitFrame */
434442
435443void FlcInitFirstFrame ()
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ struct Flc_t {
4545 Uint16 HeaderWidth; /* Fli width */
4646 Uint16 HeaderHeight; /* Fli heigth */
4747 Uint16 HeaderDepth; /* Color depth */
48- Uint16 HeaderSpeed; /* Number of video ticks between frame */
48+ double HeaderSpeed; /* Number of video ticks between frame */
4949 Uint32 FrameSize; /* Frame size in bytes */
5050 Uint16 FrameCheck; /* Frame check */
5151 Uint16 FrameChunks; /* Number of chunks in frame */
You can’t perform that action at this time.
0 commit comments