Skip to content

Commit 6baa54e

Browse files
committed
Add config variable and support for Doom
1 parent 7ba4db1 commit 6baa54e

File tree

8 files changed

+38
-2
lines changed

8 files changed

+38
-2
lines changed

src/crispy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static crispy_t crispy_s = {
3131
#ifdef CRISPY_TRUECOLOR
3232
.smoothlight = 1,
3333
.truecolor = 1,
34+
.blendquality = 1,
3435
#endif
3536
.vsync = 1,
3637
.widescreen = 1, // match screen by default

src/crispy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ typedef struct
8181
int translucency;
8282
#ifdef CRISPY_TRUECOLOR
8383
int truecolor;
84+
int blendquality;
8485
#endif
8586
int uncapped;
8687
int vsync;

src/doom/d_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ void D_BindVariables(void)
483483
M_BindIntVariable("crispy_translucency", &crispy->translucency);
484484
#ifdef CRISPY_TRUECOLOR
485485
M_BindIntVariable("crispy_truecolor", &crispy->truecolor);
486+
M_BindIntVariable("crispy_blendquality", &crispy->blendquality);
486487
#endif
487488
M_BindIntVariable("crispy_uncapped", &crispy->uncapped);
488489
M_BindIntVariable("crispy_vsync", &crispy->vsync);

src/doom/r_things.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ void R_ProjectSprite (mobj_t* thing)
817817
// [crispy] translucent sprites
818818
if (thing->flags & MF_TRANSLUCENT)
819819
{
820-
vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAdd : I_BlendOverTranmap;
820+
vis->blendfunc = (thing->frame & FF_FULLBRIGHT) ? I_BlendAddFunc : I_BlendOverTranmap;
821821
}
822822
#endif
823823
}

src/i_truecolor.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ static uint32_t blendAddLUT[512][512]; // Additive blending
4242
static uint32_t blendOverLUT[512][512]; // Overlay blending
4343
static uint32_t blendOverAltLUT[512][512]; // Overlay "alt" blending
4444

45+
const uint32_t (*I_BlendAddFunc) (const uint32_t bg_i, const uint32_t fg_i);
46+
const uint32_t (*I_BlendOverFunc) (const uint32_t bg_i, const uint32_t fg_i, const int amount);
47+
//const uint32_t (*I_BlendOverAltFunc) (const uint32_t bg_i, const uint32_t fg_i);
48+
4549
// [JN] Different blending alpha values for different games
4650
#define OVERLAY_ALPHA_TRANMAP 168 // Doom: TRANMAP, 66% opacity
4751
#define OVERLAY_ALPHA_TINTTAB 96 // Raven: TINTTAB, 38% opacity
@@ -176,7 +180,7 @@ const uint32_t I_BlendOverLow (const uint32_t bg_i, const uint32_t fg_i, const i
176180
// [crispy] TRANMAP blending emulation, used for Doom
177181
const uint32_t I_BlendOverTranmap (const uint32_t bg, const uint32_t fg)
178182
{
179-
return I_BlendOver(bg, fg, 0xA8); // 168 (66% opacity)
183+
return I_BlendOverFunc(bg, fg, 0xA8); // 168 (66% opacity)
180184
}
181185

182186
// [crispy] TINTTAB blending emulation, used for Heretic and Hexen
@@ -203,4 +207,21 @@ const uint32_t I_BlendOverAltXlatab (const uint32_t bg, const uint32_t fg)
203207
return I_BlendOver(bg, fg, 0x40); // 64 (25% opacity)
204208
}
205209

210+
// [JN] Set pointers to blending functions.
211+
void R_InitBlendQuality (void)
212+
{
213+
if (crispy->blendquality)
214+
{
215+
I_BlendAddFunc = I_BlendAdd;
216+
I_BlendOverFunc = I_BlendOver;
217+
// I_BlendOverAltFunc = I_BlendOverAlt;
218+
}
219+
else
220+
{
221+
I_BlendAddFunc = I_BlendAddLow;
222+
I_BlendOverFunc = I_BlendOverLow;
223+
// I_BlendOverAltFunc = I_BlendOverAltLow;
224+
}
225+
}
226+
206227
#endif

src/i_truecolor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
extern const uint32_t (*blendfunc) (const uint32_t fg, const uint32_t bg);
3030

3131
extern void R_InitBlendMaps (void);
32+
extern void R_InitBlendQuality (void);
33+
extern const uint32_t (*I_BlendAddFunc) (const uint32_t bg_i, const uint32_t fg_i);
34+
extern const uint32_t (*I_BlendOverFunc) (const uint32_t bg_i, const uint32_t fg_i, const int amount);
3235

3336
const uint32_t I_BlendAdd (const uint32_t bg_i, const uint32_t fg_i);
3437
const uint32_t I_BlendDark (const uint32_t bg_i, const int d);

src/m_config.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,14 @@ static default_t extra_defaults_list[] =
26062606
//
26072607

26082608
CONFIG_VARIABLE_INT(crispy_truecolor),
2609+
2610+
//!
2611+
// @game doom
2612+
//
2613+
// Quality of translucency blending.
2614+
//
2615+
2616+
CONFIG_VARIABLE_INT(crispy_blendquality),
26092617
#endif
26102618

26112619
//!

src/setup/compatibility.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void BindCompatibilityVariables(void)
9191
M_BindIntVariable("crispy_translucency", &crispy->translucency);
9292
#ifdef CRISPY_TRUECOLOR
9393
M_BindIntVariable("crispy_truecolor", &crispy->truecolor);
94+
M_BindIntVariable("crispy_blendquality", &crispy->blendquality);
9495
#endif
9596
M_BindIntVariable("crispy_uncapped", &crispy->uncapped);
9697
M_BindIntVariable("crispy_vsync", &crispy->vsync);

0 commit comments

Comments
 (0)