Merge branch 'wipes2' into 'master'

Wipe styles cleanup

See merge request STJr/SRB2!525
This commit is contained in:
James R 2019-12-24 14:47:14 -05:00
commit 75a5142aad
5 changed files with 227 additions and 61 deletions

View File

@ -274,7 +274,10 @@ static void D_Display(void)
&& wipetypepre != UINT8_MAX) && wipetypepre != UINT8_MAX)
{ {
F_WipeStartScreen(); F_WipeStartScreen();
F_WipeColorFill(31); // Check for Mega Genesis fade
wipestyleflags = WSF_FADEOUT;
if (F_TryColormapFade(31))
wipetypepost = -1; // Don't run the fade below this one
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(wipetypepre, gamestate != GS_TIMEATTACK && gamestate != GS_TITLESCREEN); F_RunWipe(wipetypepre, gamestate != GS_TIMEATTACK && gamestate != GS_TITLESCREEN);
} }
@ -488,6 +491,7 @@ static void D_Display(void)
if (rendermode != render_none) if (rendermode != render_none)
{ {
F_WipeEndScreen(); F_WipeEndScreen();
// Funny. // Funny.
if (WipeStageTitle && st_overlay) if (WipeStageTitle && st_overlay)
{ {
@ -497,6 +501,14 @@ static void D_Display(void)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
F_WipeStartScreen(); F_WipeStartScreen();
} }
// Check for Mega Genesis fade
if (F_ShouldColormapFade())
{
wipestyleflags |= WSF_FADEIN;
wipestyleflags &= ~WSF_FADEOUT;
}
F_RunWipe(wipetypepost, gamestate != GS_TIMEATTACK && gamestate != GS_TITLESCREEN); F_RunWipe(wipetypepost, gamestate != GS_TIMEATTACK && gamestate != GS_TITLESCREEN);
} }

View File

@ -917,8 +917,9 @@ void F_IntroDrawer(void)
{ {
if (rendermode != render_none) if (rendermode != render_none)
{ {
wipestyleflags = WSF_FADEOUT;
F_WipeStartScreen(); F_WipeStartScreen();
F_WipeColorFill(31); F_TryColormapFade(31);
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(99,true); F_RunWipe(99,true);
} }
@ -927,12 +928,11 @@ void F_IntroDrawer(void)
} }
else if (intro_scenenum == 10) else if (intro_scenenum == 10)
{ {
// The only fade to white in the entire damn game.
// (not true)
if (rendermode != render_none) if (rendermode != render_none)
{ {
wipestyleflags = (WSF_FADEOUT|WSF_TOWHITE);
F_WipeStartScreen(); F_WipeStartScreen();
F_WipeColorFill(0); F_TryColormapFade(0);
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(99,true); F_RunWipe(99,true);
} }
@ -941,8 +941,9 @@ void F_IntroDrawer(void)
{ {
if (rendermode != render_none) if (rendermode != render_none)
{ {
wipestyleflags = WSF_FADEOUT;
F_WipeStartScreen(); F_WipeStartScreen();
F_WipeColorFill(31); F_TryColormapFade(31);
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(99,true); F_RunWipe(99,true);
} }
@ -977,6 +978,7 @@ void F_IntroDrawer(void)
F_WipeStartScreen(); F_WipeStartScreen();
wipegamestate = -1; wipegamestate = -1;
wipestyleflags = WSF_CROSSFADE;
animtimer = stoptimer = 0; animtimer = stoptimer = 0;
} }
@ -3596,6 +3598,8 @@ void F_StartContinue(void)
return; return;
} }
wipestyleflags = WSF_FADEOUT;
F_TryColormapFade(31);
G_SetGamestate(GS_CONTINUING); G_SetGamestate(GS_CONTINUING);
gameaction = ga_nothing; gameaction = ga_nothing;

View File

@ -146,7 +146,7 @@ extern boolean WipeStageTitle;
typedef enum typedef enum
{ {
WIPESTYLE_NORMAL, WIPESTYLE_NORMAL,
WIPESTYLE_LEVEL WIPESTYLE_COLORMAP
} wipestyle_t; } wipestyle_t;
extern wipestyle_t wipestyle; extern wipestyle_t wipestyle;
@ -159,6 +159,11 @@ typedef enum
} wipestyleflags_t; } wipestyleflags_t;
extern wipestyleflags_t wipestyleflags; extern wipestyleflags_t wipestyleflags;
// Even my function names are borderline
boolean F_ShouldColormapFade(void);
boolean F_TryColormapFade(UINT8 wipecolor);
void F_DecideWipeStyle(void);
#define FADECOLORMAPDIV 8 #define FADECOLORMAPDIV 8
#define FADECOLORMAPROWS (256/FADECOLORMAPDIV) #define FADECOLORMAPROWS (256/FADECOLORMAPDIV)

View File

@ -56,7 +56,7 @@ UINT8 wipedefs[NUMWIPEDEFS] = {
0, // wipe_level_toblack 0, // wipe_level_toblack
UINT8_MAX, // wipe_intermission_toblack UINT8_MAX, // wipe_intermission_toblack
UINT8_MAX, // wipe_continuing_toblack 0, // wipe_continuing_toblack
0, // wipe_titlescreen_toblack 0, // wipe_titlescreen_toblack
0, // wipe_timeattack_toblack 0, // wipe_timeattack_toblack
99, // wipe_credits_toblack 99, // wipe_credits_toblack
@ -161,7 +161,7 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
{ {
// Determine pixel to use from fademask // Determine pixel to use from fademask
pcolor = &pMasterPalette[*lump++]; pcolor = &pMasterPalette[*lump++];
if (wipestyle == WIPESTYLE_LEVEL) if (wipestyle == WIPESTYLE_COLORMAP)
*mask++ = pcolor->s.red / FADECOLORMAPDIV; *mask++ = pcolor->s.red / FADECOLORMAPDIV;
else else
*mask++ = FixedDiv((pcolor->s.red+1)<<FRACBITS, paldiv)>>FRACBITS; *mask++ = FixedDiv((pcolor->s.red+1)<<FRACBITS, paldiv)>>FRACBITS;
@ -191,7 +191,7 @@ void F_WipeStageTitle(void)
{ {
// draw level title // draw level title
if ((WipeStageTitle && st_overlay) if ((WipeStageTitle && st_overlay)
&& (wipestyle == WIPESTYLE_LEVEL) && (wipestyle == WIPESTYLE_COLORMAP)
&& !(mapheaderinfo[gamemap-1]->levelflags & LF_NOTITLECARD) && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOTITLECARD)
&& *mapheaderinfo[gamemap-1]->lvlttl != '\0') && *mapheaderinfo[gamemap-1]->lvlttl != '\0')
{ {
@ -282,7 +282,7 @@ static void F_DoWipe(fademask_t *fademask)
relativepos += vid.width; relativepos += vid.width;
} }
} }
else if (*mask >= ((wipestyle == WIPESTYLE_LEVEL) ? FADECOLORMAPROWS : 10)) else if (*mask >= 10)
{ {
// shortcut - memcpy target to work // shortcut - memcpy target to work
while (draw_linestogo--) while (draw_linestogo--)
@ -293,25 +293,8 @@ static void F_DoWipe(fademask_t *fademask)
} }
else else
{ {
if (wipestyle == WIPESTYLE_LEVEL) // pointer to transtable that this mask would use
{ transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT);
int nmask;
UINT8 *fade = fadecolormap;
if (wipestyleflags & WSF_TOWHITE)
fade = fadecolormap + (FADECOLORMAPROWS * 256);
nmask = *mask;
if (wipestyleflags & WSF_FADEIN)
nmask = (FADECOLORMAPROWS-1) - nmask;
transtbl = fade + (nmask * 256);
}
else
{
// pointer to transtable that this mask would use
transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT);
}
// DRAWING LOOP // DRAWING LOOP
while (draw_linestogo--) while (draw_linestogo--)
@ -321,16 +304,113 @@ static void F_DoWipe(fademask_t *fademask)
e = e_base + relativepos; e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart; draw_rowstogo = draw_rowend - draw_rowstart;
if (wipestyle == WIPESTYLE_LEVEL) while (draw_rowstogo--)
{ *w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
while (draw_rowstogo--)
*w++ = transtbl[*e++]; relativepos += vid.width;
} }
else // END DRAWING LOOP
{ }
while (draw_rowstogo--)
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ]; if (++maskx >= fademask->width)
} ++masky, maskx = 0;
} while (++mask < maskend);
free(scrxpos);
free(scrypos);
}
}
static void F_DoColormapWipe(fademask_t *fademask, UINT8 *colormap)
{
// Lactozilla: F_DoWipe for WIPESTYLE_COLORMAP
{
// wipe screen, start, end
UINT8 *w = wipe_scr;
const UINT8 *s = wipe_scr_start;
const UINT8 *e = wipe_scr_end;
// first pixel for each screen
UINT8 *w_base = w;
const UINT8 *s_base = s;
const UINT8 *e_base = e;
// mask data, end
UINT8 *transtbl;
const UINT8 *mask = fademask->mask;
const UINT8 *maskend = mask + fademask->size;
// rectangle draw hints
UINT32 draw_linestart, draw_rowstart;
UINT32 draw_lineend, draw_rowend;
UINT32 draw_linestogo, draw_rowstogo;
// rectangle coordinates, etc.
UINT16* scrxpos = (UINT16*)malloc((fademask->width + 1) * sizeof(UINT16));
UINT16* scrypos = (UINT16*)malloc((fademask->height + 1) * sizeof(UINT16));
UINT16 maskx, masky;
UINT32 relativepos;
// ---
// Screw it, we do the fixed point math ourselves up front.
scrxpos[0] = 0;
for (relativepos = 0, maskx = 1; maskx < fademask->width; ++maskx)
scrxpos[maskx] = (relativepos += fademask->xscale)>>FRACBITS;
scrxpos[fademask->width] = vid.width;
scrypos[0] = 0;
for (relativepos = 0, masky = 1; masky < fademask->height; ++masky)
scrypos[masky] = (relativepos += fademask->yscale)>>FRACBITS;
scrypos[fademask->height] = vid.height;
// ---
maskx = masky = 0;
do
{
draw_rowstart = scrxpos[maskx];
draw_rowend = scrxpos[maskx + 1];
draw_linestart = scrypos[masky];
draw_lineend = scrypos[masky + 1];
relativepos = (draw_linestart * vid.width) + draw_rowstart;
draw_linestogo = draw_lineend - draw_linestart;
if (*mask == 0)
{
// shortcut - memcpy source to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
}
}
else if (*mask >= FADECOLORMAPROWS)
{
// shortcut - memcpy target to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
}
}
else
{
int nmask = *mask;
if (wipestyleflags & WSF_FADEIN)
nmask = (FADECOLORMAPROWS-1) - nmask;
transtbl = colormap + (nmask * 256);
// DRAWING LOOP
while (draw_linestogo--)
{
w = w_base + relativepos;
s = s_base + relativepos;
e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart;
while (draw_rowstogo--)
*w++ = transtbl[*e++];
relativepos += vid.width; relativepos += vid.width;
} }
@ -382,6 +462,62 @@ void F_WipeEndScreen(void)
#endif #endif
} }
/** Verifies every condition for a colormapped fade.
*/
boolean F_ShouldColormapFade(void)
{
if ((wipestyleflags & (WSF_FADEIN|WSF_FADEOUT)) // only if one of those wipestyleflags are actually set
&& !(wipestyleflags & WSF_CROSSFADE)) // and if not crossfading
{
// World
return (gamestate == GS_LEVEL
|| gamestate == GS_TITLESCREEN
// Finales
|| gamestate == GS_CONTINUING
|| gamestate == GS_CREDITS
|| gamestate == GS_EVALUATION
|| gamestate == GS_INTRO
|| gamestate == GS_ENDING
// Menus
|| gamestate == GS_TIMEATTACK);
}
return false;
}
/** Decides what wipe style to use.
*/
void F_DecideWipeStyle(void)
{
// Set default wipe style
wipestyle = WIPESTYLE_NORMAL;
// Check for colormap wipe style
if (F_ShouldColormapFade())
wipestyle = WIPESTYLE_COLORMAP;
}
/** Attempt to run a colormap fade,
provided all the conditionals were properly met.
Returns true if so.
I demand you call F_RunWipe after this function.
*/
boolean F_TryColormapFade(UINT8 wipecolor)
{
if (F_ShouldColormapFade())
{
#ifdef HWRENDER
if (rendermode == render_opengl)
F_WipeColorFill(wipecolor);
#endif
return true;
}
else
{
F_WipeColorFill(wipecolor);
return false;
}
}
/** After setting up the screens you want to wipe, /** After setting up the screens you want to wipe,
* calling this will do a 'typical' wipe. * calling this will do a 'typical' wipe.
*/ */
@ -399,18 +535,10 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
paldiv = FixedDiv(257<<FRACBITS, 11<<FRACBITS); paldiv = FixedDiv(257<<FRACBITS, 11<<FRACBITS);
// Init the wipe // Init the wipe
F_DecideWipeStyle();
WipeInAction = true; WipeInAction = true;
wipe_scr = screens[0]; wipe_scr = screens[0];
// don't know where else to put this.
// this any good?
if ((gamestate == GS_LEVEL || gamestate == GS_TITLESCREEN)
&& (wipestyleflags & (WSF_FADEIN|WSF_FADEOUT)) // only if one of those wipestyleflags are actually set
&& !(wipestyleflags & WSF_CROSSFADE)) // and if not crossfading
wipestyle = WIPESTYLE_LEVEL;
else
wipestyle = WIPESTYLE_NORMAL;
// lastwipetic should either be 0 or the tic we last wiped // lastwipetic should either be 0 or the tic we last wiped
// on for fade-to-black // on for fade-to-black
for (;;) for (;;)
@ -425,21 +553,39 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
I_Sleep(); I_Sleep();
lastwipetic = nowtime; lastwipetic = nowtime;
#ifdef HWRENDER // Wipe styles
if (rendermode == render_opengl) if (wipestyle == WIPESTYLE_COLORMAP)
{ {
// send in the wipe type and wipe frame because we need to cache the graphic #ifdef HWRENDER
if (wipestyle == WIPESTYLE_LEVEL) if (rendermode == render_opengl)
{
// send in the wipe type and wipe frame because we need to cache the graphic
HWR_DoTintedWipe(wipetype, wipeframe-1); HWR_DoTintedWipe(wipetype, wipeframe-1);
}
else else
HWR_DoWipe(wipetype, wipeframe-1); #endif
{
UINT8 *colormap = fadecolormap;
if (wipestyleflags & WSF_TOWHITE)
colormap += (FADECOLORMAPROWS * 256);
F_DoColormapWipe(fmask, colormap);
}
// Draw the title card above the wipe
F_WipeStageTitle();
} }
else else
{
#ifdef HWRENDER
if (rendermode == render_opengl)
{
// send in the wipe type and wipe frame because we need to cache the graphic
HWR_DoWipe(wipetype, wipeframe-1);
}
else
#endif #endif
F_DoWipe(fmask); F_DoWipe(fmask);
}
if (wipestyle == WIPESTYLE_LEVEL)
F_WipeStageTitle();
I_OsPolling(); I_OsPolling();
I_UpdateNoBlit(); I_UpdateNoBlit();

View File

@ -1883,9 +1883,6 @@ void G_DoLoadLevel(boolean resetplayer)
// //
void G_StartTitleCard(void) void G_StartTitleCard(void)
{ {
wipestyleflags |= WSF_FADEIN;
wipestyleflags &= ~WSF_FADEOUT;
// The title card has been disabled for this map. // The title card has been disabled for this map.
// Oh well. // Oh well.
if (mapheaderinfo[gamemap-1]->levelflags & LF_NOTITLECARD) if (mapheaderinfo[gamemap-1]->levelflags & LF_NOTITLECARD)
@ -1929,6 +1926,8 @@ void G_PreLevelTitleCard(void)
if (takescreenshot) // Only take screenshots after drawing. if (takescreenshot) // Only take screenshots after drawing.
M_DoScreenShot(); M_DoScreenShot();
} }
if (!cv_showhud.value)
wipestyleflags = WSF_CROSSFADE;
} }
INT32 pausedelay = 0; INT32 pausedelay = 0;