summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 652c380)
raw | patch | inline | side by side (parent: 652c380)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 15 Apr 2016 17:47:26 +0000 (20:47 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 15 Apr 2016 17:48:24 +0000 (20:48 +0300) |
src/game/g_window.pas | patch | blob | history |
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 419e135299da48568c51fe8974a8a2389016c0c6..33fc80c2969914e7f43c22d84edbc8c8d9ba55fb 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
wLoadingProgress: Boolean = False;
wLoadingQuit: Boolean = False;
{wWinPause: Byte = 0;}
+ ticksOverflow: Int64 = -1;
+ lastTicks: Uint32 = 0; // to detect overflow
const
// TODO: move this to a separate file
end;
function GetTimer(): Int64;
+var
+ t: Uint32;
+ tt: Int64;
begin
- Result := SDL_GetTicks() {* 1000}; // TODO: do we really need microseconds here? k8: NOPE!
+ t := SDL_GetTicks() {* 1000}; // TODO: do we really need microseconds here? k8: NOPE!
+ if ticksOverflow = -1 then
+ begin
+ ticksOverflow := 0;
+ lastTicks := t;
+ end
+ else
+ begin
+ if lastTicks > t then
+ begin
+ // overflow, increment overflow ;-)
+ ticksOverflow := ticksOverflow+(Int64($ffffffff)+Int64(1));
+ tt := (Int64($ffffffff)+Int64(1))+Int64(t);
+ t := Uint32(tt-lastTicks);
+ end;
+ end;
+ lastTicks := t;
+ result := ticksOverflow+Int64(t);
end;
procedure ResetTimer();