diff --git a/source/duke3d/src/cheats.cpp b/source/duke3d/src/cheats.cpp index 38b4eeda1..f2edca896 100644 --- a/source/duke3d/src/cheats.cpp +++ b/source/duke3d/src/cheats.cpp @@ -638,7 +638,7 @@ void G_DoCheats(void) return; case CHEAT_RATE: - if (ud.showfps++ > 2) + if (++ud.showfps > 3) ud.showfps = 0; end_cheat(pPlayer); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 5025240b2..a93bf5b49 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6748,6 +6748,8 @@ MAIN_LOOP_RESTART: OSD_DispatchQueued(); + char gameUpdate = false; + uint32_t gameUpdateStartTime = timerGetTicks(); if (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME) { if (g_networkMode != NET_DEDICATED_SERVER) @@ -6793,6 +6795,9 @@ MAIN_LOOP_RESTART: } } while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME); + + gameUpdate = true; + g_gameUpdateTime = timerGetTicks()-gameUpdateStartTime; } G_DoCheats(); @@ -6823,6 +6828,11 @@ MAIN_LOOP_RESTART: if (videoGetRenderMode() >= REND_POLYMOST) G_DrawBackground(); G_DisplayRest(smoothRatio); + + if (gameUpdate) + { + g_gameUpdateAndDrawTime = timerGetTicks()-gameUpdateStartTime; + } } // handle CON_SAVE and CON_SAVENN diff --git a/source/duke3d/src/global.h b/source/duke3d/src/global.h index c9c9ba0ac..3f4274a96 100644 --- a/source/duke3d/src/global.h +++ b/source/duke3d/src/global.h @@ -161,6 +161,8 @@ G_EXTERN projectile_t SpriteProjectile[MAXSPRITES]; G_EXTERN sound_t g_sounds[MAXSOUNDS]; G_EXTERN uint32_t everyothertime; G_EXTERN uint32_t g_moveThingsCount; +G_EXTERN uint32_t g_gameUpdateTime; +G_EXTERN uint32_t g_gameUpdateAndDrawTime; #ifndef global_c_ extern char CheatKeys[2]; diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 5f23cb676..bf1b05e37 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -1705,7 +1705,7 @@ int32_t registerosdcommands(void) { "r_camrefreshdelay", "minimum delay between security camera sprite updates, 120 = 1 second", (void *)&ud.camera_time, CVAR_INT, 1, 240 }, { "r_drawweapon", "enable/disable weapon drawing", (void *)&ud.drawweapon, CVAR_INT, 0, 2 }, - { "r_showfps", "show the frame rate counter", (void *)&ud.showfps, CVAR_INT, 0, 2 }, + { "r_showfps", "show the frame rate counter", (void *)&ud.showfps, CVAR_INT, 0, 3 }, { "r_shadows", "enable/disable sprite and model shadows", (void *)&ud.shadows, CVAR_BOOL, 0, 1 }, { "r_size", "change size of viewable area", (void *)&ud.screen_size, CVAR_INT|CVAR_FUNCPTR, 0, 64 }, { "r_rotatespritenowidescreen", "pass bit 1024 to all CON rotatesprite calls", (void *)&g_rotatespriteNoWidescreen, CVAR_BOOL|CVAR_FUNCPTR, 0, 1 }, diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 40fc2a92b..887b4ecf5 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -777,6 +777,7 @@ static void G_ShowCacheLocks(void) } #define LOW_FPS 30 +#define SLOW_FRAME_TIME 33 #if defined GEKKO # define FPS_YOFFSET 16 @@ -790,6 +791,7 @@ static void G_PrintFPS(void) { static int32_t frameCount = 0, lastFPS = 0, lastFrameTime = 0, cumulativeFrameDelay = 0; static int32_t minFPS = -1, maxFPS = 0; + static uint32_t minGameUpdate = -1, maxGameUpdate = 0; int32_t frameTime = timerGetTicks(); int32_t frameDelay = frameTime - lastFrameTime; @@ -821,6 +823,23 @@ static void G_PrintFPS(void) printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+20+FPS_YOFFSET, FPS_COLOR(minFPS < LOW_FPS), -1, tempbuf, x); } + if (ud.showfps > 2) + { + if (g_gameUpdateTime > maxGameUpdate) maxGameUpdate = g_gameUpdateTime; + if (g_gameUpdateTime < minGameUpdate) minGameUpdate = g_gameUpdateTime; + + chars = Bsprintf(tempbuf, "Game Update: %2d ms GU & Draw: %2d ms", g_gameUpdateTime, g_gameUpdateAndDrawTime); + + printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+30+2+FPS_YOFFSET, 0, -1, tempbuf, x); + printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+30+FPS_YOFFSET, + FPS_COLOR(g_gameUpdateAndDrawTime >= SLOW_FRAME_TIME), -1, tempbuf, x); + + chars = Bsprintf(tempbuf, "Min Game Update: %2d ms Max Game Update: %2d ms", minGameUpdate, maxGameUpdate); + + printext256(windowxy2.x-(chars<<(3-x))+1, windowxy1.y+40+2+FPS_YOFFSET, 0, -1, tempbuf, x); + printext256(windowxy2.x-(chars<<(3-x)), windowxy1.y+40+FPS_YOFFSET, + FPS_COLOR(maxGameUpdate >= SLOW_FRAME_TIME), -1, tempbuf, x); + } // lag meter if (g_netClientPeer) @@ -849,6 +868,8 @@ static void G_PrintFPS(void) { maxFPS = (lastFPS + maxFPS) >> 1; minFPS = (lastFPS + minFPS) >> 1; + maxGameUpdate = (g_gameUpdateTime + maxGameUpdate) >> 1; + minGameUpdate = (g_gameUpdateTime + minGameUpdate) >> 1; secondCounter = 0; } }