- adjustments for frame rate limiting copied from Duke3D project.

This commit is contained in:
Christoph Oelckers 2019-09-20 13:54:27 +02:00
parent b014ae4d54
commit ceceb63b5e
5 changed files with 35 additions and 17 deletions

View file

@ -1046,6 +1046,7 @@ nextdemo_nomenu:
if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL))
{
Demo_FinishProfile();
videoNextPage();
goto RECHECK;
}
@ -1104,6 +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();
}
// NOTE: We must prevent handleevents() and Net_GetPackets() from

View file

@ -7692,29 +7692,33 @@ void G_MaybeAllocPlayer(int32_t pnum)
int G_FPSLimit(void)
{
static uint64_t nextPageTicks = 0;
static unsigned frameWaiting = 0;
static double nextPageDelay = g_frameDelay;
static uint64_t lastFrameTicks = timerGetTicksU64() - (uint64_t)g_frameDelay;
int frameWaiting = 0;
if (frameWaiting)
{
frameWaiting--;
videoNextPage();
}
uint64_t const frameTicks = timerGetTicksU64();
uint64_t elapsedTime = frameTicks - lastFrameTicks;
uint64_t const frameTicks = timerGetTicksU64();
if (!r_maxfps || elapsedTime >= (uint64_t)nextPageDelay)
{
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;
}
if (!r_maxfps || frameTicks >= nextPageTicks)
{
if (frameTicks >= nextPageTicks + g_frameDelay)
nextPageTicks = frameTicks;
lastFrameTicks = frameTicks;
++frameWaiting;
}
nextPageTicks += g_frameDelay;
frameWaiting++;
}
return frameWaiting;
return frameWaiting;
}
// TODO: reorder (net)actor_t to eliminate slop and update assertion
EDUKE32_STATIC_ASSERT(sizeof(actor_t)%4 == 0);
EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t)%4 == 0);
@ -8370,6 +8374,7 @@ MAIN_LOOP_RESTART:
if (videoGetRenderMode() >= REND_POLYMOST)
G_DrawBackground();
G_DisplayRest(smoothRatio);
videoNextPage();
if (gameUpdate)
{

View file

@ -1160,6 +1160,7 @@ void Screen_Play(void)
// nextpage();
I_ClearAllInput();
videoNextPage();
} while (running);
}

View file

@ -223,6 +223,7 @@ void Net_WaitForServer(void)
{
display_betascreen();
gametext_center_shade(170, "Waiting for server", 14);
videoNextPage();
}
// XXX: this looks like something that should be rate limited...

View file

@ -1605,6 +1605,7 @@ void G_DisplayLogo(void)
P_SetGamePalette(g_player[myconnectindex].ps, g_player[myconnectindex].ps->palette, 0);
g_restorePalette = 0;
}
videoNextPage();
}
}
@ -1695,6 +1696,7 @@ void G_DisplayLogo(void)
P_SetGamePalette(g_player[myconnectindex].ps, g_player[myconnectindex].ps->palette, 0);
g_restorePalette = 0;
}
videoNextPage();
}
G_HandleAsync();
@ -1882,6 +1884,7 @@ 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();
}
G_HandleAsync();
@ -2281,6 +2284,7 @@ void G_BonusScreen(int32_t bonusonly)
{
videoClearScreen(0);
G_DisplayMPResultsScreen();
videoNextPage();
}
if (I_CheckAllInput())
@ -2647,6 +2651,8 @@ void G_BonusScreen(int32_t bonusonly)
}
else
break;
videoNextPage();
}
} while (1);
if (g_turdLevel)
@ -2872,6 +2878,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
{
videoClearScreen(0);
G_DisplayMPResultsScreen();
videoNextPage();
}
if (I_CheckAllInput())
@ -3156,6 +3163,8 @@ void G_BonusScreenRRRA(int32_t bonusonly)
}
else
break;
videoNextPage();
}
} while (1);
if (ud.eog)