From 8b8f0483938a5fb7aba83cd1ada0fe0f7933a34d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 23 Aug 2020 18:08:08 +0200 Subject: [PATCH] - moved parts of videoNextPage to app_loop. --- source/build/include/build.h | 2 +- source/build/src/engine.cpp | 30 ++---------------------------- source/core/gamecontrol.cpp | 16 ++++++++++++++++ source/core/savegamehelp.cpp | 2 -- source/exhumed/src/enginesubs.cpp | 3 +-- source/exhumed/src/exhumed.cpp | 2 -- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 85780f1dd..fa8f6815a 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -369,7 +369,7 @@ EXTERN int32_t display_mirror; EXTERN ClockTicks totalclock, totalclocklock; static inline int32_t BGetTime(void) { return (int32_t) totalclock; } -EXTERN int32_t numframes, randomseed; +EXTERN int32_t randomseed; EXTERN int16_t sintable[2048]; EXTERN int16_t numshades; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index e530b05f2..d7b771e7c 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -1275,8 +1275,6 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, { int32_t i; - beforedrawrooms = 0; - set_globalpos(daposx, daposy, daposz); set_globalang(daang); @@ -1922,8 +1920,6 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang) renderSetAspect(65536, divscale16((320*5)/8, 200)); - beforedrawrooms = 0; - Bmemset(gotsector, 0, sizeof(gotsector)); vec2_t const c1 = { (windowxy1.x<<12), (windowxy1.y<<12) }; @@ -2723,28 +2719,13 @@ int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daups return 0; } -void DrawFullscreenBlends(); - // // nextpage // void videoNextPage(void) { - // Draw overlay elements to the 2D drawer - FStat::PrintStat(twod); - C_DrawConsole(); - M_Drawer(); - - // Handle the final 2D overlays. - if (gamestate == GS_LEVEL) DrawFullscreenBlends(); - DrawRateStuff(); - - if (in3dmode()) - { - g_beforeSwapTime = timerGetHiTicks(); - - videoShowFrame(0); - } + g_beforeSwapTime = timerGetHiTicks(); + videoShowFrame(0); omdtims = mdtims; mdtims = timerGetTicks(); @@ -2752,13 +2733,6 @@ void videoNextPage(void) for (native_t i = 0; i < MAXSPRITES + MAXUNIQHUDID; ++i) if ((mdpause && spriteext[i].mdanimtims) || (spriteext[i].flags & SPREXT_NOMDANIM)) spriteext[i].mdanimtims += mdtims - omdtims; - - beforedrawrooms = 1; - numframes++; - // This should be in the main loop but with some of the games still having multiple render loops it cannot be moved out of here - twod->SetSize(screen->GetWidth(), screen->GetHeight()); - twodpsp.SetSize(screen->GetWidth(), screen->GetHeight()); - I_SetFrameTime(); } // diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index fcfd56132..2388da789 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -118,6 +118,7 @@ void S_ParseSndInfo(); void I_DetectOS(void); void LoadScripts(); void app_loop(); +void DrawFullscreenBlends(); bool AppActive; @@ -847,6 +848,7 @@ int RunGame() gamestate = GS_LEVEL; gi->app_init(); app_loop(); + return 0; // this is never reached. app_loop only exits via exception. } //--------------------------------------------------------------------------- @@ -863,7 +865,21 @@ void app_loop() { try { + twod->SetSize(screen->GetWidth(), screen->GetHeight()); + twodpsp.SetSize(screen->GetWidth(), screen->GetHeight()); + I_SetFrameTime(); + gi->RunGameFrame(); + + // Draw overlay elements to the 2D drawer + FStat::PrintStat(twod); + C_DrawConsole(); + M_Drawer(); + + // Handle the final 2D overlays. + if (gamestate == GS_LEVEL) DrawFullscreenBlends(); + DrawRateStuff(); + videoNextPage(); videoSetBrightness(0); // immediately reset this so that the value doesn't stick around in the backend. } diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index 937c5ae40..f8f99fc9f 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -472,7 +472,6 @@ void SaveEngineState() fw->Write(&myconnectindex, sizeof(myconnectindex)); fw->Write(&connecthead, sizeof(connecthead)); fw->Write(connectpoint2, sizeof(connectpoint2)); - fw->Write(&numframes, sizeof(numframes)); fw->Write(&randomseed, sizeof(randomseed)); fw->Write(&numshades, sizeof(numshades)); fw->Write(&automapping, sizeof(automapping)); @@ -536,7 +535,6 @@ void LoadEngineState() fr.Read(&myconnectindex, sizeof(myconnectindex)); fr.Read(&connecthead, sizeof(connecthead)); fr.Read(connectpoint2, sizeof(connectpoint2)); - fr.Read(&numframes, sizeof(numframes)); fr.Read(&randomseed, sizeof(randomseed)); fr.Read(&numshades, sizeof(numshades)); fr.Read(&automapping, sizeof(automapping)); diff --git a/source/exhumed/src/enginesubs.cpp b/source/exhumed/src/enginesubs.cpp index 2c138c3a1..023cb2621 100644 --- a/source/exhumed/src/enginesubs.cpp +++ b/source/exhumed/src/enginesubs.cpp @@ -29,8 +29,7 @@ BEGIN_PS_NS void resettiming() { - numframes = 0L; - totalclock = 0L; + totalclock = 0; // TODO totalclocklock = 0L; } diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index 461bdca60..71e8e00ed 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -77,8 +77,6 @@ void ResetEngine() totalclock = 0; ototalclock = totalclock; localclock = (int)totalclock; - - numframes = 0; } void InstallEngine()