diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index 632a3d345..173839216 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -459,6 +459,7 @@ void PreloadCache(void) { Bsprintf(tempbuf, "Loaded %d%% (%d/%d textures)\n", percentDisplayed, cnt, nPrecacheCount); viewLoadingScreenUpdate(tempbuf, percentDisplayed); + videoNextPage(); timerUpdate(); if (totalclock - clock >= 1) @@ -1694,6 +1695,7 @@ RESTART: default: break; } + videoNextPage(); } //scrNextPage(); if (TestBitString(gotpic, 2342)) diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index 44d0525e4..ba462bd44 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -411,6 +411,7 @@ _DEMOPLAYBACK: viewDrawScreen(); if (gInputMode == INPUT_MODE_1 && CGameMenuMgr::m_bActive) gGameMenuMgr.Draw(); + videoNextPage(); } if (TestBitString(gotpic, 2342)) { diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index 76d7a9e05..403ff7f71 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -2071,6 +2071,7 @@ void SaveGame(CGameMenuItemZEditBitmap *pItem, CGameMenuEvent *event) sprintf(gGameOptions.szSaveGameName, "%s", strSaveGameName); gGameOptions.nSaveGameSlot = nSlot; viewLoadingScreen(2518, "Saving", "Saving Your Game", strRestoreGameStrings[nSlot]); + videoNextPage(); gSaveGameNum = nSlot; LoadSave::SaveGame(strSaveGameName); gQuickSaveSlot = nSlot; @@ -2092,6 +2093,7 @@ void QuickSaveGame(void) sprintf(gGameOptions.szSaveGameName, "%s", strSaveGameName); gGameOptions.nSaveGameSlot = gQuickSaveSlot; viewLoadingScreen(2518, "Saving", "Saving Your Game", strRestoreGameStrings[gQuickSaveSlot]); + videoNextPage(); LoadSave::SaveGame(strSaveGameName); gGameOptions.picEntry = gSavedOffset; gSaveGameOptions[gQuickSaveSlot] = gGameOptions; @@ -2110,6 +2112,7 @@ void LoadGame(CGameMenuItemZEditBitmap *pItem, CGameMenuEvent *event) if (!testkopen(strLoadGameName, 0)) return; viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[nSlot]); + videoNextPage(); LoadSave::LoadGame(strLoadGameName); gGameMenuMgr.Deactivate(); gQuickLoadSlot = nSlot; @@ -2124,6 +2127,7 @@ void QuickLoadGame(void) if (!testkopen(strLoadGameName, 0)) return; viewLoadingScreen(2518, "Loading", "Loading Saved Game", strRestoreGameStrings[gQuickLoadSlot]); + videoNextPage(); LoadSave::LoadGame(strLoadGameName); gGameMenuMgr.Deactivate(); } diff --git a/source/blood/src/network.cpp b/source/blood/src/network.cpp index bc7d924d8..b64047088 100644 --- a/source/blood/src/network.cpp +++ b/source/blood/src/network.cpp @@ -996,6 +996,7 @@ void netInitialize(bool bConsole) char buffer[128]; sprintf(buffer, "Waiting for players (%i\\%i)", numplayers, gNetPlayers); viewLoadingScreen(2518, "Network Game", NULL, buffer); + videoNextPage(); } while (numplayers < gNetPlayers) { @@ -1037,6 +1038,7 @@ void netInitialize(bool bConsole) char buffer[128]; sprintf(buffer, "Waiting for players (%i\\%i)", numplayers, gNetPlayers); viewLoadingScreen(2518, "Network Game", NULL, buffer); + videoNextPage(); } break; } @@ -1068,6 +1070,7 @@ void netInitialize(bool bConsole) char buffer[128]; sprintf(buffer, "Waiting for players (%i\\%i)", numplayers, gNetPlayers); viewLoadingScreen(2518, "Network Game", NULL, buffer); + videoNextPage(); } break; } @@ -1129,6 +1132,7 @@ void netInitialize(bool bConsole) if (!bConsole) { viewLoadingScreen(2518, "Network Game", NULL, buffer); + videoNextPage(); } gNetENetClient = enet_host_create(NULL, 1, BLOOD_ENET_CHANNEL_MAX, 0, 0); enet_address_set_host(&gNetENetAddress, gNetAddress); @@ -1153,6 +1157,7 @@ void netInitialize(bool bConsole) if (!bConsole) { viewLoadingScreen(2518, "Network Game", NULL, "Waiting for server response"); + videoNextPage(); } while (bWaitServer) { diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 90939b403..68f256b2a 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -2918,24 +2918,27 @@ double g_frameDelay = 0.0; int viewFPSLimit(void) { - static auto nextPageTicks = (double)timerGetTicksU64(); - static unsigned frameWaiting = 0; + static double nextPageDelay = g_frameDelay; + static uint64_t lastFrameTicks = timerGetTicksU64() - (uint64_t) g_frameDelay; + int frameWaiting = 0; - if (frameWaiting) + uint64_t const frameTicks = timerGetTicksU64(); + uint64_t elapsedTime = frameTicks-lastFrameTicks; + + if (!r_maxfps || elapsedTime >= (uint64_t) nextPageDelay) { - frameWaiting--; - videoNextPage(); - } + if (elapsedTime >= (uint64_t) (nextPageDelay + g_frameDelay)) + { + //If we missed a frame, reset any cumulated remainder from rendering frames early + nextPageDelay = g_frameDelay; + } + else + { + nextPageDelay += g_frameDelay - elapsedTime; + } - auto const frameTicks = (double)timerGetTicksU64(); - - if (!r_maxfps || frameTicks >= nextPageTicks) - { - if (frameTicks >= nextPageTicks + g_frameDelay) - nextPageTicks = frameTicks; - - nextPageTicks += g_frameDelay; - frameWaiting++; + lastFrameTicks = frameTicks; + ++frameWaiting; } return frameWaiting; @@ -3588,7 +3591,6 @@ void viewLoadingScreenUpdate(const char *pzText4, int nPercent) TileHGauge(2260, 86, 110, nPercent, 100, 0, 131072); viewDrawText(3, "Please Wait", 160, 134, -128, 0, 1, 1); - scrNextPage(); } void viewLoadingScreen(int nTile, const char *pText, const char *pText2, const char *pText3) diff --git a/source/rr/src/demo.cpp b/source/rr/src/demo.cpp index 76fe04188..951dffc24 100644 --- a/source/rr/src/demo.cpp +++ b/source/rr/src/demo.cpp @@ -1046,7 +1046,7 @@ nextdemo_nomenu: if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL)) { Demo_FinishProfile(); - videoNextPage(); + videoNextPage(); goto RECHECK; } @@ -1105,7 +1105,7 @@ nextdemo_nomenu: if (ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) rotatesprite_fs((320-50)<<16, 9<<16, 65536L, 0, BETAVERSION, 0, 0, 2+8+16+128); } - videoNextPage(); + videoNextPage(); } // NOTE: We must prevent handleevents() and Net_GetPackets() from diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 3afb9e79d..69b7cc9a4 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -8424,7 +8424,7 @@ MAIN_LOOP_RESTART: if (videoGetRenderMode() >= REND_POLYMOST) G_DrawBackground(); G_DisplayRest(smoothRatio); - videoNextPage(); + videoNextPage(); if (gameUpdate) { diff --git a/source/rr/src/gameexec.cpp b/source/rr/src/gameexec.cpp index 2db76bb8e..c0a885f5f 100644 --- a/source/rr/src/gameexec.cpp +++ b/source/rr/src/gameexec.cpp @@ -1147,8 +1147,7 @@ void Screen_Play(void) if (I_CheckAllInput()) running = 0; - // nextpage(); - + videoNextPage(); I_ClearAllInput(); videoNextPage(); } while (running); diff --git a/source/rr/src/net.cpp b/source/rr/src/net.cpp index 627b8347a..d6e81800d 100644 --- a/source/rr/src/net.cpp +++ b/source/rr/src/net.cpp @@ -170,9 +170,9 @@ void Net_WaitForEverybody(void) if (G_FPSLimit()) { display_betascreen(); - gametext_center_shade(170, "Waiting for server", 14); - videoNextPage(); - } + gametext_center_shade(170, "Waiting for players", 14); + videoNextPage(); + }; G_HandleAsync(); Net_GetPackets(); diff --git a/source/rr/src/screens.cpp b/source/rr/src/screens.cpp index 6783c726e..ad487da11 100644 --- a/source/rr/src/screens.cpp +++ b/source/rr/src/screens.cpp @@ -1632,7 +1632,7 @@ void G_DisplayLogo(void) P_SetGamePalette(g_player[myconnectindex].ps, g_player[myconnectindex].ps->palette, 0); g_restorePalette = 0; } - videoNextPage(); + videoNextPage(); } } @@ -1723,7 +1723,8 @@ void G_DisplayLogo(void) P_SetGamePalette(g_player[myconnectindex].ps, g_player[myconnectindex].ps->palette, 0); g_restorePalette = 0; } - videoNextPage(); + + videoNextPage(); } G_HandleAsync(); @@ -1911,7 +1912,8 @@ static void G_BonusCutscenes(void) rotatesprite_fs(breathe[t+3]<<16, breathe[t+4]<<16, 65536L, 0, breathe[t+2], 0, 0, 2+8+16+64+128+BGSTRETCH); } } - videoNextPage(); + + videoNextPage(); } G_HandleAsync(); @@ -2311,7 +2313,7 @@ void G_BonusScreen(int32_t bonusonly) { videoClearScreen(0); G_DisplayMPResultsScreen(); - videoNextPage(); + videoNextPage(); } if (I_CheckAllInput()) @@ -2679,7 +2681,7 @@ void G_BonusScreen(int32_t bonusonly) else break; - videoNextPage(); + videoNextPage(); } } while (1); if (g_turdLevel) @@ -2905,7 +2907,7 @@ void G_BonusScreenRRRA(int32_t bonusonly) { videoClearScreen(0); G_DisplayMPResultsScreen(); - videoNextPage(); + videoNextPage(); } if (I_CheckAllInput()) @@ -3190,8 +3192,7 @@ void G_BonusScreenRRRA(int32_t bonusonly) } else break; - - videoNextPage(); + videoNextPage(); } } while (1); if (ud.eog)