revert fades

This commit is contained in:
NepDisk 2024-10-14 17:54:47 -04:00
parent 50995a0004
commit e0149fea3a
5 changed files with 56 additions and 193 deletions

View file

@ -323,7 +323,7 @@ static void D_Display(void)
if (gamestate == GS_TITLESCREEN && wipegamestate != GS_INTRO)
wipedefindex = wipe_timeattack_toblack;
if (wipetypepre < 0 || !F_WipeExists(wipetypepre))
if (wipetypepre < 0)
wipetypepre = wipedefs[wipedefindex];
if (rendermode != render_none)
@ -335,7 +335,7 @@ static void D_Display(void)
F_WipeStartScreen();
F_WipeColorFill(31);
F_WipeEndScreen();
F_RunWipe(wipetypepre, gamestate != GS_TIMEATTACK, "FADEMAP0", false, false);
F_RunWipe(wipetypepre, gamestate != GS_TIMEATTACK);
}
if (gamestate != GS_LEVEL && rendermode != render_none)
@ -348,7 +348,7 @@ static void D_Display(void)
}
else //dedicated servers
{
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", false, false);
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK);
wipegamestate = gamestate;
}
@ -616,14 +616,14 @@ static void D_Display(void)
// and input during wipe tends to mess things up
wipedefindex += WIPEFINALSHIFT;
if (wipetypepost < 0 || !F_WipeExists(wipetypepost))
if (wipetypepost < 0)
wipetypepost = wipedefs[wipedefindex];
if (rendermode != render_none)
{
F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK && gamestate != GS_TITLESCREEN, "FADEMAP0", true, false);
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK && gamestate != GS_TITLESCREEN);
}
// reset counters so timedemo doesn't count the wipe duration

View file

@ -303,7 +303,7 @@ void F_StartIntro(void)
F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
F_WipeEndScreen();
F_RunWipe(wipedefs[wipe_intro_toblack], false, "FADEMAP0", false, false);
F_RunWipe(wipedefs[wipe_intro_toblack], false);
}
S_StopMusic();
@ -399,7 +399,7 @@ void F_IntroTicker(void)
F_WipeStartScreen();
F_WipeColorFill(31);
F_WipeEndScreen();
F_RunWipe(99, true, "FADEMAP0", false, false);
F_RunWipe(99, true);
}
// Stay on black for a bit. =)
@ -2403,7 +2403,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, false);
F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeinid, true);
F_WipeStartScreen();
}
@ -2423,7 +2423,7 @@ void F_CutsceneDrawer(void)
if (dofadenow && rendermode != render_none)
{
F_WipeEndScreen();
F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeoutid, true, NULL, false, false);
F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeoutid, true);
}
V_DrawString(textxpos, textypos, V_ALLOWLOWERCASE, cutscene_disptext);

View file

@ -146,11 +146,9 @@ extern INT32 lastwipetic;
void F_WipeStartScreen(void);
void F_WipeEndScreen(void);
void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse, boolean encorewiggle);
void F_RunWipe(UINT8 wipetype, boolean drawMenu);
void F_WipeStageTitle(void);
#define F_WipeColorFill(c) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, c)
tic_t F_GetWipeLength(UINT8 wipetype);
boolean F_WipeExists(UINT8 wipetype);
enum
{

View file

@ -191,7 +191,7 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
*
* \param fademask pixels to change
*/
static void F_DoWipe(fademask_t *fademask, lighttable_t *fadecolormap, boolean reverse)
static void F_DoWipe(fademask_t *fademask)
{
// Software mask wipe -- optimized; though it might not look like it!
// Okay, to save you wondering *how* this is more optimized than the simpler
@ -209,10 +209,6 @@ static void F_DoWipe(fademask_t *fademask, lighttable_t *fadecolormap, boolean r
// 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;
@ -256,8 +252,6 @@ static void F_DoWipe(fademask_t *fademask, lighttable_t *fadecolormap, boolean r
maskx = masky = 0;
do
{
UINT8 m = *mask;
draw_rowstart = scrxpos[maskx];
draw_rowend = scrxpos[maskx + 1];
draw_linestart = scrypos[masky];
@ -266,31 +260,28 @@ static void F_DoWipe(fademask_t *fademask, lighttable_t *fadecolormap, boolean r
relativepos = (draw_linestart * vid.width) + draw_rowstart;
draw_linestogo = draw_lineend - draw_linestart;
if (reverse)
m = ((pallen-1) - m);
if (m == 0)
if (*mask == 0)
{
// shortcut - memcpy source to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, (reverse ? e_base : s_base)+relativepos, draw_rowend-draw_rowstart);
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
}
}
else if (m >= (pallen-1))
else if (*mask == 10)
{
// shortcut - memcpy target to work
while (draw_linestogo--)
{
M_Memcpy(w_base+relativepos, (reverse ? s_base : e_base)+relativepos, draw_rowend-draw_rowstart);
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width;
}
}
else
{
// pointer to transtable that this mask would use
transtbl = transtables + ((9 - m)<<FF_TRANSSHIFT);
transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT);
// DRAWING LOOP
while (draw_linestogo--)
@ -300,25 +291,8 @@ static void F_DoWipe(fademask_t *fademask, lighttable_t *fadecolormap, boolean r
e = e_base + relativepos;
draw_rowstogo = draw_rowend - draw_rowstart;
if (fadecolormap)
{
if (reverse)
s = e;
while (draw_rowstogo--)
*w++ = fadecolormap[ ( m << 8 ) + *s++ ];
}
else while (draw_rowstogo--)
{
/*if (fadecolormap != NULL)
{
if (reverse)
*w++ = fadecolormap[ ( m << 8 ) + *e++ ];
else
*w++ = fadecolormap[ ( m << 8 ) + *s++ ];
}
else*/
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
}
while (draw_rowstogo--)
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
relativepos += vid.width;
}
@ -430,38 +404,17 @@ void F_WipeStageTitle(void)
/** 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, boolean encorewiggle)
void F_RunWipe(UINT8 wipetype, boolean drawMenu)
{
#ifdef NOWIPE
(void)wipetype;
(void)drawMenu;
(void)colormap;
(void)reverse;
(void)encorewiggle;
#else
tic_t nowtime;
UINT8 wipeframe = 0;
fademask_t *fmask;
lumpnum_t clump = LUMPERROR;
lighttable_t *fcolor = NULL;
if (colormap != NULL)
clump = W_GetNumForName(colormap);
if (clump != LUMPERROR && wipetype != UINT8_MAX)
{
pallen = 32;
fcolor = Z_MallocAlign((256 * pallen), PU_STATIC, NULL, 8);
W_ReadLump(clump, fcolor);
}
else
{
pallen = 11;
reverse = false;
}
paldiv = FixedDiv(257<<FRACBITS, pallen<<FRACBITS);
paldiv = FixedDiv(257<<FRACBITS, 11<<FRACBITS);
// Init the wipe
WipeInAction = true;
@ -489,24 +442,13 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r
HWR_DoWipe(wipetype, wipeframe-1); // send in the wipe type and wipeframe because we need to cache the graphic
else
#endif
if (rendermode != render_none) //this allows F_RunWipe to be called in dedicated servers
{
F_DoWipe(fmask, fcolor, reverse);
if (encorewiggle)
{
#ifdef HWRENDER
if (rendermode != render_opengl)
#endif
F_DoEncoreWiggle(wipeframe);
}
}
F_DoWipe(fmask);
I_OsPolling();
I_UpdateNoBlit();
if (drawMenu)
if (rendermode != render_none && drawMenu)
{
#ifdef HAVE_THREADS
I_lock_mutex(&m_menu_mutex);
@ -524,62 +466,6 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r
NetKeepAlive(); // Update the network so we don't cause timeouts
}
WipeInAction = false;
if (fcolor)
{
Z_Free(fcolor);
fcolor = NULL;
}
#endif
}
/** Returns tic length of wipe
* One lump equals one tic
*/
tic_t F_GetWipeLength(UINT8 wipetype)
{
#ifdef NOWIPE
(void)wipetype;
return 0;
#else
static char lumpname[10] = "FADEmmss";
lumpnum_t lumpnum;
UINT8 wipeframe;
if (wipetype > 99)
return 0;
for (wipeframe = 0; wipeframe < 100; wipeframe++)
{
sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipetype, (UINT16)wipeframe);
lumpnum = W_CheckNumForName(lumpname);
if (lumpnum == LUMPERROR)
return --wipeframe;
}
return --wipeframe;
#endif
}
/** Does the specified wipe exist?
*/
boolean F_WipeExists(UINT8 wipetype)
{
#ifdef NOWIPE
(void)wipetype;
return false;
#else
static char lumpname[10] = "FADEmm00";
lumpnum_t lumpnum;
if (wipetype > 99)
return false;
sprintf(&lumpname[4], "%.2hu00", (UINT16)wipetype);
lumpnum = W_CheckNumForName(lumpname);
return !(lumpnum == LUMPERROR);
#endif
}

View file

@ -7863,67 +7863,53 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
// This is handled BEFORE sounds are stopped.
else if (encoremode && !prevencoremode && !demo.rewinding)
{
tic_t locstarttime, endtime, nowtime;
if (rendermode != render_none)
{
tic_t locstarttime, endtime, nowtime;
S_StopMusic(); // er, about that...
// Fade to an inverted screen, with a circle fade...
F_WipeStartScreen();
V_EncoreInvertScreen();
F_WipeEndScreen();
S_StartSound(NULL, sfx_ruby1);
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)
#define WAIT(timetowait) \
locstarttime = nowtime = lastwipetic; \
endtime = locstarttime + timetowait; \
while (nowtime < endtime) \
{ \
while (!((nowtime = I_GetTime()) - lastwipetic)) \
{ \
I_Sleep(cv_sleep.value); \
I_UpdateTime(cv_timescale.value); \
} \
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, 122);
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0);
F_WipeEndScreen();
F_RunWipe(wipedefs[wipe_encore_towhite], false);
F_RunWipe(wipedefs[wipe_encore_towhite], false, "FADEMAP1", false, true); // wiggle the screen during this!
// THEN fade to a black screen.
F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 120);
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
F_WipeEndScreen();
F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false);
// Wait a bit longer.
WAIT((3*TICRATE)/4);
F_RunWipe(wipedefs[wipe_level_final], false);
}
else
else //dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe
{
// dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe
F_RunWipe(wipedefs[wipe_encore_towhite], false, "FADEMAP1", false, true);
F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false);
F_RunWipe(wipedefs[wipe_encore_towhite], false);
F_RunWipe(wipedefs[wipe_level_final], false);
}
locstarttime = nowtime = lastwipetic;
endtime = locstarttime + (3*TICRATE)/2;
// Hold on white for extra effect.
while (nowtime < endtime)
{
// wait loop
while (!((nowtime = I_GetTime()) - lastwipetic))
{
I_Sleep(cv_sleep.value);
I_UpdateTime(cv_timescale.value);
}
lastwipetic = nowtime;
if (moviemode) // make sure we save frames for the white hold too
M_SaveFrame();
// Keep the network alive
NetKeepAlive();
}
ranspecialwipe = 1;
}
// Special stage & record attack retry fade to white
@ -7953,13 +7939,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
// But only if we didn't do the encore startup wipe
if (!demo.rewinding && !reloadinggamestate)
{
// Fade out music here. Deduct 2 tics so the fade volume actually reaches 0.
// But don't halt the music! S_Start will take care of that. This dodges a MIDI crash bug.
if (!(reloadinggamestate || titlemapinaction))
S_FadeMusic(0, FixedMul(
FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE));
// Reset the palette now all fades have been done
if (rendermode != render_none)
V_SetPaletteLump(GetPalette()); // Set the level palette
@ -7978,7 +7957,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
}
}
levelfadecol = (encoremode && !ranspecialwipe ? 209 : 0);
levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120);
// Let's fade to white here
// But only if we didn't do the encore startup wipe
@ -7990,11 +7969,11 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
F_WipeEndScreen();
F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false, "FADEMAP0", false, false);
F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false);
}
else //dedicated servers
{
F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false, "FADEMAP0", false, false);
F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false);
}
}
/*if (!titlemapinaction)