RageTimer fixes

This commit is contained in:
Glenn Maynard
2004-02-23 00:04:38 +00:00
parent 1208c42c4d
commit 2c8b17ebf8
+14
View File
@@ -13,6 +13,14 @@ const RageZeroTimer_t RageZeroTimer;
void mySDL_GetTicks( unsigned &secs, unsigned &us )
{
static bool bInitialized = false;
if( !bInitialized )
{
bInitialized = true;
if( !SDL_WasInit(SDL_INIT_TIMER) )
SDL_InitSubSystem( SDL_INIT_TIMER );
}
/* Ticks may be less than last for at least two reasons: the time may have wrapped (after
* about 49 days), or the system clock may have moved backwards. If the system clock moves
* backwards, we can't just clamp the time; if it moved back an hour, we'll sit around for
@@ -47,6 +55,12 @@ void mySDL_GetTicks( unsigned &secs, unsigned &us )
offset_us += (offset_ms%1000) * 1000;
}
if( offset_us >= TIMESTAMP_RESOLUTION )
{
offset_us -= TIMESTAMP_RESOLUTION;
++offset_secs;
}
last = millisecs;
secs = millisecs / 1000;