From ad8376bcb0e4be48aaa383d0519ed1913e6d280c Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 20:41:34 +0300 Subject: [PATCH 01/22] Initial implementation --- src/strife/am_map.c | 32 ++++++++----- src/strife/d_main.c | 11 +++++ src/strife/m_menu.c | 14 +++++- src/strife/r_data.c | 108 ++++++++++++++++++++++++++++++++++-------- src/strife/r_defs.h | 5 +- src/strife/r_draw.c | 48 +++++++++++++------ src/strife/r_state.h | 1 + src/strife/st_stuff.c | 17 ++++++- src/v_video.c | 23 ++++++++- src/v_video.h | 2 +- 10 files changed, 208 insertions(+), 53 deletions(-) diff --git a/src/strife/am_map.c b/src/strife/am_map.c index 986cad970d..bd6ed081f7 100644 --- a/src/strife/am_map.c +++ b/src/strife/am_map.c @@ -49,7 +49,12 @@ extern boolean inhelpscreens; // [crispy] // Automap colors +#ifndef CRISPY_TRUECOLOR #define BACKGROUND 240 // haleyjd [STRIFE] +#else +// [JN] For some reason, 240 in true color showing WHITE color. +#define BACKGROUND 0 +#endif #define WALLCOLORS 5 // villsa [STRIFE] #define WALLRANGE 16 #define TSWALLCOLORS 16 @@ -1235,7 +1240,12 @@ AM_drawFline_Vanilla return; } -#define PUTDOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) +#define PUTDOT_RAW(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) +#ifndef CRISPY_TRUECOLOR +#define PUTDOT(xx,yy,cc) PUTDOT_RAW(xx,yy,cc) +#else +#define PUTDOT(xx,yy,cc) PUTDOT_RAW(xx,yy,(pal_color[(cc)])) +#endif dx = fl->b.x - fl->a.x; ax = 2 * (dx<0 ? -dx : dx); @@ -1307,7 +1317,7 @@ static void AM_drawFline_Smooth(fline_t* fl, int color) the line and so needs no weighting */ /* Always write the raw color value because we've already performed the necessary lookup * into colormap */ - PUTDOT(X0, Y0, BaseColor[0]); + PUTDOT_RAW(X0, Y0, BaseColor[0]); if ((DeltaX = X1 - X0) >= 0) { @@ -1327,7 +1337,7 @@ static void AM_drawFline_Smooth(fline_t* fl, int color) while (DeltaX-- != 0) { X0 += XDir; - PUTDOT(X0, Y0, BaseColor[0]); + PUTDOT_RAW(X0, Y0, BaseColor[0]); } return; } @@ -1337,7 +1347,7 @@ static void AM_drawFline_Smooth(fline_t* fl, int color) do { Y0++; - PUTDOT(X0, Y0, BaseColor[0]); + PUTDOT_RAW(X0, Y0, BaseColor[0]); } while (--DeltaY != 0); return; @@ -1349,7 +1359,7 @@ static void AM_drawFline_Smooth(fline_t* fl, int color) { X0 += XDir; Y0++; - PUTDOT(X0, Y0, BaseColor[0]); + PUTDOT_RAW(X0, Y0, BaseColor[0]); } while (--DeltaY != 0); return; @@ -1383,12 +1393,12 @@ static void AM_drawFline_Smooth(fline_t* fl, int color) intensity weighting for this pixel, and the complement of the weighting for the paired pixel */ Weighting = ErrorAcc >> IntensityShift; - PUTDOT(X0, Y0, BaseColor[Weighting]); - PUTDOT(X0 + XDir, Y0, BaseColor[(Weighting ^ WeightingComplementMask)]); + PUTDOT_RAW(X0, Y0, BaseColor[Weighting]); + PUTDOT_RAW(X0 + XDir, Y0, BaseColor[(Weighting ^ WeightingComplementMask)]); } /* Draw the final pixel, which is always exactly intersected by the line and so needs no weighting */ - PUTDOT(X1, Y1, BaseColor[0]); + PUTDOT_RAW(X1, Y1, BaseColor[0]); return; } /* It's an X-major line; calculate 16-bit fixed-point fractional part of a @@ -1410,13 +1420,13 @@ static void AM_drawFline_Smooth(fline_t* fl, int color) intensity weighting for this pixel, and the complement of the weighting for the paired pixel */ Weighting = ErrorAcc >> IntensityShift; - PUTDOT(X0, Y0, BaseColor[Weighting]); - PUTDOT(X0, Y0 + 1, BaseColor[(Weighting ^ WeightingComplementMask)]); + PUTDOT_RAW(X0, Y0, BaseColor[Weighting]); + PUTDOT_RAW(X0, Y0 + 1, BaseColor[(Weighting ^ WeightingComplementMask)]); } /* Draw the final pixel, which is always exactly intersected by the line and so needs no weighting */ - PUTDOT(X1, Y1, BaseColor[0]); + PUTDOT_RAW(X1, Y1, BaseColor[0]); } // diff --git a/src/strife/d_main.c b/src/strife/d_main.c index e9e9945201..23d8d4bb73 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -231,7 +231,13 @@ void D_Display (void) } // save the current screen if about to wipe +#ifndef CRISPY_TRUECOLOR if (gamestate != wipegamestate) +#else + // [JN] TODO - implement support for true color, + // wiping/fading via XLATAB is not possible! + if (gamestate != wipegamestate && false) +#endif { screenwipe = true; // [crispy] wipe = true; @@ -292,7 +298,11 @@ void D_Display (void) // clean up border stuff if (gamestate != oldgamestate && gamestate != GS_LEVEL) +#ifndef CRISPY_TRUECOLOR I_SetPalette (W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE)); +#else + I_SetPalette (0); +#endif // see if the border needs to be initially drawn if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL) @@ -1350,6 +1360,7 @@ static void D_IntroBackground(void) // Draw a 95-pixel rect from STARTUP0 starting at y=57 to (0,41) on the // screen (this was a memcpy directly to 0xA3340 in low DOS memory) // [crispy] use scaled function + // [JN] TODO - update for true color. V_DrawScaledBlock(0, 41, 320, 95, rawgfx_startup0 + (320*57)); } diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index 505a01f016..742d9af5cb 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -1395,7 +1395,8 @@ void M_DrawMouse(void) // [crispy] Crispness menu static void M_DrawCrispnessBackground(void) { - byte *src, *dest; + byte *src; + pixel_t *dest; src = W_CacheLumpName(back_flat, PU_CACHE); dest = I_VideoBuffer; @@ -2715,7 +2716,18 @@ boolean M_Responder (event_t* ev) if (crispy->gamma > 4+13) // [crispy] intermediate gamma levels crispy->gamma = 0; players[consoleplayer].message = DEH_String(gammamsg[crispy->gamma]); +#ifndef CRISPY_TRUECOLOR I_SetPalette (W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE)); +#else + { + // [JN] TODO - externalize R_InitColormaps() to header file. + extern void R_InitColormaps (void); + I_SetPalette (0); + R_InitColormaps(); + inhelpscreens = true; + R_FillBackScreen(); + } +#endif return true; } else if(gameversion == exe_strife_1_31 && key == key_spy) diff --git a/src/strife/r_data.c b/src/strife/r_data.c index b141c253a9..b0baed2afb 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -157,7 +157,8 @@ fixed_t* spritewidth; fixed_t* spriteoffset; fixed_t* spritetopoffset; -lighttable_t *colormaps, *pal_color; +lighttable_t *colormaps; +lighttable_t *pal_color; // [crispy] array holding palette colors for true color mode // @@ -690,38 +691,101 @@ void R_InitSpriteLumps (void) // void R_InitColormaps (void) { +#ifndef CRISPY_TRUECOLOR int lump; // Load in the light tables, 256 byte align tables. lump = W_GetNumForName(DEH_String("COLORMAP")); colormaps = W_CacheLumpNum(lump, PU_STATIC); - pal_color = colormaps; +#else + int c, i, j = 0; + byte r, g, b; - // [crispy] initialize color translation and color strings tables - { - byte *playpal = W_CacheLumpName("PLAYPAL", PU_STATIC); - char c[3]; - int i, j; + byte *const playpal = W_CacheLumpName("PLAYPAL", PU_STATIC); + byte *const colormap = W_CacheLumpName("COLORMAP", PU_STATIC); - if (!crstr) - crstr = I_Realloc(NULL, CRMAX * sizeof(*crstr)); + if (!colormaps) + { + colormaps = (lighttable_t*) Z_Malloc((NUMCOLORMAPS + 1) * 256 * sizeof(lighttable_t), PU_STATIC, 0); + } - // [crispy] CRMAX - 2: don't override the original GREN and BLUE2 Boom tables - for (i = 0; i < CRMAX - 2; i++) - { - for (j = 0; j < 256; j++) - { - cr[i][j] = V_Colorize(playpal, i, j, false); - } + if (crispy->truecolor) + { + for (c = 0; c < NUMCOLORMAPS; c++) + { + const float scale = 1. * c / NUMCOLORMAPS; - M_snprintf(c, sizeof(c), "%c%c", cr_esc, '0' + i); - crstr[i] = M_StringDuplicate(c); - } + for (i = 0; i < 256; i++) + { + const byte k = colormap[i]; - W_ReleaseLumpName("PLAYPAL"); - } + r = gamma2table[crispy->gamma][playpal[3 * k + 0]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; + g = gamma2table[crispy->gamma][playpal[3 * k + 1]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; + b = gamma2table[crispy->gamma][playpal[3 * k + 2]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; + + colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b; + } + } + } + else + { + for (c = 0; c <= NUMCOLORMAPS; c++) + { + for (i = 0; i < 256; i++) + { + r = gamma2table[crispy->gamma][playpal[3 * colormap[c * 256 + i] + 0]] & ~3; + g = gamma2table[crispy->gamma][playpal[3 * colormap[c * 256 + i] + 1]] & ~3; + b = gamma2table[crispy->gamma][playpal[3 * colormap[c * 256 + i] + 2]] & ~3; + + colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b; + } + } + } + + W_ReleaseLumpName("COLORMAP"); + + if (!pal_color) + { + pal_color = (pixel_t*) Z_Malloc(256 * sizeof(pixel_t), PU_STATIC, 0); + } + + for (i = 0, j = 0; i < 256; i++) + { + r = gamma2table[crispy->gamma][playpal[3 * i + 0]]; + g = gamma2table[crispy->gamma][playpal[3 * i + 1]]; + b = gamma2table[crispy->gamma][playpal[3 * i + 2]]; + + pal_color[j++] = 0xff000000 | (r << 16) | (g << 8) | b; + } + + W_ReleaseLumpName("PLAYPAL"); +#endif } +// [crispy] initialize color translation and color string tables +static void R_InitHSVColors (void) +{ + byte *playpal = W_CacheLumpName("PLAYPAL", PU_STATIC); + char c[3]; + int i, j; + + if (!crstr) + crstr = I_Realloc(NULL, CRMAX * sizeof(*crstr)); + + // [crispy] CRMAX - 2: don't override the original GREN and BLUE2 Boom tables + for (i = 0; i < CRMAX - 2; i++) + { + for (j = 0; j < 256; j++) + { + cr[i][j] = V_Colorize(playpal, i, j, false); + } + + M_snprintf(c, sizeof(c), "%c%c", cr_esc, '0' + i); + crstr[i] = M_StringDuplicate(c); + } + + W_ReleaseLumpName("PLAYPAL"); +} // @@ -753,6 +817,8 @@ void R_InitData (void) D_IntroTick(); R_InitColormaps (); + // [crispy] Initialize color translation and color string tables. + R_InitHSVColors (); } diff --git a/src/strife/r_defs.h b/src/strife/r_defs.h index c83bfcc4df..e4d443773c 100644 --- a/src/strife/r_defs.h +++ b/src/strife/r_defs.h @@ -333,7 +333,7 @@ typedef struct // precalculating 24bpp lightmap/colormap LUT. // from darkening PLAYPAL to all black. // Could even us emore than 32 levels. -typedef byte lighttable_t; +typedef pixel_t lighttable_t; @@ -407,6 +407,9 @@ typedef struct vissprite_s int mobjflags; +#ifdef CRISPY_TRUECOLOR + const pixel_t (*blendfunc)(const pixel_t fg, const pixel_t bg); +#endif } vissprite_t; diff --git a/src/strife/r_draw.c b/src/strife/r_draw.c index e24a31d47b..a23067816d 100644 --- a/src/strife/r_draw.c +++ b/src/strife/r_draw.c @@ -29,6 +29,7 @@ #include "w_wad.h" #include "r_local.h" +#include "v_trans.h" // [crispy] blending functions // Needs access to LFB (guess what). #include "v_video.h" @@ -61,7 +62,7 @@ int scaledviewwidth; int viewheight; int viewwindowx; int viewwindowy; -byte* ylookup[MAXHEIGHT]; +pixel_t* ylookup[MAXHEIGHT]; int columnofs[MAXWIDTH]; // Color tables for different players, @@ -74,7 +75,7 @@ int columnofs[MAXWIDTH]; // Backing buffer containing the bezel drawn around the screen and // surrounding background. -static byte *background_buffer = NULL; +static pixel_t *background_buffer = NULL; // haleyjd 08/29/10: [STRIFE] Rogue added the ability to customize the view // border flat by storing it in the configuration file. @@ -111,7 +112,7 @@ int dccount; void R_DrawColumn (void) { int count; - byte* dest; + pixel_t* dest; fixed_t frac; fixed_t fracstep; int heightmask = dc_texheight - 1; @@ -256,7 +257,7 @@ void R_DrawColumn (void) void R_DrawMVisTLColumn(void) { int count; - byte* dest; + pixel_t* dest; fixed_t frac; fixed_t fracstep; @@ -294,9 +295,14 @@ void R_DrawMVisTLColumn(void) do { - byte src = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; - byte col = xlatab[*dest + (src << 8)]; + pixel_t src = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; +#ifndef CRISPY_TRUECOLOR + pixel_t col = xlatab[*dest + (src << 8)]; *dest = col; +#else + const pixel_t destrgb = src; + *dest = blendfunc(*dest, destrgb); +#endif dest += SCREENWIDTH; frac += fracstep; } while(count--); @@ -312,7 +318,7 @@ void R_DrawMVisTLColumn(void) void R_DrawTLColumn(void) { int count; - byte* dest; + pixel_t* dest; fixed_t frac; fixed_t fracstep; @@ -350,9 +356,14 @@ void R_DrawTLColumn(void) do { - byte src = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; - byte col = xlatab[(*dest << 8) + src]; + pixel_t src = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; +#ifndef CRISPY_TRUECOLOR + pixel_t col = xlatab[(*dest << 8) + src]; *dest = col; +#else + const pixel_t destrgb = src; + *dest = blendfunc(*dest, destrgb); +#endif dest += SCREENWIDTH; frac += fracstep; } while(count--); @@ -375,7 +386,7 @@ byte* translationtables; void R_DrawTranslatedColumn (void) { int count; - byte* dest; + pixel_t* dest; fixed_t frac; fixed_t fracstep; @@ -425,7 +436,7 @@ void R_DrawTranslatedColumn (void) void R_DrawTRTLColumn(void) { int count; - byte* dest; + pixel_t* dest; fixed_t frac; fixed_t fracstep; @@ -453,8 +464,13 @@ void R_DrawTRTLColumn(void) do { byte src = dc_colormap[dc_translation[dc_source[frac>>FRACBITS&127]]]; - byte col = xlatab[(*dest << 8) + src]; +#ifndef CRISPY_TRUECOLOR + pixel_t col = xlatab[(*dest << 8) + src]; *dest = col; +#else + const pixel_t destrgb = src; + *dest = blendfunc(*dest, destrgb); +#endif dest += SCREENWIDTH; frac += fracstep; } while (count--); @@ -487,7 +503,9 @@ void R_InitTranslationTables (void) // strictly portable, all we need to do is this: // villsa [STRIFE] 09/26/10: load table through this function instead +#ifndef CRISPY_TRUECOLOR V_LoadXlaTable(); +#endif // villsa [STRIFE] allocate a larger size for translation tables translationtables = Z_Malloc (256*8, PU_STATIC, 0); @@ -625,7 +643,7 @@ int dscount; void R_DrawSpan (void) { // unsigned int position, step; - byte *dest; + pixel_t *dest; int count; int spot; unsigned int xtemp, ytemp; @@ -760,7 +778,7 @@ void R_DrawSpanLow (void) { // unsigned int position, step; unsigned int xtemp, ytemp; - byte *dest; + pixel_t *dest; int count; int spot; @@ -859,7 +877,7 @@ R_InitBuffer void R_FillBackScreen (void) { byte* src; - byte* dest; + pixel_t* dest; int x; int y; patch_t* patch; diff --git a/src/strife/r_state.h b/src/strife/r_state.h index 79cf615590..dae4a8047d 100644 --- a/src/strife/r_state.h +++ b/src/strife/r_state.h @@ -44,6 +44,7 @@ extern fixed_t* spriteoffset; extern fixed_t* spritetopoffset; extern lighttable_t* colormaps; +extern lighttable_t* pal_color; extern int viewwidth; extern int scaledviewwidth; diff --git a/src/strife/st_stuff.c b/src/strife/st_stuff.c index c293da0623..3409982723 100644 --- a/src/strife/st_stuff.c +++ b/src/strife/st_stuff.c @@ -892,7 +892,9 @@ static void ST_doPaletteStuff(void) { int palette; +#ifndef CRISPY_TRUECOLOR byte* pal; +#endif int cnt; int bzc; @@ -940,8 +942,12 @@ static void ST_doPaletteStuff(void) if (palette != st_palette) { st_palette = palette; +#ifndef CRISPY_TRUECOLOR pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768; I_SetPalette (pal); +#else + I_SetPalette (palette); +#endif } } @@ -1003,14 +1009,19 @@ void ST_drawNumFontY2(int x, int y, int num) void ST_drawLine(int x, int y, int len, int color) { byte putcolor = (byte)(color); - byte *drawpos = I_VideoBuffer + (y << crispy->hires) * SCREENWIDTH + ((x + WIDESCREENDELTA) << crispy->hires); + pixel_t *drawpos = I_VideoBuffer + (y << crispy->hires) * SCREENWIDTH + ((x + WIDESCREENDELTA) << crispy->hires); int i = 0; while(i < (len << crispy->hires)) { if (crispy->hires) +#ifndef CRISPY_TRUECOLOR *(drawpos + SCREENWIDTH) = putcolor; *drawpos++ = putcolor; +#else + *(drawpos + SCREENWIDTH) = pal_color[putcolor]; + *drawpos++ = pal_color[putcolor]; +#endif ++i; } } @@ -1805,7 +1816,11 @@ void ST_Stop (void) if (st_stopped) return; +#ifndef CRISPY_TRUECOLOR I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE)); +#else + I_SetPalette (0); +#endif st_stopped = true; } diff --git a/src/v_video.c b/src/v_video.c index 90d955ac14..82431dc497 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -216,6 +216,16 @@ static const inline pixel_t drawalttinttab (const pixel_t dest, const pixel_t so #else {return I_BlendOverAltTinttab(dest, pal_color[source]);} #endif +// V_DrawXlaPatch (translucent patch, no coloring or color-translation are used) +static const inline pixel_t drawxlatab (const pixel_t dest, const pixel_t source) +#ifndef CRISPY_TRUECOLOR +{return xlatab[dest+(source<<8)];} +#else +// [JN] TODO - double check if it's representing vanilla Strife translucensy +// well enough. Paletted approach is same to V_DrawTLPatch, but true color, +// in fact, doesnt seem to be opaque enough. +{return I_BlendOverAltTinttab(dest, pal_color[source]);} +#endif // [crispy] array of function pointers holding the different rendering functions typedef const pixel_t drawpatchpx_t (const pixel_t dest, const pixel_t source); @@ -570,6 +580,9 @@ void V_DrawXlaPatch(int x, int y, patch_t * patch) byte *source; int w; + // [crispy] translucent patch, no coloring or color-translation are used + drawpatchpx_t *const drawpatchpx = drawxlatab; + y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); x += WIDESCREENDELTA; // [crispy] horizontal widescreen offset @@ -601,7 +614,7 @@ void V_DrawXlaPatch(int x, int y, patch_t * patch) while(count--) { - *dest = xlatab[*dest + (source[srccol >> FRACBITS] << 8)]; + *dest = drawpatchpx(*dest, source[srccol >> FRACBITS]); srccol += dyi; dest += SCREENWIDTH; } @@ -784,7 +797,7 @@ void V_DrawBlock(int x, int y, int width, int height, pixel_t *src) } // [crispy] scaled version of V_DrawBlock() -void V_DrawScaledBlock(int x, int y, int width, int height, pixel_t *src) +void V_DrawScaledBlock(int x, int y, int width, int height, byte *src) { pixel_t *dest; int i, j; @@ -809,7 +822,13 @@ void V_DrawScaledBlock(int x, int y, int width, int height, pixel_t *src) { for (j = 0; j < (width << crispy->hires); j++) { +#ifndef CRISPY_TRUECOLOR *(dest + i * SCREENWIDTH + j) = *(src + (i >> crispy->hires) * width + (j >> crispy->hires)); +#else + // [JN] TODO - add support for true color. This should use + // pal_color[] array, which is initialized far *after* intro sequence. + *(dest + i * SCREENWIDTH + j) = *(src + (i >> crispy->hires) * width + (j >> crispy->hires)); +#endif } } } diff --git a/src/v_video.h b/src/v_video.h index cab9ae9943..a7a2f1bf5d 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -70,7 +70,7 @@ void V_DrawPatchFullScreen(patch_t *patch, boolean flipped); // Draw a linear block of pixels into the view buffer. void V_DrawBlock(int x, int y, int width, int height, pixel_t *src); -void V_DrawScaledBlock(int x, int y, int width, int height, pixel_t *src); +void V_DrawScaledBlock(int x, int y, int width, int height, byte *src); void V_MarkRect(int x, int y, int width, int height); From 8dc35703970f08202ca3a451e68d8f59f926968c Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 20:57:26 +0300 Subject: [PATCH 02/22] Fix crash on drawing view border --- src/strife/r_draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strife/r_draw.c b/src/strife/r_draw.c index a23067816d..0d6299ef0c 100644 --- a/src/strife/r_draw.c +++ b/src/strife/r_draw.c @@ -902,7 +902,7 @@ void R_FillBackScreen (void) if (background_buffer == NULL) { - background_buffer = Z_Malloc(MAXWIDTH * (MAXHEIGHT - SBARHEIGHT), + background_buffer = Z_Malloc(MAXWIDTH * (MAXHEIGHT - SBARHEIGHT) * sizeof(*background_buffer), PU_STATIC, NULL); } @@ -973,7 +973,7 @@ R_VideoErase if (background_buffer != NULL) { - memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count); + memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count * sizeof(*I_VideoBuffer)); } } From 26fd68d6dd6b42b74f2b20dce9880794ae8ca190 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 21:07:29 +0300 Subject: [PATCH 03/22] Sigil weapon effect working --- src/strife/r_data.c | 12 ++++++++++++ src/strife/r_main.c | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/strife/r_data.c b/src/strife/r_data.c index b0baed2afb..ba3f3e6308 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -726,6 +726,18 @@ void R_InitColormaps (void) colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b; } } + + // [crispy] Sigil weapon effect (c == COLORMAPS) + for (i = 0; i < 256; i++) + { + const byte gray = 0xff - + (byte) (0.299 * playpal[3 * i + 0] + + 0.587 * playpal[3 * i + 1] + + 0.114 * playpal[3 * i + 2]); + r = g = b = gamma2table[crispy->gamma][gray]; + + colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b; + } } else { diff --git a/src/strife/r_main.c b/src/strife/r_main.c index 66ff0f61fd..bdfcee4b09 100644 --- a/src/strife/r_main.c +++ b/src/strife/r_main.c @@ -1062,7 +1062,9 @@ void R_SetupFrame (player_t* player) { fixedcolormap = colormaps - + player->fixedcolormap*256*sizeof(lighttable_t); + // [crispy] sizeof(lighttable_t) not needed in paletted render + // and breaks Sigil weapon effects in true color render + + player->fixedcolormap*256/**sizeof(lighttable_t)*/; walllights = scalelightfixed; From e870b443ffda322f5319fa800ee0cd03761402c0 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 21:29:42 +0300 Subject: [PATCH 04/22] crispy_truecolor config variable --- src/strife/d_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/strife/d_main.c b/src/strife/d_main.c index 23d8d4bb73..c5844b54e9 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -547,6 +547,9 @@ void D_BindVariables(void) M_BindIntVariable("crispy_soundfix", &crispy->soundfix); M_BindIntVariable("crispy_soundfull", &crispy->soundfull); M_BindIntVariable("crispy_soundmono", &crispy->soundmono); +#ifdef CRISPY_TRUECOLOR + M_BindIntVariable("crispy_truecolor", &crispy->truecolor); +#endif M_BindIntVariable("crispy_uncapped", &crispy->uncapped); M_BindIntVariable("crispy_vsync", &crispy->vsync); M_BindIntVariable("crispy_widescreen", &crispy->widescreen); From 3309930d2d6d8909663f9c07a384fa1cdb00f964 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 21:31:12 +0300 Subject: [PATCH 05/22] Btightmaps working! --- src/strife/r_data.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/strife/r_data.c b/src/strife/r_data.c index ba3f3e6308..de7361b926 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -719,9 +719,20 @@ void R_InitColormaps (void) { const byte k = colormap[i]; - r = gamma2table[crispy->gamma][playpal[3 * k + 0]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; - g = gamma2table[crispy->gamma][playpal[3 * k + 1]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; - b = gamma2table[crispy->gamma][playpal[3 * k + 2]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; + // [JN] Vanilla Strife is using COLORMAP indexes 224-255 without fading to black + // so they work as brightmaps. To replicate it, lock such indexes on first light level. + if (i > 223) + { + r = gamma2table[crispy->gamma][playpal[3 * k + 0]] + gamma2table[crispy->gamma][0] * scale; + g = gamma2table[crispy->gamma][playpal[3 * k + 1]] + gamma2table[crispy->gamma][0] * scale; + b = gamma2table[crispy->gamma][playpal[3 * k + 2]] + gamma2table[crispy->gamma][0] * scale; + } + else + { + r = gamma2table[crispy->gamma][playpal[3 * k + 0]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; + g = gamma2table[crispy->gamma][playpal[3 * k + 1]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; + b = gamma2table[crispy->gamma][playpal[3 * k + 2]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; + } colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b; } From 9cdce80bc5cff588e9cbcec6ca6533a309ae719e Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 22:03:08 +0300 Subject: [PATCH 06/22] Blending and alt blending functions --- src/i_video.c | 22 ++++++++++++++++++++++ src/strife/r_things.c | 16 ++++++++++++++++ src/v_trans.h | 2 ++ src/v_video.c | 5 +---- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/i_video.c b/src/i_video.c index cb0152da73..eece10f263 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -106,6 +106,8 @@ static unsigned int rmask, gmask, bmask, amask; // [crispy] moved up here static const uint8_t blend_alpha = 0xa8; static const uint8_t blend_alpha_tinttab = 0x60; // 96 static const uint8_t blend_alpha_alttinttab = 0x8E; // 142 +static const uint8_t blend_alpha_xlatab = 0xB2;// 178 (70% opacity) +static const uint8_t blend_alpha_altxlatab = 0x40; // 64 (25% opacity) extern pixel_t* pal_color; // [crispy] evil hack to get FPS dots working as in Vanilla #else static SDL_Color palette[256]; @@ -2165,6 +2167,26 @@ const pixel_t I_BlendOverAltTinttab (const pixel_t bg, const pixel_t fg) return amask | r | g | b; } +// [crispy] More opaque (70%) XLATAB blending emulation, used for Strife +const pixel_t I_BlendOverXlatab (const pixel_t bg, const pixel_t fg) +{ + const uint32_t r = ((blend_alpha_xlatab * (fg & rmask) + (0xff - blend_alpha_xlatab) * (bg & rmask)) >> 8) & rmask; + const uint32_t g = ((blend_alpha_xlatab * (fg & gmask) + (0xff - blend_alpha_xlatab) * (bg & gmask)) >> 8) & gmask; + const uint32_t b = ((blend_alpha_xlatab * (fg & bmask) + (0xff - blend_alpha_xlatab) * (bg & bmask)) >> 8) & bmask; + + return amask | r | g | b; +} + +// [crispy] Less opaque (25%) XLATAB blending emulation, used for Strife +const pixel_t I_BlendOverAltXlatab (const pixel_t bg, const pixel_t fg) +{ + const uint32_t r = ((blend_alpha_altxlatab * (fg & rmask) + (0xff - blend_alpha_altxlatab) * (bg & rmask)) >> 8) & rmask; + const uint32_t g = ((blend_alpha_altxlatab * (fg & gmask) + (0xff - blend_alpha_altxlatab) * (bg & gmask)) >> 8) & gmask; + const uint32_t b = ((blend_alpha_altxlatab * (fg & bmask) + (0xff - blend_alpha_altxlatab) * (bg & bmask)) >> 8) & bmask; + + return amask | r | g | b; +} + const pixel_t (*blendfunc) (const pixel_t fg, const pixel_t bg) = I_BlendOver; const pixel_t I_MapRGB (const uint8_t r, const uint8_t g, const uint8_t b) diff --git a/src/strife/r_things.c b/src/strife/r_things.c index 5ff5773ead..bff589bf6a 100644 --- a/src/strife/r_things.c +++ b/src/strife/r_things.c @@ -32,6 +32,7 @@ #include "w_wad.h" #include "r_local.h" +#include "v_trans.h" // [crispy] blending functions #include "doomstat.h" @@ -445,6 +446,9 @@ R_DrawVisSprite colfunc = R_DrawTRTLColumn; dc_translation = translationtables - 256 + (translation >> (MF_TRANSSHIFT - 8)); } +#ifdef CRISPY_TRUECOLOR + blendfunc = vis->blendfunc; +#endif } else if(vis->mobjflags & MF_MVIS) { @@ -490,6 +494,9 @@ R_DrawVisSprite } colfunc = basecolfunc; +#ifdef CRISPY_TRUECOLOR + blendfunc = I_BlendOverTinttab; +#endif } @@ -680,6 +687,15 @@ void R_ProjectSprite (mobj_t* thing) vis->colormap = spritelights[index]; } + +#ifdef CRISPY_TRUECOLOR + if (thing->flags & MF_SHADOW) + { + // [crispy] not using additive blending (I_BlendAdd) here + // to preserve look & feel of original Strife translucency + vis->blendfunc = I_BlendOverAltXlatab; + } +#endif } diff --git a/src/v_trans.h b/src/v_trans.h index 068c706b54..02690ea110 100644 --- a/src/v_trans.h +++ b/src/v_trans.h @@ -65,6 +65,8 @@ extern const pixel_t I_BlendDark (const pixel_t bg, const int d); extern const pixel_t I_BlendOver (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverTinttab (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverAltTinttab (const pixel_t bg, const pixel_t fg); +extern const pixel_t I_BlendOverXlatab (const pixel_t bg, const pixel_t fg); +extern const pixel_t I_BlendOverAltXlatab (const pixel_t bg, const pixel_t fg); #endif int V_GetPaletteIndex(byte *palette, int r, int g, int b); diff --git a/src/v_video.c b/src/v_video.c index 82431dc497..74fcd9b298 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -221,10 +221,7 @@ static const inline pixel_t drawxlatab (const pixel_t dest, const pixel_t source #ifndef CRISPY_TRUECOLOR {return xlatab[dest+(source<<8)];} #else -// [JN] TODO - double check if it's representing vanilla Strife translucensy -// well enough. Paletted approach is same to V_DrawTLPatch, but true color, -// in fact, doesnt seem to be opaque enough. -{return I_BlendOverAltTinttab(dest, pal_color[source]);} +{return I_BlendOverXlatab(dest, pal_color[source]);} #endif // [crispy] array of function pointers holding the different rendering functions From 00cd0405d1ddc65f8e6e80cd0af50958e84b5181 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 22:59:35 +0300 Subject: [PATCH 07/22] Proper translucensy values for columns and walls --- src/i_video.c | 4 ++-- src/strife/r_draw.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/i_video.c b/src/i_video.c index eece10f263..95bc72e18e 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -106,7 +106,7 @@ static unsigned int rmask, gmask, bmask, amask; // [crispy] moved up here static const uint8_t blend_alpha = 0xa8; static const uint8_t blend_alpha_tinttab = 0x60; // 96 static const uint8_t blend_alpha_alttinttab = 0x8E; // 142 -static const uint8_t blend_alpha_xlatab = 0xB2;// 178 (70% opacity) +static const uint8_t blend_alpha_xlatab = 0xC0;// 192 (75% opacity) static const uint8_t blend_alpha_altxlatab = 0x40; // 64 (25% opacity) extern pixel_t* pal_color; // [crispy] evil hack to get FPS dots working as in Vanilla #else @@ -2167,7 +2167,7 @@ const pixel_t I_BlendOverAltTinttab (const pixel_t bg, const pixel_t fg) return amask | r | g | b; } -// [crispy] More opaque (70%) XLATAB blending emulation, used for Strife +// [crispy] More opaque (75%) XLATAB blending emulation, used for Strife const pixel_t I_BlendOverXlatab (const pixel_t bg, const pixel_t fg) { const uint32_t r = ((blend_alpha_xlatab * (fg & rmask) + (0xff - blend_alpha_xlatab) * (bg & rmask)) >> 8) & rmask; diff --git a/src/strife/r_draw.c b/src/strife/r_draw.c index 0d6299ef0c..b1cacefa17 100644 --- a/src/strife/r_draw.c +++ b/src/strife/r_draw.c @@ -300,8 +300,9 @@ void R_DrawMVisTLColumn(void) pixel_t col = xlatab[*dest + (src << 8)]; *dest = col; #else + // [crispy] 75% opacity const pixel_t destrgb = src; - *dest = blendfunc(*dest, destrgb); + *dest = I_BlendOverXlatab(*dest, destrgb); #endif dest += SCREENWIDTH; frac += fracstep; @@ -361,8 +362,9 @@ void R_DrawTLColumn(void) pixel_t col = xlatab[(*dest << 8) + src]; *dest = col; #else + // [crispy] 25% opacity const pixel_t destrgb = src; - *dest = blendfunc(*dest, destrgb); + *dest = I_BlendOverAltXlatab(*dest, destrgb); #endif dest += SCREENWIDTH; frac += fracstep; From a2db2997dff380ab13ed46bc0585fc39e5caae91 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 23:49:35 +0300 Subject: [PATCH 08/22] Graphical startup working --- src/strife/d_main.c | 8 ++++++++ src/strife/m_menu.c | 2 -- src/strife/r_data.c | 11 ++++++++++- src/strife/r_main.h | 3 +++ src/v_video.c | 4 +--- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/strife/d_main.c b/src/strife/d_main.c index c5844b54e9..69bc74136f 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -2038,6 +2038,14 @@ void D_DoomMain (void) I_GraphicsCheckCommandLine(); + // [crispy] we have to predefine pal_colors[] array for proper + // drawing of intro sequence + // [JN] TODO - probably unoptimal, R_InitPalColors is called + // second time in R_InitColormaps, otherwise patches will be + // drawn with solid black color. +#ifdef CRISPY_TRUECOLOR + R_InitPalColors(); +#endif // haleyjd 20110206 [STRIFE] Startup the introduction sequence D_InitIntroSequence(); diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index 742d9af5cb..1a4df74269 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -2720,8 +2720,6 @@ boolean M_Responder (event_t* ev) I_SetPalette (W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE)); #else { - // [JN] TODO - externalize R_InitColormaps() to header file. - extern void R_InitColormaps (void); I_SetPalette (0); R_InitColormaps(); inhelpscreens = true; diff --git a/src/strife/r_data.c b/src/strife/r_data.c index de7361b926..6fdb0ed601 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -766,6 +766,16 @@ void R_InitColormaps (void) } W_ReleaseLumpName("COLORMAP"); + W_ReleaseLumpName("PLAYPAL"); + R_InitPalColors(); +#endif +} + +void R_InitPalColors (void) +{ + int i, j = 0; + byte r, g, b; + byte *const playpal = W_CacheLumpName("PLAYPAL", PU_STATIC); if (!pal_color) { @@ -782,7 +792,6 @@ void R_InitColormaps (void) } W_ReleaseLumpName("PLAYPAL"); -#endif } // [crispy] initialize color translation and color string tables diff --git a/src/strife/r_main.h b/src/strife/r_main.h index fe46206cad..1bfa3c260e 100644 --- a/src/strife/r_main.h +++ b/src/strife/r_main.h @@ -166,6 +166,9 @@ void R_RenderPlayerView (player_t *player); // Called by startup code. void R_Init (void); +void R_InitColormaps (void); +void R_InitPalColors (void); + // Called by M_Responder. void R_SetViewSize (int blocks, int detail); diff --git a/src/v_video.c b/src/v_video.c index 74fcd9b298..fd7c3c741b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -822,9 +822,7 @@ void V_DrawScaledBlock(int x, int y, int width, int height, byte *src) #ifndef CRISPY_TRUECOLOR *(dest + i * SCREENWIDTH + j) = *(src + (i >> crispy->hires) * width + (j >> crispy->hires)); #else - // [JN] TODO - add support for true color. This should use - // pal_color[] array, which is initialized far *after* intro sequence. - *(dest + i * SCREENWIDTH + j) = *(src + (i >> crispy->hires) * width + (j >> crispy->hires)); + *(dest + i * SCREENWIDTH + j) = pal_color[*(src + (i >> crispy->hires) * width + (j >> crispy->hires))]; #endif } } From 81f9886e2dfa7c458f2659003f178d41285a6c58 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 3 Mar 2024 23:55:43 +0300 Subject: [PATCH 09/22] Get rid of few TODOs --- src/strife/am_map.c | 9 ++++----- src/strife/d_main.c | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/strife/am_map.c b/src/strife/am_map.c index bd6ed081f7..55a7f64697 100644 --- a/src/strife/am_map.c +++ b/src/strife/am_map.c @@ -49,12 +49,7 @@ extern boolean inhelpscreens; // [crispy] // Automap colors -#ifndef CRISPY_TRUECOLOR #define BACKGROUND 240 // haleyjd [STRIFE] -#else -// [JN] For some reason, 240 in true color showing WHITE color. -#define BACKGROUND 0 -#endif #define WALLCOLORS 5 // villsa [STRIFE] #define WALLRANGE 16 #define TSWALLCOLORS 16 @@ -1895,7 +1890,11 @@ void AM_Drawer (void) if (!crispy->automapoverlay) { +#ifndef CRISPY_TRUECOLOR AM_clearFB(BACKGROUND); +#else + AM_clearFB(pal_color[BACKGROUND]); +#endif pspr_interp = false; // [crispy] interpolate weapon bobbing } diff --git a/src/strife/d_main.c b/src/strife/d_main.c index 69bc74136f..f8b019f16d 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -1363,7 +1363,6 @@ static void D_IntroBackground(void) // Draw a 95-pixel rect from STARTUP0 starting at y=57 to (0,41) on the // screen (this was a memcpy directly to 0xA3340 in low DOS memory) // [crispy] use scaled function - // [JN] TODO - update for true color. V_DrawScaledBlock(0, 41, 320, 95, rawgfx_startup0 + (320*57)); } From b658e7b6f99c1df6b0bd29e87ad5928d0d7eb807 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 5 Mar 2024 20:13:18 +0300 Subject: [PATCH 10/22] Better logics for brightmaps emulation --- src/strife/r_data.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/strife/r_data.c b/src/strife/r_data.c index 6fdb0ed601..73cfcc5d52 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -719,20 +719,20 @@ void R_InitColormaps (void) { const byte k = colormap[i]; - // [JN] Vanilla Strife is using COLORMAP indexes 224-255 without fading to black - // so they work as brightmaps. To replicate it, lock such indexes on first light level. - if (i > 223) - { - r = gamma2table[crispy->gamma][playpal[3 * k + 0]] + gamma2table[crispy->gamma][0] * scale; - g = gamma2table[crispy->gamma][playpal[3 * k + 1]] + gamma2table[crispy->gamma][0] * scale; - b = gamma2table[crispy->gamma][playpal[3 * k + 2]] + gamma2table[crispy->gamma][0] * scale; - } - else + if (i < 224) { r = gamma2table[crispy->gamma][playpal[3 * k + 0]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; g = gamma2table[crispy->gamma][playpal[3 * k + 1]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; b = gamma2table[crispy->gamma][playpal[3 * k + 2]] * (1. - scale) + gamma2table[crispy->gamma][0] * scale; } + else + { + // [JN] Vanilla Strife is using COLORMAP indexes 224-255 without fading to black + // so they work as brightmaps. To replicate it, lock such indexes on first light level. + r = gamma2table[crispy->gamma][playpal[3 * k + 0]] + gamma2table[crispy->gamma][0] * scale; + g = gamma2table[crispy->gamma][playpal[3 * k + 1]] + gamma2table[crispy->gamma][0] * scale; + b = gamma2table[crispy->gamma][playpal[3 * k + 2]] + gamma2table[crispy->gamma][0] * scale; + } colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b; } From 606dc34cc78277c8d4f51902a39a2c8b66922d09 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 8 Apr 2024 08:49:22 +0300 Subject: [PATCH 11/22] Update screen wiping code It's working technically now, but the problem with infinite loop of comparing old and new screen data have to be resolved. --- src/strife/f_wipe.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/strife/f_wipe.c b/src/strife/f_wipe.c index 4e5176f515..65772dca46 100644 --- a/src/strife/f_wipe.c +++ b/src/strife/f_wipe.c @@ -19,6 +19,7 @@ #include #include "z_zone.h" +#include "v_trans.h" // [crispy] blending functions #include "i_video.h" #include "v_video.h" #include "m_random.h" @@ -37,22 +38,22 @@ // when zero, stop the wipe static boolean go = 0; -static byte* wipe_scr_start; -static byte* wipe_scr_end; -static byte* wipe_scr; +static pixel_t* wipe_scr_start; +static pixel_t* wipe_scr_end; +static pixel_t* wipe_scr; void wipe_shittyColMajorXform -( short* array, +( dpixel_t* array, int width, int height ) { int x; int y; - short* dest; + dpixel_t* dest; - dest = (short*) Z_Malloc(width*height*2, PU_STATIC, 0); + dest = (dpixel_t*) Z_Malloc(width*height*sizeof(*dest), PU_STATIC, 0); for(y=0;y not ready to scroll yet) @@ -163,8 +168,8 @@ wipe_doMelt int dy; int idx; - short* s; - short* d; + dpixel_t* s; + dpixel_t* d; boolean done = true; width/=2; @@ -181,8 +186,8 @@ wipe_doMelt { dy = (y[i] < 16) ? y[i]+1 : 8; if (y[i]+dy >= height) dy = height - y[i]; - s = &((short *)wipe_scr_end)[i*height+y[i]]; - d = &((short *)wipe_scr)[y[i]*width+i]; + s = &((dpixel_t *)wipe_scr_end)[i*height+y[i]]; + d = &((dpixel_t *)wipe_scr)[y[i]*width+i]; idx = 0; for (j=dy;j;j--) { @@ -190,8 +195,8 @@ wipe_doMelt idx += width; } y[i] += dy; - s = &((short *)wipe_scr_start)[i*height]; - d = &((short *)wipe_scr)[y[i]*width+i]; + s = &((dpixel_t *)wipe_scr_start)[i*height]; + d = &((dpixel_t *)wipe_scr)[y[i]*width+i]; idx = 0; for (j=height-y[i];j;j--) { @@ -227,7 +232,7 @@ wipe_StartScreen int width, int height ) { - wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); + wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_start), PU_STATIC, NULL); I_ReadScreen(wipe_scr_start); return 0; } @@ -240,7 +245,7 @@ wipe_EndScreen int width, int height ) { - wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); + wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_end), PU_STATIC, NULL); I_ReadScreen(wipe_scr_end); V_DrawBlock(x, y, width, height, wipe_scr_start); // restore start scr. return 0; @@ -268,7 +273,7 @@ wipe_ScreenWipe { go = 1; // haleyjd 20110629 [STRIFE]: We *must* use a temp buffer here. - wipe_scr = (byte *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG + wipe_scr = (pixel_t *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG //wipe_scr = I_VideoBuffer; (*wipes[wipeno*3])(width, height, ticks); } From e176cd5616f46fc6699a3e51ac014767a9d71ff7 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 8 Apr 2024 13:46:31 +0300 Subject: [PATCH 12/22] Fix possible infinite loop in crossfading, make it work in TrueColor --- src/strife/d_main.c | 7 +------ src/strife/f_wipe.c | 22 ++++++++++++++++++---- src/strife/f_wipe.h | 4 ++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/strife/d_main.c b/src/strife/d_main.c index f8b019f16d..268e0ebf8a 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -231,15 +231,10 @@ void D_Display (void) } // save the current screen if about to wipe -#ifndef CRISPY_TRUECOLOR if (gamestate != wipegamestate) -#else - // [JN] TODO - implement support for true color, - // wiping/fading via XLATAB is not possible! - if (gamestate != wipegamestate && false) -#endif { screenwipe = true; // [crispy] + fade_safe_tics = CROSSFADETICS; // [crispy] arm fail-safe crossfade counter wipe = true; wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); } diff --git a/src/strife/f_wipe.c b/src/strife/f_wipe.c index 65772dca46..1add53ae4e 100644 --- a/src/strife/f_wipe.c +++ b/src/strife/f_wipe.c @@ -42,6 +42,9 @@ static pixel_t* wipe_scr_start; static pixel_t* wipe_scr_end; static pixel_t* wipe_scr; +// [crispy] Additional fail-safe counter for performing crossfade effect. +// Full crossfading takes 13 game tics and counter is armed in D_Display. +int fade_safe_tics; void wipe_shittyColMajorXform @@ -59,7 +62,7 @@ wipe_shittyColMajorXform for(x=0;x 0; i--) { - if(*cur_screen != *end_screen) + if(*cur_screen != *end_screen && fade_safe_tics) { changed = true; #ifndef CRISPY_TRUECOLOR @@ -135,7 +141,7 @@ wipe_initMelt int i, r; // copy start screen to main screen - memcpy(wipe_scr, wipe_scr_start, width*height); + memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr)); // makes this wipe faster (in theory) // to have stuff in column-major format @@ -273,8 +279,14 @@ wipe_ScreenWipe { go = 1; // haleyjd 20110629 [STRIFE]: We *must* use a temp buffer here. +#ifndef CRISPY_TRUECOLOR wipe_scr = (pixel_t *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG //wipe_scr = I_VideoBuffer; +#else + // [crispy] In TrueColor render perform everything in common buffer. + // Otherwise serious malloc errors will happen. + wipe_scr = I_VideoBuffer; +#endif (*wipes[wipeno*3])(width, height, ticks); } @@ -282,8 +294,10 @@ wipe_ScreenWipe V_MarkRect(0, 0, width, height); rc = (*wipes[wipeno*3+1])(width, height, ticks); +#ifndef CRISPY_TRUECOLOR // haleyjd 20110629 [STRIFE]: Copy temp buffer to the real screen. V_DrawBlock(x, y, width, height, wipe_scr); +#endif // final stuff if (rc) diff --git a/src/strife/f_wipe.h b/src/strife/f_wipe.h index 6ffd05872a..51997701e2 100644 --- a/src/strife/f_wipe.h +++ b/src/strife/f_wipe.h @@ -60,4 +60,8 @@ wipe_ScreenWipe int height, int ticks ); +// [crispy] Additional fail-safe counter for performing crossfade effect. +#define CROSSFADETICS 13; +extern int fade_safe_tics; + #endif From 0ea49bc61e38d40c61e8fbbc72ff54a0c7d9eec8 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Mon, 8 Apr 2024 21:07:06 +0300 Subject: [PATCH 13/22] Proper implementation of crossfading effect Now it looks and feels like vanilla! --- src/i_video.c | 10 ++++++++++ src/strife/f_wipe.c | 4 +++- src/v_trans.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/i_video.c b/src/i_video.c index 95bc72e18e..cf5646de87 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -2187,6 +2187,16 @@ const pixel_t I_BlendOverAltXlatab (const pixel_t bg, const pixel_t fg) return amask | r | g | b; } +// [crispy] Perform screen crossfading effect by given amount of opacity, used for Strife +const pixel_t I_BlendOverCrossfade (const pixel_t bg, const pixel_t fg, const int amount) +{ + const uint32_t r = ((amount * (fg & rmask) + (0xff - amount) * (bg & rmask)) >> 8) & rmask; + const uint32_t g = ((amount * (fg & gmask) + (0xff - amount) * (bg & gmask)) >> 8) & gmask; + const uint32_t b = ((amount * (fg & bmask) + (0xff - amount) * (bg & bmask)) >> 8) & bmask; + + return amask | r | g | b; +} + const pixel_t (*blendfunc) (const pixel_t fg, const pixel_t bg) = I_BlendOver; const pixel_t I_MapRGB (const uint8_t r, const uint8_t g, const uint8_t b) diff --git a/src/strife/f_wipe.c b/src/strife/f_wipe.c index 1add53ae4e..0879c55b82 100644 --- a/src/strife/f_wipe.c +++ b/src/strife/f_wipe.c @@ -109,7 +109,9 @@ wipe_doColorXForm #ifndef CRISPY_TRUECOLOR *cur_screen = xlatab[(*cur_screen << 8) + *end_screen]; #else - *cur_screen = I_BlendOverXlatab(*cur_screen, *end_screen); + // [crispy] perform crossfading effect with 13 given opacity steps, multipled by 19: + // 247, 228, 209, 190, 171, 152, 133, 114, 95, 76, 57, 38, 19 + *cur_screen = I_BlendOverCrossfade(*end_screen, *cur_screen, fade_safe_tics * 19); #endif } ++cur_screen; diff --git a/src/v_trans.h b/src/v_trans.h index 02690ea110..77979ed8f1 100644 --- a/src/v_trans.h +++ b/src/v_trans.h @@ -67,6 +67,7 @@ extern const pixel_t I_BlendOverTinttab (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverAltTinttab (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverXlatab (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverAltXlatab (const pixel_t bg, const pixel_t fg); +extern const pixel_t I_BlendOverCrossfade (const pixel_t bg, const pixel_t fg, const int amount); #endif int V_GetPaletteIndex(byte *palette, int r, int g, int b); From 656c3f833795fcc5b33fc7f3021284bbe014788a Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 9 Apr 2024 10:00:03 +0300 Subject: [PATCH 14/22] Fix introduction sequence for both renders --- src/strife/d_main.c | 11 ++++------- src/strife/r_data.c | 5 ++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/strife/d_main.c b/src/strife/d_main.c index 268e0ebf8a..556d3ee4bd 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -2032,14 +2032,11 @@ void D_DoomMain (void) I_GraphicsCheckCommandLine(); - // [crispy] we have to predefine pal_colors[] array for proper - // drawing of intro sequence - // [JN] TODO - probably unoptimal, R_InitPalColors is called - // second time in R_InitColormaps, otherwise patches will be - // drawn with solid black color. -#ifdef CRISPY_TRUECOLOR + // [crispy] Initialize and generate gamma-correction levels and + // pal_color[] array (TrueColor only) before introduction sequence. + I_SetGammaTable(); R_InitPalColors(); -#endif + // haleyjd 20110206 [STRIFE] Startup the introduction sequence D_InitIntroSequence(); diff --git a/src/strife/r_data.c b/src/strife/r_data.c index 73cfcc5d52..f30c54bd68 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -767,12 +767,12 @@ void R_InitColormaps (void) W_ReleaseLumpName("COLORMAP"); W_ReleaseLumpName("PLAYPAL"); - R_InitPalColors(); #endif } void R_InitPalColors (void) { +#ifdef CRISPY_TRUECOLOR int i, j = 0; byte r, g, b; byte *const playpal = W_CacheLumpName("PLAYPAL", PU_STATIC); @@ -792,6 +792,7 @@ void R_InitPalColors (void) } W_ReleaseLumpName("PLAYPAL"); +#endif } // [crispy] initialize color translation and color string tables @@ -829,8 +830,6 @@ static void R_InitHSVColors (void) void R_InitData (void) { R_InitTextures (); - // [crispy] Initialize and generate gamma-correction levels. - I_SetGammaTable(); if(devparm) printf ("."); else From 80e407bfdb04aa13b7df43b327c64a9e05a4bb1f Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 9 Apr 2024 10:39:50 +0300 Subject: [PATCH 15/22] Small corrections 1) No need for separated R_InitPalColors() function. (Re-)filling pal_color[] array must be done along with colormaps[] as it's related to gamma-correction. 2) Redraw side views of screen border on toggling gamma-correction. --- src/strife/d_main.c | 4 ++-- src/strife/m_menu.c | 1 + src/strife/r_data.c | 14 +++----------- src/strife/r_main.h | 1 - 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/strife/d_main.c b/src/strife/d_main.c index 556d3ee4bd..b38b3aa2bc 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -2033,9 +2033,9 @@ void D_DoomMain (void) I_GraphicsCheckCommandLine(); // [crispy] Initialize and generate gamma-correction levels and - // pal_color[] array (TrueColor only) before introduction sequence. + // colormaps/pal_color arrays before introduction sequence. I_SetGammaTable(); - R_InitPalColors(); + R_InitColormaps (); // haleyjd 20110206 [STRIFE] Startup the introduction sequence D_InitIntroSequence(); diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index 1a4df74269..fed1585533 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -2724,6 +2724,7 @@ boolean M_Responder (event_t* ev) R_InitColormaps(); inhelpscreens = true; R_FillBackScreen(); + viewactive = false; } #endif return true; diff --git a/src/strife/r_data.c b/src/strife/r_data.c index f30c54bd68..20ae417afd 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -766,16 +766,6 @@ void R_InitColormaps (void) } W_ReleaseLumpName("COLORMAP"); - W_ReleaseLumpName("PLAYPAL"); -#endif -} - -void R_InitPalColors (void) -{ -#ifdef CRISPY_TRUECOLOR - int i, j = 0; - byte r, g, b; - byte *const playpal = W_CacheLumpName("PLAYPAL", PU_STATIC); if (!pal_color) { @@ -847,7 +837,9 @@ void R_InitData (void) else D_IntroTick(); - R_InitColormaps (); + // [crispy] Moved to D_DoomMain for color arrays + // initialization before introduction sequence. + // R_InitColormaps (); // [crispy] Initialize color translation and color string tables. R_InitHSVColors (); } diff --git a/src/strife/r_main.h b/src/strife/r_main.h index 1bfa3c260e..52b65e0f9c 100644 --- a/src/strife/r_main.h +++ b/src/strife/r_main.h @@ -167,7 +167,6 @@ void R_RenderPlayerView (player_t *player); void R_Init (void); void R_InitColormaps (void); -void R_InitPalColors (void); // Called by M_Responder. void R_SetViewSize (int blocks, int detail); From 999da5c97abb2b56ed5193e7bd9fc33b03e2a6b3 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 9 Apr 2024 21:28:17 +0300 Subject: [PATCH 16/22] Simplify overlay blending functions --- src/doom/r_things.c | 6 ++--- src/i_video.c | 60 ++++++++++++++------------------------------- src/strife/f_wipe.c | 2 +- src/v_trans.h | 4 +-- src/v_video.c | 4 +-- 5 files changed, 26 insertions(+), 50 deletions(-) diff --git a/src/doom/r_things.c b/src/doom/r_things.c index 46d98db592..d1b52e3162 100644 --- a/src/doom/r_things.c +++ b/src/doom/r_things.c @@ -544,7 +544,7 @@ R_DrawVisSprite colfunc = basecolfunc; #ifdef CRISPY_TRUECOLOR - blendfunc = I_BlendOver; + blendfunc = I_BlendOverTranmap; #endif } @@ -817,7 +817,7 @@ void R_ProjectSprite (mobj_t* thing) // [crispy] translucent sprites if (thing->flags & MF_TRANSLUCENT) { - vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAdd : I_BlendOver; + vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAdd : I_BlendOverTranmap; } #endif } @@ -1079,7 +1079,7 @@ void R_DrawPSprite (pspdef_t* psp, psprnum_t psprnum) // [crispy] differentiate { vis->mobjflags |= MF_TRANSLUCENT; #ifdef CRISPY_TRUECOLOR - vis->blendfunc = I_BlendOver; // I_BlendAdd; + vis->blendfunc = I_BlendOverTranmap; // I_BlendAdd; #endif } diff --git a/src/i_video.c b/src/i_video.c index cf5646de87..7f23622376 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -103,11 +103,6 @@ static SDL_Texture *graypane = NULL; static SDL_Texture *orngpane = NULL; static int pane_alpha; static unsigned int rmask, gmask, bmask, amask; // [crispy] moved up here -static const uint8_t blend_alpha = 0xa8; -static const uint8_t blend_alpha_tinttab = 0x60; // 96 -static const uint8_t blend_alpha_alttinttab = 0x8E; // 142 -static const uint8_t blend_alpha_xlatab = 0xC0;// 192 (75% opacity) -static const uint8_t blend_alpha_altxlatab = 0x40; // 64 (25% opacity) extern pixel_t* pal_color; // [crispy] evil hack to get FPS dots working as in Vanilla #else static SDL_Color palette[256]; @@ -2138,66 +2133,47 @@ const pixel_t I_BlendDark (const pixel_t bg, const int d) return amask | sag | srb; } -const pixel_t I_BlendOver (const pixel_t bg, const pixel_t fg) +// [crispy] Main overlay blending function +const pixel_t I_BlendOver (const pixel_t bg, const pixel_t fg, const int amount) { - const uint32_t r = ((blend_alpha * (fg & rmask) + (0xff - blend_alpha) * (bg & rmask)) >> 8) & rmask; - const uint32_t g = ((blend_alpha * (fg & gmask) + (0xff - blend_alpha) * (bg & gmask)) >> 8) & gmask; - const uint32_t b = ((blend_alpha * (fg & bmask) + (0xff - blend_alpha) * (bg & bmask)) >> 8) & bmask; + const uint32_t r = ((amount * (fg & rmask) + (0xff - amount) * (bg & rmask)) >> 8) & rmask; + const uint32_t g = ((amount * (fg & gmask) + (0xff - amount) * (bg & gmask)) >> 8) & gmask; + const uint32_t b = ((amount * (fg & bmask) + (0xff - amount) * (bg & bmask)) >> 8) & bmask; return amask | r | g | b; } +// [crispy] TRANMAP blending emulation, used for Doom +const pixel_t I_BlendOverTranmap (const pixel_t bg, const pixel_t fg) +{ + return I_BlendOver(bg, fg, 224); // 168 (66% opacity) +} + // [crispy] TINTTAB blending emulation, used for Heretic and Hexen const pixel_t I_BlendOverTinttab (const pixel_t bg, const pixel_t fg) { - const uint32_t r = ((blend_alpha_tinttab * (fg & rmask) + (0xff - blend_alpha_tinttab) * (bg & rmask)) >> 8) & rmask; - const uint32_t g = ((blend_alpha_tinttab * (fg & gmask) + (0xff - blend_alpha_tinttab) * (bg & gmask)) >> 8) & gmask; - const uint32_t b = ((blend_alpha_tinttab * (fg & bmask) + (0xff - blend_alpha_tinttab) * (bg & bmask)) >> 8) & bmask; - - return amask | r | g | b; + return I_BlendOver(bg, fg, 0x60); // 96 (38% opacity) } // [crispy] More opaque ("Alt") TINTTAB blending emulation, used for Hexen's MF_ALTSHADOW drawing const pixel_t I_BlendOverAltTinttab (const pixel_t bg, const pixel_t fg) { - const uint32_t r = ((blend_alpha_alttinttab * (fg & rmask) + (0xff - blend_alpha_alttinttab) * (bg & rmask)) >> 8) & rmask; - const uint32_t g = ((blend_alpha_alttinttab * (fg & gmask) + (0xff - blend_alpha_alttinttab) * (bg & gmask)) >> 8) & gmask; - const uint32_t b = ((blend_alpha_alttinttab * (fg & bmask) + (0xff - blend_alpha_alttinttab) * (bg & bmask)) >> 8) & bmask; - - return amask | r | g | b; + return I_BlendOver(bg, fg, 0x8E); // 142 (56% opacity) } -// [crispy] More opaque (75%) XLATAB blending emulation, used for Strife +// [crispy] More opaque XLATAB blending emulation, used for Strife const pixel_t I_BlendOverXlatab (const pixel_t bg, const pixel_t fg) { - const uint32_t r = ((blend_alpha_xlatab * (fg & rmask) + (0xff - blend_alpha_xlatab) * (bg & rmask)) >> 8) & rmask; - const uint32_t g = ((blend_alpha_xlatab * (fg & gmask) + (0xff - blend_alpha_xlatab) * (bg & gmask)) >> 8) & gmask; - const uint32_t b = ((blend_alpha_xlatab * (fg & bmask) + (0xff - blend_alpha_xlatab) * (bg & bmask)) >> 8) & bmask; - - return amask | r | g | b; + return I_BlendOver(bg, fg, 0xC0); // 192 (75% opacity) } -// [crispy] Less opaque (25%) XLATAB blending emulation, used for Strife +// [crispy] Less opaque ("Alt") XLATAB blending emulation, used for Strife const pixel_t I_BlendOverAltXlatab (const pixel_t bg, const pixel_t fg) { - const uint32_t r = ((blend_alpha_altxlatab * (fg & rmask) + (0xff - blend_alpha_altxlatab) * (bg & rmask)) >> 8) & rmask; - const uint32_t g = ((blend_alpha_altxlatab * (fg & gmask) + (0xff - blend_alpha_altxlatab) * (bg & gmask)) >> 8) & gmask; - const uint32_t b = ((blend_alpha_altxlatab * (fg & bmask) + (0xff - blend_alpha_altxlatab) * (bg & bmask)) >> 8) & bmask; - - return amask | r | g | b; -} - -// [crispy] Perform screen crossfading effect by given amount of opacity, used for Strife -const pixel_t I_BlendOverCrossfade (const pixel_t bg, const pixel_t fg, const int amount) -{ - const uint32_t r = ((amount * (fg & rmask) + (0xff - amount) * (bg & rmask)) >> 8) & rmask; - const uint32_t g = ((amount * (fg & gmask) + (0xff - amount) * (bg & gmask)) >> 8) & gmask; - const uint32_t b = ((amount * (fg & bmask) + (0xff - amount) * (bg & bmask)) >> 8) & bmask; - - return amask | r | g | b; + return I_BlendOver(bg, fg, 0x40); // 64 (25% opacity) } -const pixel_t (*blendfunc) (const pixel_t fg, const pixel_t bg) = I_BlendOver; +const pixel_t (*blendfunc) (const pixel_t fg, const pixel_t bg) = I_BlendOverTranmap; const pixel_t I_MapRGB (const uint8_t r, const uint8_t g, const uint8_t b) { diff --git a/src/strife/f_wipe.c b/src/strife/f_wipe.c index 0879c55b82..8d18dc57c9 100644 --- a/src/strife/f_wipe.c +++ b/src/strife/f_wipe.c @@ -111,7 +111,7 @@ wipe_doColorXForm #else // [crispy] perform crossfading effect with 13 given opacity steps, multipled by 19: // 247, 228, 209, 190, 171, 152, 133, 114, 95, 76, 57, 38, 19 - *cur_screen = I_BlendOverCrossfade(*end_screen, *cur_screen, fade_safe_tics * 19); + *cur_screen = I_BlendOver(*end_screen, *cur_screen, fade_safe_tics * 19); #endif } ++cur_screen; diff --git a/src/v_trans.h b/src/v_trans.h index 77979ed8f1..f5433c13bd 100644 --- a/src/v_trans.h +++ b/src/v_trans.h @@ -62,12 +62,12 @@ extern byte *tranmap; extern const pixel_t (*blendfunc) (const pixel_t fg, const pixel_t bg); extern const pixel_t I_BlendAdd (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendDark (const pixel_t bg, const int d); -extern const pixel_t I_BlendOver (const pixel_t bg, const pixel_t fg); +extern const pixel_t I_BlendOver (const pixel_t bg, const pixel_t fg, const int amount); +extern const pixel_t I_BlendOverTranmap (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverTinttab (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverAltTinttab (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverXlatab (const pixel_t bg, const pixel_t fg); extern const pixel_t I_BlendOverAltXlatab (const pixel_t bg, const pixel_t fg); -extern const pixel_t I_BlendOverCrossfade (const pixel_t bg, const pixel_t fg, const int amount); #endif int V_GetPaletteIndex(byte *palette, int r, int g, int b); diff --git a/src/v_video.c b/src/v_video.c index fd7c3c741b..f7ecbae87c 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -184,14 +184,14 @@ static const inline pixel_t drawpatchpx10 (const pixel_t dest, const pixel_t sou #ifndef CRISPY_TRUECOLOR {return tranmap[(dest<<8)+source];} #else -{return I_BlendOver(dest, pal_color[source]);} +{return I_BlendOverTranmap(dest, pal_color[source]);} #endif // (4) color-translated, translucent patch static const inline pixel_t drawpatchpx11 (const pixel_t dest, const pixel_t source) #ifndef CRISPY_TRUECOLOR {return tranmap[(dest<<8)+dp_translation[source]];} #else -{return I_BlendOver(dest, pal_color[dp_translation[source]]);} +{return I_BlendOverTranmap(dest, pal_color[dp_translation[source]]);} #endif // [crispy] TINTTAB rendering functions: From 93f36f377cd365963256412b44f22eb2708951dc Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 9 Apr 2024 22:06:15 +0300 Subject: [PATCH 17/22] Make fail-safe crossfade counter static, better naming --- src/strife/d_main.c | 1 - src/strife/f_wipe.c | 12 +++++++----- src/strife/f_wipe.h | 4 ---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/strife/d_main.c b/src/strife/d_main.c index b38b3aa2bc..f8e37a99cc 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -234,7 +234,6 @@ void D_Display (void) if (gamestate != wipegamestate) { screenwipe = true; // [crispy] - fade_safe_tics = CROSSFADETICS; // [crispy] arm fail-safe crossfade counter wipe = true; wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); } diff --git a/src/strife/f_wipe.c b/src/strife/f_wipe.c index 8d18dc57c9..c66ee8bbbb 100644 --- a/src/strife/f_wipe.c +++ b/src/strife/f_wipe.c @@ -43,8 +43,7 @@ static pixel_t* wipe_scr_end; static pixel_t* wipe_scr; // [crispy] Additional fail-safe counter for performing crossfade effect. -// Full crossfading takes 13 game tics and counter is armed in D_Display. -int fade_safe_tics; +static int fade_counter; void wipe_shittyColMajorXform @@ -76,6 +75,9 @@ wipe_initColorXForm int ticks ) { memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr)); + // [crispy] arm fail-safe crossfade counter with + // 13 screen transitions, "zero" count won't be used. + fade_counter = 14; return 0; } @@ -99,11 +101,11 @@ wipe_doColorXForm boolean changed = false; // [crispy] reduce fail-safe crossfade counter tics - fade_safe_tics--; + fade_counter--; for(i = pix; i > 0; i--) { - if(*cur_screen != *end_screen && fade_safe_tics) + if(*cur_screen != *end_screen && fade_counter) { changed = true; #ifndef CRISPY_TRUECOLOR @@ -111,7 +113,7 @@ wipe_doColorXForm #else // [crispy] perform crossfading effect with 13 given opacity steps, multipled by 19: // 247, 228, 209, 190, 171, 152, 133, 114, 95, 76, 57, 38, 19 - *cur_screen = I_BlendOver(*end_screen, *cur_screen, fade_safe_tics * 19); + *cur_screen = I_BlendOver(*end_screen, *cur_screen, fade_counter * 19); #endif } ++cur_screen; diff --git a/src/strife/f_wipe.h b/src/strife/f_wipe.h index 51997701e2..6ffd05872a 100644 --- a/src/strife/f_wipe.h +++ b/src/strife/f_wipe.h @@ -60,8 +60,4 @@ wipe_ScreenWipe int height, int ticks ); -// [crispy] Additional fail-safe counter for performing crossfade effect. -#define CROSSFADETICS 13; -extern int fade_safe_tics; - #endif From 479d92baeead370c6e2adeff77f29c028fa43ea0 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 9 Apr 2024 22:20:14 +0300 Subject: [PATCH 18/22] Remove redundant brackets, fix typo --- src/strife/m_menu.c | 2 -- src/strife/r_things.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index fed1585533..c55b13aa83 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -2719,13 +2719,11 @@ boolean M_Responder (event_t* ev) #ifndef CRISPY_TRUECOLOR I_SetPalette (W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE)); #else - { I_SetPalette (0); R_InitColormaps(); inhelpscreens = true; R_FillBackScreen(); viewactive = false; - } #endif return true; } diff --git a/src/strife/r_things.c b/src/strife/r_things.c index bff589bf6a..e620f88e53 100644 --- a/src/strife/r_things.c +++ b/src/strife/r_things.c @@ -495,7 +495,7 @@ R_DrawVisSprite colfunc = basecolfunc; #ifdef CRISPY_TRUECOLOR - blendfunc = I_BlendOverTinttab; + blendfunc = I_BlendOverXlatab; #endif } From a711fe8dc6e583eaa18367ab68cdec4630b81223 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Tue, 9 Apr 2024 23:07:30 +0300 Subject: [PATCH 19/22] Simplify COLORMAP's brightmapped colors calculation --- src/strife/r_data.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/strife/r_data.c b/src/strife/r_data.c index 20ae417afd..fe286b7fa1 100644 --- a/src/strife/r_data.c +++ b/src/strife/r_data.c @@ -727,11 +727,11 @@ void R_InitColormaps (void) } else { - // [JN] Vanilla Strife is using COLORMAP indexes 224-255 without fading to black + // [crispy] Vanilla Strife is using COLORMAP columns 224-255 without fading to black // so they work as brightmaps. To replicate it, lock such indexes on first light level. - r = gamma2table[crispy->gamma][playpal[3 * k + 0]] + gamma2table[crispy->gamma][0] * scale; - g = gamma2table[crispy->gamma][playpal[3 * k + 1]] + gamma2table[crispy->gamma][0] * scale; - b = gamma2table[crispy->gamma][playpal[3 * k + 2]] + gamma2table[crispy->gamma][0] * scale; + r = gamma2table[crispy->gamma][playpal[3 * k + 0]]; + g = gamma2table[crispy->gamma][playpal[3 * k + 1]]; + b = gamma2table[crispy->gamma][playpal[3 * k + 2]]; } colormaps[j++] = 0xff000000 | (r << 16) | (g << 8) | b; From ee486ae071bbbef6ad959b9f2d2e00fcd8fd13b4 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Wed, 10 Apr 2024 09:12:47 +0300 Subject: [PATCH 20/22] Small styling corrections --- src/strife/d_main.c | 2 +- src/strife/f_wipe.c | 2 +- src/strife/m_menu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/strife/d_main.c b/src/strife/d_main.c index f8e37a99cc..bc352153a4 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -2034,7 +2034,7 @@ void D_DoomMain (void) // [crispy] Initialize and generate gamma-correction levels and // colormaps/pal_color arrays before introduction sequence. I_SetGammaTable(); - R_InitColormaps (); + R_InitColormaps(); // haleyjd 20110206 [STRIFE] Startup the introduction sequence D_InitIntroSequence(); diff --git a/src/strife/f_wipe.c b/src/strife/f_wipe.c index c66ee8bbbb..0a36713344 100644 --- a/src/strife/f_wipe.c +++ b/src/strife/f_wipe.c @@ -19,8 +19,8 @@ #include #include "z_zone.h" -#include "v_trans.h" // [crispy] blending functions #include "i_video.h" +#include "v_trans.h" // [crispy] blending functions #include "v_video.h" #include "m_random.h" diff --git a/src/strife/m_menu.c b/src/strife/m_menu.c index c55b13aa83..f72cff5f0d 100644 --- a/src/strife/m_menu.c +++ b/src/strife/m_menu.c @@ -2719,7 +2719,7 @@ boolean M_Responder (event_t* ev) #ifndef CRISPY_TRUECOLOR I_SetPalette (W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE)); #else - I_SetPalette (0); + I_SetPalette(0); R_InitColormaps(); inhelpscreens = true; R_FillBackScreen(); From 959462468f842a4d42e49ac567df43d6745df4fe Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Sun, 14 Apr 2024 12:00:36 +0300 Subject: [PATCH 21/22] Fix translated+translucent columns drawing --- src/strife/r_draw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/strife/r_draw.c b/src/strife/r_draw.c index b1cacefa17..8b21b2bd36 100644 --- a/src/strife/r_draw.c +++ b/src/strife/r_draw.c @@ -465,7 +465,7 @@ void R_DrawTRTLColumn(void) // Here we do an additional index re-mapping. do { - byte src = dc_colormap[dc_translation[dc_source[frac>>FRACBITS&127]]]; + pixel_t src = dc_colormap[dc_translation[dc_source[frac>>FRACBITS&127]]]; #ifndef CRISPY_TRUECOLOR pixel_t col = xlatab[(*dest << 8) + src]; *dest = col; From faea87f6ca8a5e4dd705470c31681453f677ea72 Mon Sep 17 00:00:00 2001 From: Julia Nechaevskaya Date: Fri, 19 Apr 2024 12:21:08 +0300 Subject: [PATCH 22/22] Proper memory size allocation for wiping effect Co-Authored-By: Fabian Greffrath --- src/strife/f_wipe.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/strife/f_wipe.c b/src/strife/f_wipe.c index 0a36713344..2edcb20857 100644 --- a/src/strife/f_wipe.c +++ b/src/strife/f_wipe.c @@ -283,14 +283,8 @@ wipe_ScreenWipe { go = 1; // haleyjd 20110629 [STRIFE]: We *must* use a temp buffer here. -#ifndef CRISPY_TRUECOLOR - wipe_scr = (pixel_t *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG + wipe_scr = (pixel_t *) Z_Malloc(width*height*sizeof(*wipe_scr), PU_STATIC, 0); // DEBUG //wipe_scr = I_VideoBuffer; -#else - // [crispy] In TrueColor render perform everything in common buffer. - // Otherwise serious malloc errors will happen. - wipe_scr = I_VideoBuffer; -#endif (*wipes[wipeno*3])(width, height, ticks); } @@ -298,10 +292,8 @@ wipe_ScreenWipe V_MarkRect(0, 0, width, height); rc = (*wipes[wipeno*3+1])(width, height, ticks); -#ifndef CRISPY_TRUECOLOR // haleyjd 20110629 [STRIFE]: Copy temp buffer to the real screen. V_DrawBlock(x, y, width, height, wipe_scr); -#endif // final stuff if (rc)