Port Saturn alternative FPS Counters

This commit is contained in:
NepDisk 2025-10-09 02:46:34 -04:00
parent 82a6edce5d
commit 47a95ac76b
3 changed files with 60 additions and 25 deletions

View file

@ -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<<FRACBITS, 183<<FRACBITS, FRACUNIT, V_SNAPTOBOTTOM|V_SNAPTORIGHT, framecounter, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_YELLOW, GTC_CACHE));
if (fps > (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<<FRACBITS, 183<<FRACBITS, FRACUNIT, fpsflags, framecounter, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_YELLOW, GTC_CACHE));
if (fps > (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<<FRACBITS, 190<<FRACBITS, FRACUNIT, fpsflags, frameslash, ticcntcolor);
}
// draw total frame:
V_DrawPingNum(x, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT, cap, ticcntcolor);
x -= digits * 4;
// draw "/"
V_DrawFixedPatch(x<<FRACBITS, 190<<FRACBITS, FRACUNIT, V_SNAPTOBOTTOM|V_SNAPTORIGHT, frameslash, ticcntcolor);
// draw our actual framerate
V_DrawPingNum(x, 190, fpsflags, fps, ticcntcolor);
}
else if (cv_ticrate.value == 3 || cv_ticrate.value == 4) // kart v1.0/srb2 counter
{
const char *fps_string;
INT32 ticcntcolor2 = 0;
// draw our actual framerate
V_DrawPingNum(x, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT, fps, ticcntcolor);
if (fps > (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

View file

@ -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);

View file

@ -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);