From 47a95ac76bbfa2c3ac6558fbd415b5bcd949d49e Mon Sep 17 00:00:00 2001 From: NepDisk Date: Thu, 9 Oct 2025 02:46:34 -0400 Subject: [PATCH] Port Saturn alternative FPS Counters --- src/screen.c | 75 ++++++++++++++++++++++++++++++++++----------------- src/v_video.c | 3 ++- src/v_video.h | 7 +++++ 3 files changed, 60 insertions(+), 25 deletions(-) diff --git a/src/screen.c b/src/screen.c index 4fb4965e2..c4bc47775 100644 --- a/src/screen.c +++ b/src/screen.c @@ -601,41 +601,68 @@ void SCR_CalculateFPS(void) void SCR_DisplayTicRate(void) { - const UINT8 *ticcntcolor = NULL; UINT32 cap = R_GetFramerateCap(); UINT32 benchmark = (cap == 0) ? I_GetRefreshRate() : cap; - INT32 x = 318; double fps = round(averageFPS); + INT32 fpsflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; - // draw "FPS" - V_DrawFixedPatch(306< (benchmark * 0.9)) - ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); - else if (fps < (benchmark * 0.5)) - ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); - - if (cap != 0) + if (cv_ticrate.value == 1 || cv_ticrate.value == 2) { - UINT32 digits = 1; - UINT32 c2 = cap; + const UINT8 *ticcntcolor = NULL; + INT32 x = 318; - while (c2 > 0) + // draw "FPS" + if (cv_ticrate.value == 1) + V_DrawFixedPatch(306< (benchmark * 0.9)) + ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); + else if (fps < (benchmark * 0.5)) + ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); + + if (cap != 0) { - c2 = c2 / 10; - digits++; + UINT32 digits = 1; + UINT32 c2 = cap; + + while (c2 > 0) + { + c2 = c2 / 10; + digits++; + } + + // draw total frame: + V_DrawPingNum(x, 190, fpsflags, cap, ticcntcolor); + x -= digits * 4; + + // draw "/" + V_DrawFixedPatch(x< (benchmark - 5)) + ticcntcolor2 = V_GREENMAP; + else if (fps < 20) + ticcntcolor2 = V_REDMAP; + + if (cap != 0) + fps_string = va("%d/%d\x82", (INT32)fps, cap); + else + fps_string = va("%d\x82", (INT32)fps); + + // draw "FPS" + if (cv_ticrate.value == 3) + V_DrawRightAlignedString(319, 181, V_YELLOWMAP|fpsflags, "FPS"); + + V_DrawRightAlignedString(319, 190, ticcntcolor2|fpsflags, fps_string); + } } // SCR_DisplayLocalPing diff --git a/src/v_video.c b/src/v_video.c index e2bab2fa6..50b9a6713 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -58,7 +58,8 @@ UINT8 *screens[5]; // screens[3] = fade screen start // screens[4] = fade screen end, postimage tempoarary buffer -consvar_t cv_ticrate = CVAR_INIT ("showfps", "No", CV_SAVE, CV_YesNo, NULL); +static CV_PossibleValue_t fps_cons_t[] = {{0, "No"}, {1, "Normal"}, {2, "Compact"}, {3, "Old"}, {4, "Old Compact"}, {0, NULL}}; +consvar_t cv_ticrate = CVAR_INIT ("showfps", "No", CV_SAVE, fps_cons_t, NULL); static void CV_palette_OnChange(void); diff --git a/src/v_video.h b/src/v_video.h index 445a990cd..53185fde5 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -17,6 +17,7 @@ #include "doomdef.h" #include "doomtype.h" #include "r_defs.h" +#include "r_main.h" // SRB2Kart #include "hu_stuff.h" // fonts @@ -368,6 +369,12 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option); INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option); +// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol +FUNCINLINE static ATTRINLINE INT32 V_LocalTransFlag(void) +{ + return ((10-cv_translucenthud.value)*V_10TRANS); +} + void V_DoPostProcessor(INT32 view, INT32 param); void V_DrawPatchFill(patch_t *pat);