diff options
author | Sergeanur <s.anureev@yandex.ua> | 2020-05-12 23:19:21 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2020-05-12 23:27:15 +0200 |
commit | 33dfaf7da11675fdad2909e39b6d15e49fc6cc68 (patch) | |
tree | ff2b3fe079b51b521cb26ceb2da0a5717b0601ff /src/core/Timer.cpp | |
parent | Merge remote-tracking branch 'upstream/miami' into miami (diff) | |
parent | fix shotgun (diff) | |
download | re3-33dfaf7da11675fdad2909e39b6d15e49fc6cc68.tar re3-33dfaf7da11675fdad2909e39b6d15e49fc6cc68.tar.gz re3-33dfaf7da11675fdad2909e39b6d15e49fc6cc68.tar.bz2 re3-33dfaf7da11675fdad2909e39b6d15e49fc6cc68.tar.lz re3-33dfaf7da11675fdad2909e39b6d15e49fc6cc68.tar.xz re3-33dfaf7da11675fdad2909e39b6d15e49fc6cc68.tar.zst re3-33dfaf7da11675fdad2909e39b6d15e49fc6cc68.zip |
Diffstat (limited to 'src/core/Timer.cpp')
-rw-r--r-- | src/core/Timer.cpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index aca7c1dc..ed5580fd 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -1,5 +1,6 @@ #define WITHWINDOWS #include "common.h" +#include "crossplatform.h" #include "DMAudio.h" #include "Record.h" @@ -16,15 +17,19 @@ float CTimer::ms_fTimeStepNonClipped; bool CTimer::m_UserPause; bool CTimer::m_CodePause; -uint32 oldPcTimer; - -uint32 suspendPcTimer; - uint32 _nCyclesPerMS = 1; +#ifdef _WIN32 LARGE_INTEGER _oldPerfCounter; - LARGE_INTEGER perfSuspendCounter; +#define RsTimerType uint32 +#else +#define RsTimerType double +#endif + +RsTimerType oldPcTimer; + +RsTimerType suspendPcTimer; uint32 suspendDepth; @@ -45,6 +50,7 @@ void CTimer::Initialise(void) m_snPreviousTimeInMilliseconds = 0; m_snTimeInMilliseconds = 1; +#ifdef _WIN32 LARGE_INTEGER perfFreq; if ( QueryPerformanceFrequency(&perfFreq) ) { @@ -53,6 +59,7 @@ void CTimer::Initialise(void) QueryPerformanceCounter(&_oldPerfCounter); } else +#endif { OutputDebugString("Performance counter not available, using millesecond timer\n"); _nCyclesPerMS = 0; @@ -77,6 +84,7 @@ void CTimer::Update(void) { m_snPreviousTimeInMilliseconds = m_snTimeInMilliseconds; +#ifdef _WIN32 if ( (double)_nCyclesPerMS != 0.0 ) { LARGE_INTEGER pc; @@ -106,10 +114,11 @@ void CTimer::Update(void) } } else +#endif { - uint32 timer = RsTimer(); + RsTimerType timer = RsTimer(); - uint32 updInMs = timer - oldPcTimer; + RsTimerType updInMs = timer - oldPcTimer; // We need that real frame time to fix transparent menu bug. #ifndef FIX_BUGS @@ -158,9 +167,11 @@ void CTimer::Suspend(void) if ( ++suspendDepth > 1 ) return; +#ifdef _WIN32 if ( (double)_nCyclesPerMS != 0.0 ) QueryPerformanceCounter(&perfSuspendCounter); else +#endif suspendPcTimer = RsTimer(); } @@ -169,6 +180,7 @@ void CTimer::Resume(void) if ( --suspendDepth != 0 ) return; +#ifdef _WIN32 if ( (double)_nCyclesPerMS != 0.0 ) { LARGE_INTEGER pc; @@ -177,19 +189,23 @@ void CTimer::Resume(void) _oldPerfCounter.LowPart += pc.LowPart - perfSuspendCounter.LowPart; } else +#endif oldPcTimer += RsTimer() - suspendPcTimer; } uint32 CTimer::GetCyclesPerMillisecond(void) { +#ifdef _WIN32 if (_nCyclesPerMS != 0) return _nCyclesPerMS; else +#endif return 1; } uint32 CTimer::GetCurrentTimeInCycles(void) { +#ifdef _WIN32 if ( _nCyclesPerMS != 0 ) { LARGE_INTEGER pc; @@ -197,6 +213,7 @@ uint32 CTimer::GetCurrentTimeInCycles(void) return (pc.LowPart - _oldPerfCounter.LowPart); // & 0x7FFFFFFF; pointless } else +#endif return RsTimer() - oldPcTimer; } |