aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/base/UMain.pas11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/base/UMain.pas b/src/base/UMain.pas
index f05470c1..473a78a9 100644
--- a/src/base/UMain.pas
+++ b/src/base/UMain.pas
@@ -41,6 +41,7 @@ uses
var
Done: boolean;
Restart: boolean;
+ TicksBeforeFrame: Cardinal;
procedure Main;
procedure MainLoop;
@@ -337,6 +338,7 @@ end;
procedure MainLoop;
var
Delay: integer;
+ TicksCurrent: Cardinal;
const
MAX_FPS = 100;
begin
@@ -345,6 +347,8 @@ begin
CountSkipTime(); // JB - for some reason this seems to be needed when we use the SDL Timer functions.
while not Done do
begin
+ TicksBeforeFrame := SDL_GetTicks;
+
// joypad
if (Ini.Joypad = 1) or (Params.Joypad) then
Joy.Update;
@@ -356,10 +360,9 @@ begin
Done := not Display.Draw;
SwapBuffers;
- // delay
- CountMidTime;
-
- Delay := Floor(1000 / MAX_FPS - 1000 * TimeMid);
+ // FPS limiter
+ TicksCurrent := SDL_GetTicks;
+ Delay := 1000 div MAX_FPS - (TicksCurrent - TicksBeforeFrame);
if Delay >= 1 then
SDL_Delay(Delay); // dynamic, maximum is 100 fps