- use the new SW interpolation function for all games.

This commit is contained in:
Christoph Oelckers 2020-02-02 10:27:47 +01:00
parent f76d139207
commit 4d7a43004c
8 changed files with 21 additions and 54 deletions

View file

@ -879,3 +879,16 @@ void debugprintf(const char* f, ...)
I_DebugPrint(out);
}
int CalcSmoothRatio(const ClockTicks &totalclk, const ClockTicks &ototalclk, int realgameticspersec)
{
const double TICRATE = 120.;
double rfreq = (refreshfreq != -1 ? refreshfreq : 60);
rfreq = rfreq * TICRATE / timerGetClockRate();
double elapsedTime = (totalclk - ototalclk).toScale16F();
double elapsedFrames = elapsedTime * rfreq * (1. / TICRATE);
double ratio = (elapsedFrames * realgameticspersec) / rfreq;
return clamp(xs_RoundToInt(ratio * 65536), 0, 65536);
}

View file

@ -158,6 +158,7 @@ void S_SetSoundPaused(int state);
void G_HandleMemErr(int32_t lineNum, const char* fileName, const char* funcName);
void G_FatalEngineError(void);
int CalcSmoothRatio(const ClockTicks& totalclk, const ClockTicks& ototalclk, int realgameticspersec);
struct FStartupInfo

View file

@ -796,7 +796,7 @@ nextdemo_nomenu:
}
else
{
j = calc_smoothratio_demo(totalclock, ototalclock);
j = CalcSmoothRatio(totalclock, ototalclock, REALGAMETICSPERSEC);
if (g_demo_paused && g_demo_rewind)
j = 65536-j;

View file

@ -325,17 +325,6 @@ static inline int32_t gameHandleEvents(void)
return handleevents();
}
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
{
int32_t rfreq = tabledivide64((refreshfreq != -1 ? refreshfreq : 60) * TICRATE, timerGetClockRate());
uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE);
#if 0
//POGO: additional debug info for testing purposes
OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq));
#endif
return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536);
}
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
{
if (!(((!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
@ -346,7 +335,7 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk
return 65536;
}
return calc_smoothratio_demo(totalclk, ototalclk);
return CalcSmoothRatio(totalclk, ototalclk, REALGAMETICSPERSEC);
}
// sector effector lotags

View file

@ -1489,22 +1489,10 @@ void G_Polymer_UnInit(void) { }
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
{
// if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
// (g_netServer || ud.multimode > 1) ||
// ud.recstat == 2) ||
// ud.pause_on)
// {
// return 65536;
// }
if (bRecord || bPlayback || nFreeze != 0 || bCamera || bPause)
return 65536;
int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60);
uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*120);
#if 0
//POGO: additional debug info for testing purposes
OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*30, rfreq));
#endif
return clamp(tabledivide64(65536*elapsedFrames*30, rfreq), 0, 65536);
return CalcSmoothRatio(totalclk, ototalclk, 30);
}
#define COLOR_RED redcol

View file

@ -249,7 +249,7 @@ void PlayerInterruptKeys()
}
//if ((counter++) % 4 == 0) // what was this for???
q16avel += fix16_from_int(turn);
q16avel += fix16_from_int(turn*2);
}

View file

@ -324,17 +324,6 @@ static inline void G_HandleAsync(void)
Net_GetPackets();
}
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
{
int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60);
uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE);
#if 0
//POGO: additional debug info for testing purposes
OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq));
#endif
return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536);
}
static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
{
if (!(((!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) ||
@ -345,7 +334,7 @@ static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk
return 65536;
}
return calc_smoothratio_demo(totalclk, ototalclk);
return CalcSmoothRatio(totalclk, ototalclk, REALGAMETICSPERSEC);
}
// sector effector lotags

View file

@ -1994,19 +1994,6 @@ SWBOOL PicInView(short, SWBOOL);
void DoPlayerDiveMeter(PLAYERp pp);
void MoveScrollMode2D(PLAYERp pp);
static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk)
{
const int TICRATE = 120;
const int REALGAMETICSPERSEC = TICRATE / synctics;
int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60);
double elapsedTime = (totalclk - ototalclk).toScale16F();
double elapsedFrames = elapsedTime * rfreq * (1. / TICRATE);
double ratio = (elapsedFrames * REALGAMETICSPERSEC) / rfreq;
return clamp(xs_RoundToInt(ratio * 65536), 0, 65536);
}
void
drawscreen(PLAYERp pp)
{
@ -2076,7 +2063,7 @@ drawscreen(PLAYERp pp)
PreUpdatePanel();
smoothratio = calc_smoothratio_demo(totalclock, ototalclock);
smoothratio = CalcSmoothRatio(totalclock, ototalclock, 120 / synctics);
if (!ScreenSavePic)
{