- use gFrameClock plus interpolation for third person view and tick the flash counter for the CTF HUD in the ticker, not the drawer.

This removes a lot of mess.
This commit is contained in:
Christoph Oelckers 2020-09-01 20:14:15 +02:00
parent e320e79df0
commit fda74a47b4
4 changed files with 36 additions and 49 deletions

View file

@ -335,6 +335,14 @@ void ProcessFrame(void)
gLevelTime++; gLevelTime++;
gFrameCount++; gFrameCount++;
gFrameClock += 4; gFrameClock += 4;
for(int i=0;i<8;i++)
{
dword_21EFD0[i] = dword_21EFD0[i] -= 4;
if (dword_21EFD0[i] < 0)
dword_21EFD0[i] = 0;
}
if ((gGameOptions.uGameFlags&1) != 0 && !gStartNewGame) if ((gGameOptions.uGameFlags&1) != 0 && !gStartNewGame)
{ {
seqKillAll(); seqKillAll();

View file

@ -473,16 +473,13 @@ private:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void viewDrawCtfHudVanilla(int arg) void viewDrawCtfHudVanilla()
{ {
FString gTempStr; FString gTempStr;
int x = 1, y = 1; int x = 1, y = 1;
if (dword_21EFD0[0] == 0 || (gFrameClock & 8)) if (dword_21EFD0[0] == 0 || (gFrameClock & 8))
{ {
SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_BLUE"), x, y, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1); SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_BLUE"), x, y, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
dword_21EFD0[0] = dword_21EFD0[0] - arg;
if (dword_21EFD0[0] < 0)
dword_21EFD0[0] = 0;
gTempStr.Format("%-3d", dword_21EFB0[0]); gTempStr.Format("%-3d", dword_21EFB0[0]);
SBar_DrawString(this, &smallf, gTempStr, x, y + 10, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1); SBar_DrawString(this, &smallf, gTempStr, x, y + 10, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1);
} }
@ -490,9 +487,6 @@ private:
if (dword_21EFD0[1] == 0 || (gFrameClock & 8)) if (dword_21EFD0[1] == 0 || (gFrameClock & 8))
{ {
SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_RED"), x, y, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1); SBar_DrawString(this, &smallf, GStrings("TXT_COLOR_RED"), x, y, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
dword_21EFD0[1] = dword_21EFD0[1] - arg;
if (dword_21EFD0[1] < 0)
dword_21EFD0[1] = 0;
gTempStr.Format("%3d", dword_21EFB0[1]); gTempStr.Format("%3d", dword_21EFB0[1]);
SBar_DrawString(this, &smallf, gTempStr, x, y + 10, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1); SBar_DrawString(this, &smallf, gTempStr, x, y + 10, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1);
} }
@ -504,17 +498,13 @@ private:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void flashTeamScore(int arg, int team, bool show) void flashTeamScore(int team, bool show)
{ {
dassert(0 == team || 1 == team); // 0: blue, 1: red dassert(0 == team || 1 == team); // 0: blue, 1: red
if (dword_21EFD0[team] == 0 || (gFrameClock & 8)) if (dword_21EFD0[team] == 0 || (gFrameClock & 8))
{ {
dword_21EFD0[team] = dword_21EFD0[team] - arg; if (show)
if (dword_21EFD0[team] < 0)
dword_21EFD0[team] = 0;
if (show)
DrawStatNumber("%d", dword_21EFB0[team], kSBarNumberInv, -30, team ? 25 : -10, 0, team ? 2 : 10, 512, 65536 * 0.75, DI_SCREEN_RIGHT_CENTER); DrawStatNumber("%d", dword_21EFB0[team], kSBarNumberInv, -30, team ? 25 : -10, 0, team ? 2 : 10, 512, 65536 * 0.75, DI_SCREEN_RIGHT_CENTER);
} }
} }
@ -525,12 +515,12 @@ private:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void viewDrawCtfHud(int arg) void viewDrawCtfHud()
{ {
if (hud_size == Hud_Nothing) if (hud_size == Hud_Nothing)
{ {
flashTeamScore(arg, 0, false); flashTeamScore(0, false);
flashTeamScore(arg, 1, false); flashTeamScore(1, false);
return; return;
} }
@ -558,7 +548,7 @@ private:
DrawStatMaskedSprite(2332, 305-320, 83 - 100, 0, 10, 512, 65536, DI_SCREEN_RIGHT_CENTER); DrawStatMaskedSprite(2332, 305-320, 83 - 100, 0, 10, 512, 65536, DI_SCREEN_RIGHT_CENTER);
else if (blueFlagTaken) else if (blueFlagTaken)
DrawStatMaskedSprite(4097, 307-320, 77 - 100, 0, blueFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER); DrawStatMaskedSprite(4097, 307-320, 77 - 100, 0, blueFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER);
flashTeamScore(arg, 0, true); flashTeamScore(0, true);
bool meHaveRedFlag = gMe->hasFlag & 2; bool meHaveRedFlag = gMe->hasFlag & 2;
DrawStatMaskedSprite(meHaveRedFlag ? 3558 : 3559, 0, 10, 0, 2, 512, 65536 * 0.35, DI_SCREEN_RIGHT_CENTER); DrawStatMaskedSprite(meHaveRedFlag ? 3558 : 3559, 0, 10, 0, 2, 512, 65536 * 0.35, DI_SCREEN_RIGHT_CENTER);
@ -566,7 +556,7 @@ private:
DrawStatMaskedSprite(2332, 305-320, 17, 0, 2, 512, 65536, DI_SCREEN_RIGHT_CENTER); DrawStatMaskedSprite(2332, 305-320, 17, 0, 2, 512, 65536, DI_SCREEN_RIGHT_CENTER);
else if (redFlagTaken) else if (redFlagTaken)
DrawStatMaskedSprite(4097, 307-320, 11, 0, redFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER); DrawStatMaskedSprite(4097, 307-320, 11, 0, redFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER);
flashTeamScore(arg, 1, true); flashTeamScore(1, true);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -784,7 +774,7 @@ private:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
public: public:
void UpdateStatusBar(int arg) void UpdateStatusBar()
{ {
PLAYER* pPlayer = gView; PLAYER* pPlayer = gView;
XSPRITE* pXSprite = pPlayer->pXSprite; XSPRITE* pXSprite = pPlayer->pXSprite;
@ -830,11 +820,11 @@ private:
{ {
if (VanillaMode()) if (VanillaMode())
{ {
viewDrawCtfHudVanilla(arg); viewDrawCtfHudVanilla();
} }
else else
{ {
viewDrawCtfHud(arg); viewDrawCtfHud();
viewDrawPlayerFlags(); viewDrawPlayerFlags();
} }
} }
@ -862,7 +852,7 @@ static void UpdateFrame(void)
twod->AddFlatFill(windowxy1.x - 3, windowxy2.y + 1, windowxy2.x + 1, windowxy2.y + 4, tex, 0, 1, 0xff2a2a2a); twod->AddFlatFill(windowxy1.x - 3, windowxy2.y + 1, windowxy2.x + 1, windowxy2.y + 4, tex, 0, 1, 0xff2a2a2a);
} }
void UpdateStatusBar(int arg) void UpdateStatusBar()
{ {
DBloodStatusBar sbar; DBloodStatusBar sbar;
@ -871,7 +861,7 @@ void UpdateStatusBar(int arg)
UpdateFrame(); UpdateFrame();
} }
sbar.UpdateStatusBar(arg); sbar.UpdateStatusBar();
} }

View file

@ -302,16 +302,11 @@ void viewInit(void)
gViewMap.sub_25C38(0, 0, gZoom, 0); gViewMap.sub_25C38(0, 0, gZoom, 0);
} }
void viewDrawInterface(int arg)
{
UpdateStatusBar(arg);
}
int othercameradist = 1280; int othercameradist = 1280;
int cameradist = -1; int cameradist = -1;
int othercameraclock, cameraclock; int othercameraclock, cameraclock;
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fixed_t zm) void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fixed_t zm, int smoothratio)
{ {
int vX = mulscale30(-Cos(nAng), 1280); int vX = mulscale30(-Cos(nAng), 1280);
int vY = mulscale30(-Sin(nAng), 1280); int vY = mulscale30(-Sin(nAng), 1280);
@ -349,14 +344,15 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec
*pX += mulscale16(vX, othercameradist); *pX += mulscale16(vX, othercameradist);
*pY += mulscale16(vY, othercameradist); *pY += mulscale16(vY, othercameradist);
*pZ += mulscale16(vZ, othercameradist); *pZ += mulscale16(vZ, othercameradist);
othercameradist = ClipHigh(othercameradist+((gameclock-othercameraclock)<<10), 65536); int myclock = gFrameClock + mulscale16(4, smoothratio);
othercameraclock = gameclock; othercameradist = ClipHigh(othercameradist+((myclock-othercameraclock)<<10), 65536);
othercameraclock = myclock;
dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors); dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors);
FindSector(*pX, *pY, *pZ, vsectnum); FindSector(*pX, *pY, *pZ, vsectnum);
pSprite->cstat = bakCstat; pSprite->cstat = bakCstat;
} }
void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fixed_t zm) void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fixed_t zm, int smoothratio)
{ {
int vX = mulscale30(-Cos(nAng), 1280); int vX = mulscale30(-Cos(nAng), 1280);
int vY = mulscale30(-Sin(nAng), 1280); int vY = mulscale30(-Sin(nAng), 1280);
@ -395,8 +391,9 @@ void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum,
*pX += mulscale16(vX, cameradist); *pX += mulscale16(vX, cameradist);
*pY += mulscale16(vY, cameradist); *pY += mulscale16(vY, cameradist);
*pZ += mulscale16(vZ, cameradist); *pZ += mulscale16(vZ, cameradist);
cameradist = ClipHigh(cameradist+((gameclock-cameraclock)<<10), 65536); int myclock = gFrameClock + mulscale16(4, smoothratio);
cameraclock = gameclock; cameradist = ClipHigh(cameradist+((myclock-cameraclock)<<10), 65536);
cameraclock = myclock;
dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors); dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors);
FindSector(*pX, *pY, *pZ, vsectnum); FindSector(*pX, *pY, *pZ, vsectnum);
pSprite->cstat = bakCstat; pSprite->cstat = bakCstat;
@ -603,16 +600,11 @@ int32_t g_frameRate;
void viewDrawScreen(bool sceneonly) void viewDrawScreen(bool sceneonly)
{ {
int nPalette = 0; int nPalette = 0;
static int lastUpdate;
int defaultHoriz = r_horizcenter ? 100 : 90; int defaultHoriz = r_horizcenter ? 100 : 90;
#ifdef USE_OPENGL #ifdef USE_OPENGL
polymostcenterhoriz = defaultHoriz; polymostcenterhoriz = defaultHoriz;
#endif #endif
int delta = gameclock - lastUpdate;
if (delta < 0)
delta = 0;
lastUpdate = gameclock;
if (!paused && (!M_Active() || gGameOptions.nGameType != 0)) if (!paused && (!M_Active() || gGameOptions.nGameType != 0))
{ {
gInterpolate = I_GetTimeFrac() * MaxSmoothRatio; gInterpolate = I_GetTimeFrac() * MaxSmoothRatio;
@ -734,11 +726,11 @@ void viewDrawScreen(bool sceneonly)
} }
cZ += FixedToInt(q16horiz * 10); cZ += FixedToInt(q16horiz * 10);
cameradist = -1; cameradist = -1;
cameraclock = gameclock; cameraclock = gFrameClock +mulscale16(4, (int)gInterpolate);
} }
else else
{ {
CalcPosition(gView->pSprite, (int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum, FixedToInt(cA), q16horiz); CalcPosition(gView->pSprite, (int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum, FixedToInt(cA), q16horiz, (int)gInterpolate);
} }
CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum); CheckLink((int*)&cX, (int*)&cY, (int*)&cZ, &nSectnum);
int v78 = interpolateang(gScreenTiltO, gScreenTilt, gInterpolate); int v78 = interpolateang(gScreenTiltO, gScreenTilt, gInterpolate);
@ -758,7 +750,7 @@ void viewDrawScreen(bool sceneonly)
else if (v4 && gNetPlayers > 1) else if (v4 && gNetPlayers > 1)
{ {
#if 0 // needs to be redone for pure hardware rendering. #if 0 // needs to be redone for pure hardware rendering.
int tmp = (gameclock / 240) % (gNetPlayers - 1); int tmp = (gFrameClock / 240) % (gNetPlayers - 1);
int i = connecthead; int i = connecthead;
while (1) while (1)
{ {
@ -801,7 +793,7 @@ void viewDrawScreen(bool sceneonly)
vd4 += QRandom2(nValue >> 4); vd4 += QRandom2(nValue >> 4);
vd0 += QRandom2(nValue); vd0 += QRandom2(nValue);
} }
CalcOtherPosition(pOther->pSprite, &vd8, &vd4, &vd0, &vcc, v50, 0); CalcOtherPosition(pOther->pSprite, &vd8, &vd4, &vd0, &vcc, v50, 0, (int)gInterpolate);
CheckLink(&vd8, &vd4, &vd0, &vcc); CheckLink(&vd8, &vd4, &vd0, &vcc);
if (IsUnderwaterSector(vcc)) if (IsUnderwaterSector(vcc))
{ {
@ -847,7 +839,7 @@ void viewDrawScreen(bool sceneonly)
} }
else else
{ {
othercameraclock = gameclock; othercameraclock = gFrameClock + mulscale16(4, (int)gInterpolate);
} }
if (!bDelirium) if (!bDelirium)
@ -988,7 +980,7 @@ void viewDrawScreen(bool sceneonly)
{ {
gViewMap.sub_25DB0(gView->pSprite); gViewMap.sub_25DB0(gView->pSprite);
} }
viewDrawInterface(delta); UpdateStatusBar();
int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220; int zn = ((gView->zWeapon-gView->zView-(12<<8))>>7)+220;
PLAYER *pPSprite = &gPlayer[gMe->pSprite->type-kDudePlayer1]; PLAYER *pPSprite = &gPlayer[gMe->pSprite->type-kDudePlayer1];
if (IsPlayerSprite(gMe->pSprite) && pPSprite->hand == 1) if (IsPlayerSprite(gMe->pSprite) && pPSprite->hand == 1)

View file

@ -154,12 +154,9 @@ void CalcInterpolations(void);
void RestoreInterpolations(void); void RestoreInterpolations(void);
void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int nPalette, int position, char shadow, unsigned int nStat = 0, uint8_t alpha = 255); void viewDrawText(int nFont, const char *pString, int x, int y, int nShade, int nPalette, int position, char shadow, unsigned int nStat = 0, uint8_t alpha = 255);
void InitStatusBar(void); void InitStatusBar(void);
void UpdateStatusBar(int arg); void UpdateStatusBar();
void viewInit(void); void viewInit(void);
void viewDrawInterface(int arg);
void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth); void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth);
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm);
void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, int zm);
void viewSetMessage(const char *pMessage, const int pal = 0, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL); void viewSetMessage(const char *pMessage, const int pal = 0, const MESSAGE_PRIORITY priority = MESSAGE_PRIORITY_NORMAL);