diff --git a/src/d_main.c b/src/d_main.c index 11f6fbe9..a7ec34a6 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -448,12 +448,14 @@ void D_Display (void) int nowtime, tics; do { + I_Sleep(1); nowtime = I_GetTime(); tics = nowtime - wipestart; } while (!tics); wipestart = nowtime; - done = wipe_ScreenWipe(wipe_Melt, 0, 0, video.unscaledw, SCREENHEIGHT, tics); + done = wipe_ScreenWipe(strictmode ? wipe_Melt : screen_melt, + 0, 0, video.unscaledw, SCREENHEIGHT, tics); M_Drawer(); // menu is drawn even on top of wipes I_FinishUpdate(); // page flip or blit buffer } diff --git a/src/f_wipe.c b/src/f_wipe.c index 137f8bc6..dfbaca22 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -23,6 +23,7 @@ #include "f_wipe.h" #include "i_video.h" #include "m_random.h" +#include "v_flextran.h" #include "v_video.h" #include "z_zone.h" @@ -57,33 +58,47 @@ static void wipe_shittyColMajorXform(byte *array, int width, int height) Z_Free(dest); } +// [FG] cross-fading screen wipe implementation + +static int fade_tick; + static int wipe_initColorXForm(int width, int height, int ticks) { V_PutBlock(0, 0, width, height, wipe_scr_start); + fade_tick = 0; return 0; } -// killough 3/5/98: reformatted and cleaned up static int wipe_doColorXForm(int width, int height, int ticks) { - boolean unchanged = true; - byte *w = wipe_scr; - byte *e = wipe_scr_end; - byte *end = wipe_scr+width*height; - for (;w != end; w++, e++) - if (*w != *e) - { - int newval; - unchanged = false; - *w = *w > *e ? - (newval = *w - ticks) < *e ? *e : newval : - (newval = *w + ticks) > *e ? *e : newval ; - } - return unchanged; + for (int y = 0; y < height; y++) + { + byte *sta = wipe_scr_start + y * width; + byte *end = wipe_scr_end + y * width; + byte *dst = wipe_scr + y * video.pitch; + + for (int x = 0; x < width; x++) + { + unsigned int *fg2rgb = Col2RGB8[fade_tick]; + unsigned int *bg2rgb = Col2RGB8[64 - fade_tick]; + unsigned int fg, bg; + + fg = fg2rgb[end[x]]; + bg = bg2rgb[sta[x]]; + fg = (fg + bg) | 0x1f07c1f; + dst[x] = RGB32k[0][0][fg & (fg >> 15)]; + } + } + + fade_tick += 2 * ticks; + + return (fade_tick > 64); } -static int wipe_exitColorXForm(int width, int height, int ticks) +static int wipe_exit(int width, int height, int ticks) { + Z_Free(wipe_scr_start); + Z_Free(wipe_scr_end); return 0; } @@ -173,8 +188,7 @@ static int wipe_doMelt(int width, int height, int ticks) static int wipe_exitMelt(int width, int height, int ticks) { Z_Free(col_y); - Z_Free(wipe_scr_start); - Z_Free(wipe_scr_end); + wipe_exit(width, height, ticks); return 0; } @@ -195,13 +209,21 @@ int wipe_EndScreen(int x, int y, int width, int height) return 0; } +static int wipe_NOP(int x, int y, int t) +{ + return 0; +} + static int (*const wipes[])(int, int, int) = { - wipe_initColorXForm, - wipe_doColorXForm, - wipe_exitColorXForm, + wipe_NOP, + wipe_NOP, + wipe_exit, wipe_initMelt, wipe_doMelt, - wipe_exitMelt + wipe_exitMelt, + wipe_initColorXForm, + wipe_doColorXForm, + wipe_exit, }; // killough 3/5/98: reformatted and cleaned up diff --git a/src/f_wipe.h b/src/f_wipe.h index 1b0b6d71..1121bf9f 100644 --- a/src/f_wipe.h +++ b/src/f_wipe.h @@ -25,9 +25,9 @@ // enum { - // simple gradual pixel change for 8-bit only - wipe_ColorXForm, + wipe_None, wipe_Melt, // weird screen melt + wipe_ColorXForm, wipe_NUMWIPES }; diff --git a/src/m_menu.c b/src/m_menu.c index 68c964b5..f05288eb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2022,6 +2022,7 @@ enum str_menu_backdrop, str_widescreen, str_bobbing_pct, + str_screen_melt, str_invul_mode, }; @@ -4122,6 +4123,10 @@ static const char *menu_backdrop_strings[] = { "Off", "Dark", "Texture" }; +static const char *screen_melt_strings[] = { + "Off", "Melt", "Crossfade" +}; + static const char *invul_mode_strings[] = { "Vanilla", "MBF", "Gray" }; @@ -4247,7 +4252,8 @@ setup_menu_t gen_settings6[] = { {"Quality of life", S_SKIP|S_TITLE, m_null, M_X, M_Y}, - {"Screen melt", S_ONOFF|S_STRICT, m_null, M_X, M_SPC, {"screen_melt"}}, + {"Screen wipe effect", S_CHOICE|S_STRICT, m_null, M_X, M_SPC, + {"screen_melt"}, 0, NULL, str_screen_melt}, {"On death action", S_CHOICE, m_null, M_X, M_SPC, {"death_use_action"}, 0, NULL, str_death_use_action}, @@ -6919,6 +6925,7 @@ static const char **selectstrings[] = { menu_backdrop_strings, widescreen_strings, bobbing_pct_strings, + screen_melt_strings, invul_mode_strings, }; diff --git a/src/m_misc.c b/src/m_misc.c index 3b83c513..5af3bb2e 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -33,6 +33,7 @@ #include "doomkeys.h" #include "doomstat.h" #include "dstrings.h" +#include "f_wipe.h" #include "g_game.h" #include "hu_lib.h" // HU_MAXMESSAGES #include "hu_obituary.h" @@ -606,8 +607,8 @@ default_t defaults[] = { { "screen_melt", (config_t *) &screen_melt, NULL, - {1}, {0,1}, number, ss_gen, wad_no, - "0 to disable screen melt" + {wipe_Melt}, {wipe_None, wipe_ColorXForm}, number, ss_gen, wad_no, + "screen wipe effect (0 = none, 1 = melt, 2 = crossfade)" }, {