diff --git a/source/exhumed/src/aistuff.h b/source/exhumed/src/aistuff.h index c944a4d12..5ac93d7d0 100644 --- a/source/exhumed/src/aistuff.h +++ b/source/exhumed/src/aistuff.h @@ -152,7 +152,7 @@ void StopFiringWeapon(short nPlayer); void FireWeapon(short nPlayer); void CheckClip(short nPlayer); void MoveWeapons(short nPlayer); -void DrawWeapons(int smooth); +void DrawWeapons(double smooth); // items diff --git a/source/exhumed/src/engine.h b/source/exhumed/src/engine.h index 540fd495b..a27649b89 100644 --- a/source/exhumed/src/engine.h +++ b/source/exhumed/src/engine.h @@ -146,6 +146,11 @@ inline int Sin(int angle) return sintable[angle & kAngleMask]; } +inline double FSin(double angle) +{ + return calcSinTableValue(fmod(angle, kAngleMask + 1)); +} + inline int Cos(int angle) { return sintable[(angle + 512) & kAngleMask]; diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 71e8e00ed..578d4c733 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -412,7 +412,7 @@ void DrawClock() DoEnergyTile(); } -int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) +double calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) { if (bRecord || bPlayback || nFreeze != 0 || bCamera || paused) return 65536; diff --git a/source/exhumed/src/gameloop.cpp b/source/exhumed/src/gameloop.cpp index 6e3902b4b..4a6fc520c 100644 --- a/source/exhumed/src/gameloop.cpp +++ b/source/exhumed/src/gameloop.cpp @@ -60,7 +60,7 @@ extern ClockTicks tclocks; void RunCinemaScene(int num); void GameMove(void); void DrawClock(); -int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk); +double calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk); void DoTitle(CompletionFunc completion); static int FinishLevel(TArray &jobs) @@ -117,7 +117,7 @@ static void GameDisplay(void) DrawClock(); } - auto smoothRatio = calc_smoothratio(totalclock, tclocks); + double smoothRatio = calc_smoothratio(totalclock, tclocks); DrawView(smoothRatio); DrawStatusBar(); diff --git a/source/exhumed/src/gun.cpp b/source/exhumed/src/gun.cpp index 3843df8cb..5f7ffce83 100644 --- a/source/exhumed/src/gun.cpp +++ b/source/exhumed/src/gun.cpp @@ -924,7 +924,7 @@ loc_flag: } } -void DrawWeapons(int smooth) +void DrawWeapons(double smooth) { if (bCamera) { return; @@ -958,21 +958,22 @@ void DrawWeapons(int smooth) nPal = RemapPLU(nPal); - int nVal = totalvel[nLocalPlayer] >> 1; + double xOffset, yOffset; - // CHECKME - not & 0x7FF? - int nBobAngle = angle_interpolate16(obobangle, bobangle, smooth); - int yOffset = (nVal * (sintable[nBobAngle & 0x3FF] >> 8)) >> 9; - - int xOffset = 0; - - if (var_34 == 1) + if (cl_weaponsway && var_34 == 1) { - xOffset = ((Sin(nBobAngle + 512) >> 8) * nVal) >> 8; + // CHECKME - not & 0x7FF? + double nBobAngle = obobangle + fmulscale16(((bobangle + 1024 - obobangle) & 2047) - 1024, smooth); + double nVal = (ototalvel[nLocalPlayer] + fmulscale16(totalvel[nLocalPlayer] - ototalvel[nLocalPlayer], smooth)) / 2.; + yOffset = (nVal * (calcSinTableValue(fmod(nBobAngle, 1024)) / 256.)) / 512.; + + if (var_34 == 1) + { + xOffset = ((FSin(nBobAngle + 512) / 256.) * nVal) / 256.; + } } else { - xOffset = 0; obobangle = bobangle = 512; } diff --git a/source/exhumed/src/player.cpp b/source/exhumed/src/player.cpp index 9a40ace4f..207556d96 100644 --- a/source/exhumed/src/player.cpp +++ b/source/exhumed/src/player.cpp @@ -112,6 +112,7 @@ short nPlayerDouble[kMaxPlayers]; short nPlayerViewSect[kMaxPlayers]; short nPlayerFloorSprite[kMaxPlayers]; PlayerSave sPlayerSave[kMaxPlayers]; +int ototalvel[kMaxPlayers] = { 0 }; int totalvel[kMaxPlayers] = { 0 }; int16_t eyelevel[kMaxPlayers], oeyelevel[kMaxPlayers]; short nNetStartSprite[kMaxPlayers] = { 0 }; @@ -677,7 +678,7 @@ void RestartPlayer(short nPlayer) sprintf(playerNames[nPlayer], "JOE%d", nPlayer); namelen[nPlayer] = strlen(playerNames[nPlayer]); - totalvel[nPlayer] = 0; + ototalvel[nPlayer] = totalvel[nPlayer] = 0; memset(&sPlayerInput[nPlayer], 0, sizeof(PlayerInput)); sPlayerInput[nPlayer].nItem = -1; @@ -798,7 +799,7 @@ void StartDeathSeq(int nPlayer, int nVal) } } - totalvel[nPlayer] = 0; + ototalvel[nPlayer] = totalvel[nPlayer] = 0; if (nPlayer == nLocalPlayer) { RefreshStatus(); @@ -1425,6 +1426,7 @@ loc_1AB8E: sqrtNum = INT_MAX; } + ototalvel[nPlayer] = totalvel[nPlayer]; totalvel[nPlayer] = ksqrt(sqrtNum); int nViewSect = sprite[nPlayerSprite].sectnum; diff --git a/source/exhumed/src/player.h b/source/exhumed/src/player.h index 39c837b4d..49321f55e 100644 --- a/source/exhumed/src/player.h +++ b/source/exhumed/src/player.h @@ -106,7 +106,7 @@ extern short nPlayerClip[]; extern short obobangle, bobangle; -extern int totalvel[]; +extern int ototalvel[], totalvel[]; extern int16_t eyelevel[], oeyelevel[]; extern short nNetStartSprite[kMaxPlayers]; diff --git a/source/exhumed/src/sequence.cpp b/source/exhumed/src/sequence.cpp index 1aa0c04fb..10f4b1574 100644 --- a/source/exhumed/src/sequence.cpp +++ b/source/exhumed/src/sequence.cpp @@ -354,7 +354,7 @@ short seq_GetFrameFlag(short val, short nFrame) return FrameFlag[SeqBase[val] + nFrame]; } -void seq_DrawPilotLightSeq(int xOffset, int yOffset) +void seq_DrawPilotLightSeq(double xOffset, double yOffset) { short nSect = nPlayerViewSect[nLocalPlayer]; @@ -371,10 +371,10 @@ void seq_DrawPilotLightSeq(int xOffset, int yOffset) return; short nTile = ChunkPict[nFrameBase]; - int x = ChunkXpos[nFrameBase] + (160 + xOffset); - int y = ChunkYpos[nFrameBase] + (100 + yOffset); + double x = ChunkXpos[nFrameBase] + (160 + xOffset); + double y = ChunkYpos[nFrameBase] + (100 + yOffset); - hud_drawsprite(x, y, 65536, (-2 * fix16_to_int(nPlayerDAng)) & kAngleMask, nTile, 0, 0, 1); + hud_drawsprite(x, y, 65536, fmod(-2 * (nPlayerDAng / (double)(FRACUNIT)), kAngleMask + 1), nTile, 0, 0, 1); nFrameBase++; } } @@ -387,7 +387,7 @@ void seq_DrawPilotLightSeq(int xOffset, int yOffset) */ -int seq_DrawGunSequence(int nSeqOffset, short dx, int xOffs, int yOffs, int nShade, int nPal) +int seq_DrawGunSequence(int nSeqOffset, short dx, double xOffs, double yOffs, int nShade, int nPal) { int nFrame = SeqBase[nSeqOffset] + dx; int nFrameBase = FrameBase[nFrame]; diff --git a/source/exhumed/src/sequence.h b/source/exhumed/src/sequence.h index 79d698d1d..d8db8d145 100644 --- a/source/exhumed/src/sequence.h +++ b/source/exhumed/src/sequence.h @@ -142,11 +142,11 @@ int seq_GetSeqPicnum2(short nSeq, short nFrame); int seq_GetSeqPicnum(short nSeq, short edx, short ebx); void seq_DrawStatusSequence(short nSequence, uint16_t edx, short ebx); -int seq_DrawGunSequence(int nSeqOffset, short dx, int xOffs, int yOffs, int nShade, int nPal); +int seq_DrawGunSequence(int nSeqOffset, short dx, double xOffs, double yOffs, int nShade, int nPal); short seq_GetFrameFlag(short val, short nFrame); int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx); int seq_PlotArrowSequence(short nSprite, short nSeq, int nVal); -void seq_DrawPilotLightSeq(int xOffset, int yOffset); +void seq_DrawPilotLightSeq(double xOffset, double yOffset); END_PS_NS diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 25b17ebae..708ab80dd 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -237,7 +237,7 @@ static inline int interpolate16(int a, int b, int smooth) static TextOverlay subtitleOverlay; -void DrawView(int smoothRatio, bool sceneonly) +void DrawView(double smoothRatio, bool sceneonly) { int playerX; int playerY; diff --git a/source/exhumed/src/view.h b/source/exhumed/src/view.h index 93ba55ecf..4707b8d4d 100644 --- a/source/exhumed/src/view.h +++ b/source/exhumed/src/view.h @@ -29,7 +29,7 @@ extern short bCamera; void InitView(); void DrawStatusBar(); -void DrawView(int smoothRatio, bool sceneonly = false); +void DrawView(double smoothRatio, bool sceneonly = false); void ResetView(); void NoClip(); void Clip();