- use a more precise timer for Exhumed's text scroller.

This commit is contained in:
Christoph Oelckers 2020-09-05 20:31:45 +02:00
parent a7b198d7ee
commit 8dfb7967e2
4 changed files with 11 additions and 12 deletions

View file

@ -630,7 +630,7 @@ public:
int DisplayFrame() int DisplayFrame()
{ {
auto& job = jobs[index]; auto& job = jobs[index];
auto now = I_nsTime(); auto now = I_GetTimeNS();
bool processed = job.job->ProcessInput(); bool processed = job.job->ProcessInput();
bool skiprequest = inputState.CheckAllInput() && !processed; bool skiprequest = inputState.CheckAllInput() && !processed;
if (startTime == -1) if (startTime == -1)
@ -661,7 +661,7 @@ public:
int FadeoutFrame() int FadeoutFrame()
{ {
auto now = I_nsTime(); auto now = I_GetTimeNS();
if (!M_Active()) if (!M_Active())
{ {

View file

@ -834,7 +834,7 @@ public:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void TextOverlay::Start(int starttime) void TextOverlay::Start(double starttime)
{ {
lastclock = 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()) if (nHeight + nCrawlY > 0 || CDplaying())
{ {
nCrawlY-= (clock - lastclock) / 15.; // do proper interpolation. 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; lastclock = clock;
return true; 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); DrawTexture(twod, tileGetTexture(cinematile), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, TRANSLATION(Translation_BasePalettes, currentCinemaPalette), TAG_DONE);
text.DisplayText(); 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; int ret = skiprequest ? -1 : cont ? 1 : 0;
// quit the game if we've finished level 4 and displayed the advert text // quit the game if we've finished level 4 and displayed the advert text

View file

@ -185,18 +185,18 @@ class TextOverlay
double nCrawlY; double nCrawlY;
short nLeft[50]; short nLeft[50];
int nHeight; int nHeight;
int lastclock; double lastclock;
TArray<FString> screentext; TArray<FString> screentext;
int currentCinemaPalette = 0; int currentCinemaPalette = 0;
public: public:
void Start(int starttime); void Start(double starttime);
void ComputeCinemaText(); void ComputeCinemaText();
void ReadyCinemaText(uint16_t nVal); void ReadyCinemaText(uint16_t nVal);
void DisplayText(); void DisplayText();
bool AdvanceCinemaText(int clock); bool AdvanceCinemaText(double clock);
void SetPalette(int pal) { currentCinemaPalette = pal; } void SetPalette(int pal) { currentCinemaPalette = pal; }
}; };

View file

@ -405,7 +405,6 @@ void DrawView(double smoothRatio, bool sceneonly)
if (nFreeze == 2) if (nFreeze == 2)
{ {
int myclock = leveltime + mulscale16(4, (int)smoothRatio);
if (nHeadStage == 4) if (nHeadStage == 4)
{ {
nHeadStage = 5; nHeadStage = 5;
@ -424,7 +423,7 @@ void DrawView(double smoothRatio, bool sceneonly)
if (bSubTitles) if (bSubTitles)
{ {
subtitleOverlay.Start(myclock); subtitleOverlay.Start(I_GetTimeNS());
if (currentLevel->levelNumber == 1) if (currentLevel->levelNumber == 1)
subtitleOverlay.ReadyCinemaText(1); subtitleOverlay.ReadyCinemaText(1);
else else
@ -434,7 +433,7 @@ void DrawView(double smoothRatio, bool sceneonly)
} }
else if (nHeadStage == 5) else if (nHeadStage == 5)
{ {
if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(myclock)) || inputState.CheckAllInput()) if ((bSubTitles && !subtitleOverlay.AdvanceCinemaText(I_GetTimeNS())) || inputState.CheckAllInput())
{ {
inputState.ClearAllInput(); inputState.ClearAllInput();
EndLevel = 1; EndLevel = 1;