Encore invert fade

This commit is contained in:
TehRealSalt 2019-08-10 00:54:16 -04:00
parent 274dc434ff
commit aad0dbd076
8 changed files with 147 additions and 93 deletions

View file

@ -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)
{

View file

@ -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;
}

View file

@ -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
};

View file

@ -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)
};
//--------------------------------------------------------------------------

View file

@ -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

View file

@ -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
}

View file

@ -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)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
UINT8 *buf = screens[0];
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
UINT8 *buf = screens[0];
// heavily simplified -- we don't need to know x or y
// position when we're doing a full screen fade
for (; buf < deststop; ++buf)
*buf = fadetable[*buf];
}
// heavily simplified -- we don't need to know x or y
// position when we're doing a full screen fade
for (; buf < deststop; ++buf)
*buf = fadetable[*buf];
}
}
//
// Fade the screen buffer, using a custom COLORMAP lump.
// Split from V_DrawFadeScreen, because that function has
// WAY too many options piled on top of it as is. :V
//
void V_DrawCustomFadeScreen(const char *lump, UINT8 strength)
{
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
{
//HWR_DrawCustomFadeScreen(color, strength);
return;
}
#endif
{
lumpnum_t lumpnum = LUMPERROR;
lighttable_t *clm = NULL;
if (lump != NULL)
lumpnum = W_GetNumForName(lump);
else
return;
if (lumpnum != LUMPERROR)
{
clm = Z_MallocAlign((256 * 32), PU_STATIC, NULL, 8);
W_ReadLump(lumpnum, clm);
if (clm != NULL)
{
const UINT8 *fadetable = ((UINT8 *)clm + strength*256);
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
UINT8 *buf = screens[0];
// heavily simplified -- we don't need to know x or y
// position when we're doing a full screen fade
for (; buf < deststop; ++buf)
*buf = fadetable[*buf];
Z_Free(clm);
clm = NULL;
}
}
}
}
// Simple translucency with one color, over a set number of lines starting from the top.
@ -1332,6 +1379,34 @@ void V_DrawFadeConsBack(INT32 plines)
*buf = consolebgmap[*buf];
}
//
// Invert the entire screen, for Encore fades
//
void V_EncoreInvertScreen(void)
{
#ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none)
{
//HWR_EncoreInvertScreen();
return;
}
#endif
{
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
UINT8 *buf = screens[0];
for (; buf < deststop; ++buf)
{
*buf = NearestColor(
256 - pLocalPalette[*buf].s.red,
256 - pLocalPalette[*buf].s.green,
256 - pLocalPalette[*buf].s.blue
);
}
}
}
// Gets string colormap, used for 0x80 color codes
//
UINT8 *V_GetStringColormap(INT32 colorflags)

View file

@ -158,8 +158,9 @@ void V_DrawVhsEffect(boolean rewind);
// fade down the screen buffer before drawing the menu over
void V_DrawFadeScreen(UINT16 color, UINT8 strength);
void V_DrawCustomFadeScreen(const char *lump, UINT8 strength);
void V_DrawFadeConsBack(INT32 plines);
void V_EncoreInvertScreen(void);
// draw a single character
void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed);