Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strife: add true color support #1183

Merged
merged 22 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ad8376b
Initial implementation
JNechaevsky Mar 3, 2024
8dc3570
Fix crash on drawing view border
JNechaevsky Mar 3, 2024
26fd68d
Sigil weapon effect working
JNechaevsky Mar 3, 2024
e870b44
crispy_truecolor config variable
JNechaevsky Mar 3, 2024
3309930
Btightmaps working!
JNechaevsky Mar 3, 2024
9cdce80
Blending and alt blending functions
JNechaevsky Mar 3, 2024
00cd040
Proper translucensy values for columns and walls
JNechaevsky Mar 3, 2024
a2db299
Graphical startup working
JNechaevsky Mar 3, 2024
81f9886
Get rid of few TODOs
JNechaevsky Mar 3, 2024
b658e7b
Better logics for brightmaps emulation
JNechaevsky Mar 5, 2024
606dc34
Update screen wiping code
JNechaevsky Apr 8, 2024
e176cd5
Fix possible infinite loop in crossfading, make it work in TrueColor
JNechaevsky Apr 8, 2024
0ea49bc
Proper implementation of crossfading effect
JNechaevsky Apr 8, 2024
656c3f8
Fix introduction sequence for both renders
JNechaevsky Apr 9, 2024
80e407b
Small corrections
JNechaevsky Apr 9, 2024
999da5c
Simplify overlay blending functions
JNechaevsky Apr 9, 2024
93f36f3
Make fail-safe crossfade counter static, better naming
JNechaevsky Apr 9, 2024
479d92b
Remove redundant brackets, fix typo
JNechaevsky Apr 9, 2024
a711fe8
Simplify COLORMAP's brightmapped colors calculation
JNechaevsky Apr 9, 2024
ee486ae
Small styling corrections
JNechaevsky Apr 10, 2024
9594624
Fix translated+translucent columns drawing
JNechaevsky Apr 14, 2024
faea87f
Proper memory size allocation for wiping effect
JNechaevsky Apr 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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];
Expand Down Expand Up @@ -2165,6 +2167,36 @@ const pixel_t I_BlendOverAltTinttab (const pixel_t bg, const pixel_t fg)
return amask | r | g | b;
}

// [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;
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;
}

// [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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now we have reached the point where we can leave this as the only actual implementation of I_BlendOver() and have all the other variants turned into macros with hard-coded amount values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've read all of your remarks, but let's please start from this one. I've got your idea of simplification and reducing amount of existing duplications and opacity values. This should be something like this:

const pixel_t I_BlendOver (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;
}

// This should replace Doom's I_BlendOver calls:
const pixel_t I_BlendOverTranmap (const pixel_t bg, const pixel_t fg)
{
    // ... i.e. when I_BlendOverTranmap is called, catch it's values and pass it to main BlendOver function
    return I_BlendOver(bg, fg, 0xa8); // 168
}

But... You mean exactly to macrocize such "passing" pixel_t functions? Is it possible at all, without writing them in .c files? I never tried to write whole function as macro, so small hint or example will be very appreciated.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like

#define I_BlendOverTranmap(a,b) I_BlendOver(a,b,0xa8)

with the corresponding comment in v_video.h.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't worked on my side. In Doom all I_BlendOver calls replaced with I_BlendOverTranmap (this one no longer exist in i_video.c file), and header file contains:

extern const pixel_t I_BlendOver (const pixel_t bg, const pixel_t fg, const int amount);
#define I_BlendOverTranmap(bg, fg) I_BlendOver(bg, fg, 0xa8)

Compiler gives following multiple errors like:

# cmake --build build
[5/47] Building C object src/doom/CMakeFiles/doom.dir/r_things.c.obj
FAILED: src/doom/CMakeFiles/doom.dir/r_things.c.obj
R:\MSYS\mingw64\bin\cc.exe  -IR:/MSYS/home/julia/crispy-doom/src/doom/.. -IR:/MSYS/home/julia/crispy-doom/build/src/doom/../.. -isystem R:/MSYS/mingw64/include/SDL2 -O3 -DNDEBUG -Wall -Wdeclaration-after-statement -Wredundant-decls -MD -MT src/doom/CMakeFiles/doom.dir/r_things.c.obj -MF src\doom\CMakeFiles\doom.dir\r_things.c.obj.d -o src/doom/CMakeFiles/doom.dir/r_things.c.obj -c R:/MSYS/home/julia/crispy-doom/src/doom/r_things.c
R:/MSYS/home/julia/crispy-doom/src/doom/r_things.c: In function 'R_DrawVisSprite':
R:/MSYS/home/julia/crispy-doom/src/doom/r_things.c:547:17: error: 'I_BlendOverTranmap' undeclared (first use in this function); did you mean 'I_BlendOverXlatab'?
  547 |     blendfunc = I_BlendOverTranmap;
      |                 ^~~~~~~~~~~~~~~~~~
      |                 I_BlendOverXlatab

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, dammit, function pointers. Right this won't work. The solution you suggested before looked reasonable, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 999da5c. Yeah, to make pointers and cases like this happy, my another idea was to extend I_BlendAdd with incoming amount parameter, but this is doesn't reasonable, since additive blending doesn't have any meanings of "amount" at all, and such parameter will be simply useless.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

{
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)
Expand Down
31 changes: 20 additions & 11 deletions src/strife/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,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)]))
fabiangreffrath marked this conversation as resolved.
Show resolved Hide resolved
#endif

dx = fl->b.x - fl->a.x;
ax = 2 * (dx<0 ? -dx : dx);
Expand Down Expand Up @@ -1307,7 +1312,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)
{
Expand All @@ -1327,7 +1332,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;
}
Expand All @@ -1337,7 +1342,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;
Expand All @@ -1349,7 +1354,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;
Expand Down Expand Up @@ -1383,12 +1388,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
Expand All @@ -1410,13 +1415,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]);
}

//
Expand Down Expand Up @@ -1885,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
}

Expand Down
13 changes: 13 additions & 0 deletions src/strife/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ void D_Display (void)
if (gamestate != wipegamestate)
{
screenwipe = true; // [crispy]
fade_safe_tics = CROSSFADETICS; // [crispy] arm fail-safe crossfade counter
fabiangreffrath marked this conversation as resolved.
Show resolved Hide resolved
wipe = true;
wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
}
Expand Down Expand Up @@ -292,7 +293,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)
Expand Down Expand Up @@ -537,6 +542,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);
Expand Down Expand Up @@ -2024,6 +2032,11 @@ void D_DoomMain (void)

I_GraphicsCheckCommandLine();

// [crispy] Initialize and generate gamma-correction levels and
// colormaps/pal_color arrays before introduction sequence.
I_SetGammaTable();
R_InitColormaps ();

// haleyjd 20110206 [STRIFE] Startup the introduction sequence
D_InitIntroSequence();

Expand Down
67 changes: 44 additions & 23 deletions src/strife/f_wipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <string.h>

#include "z_zone.h"
#include "v_trans.h" // [crispy] blending functions
#include "i_video.h"
#include "v_video.h"
#include "m_random.h"
Expand All @@ -37,28 +38,31 @@
// 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;

// [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
( 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<height;y++)
for(x=0;x<width;x++)
dest[x*height+y] = array[y*width+x];

memcpy(array, dest, width*height*2);
memcpy(array, dest, width*height*sizeof(*dest));

Z_Free(dest);

Expand All @@ -71,7 +75,7 @@ wipe_initColorXForm
int height,
int ticks )
{
memcpy(wipe_scr, wipe_scr_start, width*height);
memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr));
return 0;
}

Expand All @@ -88,18 +92,27 @@ wipe_doColorXForm
int height,
int ticks )
{
byte *cur_screen = wipe_scr;
byte *end_screen = wipe_scr_end;
pixel_t *cur_screen = wipe_scr;
pixel_t *end_screen = wipe_scr_end;
int pix = width*height;
int i;
boolean changed = false;

// [crispy] reduce fail-safe crossfade counter tics
fade_safe_tics--;
fabiangreffrath marked this conversation as resolved.
Show resolved Hide resolved

for(i = pix; i > 0; i--)
{
if(*cur_screen != *end_screen)
if(*cur_screen != *end_screen && fade_safe_tics)
fabiangreffrath marked this conversation as resolved.
Show resolved Hide resolved
{
changed = true;
#ifndef CRISPY_TRUECOLOR
*cur_screen = xlatab[(*cur_screen << 8) + *end_screen];
#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);
#endif
}
++cur_screen;
++end_screen;
Expand Down Expand Up @@ -130,12 +143,12 @@ 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
wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height);
wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height);
wipe_shittyColMajorXform((dpixel_t*)wipe_scr_start, width/2, height);
wipe_shittyColMajorXform((dpixel_t*)wipe_scr_end, width/2, height);

// setup initial column positions
// (y<0 => not ready to scroll yet)
Expand Down Expand Up @@ -163,8 +176,8 @@ wipe_doMelt
int dy;
int idx;

short* s;
short* d;
dpixel_t* s;
dpixel_t* d;
boolean done = true;

width/=2;
Expand All @@ -181,17 +194,17 @@ 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--)
{
d[idx] = *(s++);
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--)
{
Expand Down Expand Up @@ -227,7 +240,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;
}
Expand All @@ -240,7 +253,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;
Expand Down Expand Up @@ -268,17 +281,25 @@ 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
#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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, even if you allocate the correct amount of memory with sizeof(*wipe_scr)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm afraid. "Debug" build type can survive it, but "Release" type almost imideatelly crashes after crossfade or next hitting of Z_Malloc (like opening Load menu) with something like this:

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ff6f69f396e in Z_Malloc ()
(gdb) bt
#0  0x00007ff6f69f396e in Z_Malloc ()
#1  0x00007ff6f6a07357 in M_StringAlloc.constprop.0 ()
#2  0x00007ff6f6a07c74 in M_SafeFilePath ()
#3  0x00007ff6f6a026f5 in M_ReadSaveStrings ()
#4  0x00007ff6f6a06415 in M_Responder ()
#5  0x00007ff6f69f698d in D_ProcessEvents ()
#6  0x00007ff6f69c6930 in BuildNewTic ()
#7  0x00007ff6f69c6afc in NetUpdate.part.0 ()
#8  0x00007ff6f69c7782 in TryRunTics ()
#9  0x00007ff6f69f6e9a in D_DoomLoop ()
#10 0x00007ff6f69f89c7 in D_DoomMain ()
#11 0x00007ff6f69c159f in SDL_main ()
#12 0x00007ff6f6a3f0fe in main_getcmdline ()
#13 0x00007ff6f69c12ee in __tmainCRTStartup () at C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:267
#14 0x00007ff6f69c13e6 in WinMainCRTStartup () at C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:157
(gdb)

Since it's not a simple game of PU_STATIC vs. PU_CACHE, using of I_VideoBuffer is the best I can do.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have a closer look at this, probably this weekend, before I wave it through.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me:

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I have missed most important part just like in other parts of wiping functions - *sizeof(*wipe_scr). Working on my side too, thank you! Will commit changes soon.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say let's go the Doom way.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But for some reason there is this comment:

// haleyjd 20110629 [STRIFE]: We *must* use a temp buffer here.

So, better explicitly call Z_Free()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call Z_Free(wipe_scr); below this line.

Hm, didn't worked for me, that's odd. 🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, Z_Free() only marks a block in zone memory as "free". That is, Z_Malloc() only allocates in the zone memory as well, so why does the heap memory consumption of the whole process grow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You right, turns out, it's not a wipe, it's something else. Even if wipe is disabled here as:

    // save the current screen if about to wipe
    if (gamestate != wipegamestate && false) // +++ && false

...leak still happening. Probably something around with malloc?

wipe_scr = I_VideoBuffer;
#endif
(*wipes[wipeno*3])(width, height, ticks);
}

// do a piece of wipe-in
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)
Expand Down
4 changes: 4 additions & 0 deletions src/strife/f_wipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ wipe_ScreenWipe
int height,
int ticks );

// [crispy] Additional fail-safe counter for performing crossfade effect.
#define CROSSFADETICS 13;
fabiangreffrath marked this conversation as resolved.
Show resolved Hide resolved
extern int fade_safe_tics;

#endif
Loading