From 9a10dfeaee7a76e5247ffda4cedd9dcdf2648efa Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Wed, 25 Oct 2017 16:40:21 +0100 Subject: [PATCH] Replaced the laggy randomised-at-runtime static with sufficiently random low-impact pregenerated static. Requires new patch.dta. https://cdn.discordapp.com/attachments/293238104096112641/372770688890830859/srb20003.gif --- src/dehacked.c | 1 - src/m_menu.c | 64 +++++++++++++++++++++++++++++------------- src/v_video.c | 75 ++++++++++++++++++++++++++------------------------ src/v_video.h | 1 - src/y_inter.c | 2 +- 5 files changed, 85 insertions(+), 58 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 774257d4d..6bf22a204 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7331,7 +7331,6 @@ struct { {"V_70TRANS",V_70TRANS}, {"V_80TRANS",V_80TRANS}, {"V_90TRANS",V_90TRANS}, - {"V_STATIC",V_STATIC}, {"V_HUDTRANSHALF",V_HUDTRANSHALF}, {"V_HUDTRANS",V_HUDTRANS}, {"V_HUDTRANSDOUBLE",V_HUDTRANSDOUBLE}, diff --git a/src/m_menu.c b/src/m_menu.c index a4a271d7e..780ca3d16 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3085,6 +3085,26 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) */ } +#define scale FRACUNIT/2 + +static fixed_t staticalong = 0; + +static void M_DrawStaticBox(fixed_t x, fixed_t y, INT32 flags, fixed_t w, fixed_t h) +{ + patch_t *patch = W_CachePatchName("LSSTATIC", PU_CACHE); + INT32 pw = SHORT(patch->width); + fixed_t sw = FixedDiv(w, scale); + + if (staticalong >= (pw - sw)) + staticalong = 0; + + V_DrawCroppedPatch(x<>FRACBITS]))<<8)&0xff00) + (*dest&0xff)); } -static UINT8 staticstep = 0; -static fixed_t staticval = 0; - -static inline UINT8 staticpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) -{ - UINT8 val = source[ofs>>FRACBITS]; - (void)dest; - if ((++staticstep) >= 4) - { - staticstep = 0; - staticval = M_RandomFixed(); - } - if (val < 7) return val; - return ((staticval>>staticstep)&7)+(val-7); -} - // Draws a patch scaled to arbitrary size. void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) { @@ -571,25 +555,18 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t patchdrawfunc = standardpdraw; v_translevel = NULL; - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT)) == 12) // static + if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) { - alphalevel = 0; - patchdrawfunc = staticpdraw; - } - else - { - if (alphalevel) - { - if (alphalevel == 13) - alphalevel = hudminusalpha[cv_translucenthud.value]; - else if (alphalevel == 14) - alphalevel = 10 - cv_translucenthud.value; - else if (alphalevel == 15) - alphalevel = hudplusalpha[cv_translucenthud.value]; + if (alphalevel == 13) + alphalevel = hudminusalpha[cv_translucenthud.value]; + else if (alphalevel == 14) + alphalevel = 10 - cv_translucenthud.value; + else if (alphalevel == 15) + alphalevel = hudplusalpha[cv_translucenthud.value]; + + if (alphalevel >= 10) + return; // invis - if (alphalevel >= 10) - return; // invis - } if (alphalevel) { v_translevel = transtables + ((alphalevel-1)<> V_ALPHASHIFT))) + { + if (alphalevel == 13) + alphalevel = hudminusalpha[cv_translucenthud.value]; + else if (alphalevel == 14) + alphalevel = 10 - cv_translucenthud.value; + else if (alphalevel == 15) + alphalevel = hudplusalpha[cv_translucenthud.value]; + + if (alphalevel >= 10) + return; // invis + + if (alphalevel) + { + v_translevel = transtables + ((alphalevel-1)<>FRACBITS) < SHORT(patch->width) && (col>>FRACBITS) < w; col += colfrac, ++x, desttop++) + for (col = sx<>FRACBITS) < SHORT(patch->width) && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) { INT32 topdelta, prevdelta = -1; if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) @@ -863,10 +866,10 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ dest = desttop; dest += FixedInt(FixedMul(topdelta<>FRACBITS) < column->length && ((ofs>>FRACBITS) + topdelta) < h; ofs += rowfrac) + for (ofs = sy<>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) { if (dest >= screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) - *dest = source[ofs>>FRACBITS]; + *dest = patchdrawfunc(dest, source, ofs); dest += vid.width; } column = (const column_t *)((const UINT8 *)column + column->length + 4); diff --git a/src/v_video.h b/src/v_video.h index 3781f3337..f9fd475f4 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -94,7 +94,6 @@ extern RGBA_t *pMasterPalette; #define V_70TRANS 0x00070000 #define V_80TRANS 0x00080000 // used to be V_8020TRANS #define V_90TRANS 0x00090000 -#define V_STATIC 0x000C0000 // ogl unsupported kthnxbai #define V_HUDTRANSHALF 0x000D0000 #define V_HUDTRANS 0x000E0000 // draw the hud translucent #define V_HUDTRANSDOUBLE 0x000F0000 diff --git a/src/y_inter.c b/src/y_inter.c index 185a6c1fe..0ed225584 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -205,7 +205,7 @@ static void Y_IntermissionTokenDrawer(void) calc = (lowy - y)*2; if (calc > 0) - V_DrawCroppedPatch(32<width), calc); + V_DrawCroppedPatch(32<width), calc); } //