- fixed SW's interpolation math.

This commit is contained in:
Christoph Oelckers 2020-02-02 09:51:44 +01:00
parent a594ba32d4
commit f76d139207
2 changed files with 18 additions and 1 deletions

View file

@ -44,6 +44,10 @@ public:
{
return ticksS32 >> 16;
}
double toScale16F() const
{
return ticksS32 * (1/(65536.*65536.));
}
ClockTicks& setFromScale16(int64_t const ticksScale16)
{
ticksS32 = ticksScale16 << 16;

View file

@ -1994,6 +1994,19 @@ 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)
{
@ -2063,7 +2076,7 @@ drawscreen(PLAYERp pp)
PreUpdatePanel();
smoothratio = min(max(((int32_t) totalclock - ototalclock) * (65536 / synctics),0),65536);
smoothratio = calc_smoothratio_demo(totalclock, ototalclock);
if (!ScreenSavePic)
{