From 568f213de8ef6f42f5e695df0424bcf6a6f6bfff Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 25 Jul 2012 18:56:15 +0000 Subject: [PATCH] Add gethitickms() to the Windows layer. git-svn-id: https://svn.eduke32.com/eduke32@2848 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/sdlayer.c | 1 - polymer/eduke32/build/src/winlayer.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 15a311a7a..cd8ffbce7 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -878,7 +878,6 @@ uint64_t gethitickspersec(void) #endif } -// TODO: winlayer too // Returns the time since an unspecified starting time in milliseconds. // (May be not monotonic for certain configurations.) ATTRIBUTE((flatten)) diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index dc39b582f..cccc30de7 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -1558,6 +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 void (*usertimercallback)(void) = NULL; // This timer stuff is all Ken's idea. @@ -1602,6 +1603,8 @@ int32_t inittimer(int32_t tickspersecond) usertimercallback = NULL; + hiticksperms = (double)gethitickspersec() / 1000; + return 0; } @@ -1614,6 +1617,8 @@ void uninittimer(void) timerfreq=0; timerticspersec = 0; + + hiticksperms = 1e308; } // @@ -1663,6 +1668,13 @@ uint64_t gethitickspersec(void) return timerfreq; } +// Returns the time since an unspecified starting time in milliseconds. +ATTRIBUTE((flatten)) +double gethitickms(void) +{ + return (double)gethiticks() / hiticksperms; +} + // // gettimerfreq() -- returns the number of ticks per second the timer is configured to generate //