mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-24 21:38:39 -04:00
fix scaled time interpolation (#363)
* fix scaled time interpolation * remove float
This commit is contained in:
parent
03b0409584
commit
385dfc44f7
@ -76,6 +76,9 @@ typedef int64_t Long64;
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
#ifndef BETWEEN
|
||||
#define BETWEEN(l,u,x) ((l)>(x)?(l):(x)>(u)?(u):(x))
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__cplusplus)
|
||||
#define inline __inline
|
||||
|
@ -98,6 +98,7 @@ int I_GetTimeMS(void)
|
||||
|
||||
// killough 4/13/98: Make clock rate adjustable by scale factor
|
||||
int realtic_clock_rate = 100;
|
||||
static int clock_rate;
|
||||
static Long64 I_GetTime_Scale = 1<<24;
|
||||
int I_GetTime_Scaled(void)
|
||||
{
|
||||
@ -119,6 +120,26 @@ static int I_GetTime_Error()
|
||||
|
||||
int (*I_GetTime)() = I_GetTime_Error; // killough
|
||||
|
||||
// During a fast demo, no time elapses in between ticks
|
||||
static int I_TickElapsedTimeFastDemo(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int I_TickElapsedRealTime(void)
|
||||
{
|
||||
return I_GetTimeMS() - I_GetTime() * 1000 / TICRATE;
|
||||
}
|
||||
|
||||
static int I_TickElapsedScaledTime(void)
|
||||
{
|
||||
int scaled_time = I_GetTimeMS() * clock_rate / 100;
|
||||
|
||||
return scaled_time - I_GetTime() * 1000 / TICRATE;
|
||||
}
|
||||
|
||||
int (*I_TickElapsedTime)(void) = I_TickElapsedRealTime;
|
||||
|
||||
int controllerpresent; // phares 4/3/98
|
||||
|
||||
int leds_always_off; // Tells it not to update LEDs
|
||||
@ -227,7 +248,9 @@ extern boolean nomusicparm, nosfxparm;
|
||||
|
||||
void I_Init(void)
|
||||
{
|
||||
int clock_rate = realtic_clock_rate, p;
|
||||
int p;
|
||||
|
||||
clock_rate = realtic_clock_rate;
|
||||
|
||||
if((p = M_CheckParm("-speed")) && p < myargc-1 &&
|
||||
(p = atoi(myargv[p+1])) >= 10 && p <= 1000)
|
||||
@ -238,15 +261,22 @@ void I_Init(void)
|
||||
|
||||
// killough 4/14/98: Adjustable speedup based on realtic_clock_rate
|
||||
if(fastdemo)
|
||||
{
|
||||
I_GetTime = I_GetTime_FastDemo;
|
||||
I_TickElapsedTime = I_TickElapsedTimeFastDemo;
|
||||
}
|
||||
else
|
||||
if(clock_rate != 100)
|
||||
{
|
||||
I_GetTime_Scale = ((Long64) clock_rate << 24) / 100;
|
||||
I_GetTime = I_GetTime_Scaled;
|
||||
I_TickElapsedTime = I_TickElapsedScaledTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
I_GetTime = I_GetTime_RealTime;
|
||||
I_TickElapsedTime = I_TickElapsedRealTime;
|
||||
}
|
||||
|
||||
I_InitJoystick();
|
||||
|
||||
|
@ -44,6 +44,8 @@ int I_GetTime_RealTime(); // killough
|
||||
int I_GetTime_Adaptive(void); // killough 4/10/98
|
||||
extern int GetTime_Scale;
|
||||
|
||||
extern int (*I_TickElapsedTime)(void);
|
||||
|
||||
// [FG] Same as I_GetTime, but returns time in milliseconds
|
||||
int I_GetTimeMS();
|
||||
// [FG] toggle demo warp mode
|
||||
|
@ -939,7 +939,10 @@ void I_FinishUpdate(void)
|
||||
// [AM] Figure out how far into the current tic we're in as a fixed_t.
|
||||
if (uncapped)
|
||||
{
|
||||
fractionaltic = I_GetTimeMS() * TICRATE % 1000 * FRACUNIT / 1000;
|
||||
int tic_time = I_TickElapsedTime();
|
||||
|
||||
fractionaltic = tic_time * FRACUNIT * TICRATE / 1000;
|
||||
fractionaltic = BETWEEN(0, FRACUNIT, fractionaltic);
|
||||
}
|
||||
|
||||
I_RestoreDiskBackground();
|
||||
|
Loading…
x
Reference in New Issue
Block a user