From 42fa2cf28628217d078b0e9a9f7474fb05f0c467 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Tue, 28 Feb 2023 19:20:31 -0600 Subject: [PATCH] hwr2: restore software CustomFadeScreen --- src/v_video.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index 87a4ddfbe..b9ea539bb 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1570,8 +1570,6 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength) // void V_DrawCustomFadeScreen(const char *lump, UINT8 strength) { - (void)lump; - (void)strength; #ifdef HWRENDER if (rendermode != render_soft && rendermode != render_none) { @@ -1580,7 +1578,37 @@ void V_DrawCustomFadeScreen(const char *lump, UINT8 strength) } #endif - // NOTE: This is not implementable in HWR2. + // TODO: fix this for Twodee + { + lumpnum_t lumpnum = LUMPERROR; + lighttable_t *clm = NULL; + + if (lump != NULL) + lumpnum = W_GetNumForName(lump); + else + return; + + if (lumpnum != LUMPERROR) + { + clm = static_cast(Z_MallocAlign(COLORMAP_SIZE, PU_STATIC, NULL, 8)); + W_ReadLump(lumpnum, clm); + + if (clm != NULL) + { + const UINT8 *fadetable = ((UINT8 *)clm + strength*256); + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + UINT8 *buf = screens[0]; + + // heavily simplified -- we don't need to know x or y + // position when we're doing a full screen fade + for (; buf < deststop; ++buf) + *buf = fadetable[*buf]; + + Z_Free(clm); + clm = NULL; + } + } + } } // Simple translucency with one color, over a set number of lines starting from the top.