diff --git a/src/i_video.c b/src/i_video.c index 95bc72e18..cf5646de8 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 1add53ae4..0879c55b8 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 02690ea11..77979ed8f 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);