From 8dfb7967e21aaf4a77687c5a33bb6eff890ecfa9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Sep 2020 20:31:45 +0200 Subject: [PATCH] - use a more precise timer for Exhumed's text scroller. --- source/core/screenjob.cpp | 4 ++-- source/exhumed/src/2d.cpp | 8 ++++---- source/exhumed/src/exhumed.h | 6 +++--- source/exhumed/src/view.cpp | 5 ++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 6c7663240..9a7fb5bce 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -630,7 +630,7 @@ public: int DisplayFrame() { auto& job = jobs[index]; - auto now = I_nsTime(); + auto now = I_GetTimeNS(); bool processed = job.job->ProcessInput(); bool skiprequest = inputState.CheckAllInput() && !processed; if (startTime == -1) @@ -661,7 +661,7 @@ public: int FadeoutFrame() { - auto now = I_nsTime(); + auto now = I_GetTimeNS(); if (!M_Active()) { diff --git a/source/exhumed/src/2d.cpp b/source/exhumed/src/2d.cpp index 34b1ccf13..f17345832 100644 --- a/source/exhumed/src/2d.cpp +++ b/source/exhumed/src/2d.cpp @@ -834,7 +834,7 @@ public: // //--------------------------------------------------------------------------- -void TextOverlay::Start(int starttime) +void TextOverlay::Start(double starttime) { lastclock = starttime; } @@ -879,12 +879,12 @@ void TextOverlay::DisplayText() } } -bool TextOverlay::AdvanceCinemaText(int clock) +bool TextOverlay::AdvanceCinemaText(double clock) { if (nHeight + nCrawlY > 0 || CDplaying()) { nCrawlY-= (clock - lastclock) / 15.; // do proper interpolation. - Printf("Scroll: crawlY = %f, clock = %d, time = %d, real time = %u\n", nCrawlY, clock, lastclock - clock, I_msTime()); + Printf("Scroll: crawlY = %f, clock = %f, time = %f, real time = %u\n", nCrawlY, clock, lastclock - clock, I_msTime()); lastclock = clock; return true; } @@ -980,7 +980,7 @@ public: DrawTexture(twod, tileGetTexture(cinematile), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, TRANSLATION(Translation_BasePalettes, currentCinemaPalette), TAG_DONE); text.DisplayText(); - auto cont = text.AdvanceCinemaText(clock * 120 / 1'000'000'000); + auto cont = text.AdvanceCinemaText(clock * (120. / 1'000'000'000)); int ret = skiprequest ? -1 : cont ? 1 : 0; // quit the game if we've finished level 4 and displayed the advert text diff --git a/source/exhumed/src/exhumed.h b/source/exhumed/src/exhumed.h index 44863febb..3b8ab60a2 100644 --- a/source/exhumed/src/exhumed.h +++ b/source/exhumed/src/exhumed.h @@ -185,18 +185,18 @@ class TextOverlay double nCrawlY; short nLeft[50]; int nHeight; - int lastclock; + double lastclock; TArray screentext; int currentCinemaPalette = 0; public: - void Start(int starttime); + void Start(double starttime); void ComputeCinemaText(); void ReadyCinemaText(uint16_t nVal); void DisplayText(); - bool AdvanceCinemaText(int clock); + bool AdvanceCinemaText(double clock); void SetPalette(int pal) { currentCinemaPalette = pal; } }; diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index 880ea19ca..685b29545 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -405,7 +405,6 @@ void DrawView(double smoothRatio, bool sceneonly) if (nFreeze == 2) { - int myclock = leveltime + mulscale16(4, (int)smoothRatio); if (nHeadStage == 4) { nHeadStage = 5; @@ -424,7 +423,7 @@ void DrawView(double smoothRatio, bool sceneonly) if (bSubTitles) { - subtitleOverlay.Start(myclock); + subtitleOverlay.Start(I_GetTimeNS()); if (currentLevel->levelNumber == 1) subtitleOverlay.ReadyCinemaText(1); else @@ -434,7 +433,7 @@ void DrawView(double smoothRatio, bool sceneonly) } else if (nHeadStage == 5) { - if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(myclock)) || inputState.CheckAllInput()) + if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(I_GetTimeNS())) || inputState.CheckAllInput()) { inputState.ClearAllInput(); EndLevel = 1;