diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index cd8ffbce7..56f1b56c5 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -778,7 +778,7 @@ void releaseallbuttons(void) static Uint32 timerfreq=0; static Uint32 timerlastsample=0; int32_t timerticspersec=0; -static double hiticksperms = 1e308; +static double msperhitick = 0; static void(*usertimercallback)(void) = NULL; @@ -797,7 +797,7 @@ int32_t inittimer(int32_t tickspersecond) usertimercallback = NULL; - hiticksperms = (double)gethitickspersec() / 1000; + msperhitick = 1000.0 / (double)gethitickspersec(); return 0; } @@ -811,7 +811,7 @@ void uninittimer(void) timerfreq=0; - hiticksperms = 1e308; + msperhitick = 0; } // @@ -883,7 +883,7 @@ uint64_t gethitickspersec(void) ATTRIBUTE((flatten)) double gethitickms(void) { - return (double)gethiticks() / hiticksperms; + return (double)gethiticks() * msperhitick; } // diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index cccc30de7..b422e0b0b 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -1558,7 +1558,7 @@ static const char *GetDInputError(HRESULT code) static int64_t timerfreq=0; static int32_t timerlastsample=0; int32_t timerticspersec=0; -static double hiticksperms = 1e308; +static double msperhitick = 0; static void (*usertimercallback)(void) = NULL; // This timer stuff is all Ken's idea. @@ -1603,7 +1603,7 @@ int32_t inittimer(int32_t tickspersecond) usertimercallback = NULL; - hiticksperms = (double)gethitickspersec() / 1000; + msperhitick = 1000.0 / (double)gethitickspersec(); return 0; } @@ -1618,7 +1618,7 @@ void uninittimer(void) timerfreq=0; timerticspersec = 0; - hiticksperms = 1e308; + msperhitick = 0; } // @@ -1672,7 +1672,7 @@ uint64_t gethitickspersec(void) ATTRIBUTE((flatten)) double gethitickms(void) { - return (double)gethiticks() / hiticksperms; + return (double)gethiticks() * msperhitick; } // diff --git a/polymer/eduke32/source/lunatic/test.elua b/polymer/eduke32/source/lunatic/test.elua index 730d3db6b..5468fd7eb 100644 --- a/polymer/eduke32/source/lunatic/test.elua +++ b/polymer/eduke32/source/lunatic/test.elua @@ -203,8 +203,8 @@ gameevent(gv.EVENT_ENTERLEVEL, t = gv.gethitickms()-t - -- x86_64: 40ns/call, x86: 290 ns/call - -- Windows 32-bit: about 1 us/call + -- x86_64: 35ns/call, x86: 290 ns/call? + -- Windows 32-bit: about 1 us/call? printf("%d gethitickms() calls took %.03f ms (%.03f us/call)", N, t, (t*1000)/N)