This commit is contained in:
Christoph Oelckers 2014-09-16 08:44:37 +02:00
commit 134c9ade21

View file

@ -123,14 +123,13 @@ void I_EndRead(void)
static DWORD TicStart; static DWORD TicStart;
static DWORD TicNext;
static DWORD BaseTime; static DWORD BaseTime;
static int TicFrozen; static int TicFrozen;
// Signal based timer. // Signal based timer.
static Semaphore timerWait; static Semaphore timerWait;
static int tics; static int tics;
static DWORD sig_start, sig_next; static DWORD sig_start;
void I_SelectTimer(); void I_SelectTimer();
@ -169,7 +168,6 @@ int I_GetTimePolled (bool saveMS)
if (saveMS) if (saveMS)
{ {
TicStart = tm; TicStart = tm;
TicNext = Scale((Scale (tm, TICRATE, 1000) + 1), 1000, TICRATE);
} }
return Scale(tm - BaseTime, TICRATE, 1000); return Scale(tm - BaseTime, TICRATE, 1000);
} }
@ -179,7 +177,6 @@ int I_GetTimeSignaled (bool saveMS)
if (saveMS) if (saveMS)
{ {
TicStart = sig_start; TicStart = sig_start;
TicNext = sig_next;
} }
return tics; return tics;
} }
@ -250,7 +247,6 @@ void I_HandleAlarm (int sig)
if(!TicFrozen) if(!TicFrozen)
tics++; tics++;
sig_start = SDL_GetTicks(); sig_start = SDL_GetTicks();
sig_next = Scale((Scale (sig_start, TICRATE, 1000) + 1), 1000, TICRATE);
SEMAPHORE_SIGNAL(timerWait) SEMAPHORE_SIGNAL(timerWait)
} }
@ -293,15 +289,14 @@ void I_SelectTimer()
fixed_t I_GetTimeFrac (uint32 *ms) fixed_t I_GetTimeFrac (uint32 *ms)
{ {
DWORD now = SDL_GetTicks (); DWORD now = SDL_GetTicks ();
if (ms) *ms = TicNext; if (ms) *ms = TicStart + (1000 / TICRATE);
DWORD step = TicNext - TicStart; if (TicStart == 0)
if (step == 0)
{ {
return FRACUNIT; return FRACUNIT;
} }
else else
{ {
fixed_t frac = clamp<fixed_t> ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); fixed_t frac = clamp<fixed_t> ((now - TicStart)*FRACUNIT*TICRATE/1000, 0, FRACUNIT);
return frac; return frac;
} }
} }