Add tinted fade support to HWR_FadeScreenMenuBack

This commit is contained in:
Hannu Hanhi 2022-03-23 01:19:15 +02:00
parent 978006bc97
commit d310729b54

View file

@ -30,6 +30,7 @@
#include "../st_stuff.h"
#include "../p_local.h" // stplyr
#include "../g_game.h" // players
#include "../f_finale.h" // fade color factors
#include <fcntl.h>
#include "../i_video.h" // for rendermode != render_glide
@ -783,6 +784,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
{
FOutVector v[4];
FSurfaceInfo Surf;
FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest;
v[0].x = v[3].x = -1.0f;
v[2].x = v[1].x = 1.0f;
@ -795,7 +797,29 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
v[0].t = v[1].t = 1.0f;
v[2].t = v[3].t = 0.0f;
if (color & 0xFF00) // Do COLORMAP fade.
if (color & 0xFF00) // Special fade options
{
UINT16 option = color & 0x0F00;
if (option == 0x0A00 || option == 0x0B00) // Tinted fades
{
INT32 r, g, b;
int fade = strength * 8;
r = FADEREDFACTOR*fade/10;
g = FADEGREENFACTOR*fade/10;
b = FADEBLUEFACTOR*fade/10;
Surf.PolyColor.s.red = min(r, 255);
Surf.PolyColor.s.green = min(g, 255);
Surf.PolyColor.s.blue = min(b, 255);
Surf.PolyColor.s.alpha = 255;
if (option == 0x0A00) // Tinted subtractive fade
poly_flags |= PF_ReverseSubtract;
else if (option == 0x0B00) // Tinted additive fade
poly_flags |= PF_Additive;
}
else // COLORMAP fade
{
if (HWR_ShouldUsePaletteRendering())
{
@ -810,16 +834,22 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
return;
}
else
{
Surf.PolyColor.rgba = UINT2RGBA(0x01010160);
Surf.PolyColor.s.alpha = (strength*8);
poly_flags |= PF_Translucent;
}
}
}
else // Do TRANSMAP** fade.
{
RGBA_t *palette = HWR_GetTexturePalette();
Surf.PolyColor.rgba = palette[color&0xFF].rgba;
Surf.PolyColor.s.alpha = softwaretranstogl[strength];
poly_flags |= PF_Translucent;
}
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);
HWD.pfnDrawPolygon(&Surf, v, 4, poly_flags);
}
// -----------------+