From daf368840943f769bb13908af7b39216c7bdd537 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 19 Jul 2005 03:09:20 +0000 Subject: [PATCH] We don't actually care that GetMicrosecondsSinceStart returns a time since start; only that it's self-consistent. If we want time since start, we can record it ourself instead of making platform-specific code do it, and only GetTimeSinceStart needs to do that, not RageTimers. --- stepmania/src/RageTimer.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/stepmania/src/RageTimer.cpp b/stepmania/src/RageTimer.cpp index 876b39b275..97e0605d6c 100644 --- a/stepmania/src/RageTimer.cpp +++ b/stepmania/src/RageTimer.cpp @@ -29,29 +29,31 @@ #define TIMESTAMP_RESOLUTION 1000000 const RageTimer RageZeroTimer(0,0); +static uint64_t g_iStartTime = ArchHooks::GetMicrosecondsSinceStart( true ); -static void GetTime( unsigned &secs, unsigned &us, bool bAccurate ) +static uint64_t GetTime( bool bAccurate ) { // if !bAccurate, then don't call ArchHooks to find the current time. Just return the // last calculated time. GetMicrosecondsSinceStart is slow on some archs. static uint64_t usecs = 0; if( bAccurate ) usecs = ArchHooks::GetMicrosecondsSinceStart( true ); - - secs = unsigned(usecs / 1000000); - us = unsigned(usecs % 1000000); + return usecs; } float RageTimer::GetTimeSinceStart( bool bAccurate ) { - unsigned secs, us; - GetTime( secs, us, bAccurate ); - return secs + (us / 1000000.0f); + uint64_t usecs = GetTime( bAccurate ); + usecs -= g_iStartTime; + return usecs / 1000000.0f; } void RageTimer::Touch() { - GetTime( this->m_secs, this->m_us, true ); + uint64_t usecs = GetTime( true ); + + this->m_secs = unsigned(usecs / 1000000); + this->m_us = unsigned(usecs % 1000000); } float RageTimer::Ago() const