File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -79,19 +79,22 @@ begin
7979end ;
8080
8181function TimerCallback (interval: UInt32; param: Pointer): UInt32; cdecl;
82- var frameIntervalMs, nowMs : LongInt;
82+ var frameIntervalMs, nowMs, elapsed : LongInt;
8383begin
8484 frameIntervalMs := 1000 div targetFrames;
8585 nowMs := SDL_GetTicks();
86- subFrameCount += nowMs - lastFrameTick;
87- lastFrameTick := nowMs;
88-
89- while (subFrameCount >= frameIntervalMs) do
86+ elapsed := nowMs - lastFrameTick;
87+ if (elapsed >= frameIntervalMs) then
9088 begin
91- dec(subFrameCount, frameIntervalMs);
92- inc(framecount);
93- end ;
89+ lastFrameTick := nowMs;
90+ subFrameCount += elapsed;
9491
92+ while (subFrameCount >= frameIntervalMs) do
93+ begin
94+ dec(subFrameCount, frameIntervalMs);
95+ inc(framecount);
96+ end ;
97+ end ;
9598 TimerCallback:=interval;
9699end ;
97100
@@ -263,11 +266,11 @@ end;
263266
264267procedure WaitRaster ;
265268begin
269+ lastFrameCount := framecount;
266270 while (lastFrameCount = framecount) do
267271 begin
268272 SDL_Delay(1 );
269273 end ;
270- lastFrameCount := framecount;
271274end ;
272275
273276function KeyPressed : boolean;
You can’t perform that action at this time.
0 commit comments