From 94081f469e14d7ad600a8976a2d967349b21f293 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sun, 4 Aug 2019 23:42:30 -0400 Subject: [PATCH 1/9] Genesis wipe stuff Very unoptimized, lags in anything besides 320x200 --- src/f_wipe.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++-- src/r_data.c | 3 +- src/r_data.h | 1 + 3 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index 3c8713d18..842161a62 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -12,12 +12,19 @@ /// \file f_wipe.c /// \brief SRB2 2.1 custom fade mask "wipe" behavior. +#define GENESIS_WIPE // Sal: experimental Genesis-style colorful wipes + #include "f_finale.h" #include "i_video.h" #include "v_video.h" +#ifdef GENESIS_WIPE +#include "r_data.h" // NearestColor +#else #include "r_draw.h" // transtable #include "p_pspr.h" // tr_transxxx +#endif + #include "w_wad.h" #include "z_zone.h" @@ -89,6 +96,7 @@ INT32 lastwipetic = 0; static UINT8 *wipe_scr_start; //screen 3 static UINT8 *wipe_scr_end; //screen 4 static UINT8 *wipe_scr; //screen 0 (main drawing) +static UINT8 pallen; static fixed_t paldiv; /** Create fademask_t from lump @@ -211,7 +219,12 @@ static void F_DoWipe(fademask_t *fademask) const UINT8 *e_base = e; // mask data, end - UINT8 *transtbl; +#ifdef GENESIS_WIPE + UINT8 i; + RGBA_t wcolor, *ecolor; +#else + UINT8 *transtbl; +#endif const UINT8 *mask = fademask->mask; const UINT8 *maskend = mask + fademask->size; @@ -259,7 +272,7 @@ static void F_DoWipe(fademask_t *fademask) relativepos += vid.width; } } - else if (*mask == 10) + else if (*mask == pallen) { // shortcut - memcpy target to work while (draw_linestogo--) @@ -270,6 +283,70 @@ static void F_DoWipe(fademask_t *fademask) } else { +#ifdef GENESIS_WIPE + // DRAWING LOOP + while (draw_linestogo--) + { + w = w_base + relativepos; + s = s_base + relativepos; + e = e_base + relativepos; + draw_rowstogo = draw_rowend - draw_rowstart; + + ecolor = &pLocalPalette[*e]; + + while (draw_rowstogo--) + { + memcpy(&wcolor, &pLocalPalette[*s++], sizeof(RGBA_t)); + + // GENESIS WIPE: + // Change red until it reaches the intended value + // Then green, then blue. + + for (i = 0; i < *mask; i++) + { + if (abs(wcolor.s.red - ecolor->s.red) > 34) + { + if (wcolor.s.red < ecolor->s.red) + wcolor.s.red += 34; + else + wcolor.s.red -= 34; + } + else + { + wcolor.s.red = ecolor->s.red; + + if (abs(wcolor.s.green - ecolor->s.green) > 34) + { + if (wcolor.s.green < ecolor->s.green) + wcolor.s.green += 34; + else + wcolor.s.green -= 34; + } + else + { + wcolor.s.green = ecolor->s.green; + + if (abs(wcolor.s.blue - ecolor->s.blue) > 34) + { + if (wcolor.s.blue < ecolor->s.blue) + wcolor.s.blue += 34; + else + wcolor.s.blue -= 34; + + } + else + wcolor.s.blue = ecolor->s.blue; + } + } + } + + *w++ = NearestColor(wcolor.s.red, wcolor.s.green, wcolor.s.blue); + } + + relativepos += vid.width; + } + // END DRAWING LOOP +#else // pointer to transtable that this mask would use transtbl = transtables + ((9 - *mask)<= fademask->width) @@ -347,7 +425,13 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) UINT8 wipeframe = 0; fademask_t *fmask; - paldiv = FixedDiv(257< Date: Wed, 7 Aug 2019 02:21:04 -0400 Subject: [PATCH 2/9] Uses pre-defined colormap lumps now Works much faster now. I'd like to clean up this code some though --- src/d_main.c | 4 +- src/f_finale.c | 8 +-- src/f_finale.h | 2 +- src/f_wipe.c | 141 +++++++++++++++++++------------------------------ src/p_setup.c | 6 +-- 5 files changed, 65 insertions(+), 96 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1404a5e61..a6bd48e0e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -325,7 +325,7 @@ static void D_Display(void) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); + F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", false); } if (gamestate != GS_LEVEL && rendermode != render_none) @@ -556,7 +556,7 @@ static void D_Display(void) if (rendermode != render_none) { F_WipeEndScreen(); - F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); + F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", true); } } diff --git a/src/f_finale.c b/src/f_finale.c index 9a4be070c..d45a9cfa9 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -220,7 +220,7 @@ void F_StartIntro(void) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_final], false); + F_RunWipe(wipedefs[wipe_level_final], false, "FADEMAP0", false); } if (introtoplay) @@ -306,7 +306,7 @@ void F_IntroDrawer(void) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(99,true); + F_RunWipe(99, true, "FADEMAP0", false); } // Stay on black for a bit. =) @@ -1420,7 +1420,7 @@ void F_CutsceneDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, cutscenes[cutnum]->scene[scenenum].fadecolor); F_WipeEndScreen(); - F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeinid, true); + F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeinid, true, NULL, false); F_WipeStartScreen(); } @@ -1440,7 +1440,7 @@ void F_CutsceneDrawer(void) if (dofadenow && rendermode != render_none) { F_WipeEndScreen(); - F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeoutid, true); + F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeoutid, true, NULL, false); } V_DrawString(textxpos, textypos, 0, cutscene_disptext); diff --git a/src/f_finale.h b/src/f_finale.h index 45166e03d..a6fccf888 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -74,7 +74,7 @@ extern INT32 lastwipetic; void F_WipeStartScreen(void); void F_WipeEndScreen(void); -void F_RunWipe(UINT8 wipetype, boolean drawMenu); +void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse); enum { diff --git a/src/f_wipe.c b/src/f_wipe.c index 842161a62..0abef4ca7 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -18,12 +18,9 @@ #include "i_video.h" #include "v_video.h" -#ifdef GENESIS_WIPE #include "r_data.h" // NearestColor -#else #include "r_draw.h" // transtable #include "p_pspr.h" // tr_transxxx -#endif #include "w_wad.h" #include "z_zone.h" @@ -93,6 +90,9 @@ boolean WipeInAction = false; INT32 lastwipetic = 0; #ifndef NOWIPE + +#define GENLEN 31 + static UINT8 *wipe_scr_start; //screen 3 static UINT8 *wipe_scr_end; //screen 4 static UINT8 *wipe_scr; //screen 0 (main drawing) @@ -189,7 +189,7 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) { * * \param fademask pixels to change */ -static void F_DoWipe(fademask_t *fademask) +static void F_DoWipe(fademask_t *fademask, lighttable_t *fadecolormap, boolean reverse) { // Software mask wipe -- optimized; though it might not look like it! // Okay, to save you wondering *how* this is more optimized than the simpler @@ -207,6 +207,10 @@ static void F_DoWipe(fademask_t *fademask) // look a little messy; sorry!) but it simultaneously runs at twice the speed. // In addition, we precalculate all the X and Y positions that we need to draw // from and to, so it uses a little extra memory, but again, helps it run faster. + // --- + // Sal: I kinda destroyed some of this code by introducing Genesis-style fades. + // A colormap can be provided in F_RunWipe, which the white/black values will be + // remapped to the appropriate entry in the fade colormap. { // wipe screen, start, end UINT8 *w = wipe_scr; @@ -219,12 +223,7 @@ static void F_DoWipe(fademask_t *fademask) const UINT8 *e_base = e; // mask data, end -#ifdef GENESIS_WIPE - UINT8 i; - RGBA_t wcolor, *ecolor; -#else - UINT8 *transtbl; -#endif + UINT8 *transtbl; const UINT8 *mask = fademask->mask; const UINT8 *maskend = mask + fademask->size; @@ -255,6 +254,8 @@ static void F_DoWipe(fademask_t *fademask) maskx = masky = 0; do { + UINT8 m = *mask; + draw_rowstart = scrxpos[maskx]; draw_rowend = scrxpos[maskx + 1]; draw_linestart = scrypos[masky]; @@ -263,27 +264,32 @@ static void F_DoWipe(fademask_t *fademask) relativepos = (draw_linestart * vid.width) + draw_rowstart; draw_linestogo = draw_lineend - draw_linestart; - if (*mask == 0) + if (reverse) + m = ((pallen-1) - m); + + if (m == 0) { // shortcut - memcpy source to work while (draw_linestogo--) { - M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart); + M_Memcpy(w_base+relativepos, (reverse ? e_base : s_base)+relativepos, draw_rowend-draw_rowstart); relativepos += vid.width; } } - else if (*mask == pallen) + else if (m >= (pallen-1)) { // shortcut - memcpy target to work while (draw_linestogo--) { - M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart); + M_Memcpy(w_base+relativepos, (reverse ? s_base : e_base)+relativepos, draw_rowend-draw_rowstart); relativepos += vid.width; } } else { -#ifdef GENESIS_WIPE + // pointer to transtable that this mask would use + transtbl = transtables + ((9 - m)<s.red) > 34) - { - if (wcolor.s.red < ecolor->s.red) - wcolor.s.red += 34; - else - wcolor.s.red -= 34; - } + if (reverse) + *w++ = fadecolormap[ ( m << 8 ) + *e++ ]; else - { - wcolor.s.red = ecolor->s.red; - - if (abs(wcolor.s.green - ecolor->s.green) > 34) - { - if (wcolor.s.green < ecolor->s.green) - wcolor.s.green += 34; - else - wcolor.s.green -= 34; - } - else - { - wcolor.s.green = ecolor->s.green; - - if (abs(wcolor.s.blue - ecolor->s.blue) > 34) - { - if (wcolor.s.blue < ecolor->s.blue) - wcolor.s.blue += 34; - else - wcolor.s.blue -= 34; - - } - else - wcolor.s.blue = ecolor->s.blue; - } - } + *w++ = fadecolormap[ ( m << 8 ) + *s++ ]; } - - *w++ = NearestColor(wcolor.s.red, wcolor.s.green, wcolor.s.blue); + else + *w++ = transtbl[ ( *e++ << 8 ) + *s++ ]; } relativepos += vid.width; } // END DRAWING LOOP -#else - // pointer to transtable that this mask would use - transtbl = transtables + ((9 - *mask)<= fademask->width) @@ -415,23 +364,36 @@ void F_WipeEndScreen(void) /** After setting up the screens you want to wipe, * calling this will do a 'typical' wipe. */ -void F_RunWipe(UINT8 wipetype, boolean drawMenu) +void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse) { #ifdef NOWIPE (void)wipetype; (void)drawMenu; + (void)colormap; + (void)reverse; #else tic_t nowtime; UINT8 wipeframe = 0; fademask_t *fmask; -#ifndef GENESIS_WIPE - pallen = 21; // 21 steps -#else - pallen = 10; // 10 steps -#endif + lumpnum_t clump; + lighttable_t *fcolor = NULL; - paldiv = FixedDiv(257< Date: Thu, 8 Aug 2019 01:43:50 -0400 Subject: [PATCH 3/9] Set new fades, fixed crash upon using non-colormapped fade --- src/f_wipe.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index 0abef4ca7..a1107e16f 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -51,26 +51,26 @@ UINT8 wipedefs[NUMWIPEDEFS] = { 99, // wipe_credits_intermediate (0) 0, // wipe_level_toblack - UINT8_MAX, // wipe_intermission_toblack + 0, // wipe_intermission_toblack 0, // wipe_voting_toblack, - UINT8_MAX, // wipe_continuing_toblack - 3, // wipe_titlescreen_toblack + 0, // wipe_continuing_toblack + 0, // wipe_titlescreen_toblack 0, // wipe_timeattack_toblack 99, // wipe_credits_toblack 0, // wipe_evaluation_toblack 0, // wipe_gameend_toblack UINT8_MAX, // wipe_intro_toblack (hardcoded) - UINT8_MAX, // wipe_cutscene_toblack (hardcoded) + 99, // wipe_cutscene_toblack (hardcoded) - UINT8_MAX, // wipe_specinter_toblack - UINT8_MAX, // wipe_multinter_toblack - 99, // wipe_speclevel_towhite + 0, // wipe_specinter_toblack + 0, // wipe_multinter_toblack + 0, // wipe_speclevel_towhite - 3, // wipe_level_final + UINT8_MAX, // wipe_level_final 0, // wipe_intermission_final 0, // wipe_voting_final 0, // wipe_continuing_final - 3, // wipe_titlescreen_final + 0, // wipe_titlescreen_final 0, // wipe_timeattack_final 99, // wipe_credits_final 0, // wipe_evaluation_final @@ -376,10 +376,11 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r UINT8 wipeframe = 0; fademask_t *fmask; - lumpnum_t clump; + lumpnum_t clump = LUMPERROR; lighttable_t *fcolor = NULL; - clump = W_GetNumForName(colormap); + if (colormap != NULL) + clump = W_GetNumForName(colormap); if (clump != LUMPERROR && wipetype != UINT8_MAX) { From aad0dbd076890afd1e7877268efab8020ee0dd39 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 10 Aug 2019 00:54:16 -0400 Subject: [PATCH 4/9] Encore invert fade --- src/d_main.c | 7 ---- src/dehacked.c | 32 ++++----------- src/f_finale.h | 12 ++---- src/f_wipe.c | 9 +---- src/p_setup.c | 63 ++++++++++++++++++------------ src/st_stuff.c | 11 ++---- src/v_video.c | 103 ++++++++++++++++++++++++++++++++++++++++++------- src/v_video.h | 3 +- 8 files changed, 147 insertions(+), 93 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a6bd48e0e..53d32f412 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -308,13 +308,6 @@ static void D_Display(void) wipedefindex = gamestate; // wipe_xxx_toblack if (gamestate == GS_TITLESCREEN && wipegamestate != GS_INTRO) wipedefindex = wipe_timeattack_toblack; - else if (gamestate == GS_INTERMISSION) - { - if (intertype == int_spec) // Special Stage - wipedefindex = wipe_specinter_toblack; - else //if (intertype != int_coop) // Multiplayer - wipedefindex = wipe_multinter_toblack; - } if (rendermode != render_none) { diff --git a/src/dehacked.c b/src/dehacked.c index be45f3f0f..62d99bfe1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3256,29 +3256,13 @@ static void readwipes(MYFILE *f) else if (fastcmp(pword, "FINAL")) wipeoffset = wipe_intermission_final; } - else if (fastncmp(word, "SPECINTER_", 10)) - { - pword = word + 10; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_specinter_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_specinter_final; - } else if (fastncmp(word, "VOTING_", 7)) { pword = word + 7; if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_specinter_toblack; + wipeoffset = wipe_voting_toblack; else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_specinter_final; - } - else if (fastncmp(word, "MULTINTER_", 10)) - { - pword = word + 10; - if (fastcmp(pword, "TOBLACK")) - wipeoffset = wipe_multinter_toblack; - else if (fastcmp(pword, "FINAL")) - wipeoffset = wipe_multinter_final; + wipeoffset = wipe_voting_final; } else if (fastncmp(word, "CONTINUING_", 11)) { @@ -3330,11 +3314,11 @@ static void readwipes(MYFILE *f) else if (fastcmp(pword, "FINAL")) wipeoffset = wipe_gameend_final; } - else if (fastncmp(word, "SPECLEVEL_", 10)) + else if (fastncmp(word, "ENCORE_", 7)) { - pword = word + 10; - if (fastcmp(pword, "TOWHITE")) - wipeoffset = wipe_speclevel_towhite; + pword = word + 7; + if (fastcmp(pword, "TOINVERT")) + wipeoffset = wipe_encore_toinvert; } if (wipeoffset < 0) @@ -3344,10 +3328,10 @@ static void readwipes(MYFILE *f) } if (value == UINT8_MAX - && (wipeoffset <= wipe_level_toblack || wipeoffset >= wipe_speclevel_towhite)) + && (wipeoffset <= wipe_level_toblack || wipeoffset >= wipe_encore_toinvert)) { // Cannot disable non-toblack wipes - // (or the level toblack wipe, or the special towhite wipe) + // (or the level toblack wipe, or the special encore wipe) deh_warning("Wipes: can't disable wipe of type '%s'", word); continue; } diff --git a/src/f_finale.h b/src/f_finale.h index a6fccf888..b7a7f3c76 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -80,6 +80,7 @@ enum { wipe_credits_intermediate, // makes a good 0 I guess. + // Gamestate wipes wipe_level_toblack, wipe_intermission_toblack, wipe_voting_toblack, @@ -92,11 +93,10 @@ enum wipe_intro_toblack, wipe_cutscene_toblack, - // custom intermissions - wipe_specinter_toblack, - wipe_multinter_toblack, - wipe_speclevel_towhite, + // Specialized wipes + wipe_encore_toinvert, + // "From black" wipes wipe_level_final, wipe_intermission_final, wipe_voting_final, @@ -109,10 +109,6 @@ enum wipe_intro_final, wipe_cutscene_final, - // custom intermissions - wipe_specinter_final, - wipe_multinter_final, - NUMWIPEDEFS, WIPEFINALSHIFT = wipe_level_final - wipe_level_toblack }; diff --git a/src/f_wipe.c b/src/f_wipe.c index a1107e16f..c7f0f8e04 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -62,9 +62,7 @@ UINT8 wipedefs[NUMWIPEDEFS] = { UINT8_MAX, // wipe_intro_toblack (hardcoded) 99, // wipe_cutscene_toblack (hardcoded) - 0, // wipe_specinter_toblack - 0, // wipe_multinter_toblack - 0, // wipe_speclevel_towhite + 72, // wipe_encore_toinvert UINT8_MAX, // wipe_level_final 0, // wipe_intermission_final @@ -76,10 +74,7 @@ UINT8 wipedefs[NUMWIPEDEFS] = { 0, // wipe_evaluation_final 0, // wipe_gameend_final 99, // wipe_intro_final (hardcoded) - 99, // wipe_cutscene_final (hardcoded) - - 0, // wipe_specinter_final - 0 // wipe_multinter_final + 99 // wipe_cutscene_final (hardcoded) }; //-------------------------------------------------------------------------- diff --git a/src/p_setup.c b/src/p_setup.c index 0edd899c6..1952404c9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2778,7 +2778,7 @@ boolean P_SetupLevel(boolean skipprecip) // use gamemap to get map number. // 99% of the things already did, so. // Map header should always be in place at this point - INT32 i, loadprecip = 1, ranspecialwipe = 0; + INT32 i, loadprecip = 1; INT32 loademblems = 1; INT32 fromnetsave = 0; boolean loadedbm = false; @@ -2857,36 +2857,50 @@ boolean P_SetupLevel(boolean skipprecip) S_StartSound(NULL, sfx_ruby1); + // Fade to an inverted screen, with a circle fade... F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 209); + V_EncoreInvertScreen(); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_speclevel_towhite], false, NULL, false); + F_RunWipe(wipedefs[wipe_encore_toinvert], false, NULL, false); + + // Hold on invert for extra effect. + // (This define might be useful for other areas of code? Not sure) +#define WAIT(timetowait) \ + locstarttime = nowtime = lastwipetic; \ + endtime = locstarttime + timetowait; \ + while (nowtime < endtime) \ + { \ + while (!((nowtime = I_GetTime()) - lastwipetic)) \ + I_Sleep(); \ + lastwipetic = nowtime; \ + if (moviemode) \ + M_SaveFrame(); \ + NetKeepAlive(); \ + } \ + + WAIT((3*TICRATE)/2); + S_StartSound(NULL, sfx_ruby2); + + // Then fade to a white screen F_WipeStartScreen(); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); - F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_final], false, "FADEMAP1", false); - locstarttime = nowtime = lastwipetic; - endtime = locstarttime + (3*TICRATE)/2; + F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP1", false); - // Hold on white for extra effect. - while (nowtime < endtime) - { - // wait loop - while (!((nowtime = I_GetTime()) - lastwipetic)) - I_Sleep(); - lastwipetic = nowtime; - if (moviemode) // make sure we save frames for the white hold too - M_SaveFrame(); + // THEN fade to a black screen. + F_WipeStartScreen(); - // Keep the network alive - NetKeepAlive(); - } + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + F_WipeEndScreen(); - ranspecialwipe = 1; + F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP0", false); + + // Wait a bit longer. + WAIT((3*TICRATE)/4); } // Make sure all sounds are stopped before Z_FreeTags. @@ -2897,17 +2911,18 @@ boolean P_SetupLevel(boolean skipprecip) // We should be fine starting it here. S_Start(); - levelfadecol = (encoremode && !ranspecialwipe ? 209 : 0); + levelfadecol = (encoremode ? 0 : 31); // Let's fade to white here // But only if we didn't do the encore startup wipe - if (rendermode != render_none && !ranspecialwipe && !demo.rewinding) + if (rendermode != render_none && !demo.rewinding) { F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); F_WipeEndScreen(); - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false, "FADEMAP1", false); // Fading to white + + F_RunWipe(wipedefs[wipe_level_toblack], false, ((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), false); } // Reset the palette now all fades have been done diff --git a/src/st_stuff.c b/src/st_stuff.c index e59846aed..caed81f3e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2134,12 +2134,7 @@ void ST_Drawer(void) ST_MayonakaStatic(); } - // Draw a white fade on level opening - if (timeinmap < 15) - { - if (timeinmap <= 5) - V_DrawFill(0,0,BASEVIDWIDTH,BASEVIDHEIGHT,0); // Pure white on first few frames, to hide SRB2's awful level load artifacts - else - V_DrawFadeScreen(0, 15-timeinmap); // Then gradually fade out from there - } + // Draw a fade on level opening + if (timeinmap < 16) + V_DrawCustomFadeScreen(((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), 32-(timeinmap*2)); // Then gradually fade out from there } diff --git a/src/v_video.c b/src/v_video.c index 1b1d03baa..297eae9c4 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1287,28 +1287,75 @@ void V_DrawVhsEffect(boolean rewind) void V_DrawFadeScreen(UINT16 color, UINT8 strength) { #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - { - HWR_FadeScreenMenuBack(color, strength); - return; - } + if (rendermode != render_soft && rendermode != render_none) + { + HWR_FadeScreenMenuBack(color, strength); + return; + } #endif - { - const UINT8 *fadetable = + { + const UINT8 *fadetable = (color > 0xFFF0) // Grab a specific colormap palette? ? R_GetTranslationColormap(color | 0xFFFF0000, strength, GTC_CACHE) : ((color & 0xFF00) // Color is not palette index? ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. : ((UINT8 *)transtables + ((9-strength)< Date: Sat, 10 Aug 2019 01:59:23 -0400 Subject: [PATCH 5/9] Encore wiggle --- src/d_main.c | 4 ++-- src/f_finale.c | 8 ++++---- src/f_finale.h | 2 +- src/f_wipe.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- src/p_setup.c | 8 ++++---- 5 files changed, 60 insertions(+), 12 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 53d32f412..1295722d0 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -318,7 +318,7 @@ static void D_Display(void) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", false); + F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", false, false); } if (gamestate != GS_LEVEL && rendermode != render_none) @@ -549,7 +549,7 @@ static void D_Display(void) if (rendermode != render_none) { F_WipeEndScreen(); - F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", true); + F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", true, false); } } diff --git a/src/f_finale.c b/src/f_finale.c index d45a9cfa9..7ea2e08a7 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -220,7 +220,7 @@ void F_StartIntro(void) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_final], false, "FADEMAP0", false); + F_RunWipe(wipedefs[wipe_level_final], false, "FADEMAP0", false, false); } if (introtoplay) @@ -306,7 +306,7 @@ void F_IntroDrawer(void) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(99, true, "FADEMAP0", false); + F_RunWipe(99, true, "FADEMAP0", false, false); } // Stay on black for a bit. =) @@ -1420,7 +1420,7 @@ void F_CutsceneDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, cutscenes[cutnum]->scene[scenenum].fadecolor); F_WipeEndScreen(); - F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeinid, true, NULL, false); + F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeinid, true, NULL, false, false); F_WipeStartScreen(); } @@ -1440,7 +1440,7 @@ void F_CutsceneDrawer(void) if (dofadenow && rendermode != render_none) { F_WipeEndScreen(); - F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeoutid, true, NULL, false); + F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeoutid, true, NULL, false, false); } V_DrawString(textxpos, textypos, 0, cutscene_disptext); diff --git a/src/f_finale.h b/src/f_finale.h index b7a7f3c76..d2231b8d0 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -74,7 +74,7 @@ extern INT32 lastwipetic; void F_WipeStartScreen(void); void F_WipeEndScreen(void); -void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse); +void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse, boolean encorewiggle); enum { diff --git a/src/f_wipe.c b/src/f_wipe.c index c7f0f8e04..e6d961c4d 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -356,10 +356,55 @@ void F_WipeEndScreen(void) #endif } +/** Wiggle post processor for encore wipes + */ +static void F_DoEncoreWiggle(UINT8 time) +{ + UINT8 *tmpscr = wipe_scr_start; + UINT8 *srcscr = wipe_scr; + angle_t disStart = (time * 128) & FINEMASK; + INT32 y, sine, newpix, scanline; + + for (y = 0; y < vid.height; y++) + { + sine = (FINESINE(disStart) * (time*12))>>FRACBITS; + scanline = y / vid.dupy; + if (scanline & 1) + sine = -sine; + newpix = abs(sine); + + if (sine < 0) + { + M_Memcpy(&tmpscr[(y*vid.width)+newpix], &srcscr[(y*vid.width)], vid.width-newpix); + + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+newpix] = srcscr[(y*vid.width)]; + newpix--; + } + } + else + { + M_Memcpy(&tmpscr[(y*vid.width)], &srcscr[(y*vid.width) + sine], vid.width-newpix); + + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width) + vid.width - newpix] = srcscr[(y*vid.width) + (vid.width-1)]; + newpix--; + } + } + + disStart += (time*8); //the offset into the displacement map, increment each game loop + disStart &= FINEMASK; //clip it to FINEMASK + } +} + /** After setting up the screens you want to wipe, * calling this will do a 'typical' wipe. */ -void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse) +void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse, boolean encorewiggle) { #ifdef NOWIPE (void)wipetype; @@ -415,6 +460,9 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r else #endif F_DoWipe(fmask, fcolor, reverse); + if (encorewiggle) + F_DoEncoreWiggle(wipeframe); + I_OsPolling(); I_UpdateNoBlit(); diff --git a/src/p_setup.c b/src/p_setup.c index 1952404c9..e40602039 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2863,7 +2863,7 @@ boolean P_SetupLevel(boolean skipprecip) V_EncoreInvertScreen(); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_encore_toinvert], false, NULL, false); + F_RunWipe(wipedefs[wipe_encore_toinvert], false, NULL, false, false); // Hold on invert for extra effect. // (This define might be useful for other areas of code? Not sure) @@ -2889,7 +2889,7 @@ boolean P_SetupLevel(boolean skipprecip) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP1", false); + F_RunWipe(99, false, "FADEMAP1", false, true); // wiggle the screen during this! // THEN fade to a black screen. F_WipeStartScreen(); @@ -2897,7 +2897,7 @@ boolean P_SetupLevel(boolean skipprecip) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP0", false); + F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false); // Wait a bit longer. WAIT((3*TICRATE)/4); @@ -2922,7 +2922,7 @@ boolean P_SetupLevel(boolean skipprecip) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_toblack], false, ((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), false); + F_RunWipe(wipedefs[wipe_level_toblack], false, ((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), false, false); } // Reset the palette now all fades have been done From 71f35c7f5b7cea1fbc86d8699eb52088bde02735 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 10 Aug 2019 02:07:18 -0400 Subject: [PATCH 6/9] Add encore_towhite --- src/dehacked.c | 2 ++ src/f_finale.h | 1 + src/f_wipe.c | 1 + src/p_setup.c | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 62d99bfe1..a1330343b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3319,6 +3319,8 @@ static void readwipes(MYFILE *f) pword = word + 7; if (fastcmp(pword, "TOINVERT")) wipeoffset = wipe_encore_toinvert; + else if (fastcmp(pword, "TOWHITE")) + wipeoffset = wipe_encore_towhite; } if (wipeoffset < 0) diff --git a/src/f_finale.h b/src/f_finale.h index d2231b8d0..d1efa6ce2 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -95,6 +95,7 @@ enum // Specialized wipes wipe_encore_toinvert, + wipe_encore_towhite, // "From black" wipes wipe_level_final, diff --git a/src/f_wipe.c b/src/f_wipe.c index e6d961c4d..c4064eec5 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -63,6 +63,7 @@ UINT8 wipedefs[NUMWIPEDEFS] = { 99, // wipe_cutscene_toblack (hardcoded) 72, // wipe_encore_toinvert + 99, // wipe_encore_towhite UINT8_MAX, // wipe_level_final 0, // wipe_intermission_final diff --git a/src/p_setup.c b/src/p_setup.c index e40602039..4452dfe4c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2889,7 +2889,7 @@ boolean P_SetupLevel(boolean skipprecip) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); F_WipeEndScreen(); - F_RunWipe(99, false, "FADEMAP1", false, true); // wiggle the screen during this! + F_RunWipe(wipedefs[wipe_encore_towhite], false, "FADEMAP1", false, true); // wiggle the screen during this! // THEN fade to a black screen. F_WipeStartScreen(); From 978c4f7e24bfdb326fa77c461cd7cf2dd16dc4b1 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 10 Aug 2019 09:50:42 -0400 Subject: [PATCH 7/9] Minor fixes --- src/f_finale.c | 2 +- src/f_wipe.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 7ea2e08a7..c620c3ffd 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -220,7 +220,7 @@ void F_StartIntro(void) F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_final], false, "FADEMAP0", false, false); + F_RunWipe(wipedefs[wipe_intro_toblack], false, "FADEMAP0", false, false); } if (introtoplay) diff --git a/src/f_wipe.c b/src/f_wipe.c index c4064eec5..c50afcd21 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -412,6 +412,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r (void)drawMenu; (void)colormap; (void)reverse; + (void)encorewiggle; #else tic_t nowtime; UINT8 wipeframe = 0; @@ -462,7 +463,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r #endif F_DoWipe(fmask, fcolor, reverse); if (encorewiggle) - F_DoEncoreWiggle(wipeframe); + F_DoEncoreWiggle(wipeframe); // Can't think of a better way to run this on fades, unfortunately. I_OsPolling(); I_UpdateNoBlit(); From 780202668b0ff1f515fe0e8d6a2ae9f6707f602f Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sun, 11 Aug 2019 15:35:38 -0400 Subject: [PATCH 8/9] Only run Encore wiggle in software --- src/f_wipe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/f_wipe.c b/src/f_wipe.c index c50afcd21..319d2b2f4 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -462,8 +462,12 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r else #endif F_DoWipe(fmask, fcolor, reverse); + +#ifndef HWRENDER if (encorewiggle) F_DoEncoreWiggle(wipeframe); // Can't think of a better way to run this on fades, unfortunately. +#endif + I_OsPolling(); I_UpdateNoBlit(); From 7f6d825809c561cc3bf73f887299742eff747d2f Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Thu, 3 Oct 2019 01:10:10 -0400 Subject: [PATCH 9/9] Remove unused GENESIS_WIPE define --- src/f_wipe.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index 319d2b2f4..12887acf5 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -12,8 +12,6 @@ /// \file f_wipe.c /// \brief SRB2 2.1 custom fade mask "wipe" behavior. -#define GENESIS_WIPE // Sal: experimental Genesis-style colorful wipes - #include "f_finale.h" #include "i_video.h" #include "v_video.h"