From b1a30806714865a58058d2bd4d756ef6a59ca45a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 2 Sep 2020 21:42:12 +0200 Subject: [PATCH] - migrated Exhumed to a local ticker as well. gameclock is history - all games now run on a timer that increments once per tick under their own control and not independently of the ticker routine. --- source/blood/src/view.cpp | 6 ------ source/core/gamecontrol.cpp | 2 -- source/exhumed/src/2d.cpp | 6 +++--- source/exhumed/src/input.cpp | 26 ++++++++++++++++++++------ source/exhumed/src/view.cpp | 5 +++-- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index f1b5d2cfa..377cb5d09 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -985,13 +985,7 @@ void viewDrawScreen(bool sceneonly) PLAYER *pPSprite = &gPlayer[gMe->pSprite->type-kDudePlayer1]; if (IsPlayerSprite(gMe->pSprite) && pPSprite->hand == 1) { - //static int lastClock; gChoke.animateChoke(160, zn, (int)gInterpolate); - //if ((gGameClock % 5) == 0 && gGameClock != lastClock) - //{ - // gChoke.swayV(pPSprite); - //} - //lastClock = gGameClock; } #if 0 if (byte_1A76C6) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 2ef7c92de..57b2faf54 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -96,8 +96,6 @@ GameInterface* gi; int myconnectindex, numplayers; int connecthead, connectpoint2[MAXMULTIPLAYERS]; auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. -int gameclock; -uint64_t gameclockstart; int lastTic; int automapMode; diff --git a/source/exhumed/src/2d.cpp b/source/exhumed/src/2d.cpp index f96637f8f..ac6bb5b53 100644 --- a/source/exhumed/src/2d.cpp +++ b/source/exhumed/src/2d.cpp @@ -879,12 +879,12 @@ void TextOverlay::DisplayText() } } -bool TextOverlay::AdvanceCinemaText(int gameclock) +bool TextOverlay::AdvanceCinemaText(int clock) { if (nHeight + nCrawlY > 0 || CDplaying()) { - nCrawlY-= (gameclock - lastclock) / 15.; // do proper interpolation. - lastclock = gameclock; + nCrawlY-= (clock - lastclock) / 15.; // do proper interpolation. + lastclock = clock; return true; } diff --git a/source/exhumed/src/input.cpp b/source/exhumed/src/input.cpp index 834a3b333..61625477e 100644 --- a/source/exhumed/src/input.cpp +++ b/source/exhumed/src/input.cpp @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "view.h" #include "gamecontrol.h" #include +#include "v_video.h" BEGIN_PS_NS @@ -91,20 +92,33 @@ static int32_t nonsharedtimer; void CheckKeys2() { + static int nonsharedtimer; + int ms = screen->FrameTime; + int interval; + if (nonsharedtimer > 0 || ms < nonsharedtimer) + { + interval = ms - nonsharedtimer; + } + else + { + interval = 0; + } + nonsharedtimer = screen->FrameTime; + + if (System_WantGuiCapture()) + return; + if (automapMode != am_off) { - int const timerOffset = (gameclock - nonsharedtimer); - nonsharedtimer += timerOffset; + double j = interval * (120. / 1000); if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen)) - lMapZoom += mulscale6(timerOffset, max(lMapZoom, 256)); - + lMapZoom += (int)fmulscale6(j, max(lMapZoom, 256)); if (buttonMap.ButtonDown(gamefunc_Shrink_Screen)) - lMapZoom -= mulscale6(timerOffset, max(lMapZoom, 256)); + lMapZoom -= (int)fmulscale6(j, max(lMapZoom, 256)); lMapZoom = clamp(lMapZoom, 48, 2048); } - if (PlayerList[nLocalPlayer].nHealth <= 0) { SetAirFrame(); diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 350ab4535..e0ec496b6 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -404,6 +404,7 @@ void DrawView(double smoothRatio, bool sceneonly) if (nFreeze == 2) { + int myclock = leveltime + mulscale16(4, (int)smoothRatio); if (nHeadStage == 4) { nHeadStage = 5; @@ -422,7 +423,7 @@ void DrawView(double smoothRatio, bool sceneonly) if (bSubTitles) { - subtitleOverlay.Start(gameclock); + subtitleOverlay.Start(myclock); if (currentLevel->levelNumber == 1) subtitleOverlay.ReadyCinemaText(0); else @@ -432,7 +433,7 @@ void DrawView(double smoothRatio, bool sceneonly) } else if (nHeadStage == 5) { - if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(gameclock)) || inputState.CheckAllInput()) + if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(myclock)) || inputState.CheckAllInput()) { inputState.ClearAllInput(); EndLevel = 2;