From c51cfcd81735f2cd78f25302db27697e11afd21c Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:44:37 +0100 Subject: [PATCH] Add cv_uncappedhud toggle and R_GetHudUncap Turns out I need to AND with FRACMASK everywhere to avoid discrepencies, so might as well make a function for it (no, it's NOT interpolation, I swear...!) --- src/f_finale.c | 10 +++++----- src/k_kart.c | 19 +++++++++---------- src/m_menu.c | 4 ++++ src/r_main.c | 7 +++++++ src/r_main.h | 5 ++++- src/st_stuff.c | 2 +- src/y_inter.c | 5 ++--- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index f085ae6f6..cd72cc122 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -169,8 +169,8 @@ static void F_SkyScroll(INT32 scrollspeed) w = (vid.width / vid.dupx)<width)*16))<width)<width)*16))<width)*16))<width)<width)*16))<= 20) V_DrawSmallScaledPatch(84, 87, 0, ttkart); else if (finalecount >= 10) - V_DrawSciencePatch((84<height, mapheight); zoom = FixedMul(min(xscale, yscale), FRACUNIT-FRACUNIT/20); - #define lerp(from, to) from + FixedMul(rendertimefrac, to - from) + #define lerp(from, to) cv_uncappedhud.value ? from + FixedMul(rendertimefrac, to - from) : to amnumxpos = (FixedMul(lerp(mo->old_x, mo->x), zoom) - FixedMul(xoffset, zoom)); amnumypos = -(FixedMul(lerp(mo->old_y, mo->y), zoom) - FixedMul(yoffset, zoom)); #undef lerp @@ -9854,7 +9854,7 @@ static void K_drawKartFinish(void) x = ((vid.width<width)<kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; + x = (FixedMul(((TICRATE - stplyr->kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; if (splitscreen && stplyr == &players[displayplayers[1]]) x = -x; @@ -9873,7 +9873,7 @@ static void K_drawBattleFullscreen(void) // fill in the fractional bits if (cardanim && cardanim != 164*FRACUNIT) { - INT32 frac = (rendertimefrac & FRACMASK) * ((164 - stplyr->kartstuff[k_cardanimation])/8 + 1); + INT32 frac = R_GetHudUncap() * ((164 - stplyr->kartstuff[k_cardanimation])/8 + 1); if (stplyr->exiting) cardanim += frac; else @@ -10171,12 +10171,12 @@ static void K_drawInput(void) if (timeinmap < 113) { INT32 count = ((INT32)(timeinmap) - 105); - INT32 frac = count > 0 && count < 6 ? rendertimefrac << (FRACBITS - count - 11) : 0; + INT32 frac = count > 0 && count < 6 ? R_GetHudUncap() << (FRACBITS - count - 11) : 0; offs = 64*FRACUNIT; while (count-- > 0) offs >>= 1; - x += offs - frac; + x += (offs < FRACUNIT ? 0 : offs) - frac; } #define BUTTW 8 @@ -10273,9 +10273,8 @@ static void K_drawLapStartAnim(void) UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); INT32 vflags = V_SNAPTOTOP|V_HUDTRANS; - fixed_t frac = rendertimefrac & FRACMASK; - fixed_t slideout = max(0, 32*(((progress - 76)*FRACUNIT) + frac)); - fixed_t slidein = max(0, 32*(((stplyr->kartstuff[k_lapanimation] - 76)*FRACUNIT) - frac)); + fixed_t slideout = max(0, 32*(((progress - 76)*FRACUNIT) + R_GetHudUncap())); + fixed_t slidein = max(0, 32*(((stplyr->kartstuff[k_lapanimation] - 76)*FRACUNIT) - R_GetHudUncap())); // First, draw the emblem and hand INT32 emblemx = (BASEVIDWIDTH << (FRACBITS - 1)) + slidein; @@ -10286,7 +10285,7 @@ static void K_drawLapStartAnim(void) INT32 hand = stplyr->kartstuff[k_laphand]; if (hand >= 1 && hand <= 3) { - y += 4*FRACUNIT - abs((int)(leveltime % 8)*FRACUNIT + rendertimefrac - 4*FRACUNIT); + y += 4*FRACUNIT - abs((int)(leveltime % 8)*FRACUNIT + R_GetHudUncap() - 4*FRACUNIT); V_DrawFixedPatch(emblemx, y, FRACUNIT, vflags, kp_lapanim_hand[hand - 1], NULL); } @@ -10564,7 +10563,7 @@ void K_drawKartHUD(void) if (timeinmap < 113) { INT32 count = ((INT32)(timeinmap) - 104); - INT32 frac = count > 0 ? rendertimefrac << max(0, FRACBITS - count - 9) : 0; + INT32 frac = count > 0 ? R_GetHudUncap() << max(0, FRACBITS - count - 9) : 0; offs = 256*FRACUNIT; while (count-- > 0) diff --git a/src/m_menu.c b/src/m_menu.c index 36ba581f1..af5c93459 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2013,6 +2013,8 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 90}, {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 95}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 105}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 115}, {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 125}, @@ -2040,6 +2042,7 @@ static const char* OP_SaturnTooltips[] = "Show Localskin Menus.", "Nametag Options.", "Driftgauge Options.", + "Uncaps the HUD framerate, making it appear smoother.", "Disables the flicker effect on Midnight Channel.", "Options for sprite distortion effects.", "Move position of HUD elements.", @@ -2065,6 +2068,7 @@ enum sm_showlocalskin, sm_nametagmen, sm_driftgaugemen, + sm_uncappedhud, sm_pisschannel, sm_distortionmenu, sm_hudoffsets, diff --git a/src/r_main.c b/src/r_main.c index fd2707a2d..565900d99 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -196,6 +196,7 @@ consvar_t cv_soniccd = {"soniccd", "Off", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NUL consvar_t cv_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_uncappedhud = {"uncappedhud", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -512,6 +513,11 @@ fixed_t R_PointToDist(fixed_t x, fixed_t y) return R_PointToDist2(viewx, viewy, x, y); } +INT32 R_GetHudUncap(void) +{ + return cv_uncappedhud.value ? rendertimefrac & FRACMASK : 0; +} + // // R_ScaleFromGlobalAngle // Returns the texture mapping scale for the current line (horizontal span) @@ -1862,6 +1868,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); + CV_RegisterVar(&cv_uncappedhud); CV_RegisterVar(&cv_maxportals); diff --git a/src/r_main.h b/src/r_main.h index c8c3f4e8c..1cbcd58f0 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -106,7 +106,7 @@ extern ps_metric_t ps_numpolyobjects; // REFRESH - the actual rendering functions. // -extern consvar_t cv_showhud, cv_translucenthud; +extern consvar_t cv_showhud, cv_translucenthud, cv_uncappedhud; extern consvar_t cv_homremoval; extern consvar_t cv_chasecam, cv_chasecam2, cv_chasecam3, cv_chasecam4; extern consvar_t cv_flipcam, cv_flipcam2, cv_flipcam3, cv_flipcam4; @@ -140,4 +140,7 @@ void R_RenderPlayerView(player_t *player); // add commands related to engine, at game startup void R_RegisterEngineStuff(void); + +// return multiplier for HUD uncap +INT32 R_GetHudUncap(void); #endif diff --git a/src/st_stuff.c b/src/st_stuff.c index bcc5c0f62..036eabead 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -741,7 +741,7 @@ static void ST_drawLevelTitle(void) // uh... "fill in the bits" of sub, or something... no idea what I came up with // VERY janky, but doesn't require m_easing - INT32 frac = (FixedMul(rendertimefrac, FixedDiv(dupcalc, BASEVIDWIDTH)) >> (count + 4))/13; // these two magic numbers seem to do the trick + INT32 frac = (FixedMul(R_GetHudUncap(), FixedDiv(dupcalc, BASEVIDWIDTH)) >> (count + 4))/13; // these two magic numbers seem to do the trick sub = dupcalc; while (count-- > 0) diff --git a/src/y_inter.c b/src/y_inter.c index 961ff28f5..0520b4730 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -432,12 +432,11 @@ void Y_IntermissionDrawer(void) if (sorttic != -1 && intertic >= sorttic && !demo.playback) { INT32 count = (intertic - sorttic); - INT32 frac = rendertimefrac & FRACMASK; if (count < 8) - x -= ((((count<>FRACBITS) / (8 * vid.dupx); + x -= ((((count<>FRACBITS) / (8 * vid.dupx); else if (count < 16) - x += (((((16 - count)<>FRACBITS) / (8 * vid.dupx); + x += (((((16 - count)<>FRACBITS) / (8 * vid.dupx); } // SRB2kart 290117 - compeltely replaced this block.