diff options
author | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-02-22 16:22:28 +0000 |
---|---|---|
committer | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-02-22 16:22:28 +0000 |
commit | e90a0510b951c4e08d94d7ca4643eec6add3437c (patch) | |
tree | eebbb1f3155a05d003feb8b54611b89d26b0c8ce /src/base | |
parent | c710a7b0d52b408b865e82eb55480146cbbbaed7 (diff) | |
download | usdx-e90a0510b951c4e08d94d7ca4643eec6add3437c.tar.gz usdx-e90a0510b951c4e08d94d7ca4643eec6add3437c.tar.xz usdx-e90a0510b951c4e08d94d7ca4643eec6add3437c.zip |
some changes to fps limiter,
dependency to old UTime stuff removed
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2139 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/UMain.pas | 11 |
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 |