Slap colormap fades everywhere

This commit is contained in:
Jaime Passos 2019-12-04 19:25:39 -03:00
parent 82cbd953fb
commit 6adb957f0f
9 changed files with 100 additions and 35 deletions

View File

@ -274,7 +274,10 @@ static void D_Display(void)
&& wipetypepre != UINT8_MAX)
{
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_RunWipe(wipetypepre, gamestate != GS_TIMEATTACK && gamestate != GS_TITLESCREEN);
}
@ -488,15 +491,24 @@ static void D_Display(void)
if (rendermode != render_none)
{
F_WipeEndScreen();
// Funny.
if (WipeStageTitle && st_overlay)
{
lt_ticker--;
lt_lasttic = lt_ticker;
ST_preLevelTitleCardDrawer(0, false);
ST_preLevelTitleCardDrawer(false);
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
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);
}

View File

@ -910,8 +910,9 @@ void F_IntroDrawer(void)
{
if (rendermode != render_none)
{
wipestyleflags = WSF_FADEOUT;
F_WipeStartScreen();
F_WipeColorFill(31);
F_TryColormapFade(31);
F_WipeEndScreen();
F_RunWipe(99,true);
}
@ -920,12 +921,11 @@ void F_IntroDrawer(void)
}
else if (intro_scenenum == 10)
{
// The only fade to white in the entire damn game.
// (not true)
if (rendermode != render_none)
{
wipestyleflags = (WSF_FADEOUT|WSF_TOWHITE);
F_WipeStartScreen();
F_WipeColorFill(0);
F_TryColormapFade(0);
F_WipeEndScreen();
F_RunWipe(99,true);
}
@ -934,8 +934,9 @@ void F_IntroDrawer(void)
{
if (rendermode != render_none)
{
wipestyleflags = WSF_FADEOUT;
F_WipeStartScreen();
F_WipeColorFill(31);
F_TryColormapFade(31);
F_WipeEndScreen();
F_RunWipe(99,true);
}
@ -970,6 +971,7 @@ void F_IntroDrawer(void)
F_WipeStartScreen();
wipegamestate = -1;
wipestyleflags = WSF_CROSSFADE;
animtimer = stoptimer = 0;
}

View File

@ -146,7 +146,7 @@ extern boolean WipeStageTitle;
typedef enum
{
WIPESTYLE_NORMAL,
WIPESTYLE_LEVEL
WIPESTYLE_COLORMAP
} wipestyle_t;
extern wipestyle_t wipestyle;
@ -159,6 +159,11 @@ typedef enum
} wipestyleflags_t;
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 FADECOLORMAPROWS (256/FADECOLORMAPDIV)

View File

@ -161,7 +161,7 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
{
// Determine pixel to use from fademask
pcolor = &pMasterPalette[*lump++];
if (wipestyle == WIPESTYLE_LEVEL)
if (wipestyle == WIPESTYLE_COLORMAP)
*mask++ = pcolor->s.red / FADECOLORMAPDIV;
else
*mask++ = FixedDiv((pcolor->s.red+1)<<FRACBITS, paldiv)>>FRACBITS;
@ -191,7 +191,7 @@ void F_WipeStageTitle(void)
{
// draw level title
if ((WipeStageTitle && st_overlay)
&& (wipestyle == WIPESTYLE_LEVEL)
&& (wipestyle == WIPESTYLE_COLORMAP)
&& !(mapheaderinfo[gamemap-1]->levelflags & LF_NOTITLECARD)
&& *mapheaderinfo[gamemap-1]->lvlttl != '\0')
{
@ -282,7 +282,7 @@ static void F_DoWipe(fademask_t *fademask)
relativepos += vid.width;
}
}
else if (*mask >= ((wipestyle == WIPESTYLE_LEVEL) ? FADECOLORMAPROWS : 10))
else if (*mask >= ((wipestyle == WIPESTYLE_COLORMAP) ? FADECOLORMAPROWS : 10))
{
// shortcut - memcpy target to work
while (draw_linestogo--)
@ -293,7 +293,7 @@ static void F_DoWipe(fademask_t *fademask)
}
else
{
if (wipestyle == WIPESTYLE_LEVEL)
if (wipestyle == WIPESTYLE_COLORMAP)
{
int nmask;
UINT8 *fade = fadecolormap;
@ -321,7 +321,7 @@ static void F_DoWipe(fademask_t *fademask)
e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart;
if (wipestyle == WIPESTYLE_LEVEL)
if (wipestyle == WIPESTYLE_COLORMAP)
{
while (draw_rowstogo--)
*w++ = transtbl[*e++];
@ -382,6 +382,62 @@ void F_WipeEndScreen(void)
#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,
* calling this will do a 'typical' wipe.
*/
@ -399,18 +455,10 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
paldiv = FixedDiv(257<<FRACBITS, 11<<FRACBITS);
// Init the wipe
F_DecideWipeStyle();
WipeInAction = true;
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
// on for fade-to-black
for (;;)
@ -429,7 +477,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
if (rendermode == render_opengl)
{
// send in the wipe type and wipe frame because we need to cache the graphic
if (wipestyle == WIPESTYLE_LEVEL)
if (wipestyle == WIPESTYLE_COLORMAP)
HWR_DoTintedWipe(wipetype, wipeframe-1);
else
HWR_DoWipe(wipetype, wipeframe-1);
@ -438,7 +486,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
#endif
F_DoWipe(fmask);
if (wipestyle == WIPESTYLE_LEVEL)
if (wipestyle == WIPESTYLE_COLORMAP)
F_WipeStageTitle();
I_OsPolling();

View File

@ -1804,9 +1804,6 @@ void G_DoLoadLevel(boolean resetplayer)
//
void G_StartTitleCard(void)
{
wipestyleflags |= WSF_FADEIN;
wipestyleflags &= ~WSF_FADEOUT;
// The title card has been disabled for this map.
// Oh well.
if (mapheaderinfo[gamemap-1]->levelflags & LF_NOTITLECARD)
@ -1828,7 +1825,7 @@ void G_StartTitleCard(void)
//
// Run the title card before fading in to the level.
//
void G_PreLevelTitleCard(tic_t ticker, boolean update)
void G_PreLevelTitleCard(void)
{
tic_t starttime = I_GetTime();
tic_t endtime = starttime + (PRELEVELTIME*NEWTICRATERATIO);
@ -1842,13 +1839,15 @@ void G_PreLevelTitleCard(tic_t ticker, boolean update)
lasttime = nowtime;
ST_runTitleCard();
ST_preLevelTitleCardDrawer(ticker, update);
ST_preLevelTitleCardDrawer(true);
if (moviemode)
M_SaveFrame();
if (takescreenshot) // Only take screenshots after drawing.
M_DoScreenShot();
}
if (!st_overlay)
wipestyleflags = WSF_CROSSFADE;
}
INT32 pausedelay = 0;

View File

@ -141,7 +141,7 @@ void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar,
boolean SSSG, boolean FLS);
void G_DoLoadLevel(boolean resetplayer);
void G_StartTitleCard(void);
void G_PreLevelTitleCard(tic_t ticker, boolean update);
void G_PreLevelTitleCard(void);
void G_DeferedPlayDemo(const char *demo);
// Can be called by the startup code or M_Responder, calls P_SetupLevel.

View File

@ -3265,7 +3265,7 @@ boolean P_SetupLevel(boolean skipprecip)
// If so...
if ((!(mapheaderinfo[gamemap-1]->levelflags & LF_NOTITLECARD)) && (*mapheaderinfo[gamemap-1]->lvlttl != '\0'))
G_PreLevelTitleCard(lt_ticker, true);
G_PreLevelTitleCard();
return true;
}

View File

@ -1348,11 +1348,10 @@ luahook:
//
// Drawer for G_PreLevelTitleCard.
//
void ST_preLevelTitleCardDrawer(tic_t ticker, boolean update)
void ST_preLevelTitleCardDrawer(boolean update)
{
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
if (ticker < PRELEVELTIME-1)
ST_drawWipeTitleCard();
ST_drawWipeTitleCard();
I_OsPolling();
I_UpdateNoBlit();

View File

@ -52,7 +52,7 @@ void ST_startTitleCard(void);
void ST_runTitleCard(void);
void ST_drawTitleCard(void);
void ST_preDrawTitleCard(void);
void ST_preLevelTitleCardDrawer(tic_t ticker, boolean update);
void ST_preLevelTitleCardDrawer(boolean update);
void ST_drawWipeTitleCard(void);
extern tic_t lt_ticker, lt_lasttic;