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 21 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
6 changes: 3 additions & 3 deletions src/doom/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ R_DrawVisSprite

colfunc = basecolfunc;
#ifdef CRISPY_TRUECOLOR
blendfunc = I_BlendOver;
blendfunc = I_BlendOverTranmap;
#endif
}

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

Expand Down
42 changes: 25 additions & 17 deletions src/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +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
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 @@ -2136,36 +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 I_BlendOver(bg, fg, 0x8E); // 142 (56% opacity)
}

return amask | r | g | b;
// [crispy] More opaque XLATAB blending emulation, used for Strife
const pixel_t I_BlendOverXlatab (const pixel_t bg, const pixel_t fg)
{
return I_BlendOver(bg, fg, 0xC0); // 192 (75% opacity)
}

// [crispy] Less opaque ("Alt") XLATAB blending emulation, used for Strife
const pixel_t I_BlendOverAltXlatab (const pixel_t bg, const pixel_t fg)
{
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)
{
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
12 changes: 12 additions & 0 deletions src/strife/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,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 +541,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 +2031,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
Loading