Merge branch 'genesis-wipe' into 'master'

Genesis-style wipes

See merge request KartKrew/Kart!164
This commit is contained in:
Sal 2019-10-03 01:10:33 -04:00
commit eb7f662654
11 changed files with 281 additions and 118 deletions

View file

@ -308,13 +308,6 @@ static void D_Display(void)
wipedefindex = gamestate; // wipe_xxx_toblack wipedefindex = gamestate; // wipe_xxx_toblack
if (gamestate == GS_TITLESCREEN && wipegamestate != GS_INTRO) if (gamestate == GS_TITLESCREEN && wipegamestate != GS_INTRO)
wipedefindex = wipe_timeattack_toblack; 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) if (rendermode != render_none)
{ {
@ -325,7 +318,7 @@ static void D_Display(void)
F_WipeStartScreen(); F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", false, false);
} }
if (gamestate != GS_LEVEL && rendermode != render_none) if (gamestate != GS_LEVEL && rendermode != render_none)
@ -556,7 +549,7 @@ static void D_Display(void)
if (rendermode != render_none) if (rendermode != render_none)
{ {
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK); F_RunWipe(wipedefs[wipedefindex], gamestate != GS_TIMEATTACK, "FADEMAP0", true, false);
} }
} }

View file

@ -3257,29 +3257,13 @@ static void readwipes(MYFILE *f)
else if (fastcmp(pword, "FINAL")) else if (fastcmp(pword, "FINAL"))
wipeoffset = wipe_intermission_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)) else if (fastncmp(word, "VOTING_", 7))
{ {
pword = word + 7; pword = word + 7;
if (fastcmp(pword, "TOBLACK")) if (fastcmp(pword, "TOBLACK"))
wipeoffset = wipe_specinter_toblack; wipeoffset = wipe_voting_toblack;
else if (fastcmp(pword, "FINAL")) else if (fastcmp(pword, "FINAL"))
wipeoffset = wipe_specinter_final; wipeoffset = wipe_voting_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;
} }
else if (fastncmp(word, "CONTINUING_", 11)) else if (fastncmp(word, "CONTINUING_", 11))
{ {
@ -3331,11 +3315,13 @@ static void readwipes(MYFILE *f)
else if (fastcmp(pword, "FINAL")) else if (fastcmp(pword, "FINAL"))
wipeoffset = wipe_gameend_final; wipeoffset = wipe_gameend_final;
} }
else if (fastncmp(word, "SPECLEVEL_", 10)) else if (fastncmp(word, "ENCORE_", 7))
{ {
pword = word + 10; pword = word + 7;
if (fastcmp(pword, "TOWHITE")) if (fastcmp(pword, "TOINVERT"))
wipeoffset = wipe_speclevel_towhite; wipeoffset = wipe_encore_toinvert;
else if (fastcmp(pword, "TOWHITE"))
wipeoffset = wipe_encore_towhite;
} }
if (wipeoffset < 0) if (wipeoffset < 0)
@ -3345,10 +3331,10 @@ static void readwipes(MYFILE *f)
} }
if (value == UINT8_MAX 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 // 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); deh_warning("Wipes: can't disable wipe of type '%s'", word);
continue; continue;
} }

View file

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

View file

@ -74,12 +74,13 @@ extern INT32 lastwipetic;
void F_WipeStartScreen(void); void F_WipeStartScreen(void);
void F_WipeEndScreen(void); void F_WipeEndScreen(void);
void F_RunWipe(UINT8 wipetype, boolean drawMenu); void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean reverse, boolean encorewiggle);
enum enum
{ {
wipe_credits_intermediate, // makes a good 0 I guess. wipe_credits_intermediate, // makes a good 0 I guess.
// Gamestate wipes
wipe_level_toblack, wipe_level_toblack,
wipe_intermission_toblack, wipe_intermission_toblack,
wipe_voting_toblack, wipe_voting_toblack,
@ -92,11 +93,11 @@ enum
wipe_intro_toblack, wipe_intro_toblack,
wipe_cutscene_toblack, wipe_cutscene_toblack,
// custom intermissions // Specialized wipes
wipe_specinter_toblack, wipe_encore_toinvert,
wipe_multinter_toblack, wipe_encore_towhite,
wipe_speclevel_towhite,
// "From black" wipes
wipe_level_final, wipe_level_final,
wipe_intermission_final, wipe_intermission_final,
wipe_voting_final, wipe_voting_final,
@ -109,10 +110,6 @@ enum
wipe_intro_final, wipe_intro_final,
wipe_cutscene_final, wipe_cutscene_final,
// custom intermissions
wipe_specinter_final,
wipe_multinter_final,
NUMWIPEDEFS, NUMWIPEDEFS,
WIPEFINALSHIFT = wipe_level_final - wipe_level_toblack WIPEFINALSHIFT = wipe_level_final - wipe_level_toblack
}; };

View file

@ -16,8 +16,10 @@
#include "i_video.h" #include "i_video.h"
#include "v_video.h" #include "v_video.h"
#include "r_data.h" // NearestColor
#include "r_draw.h" // transtable #include "r_draw.h" // transtable
#include "p_pspr.h" // tr_transxxx #include "p_pspr.h" // tr_transxxx
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"
@ -47,35 +49,31 @@ UINT8 wipedefs[NUMWIPEDEFS] = {
99, // wipe_credits_intermediate (0) 99, // wipe_credits_intermediate (0)
0, // wipe_level_toblack 0, // wipe_level_toblack
UINT8_MAX, // wipe_intermission_toblack 0, // wipe_intermission_toblack
0, // wipe_voting_toblack, 0, // wipe_voting_toblack,
UINT8_MAX, // wipe_continuing_toblack 0, // wipe_continuing_toblack
3, // wipe_titlescreen_toblack 0, // wipe_titlescreen_toblack
0, // wipe_timeattack_toblack 0, // wipe_timeattack_toblack
99, // wipe_credits_toblack 99, // wipe_credits_toblack
0, // wipe_evaluation_toblack 0, // wipe_evaluation_toblack
0, // wipe_gameend_toblack 0, // wipe_gameend_toblack
UINT8_MAX, // wipe_intro_toblack (hardcoded) UINT8_MAX, // wipe_intro_toblack (hardcoded)
UINT8_MAX, // wipe_cutscene_toblack (hardcoded) 99, // wipe_cutscene_toblack (hardcoded)
UINT8_MAX, // wipe_specinter_toblack 72, // wipe_encore_toinvert
UINT8_MAX, // wipe_multinter_toblack 99, // wipe_encore_towhite
99, // wipe_speclevel_towhite
3, // wipe_level_final UINT8_MAX, // wipe_level_final
0, // wipe_intermission_final 0, // wipe_intermission_final
0, // wipe_voting_final 0, // wipe_voting_final
0, // wipe_continuing_final 0, // wipe_continuing_final
3, // wipe_titlescreen_final 0, // wipe_titlescreen_final
0, // wipe_timeattack_final 0, // wipe_timeattack_final
99, // wipe_credits_final 99, // wipe_credits_final
0, // wipe_evaluation_final 0, // wipe_evaluation_final
0, // wipe_gameend_final 0, // wipe_gameend_final
99, // wipe_intro_final (hardcoded) 99, // wipe_intro_final (hardcoded)
99, // wipe_cutscene_final (hardcoded) 99 // wipe_cutscene_final (hardcoded)
0, // wipe_specinter_final
0 // wipe_multinter_final
}; };
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -86,9 +84,13 @@ boolean WipeInAction = false;
INT32 lastwipetic = 0; INT32 lastwipetic = 0;
#ifndef NOWIPE #ifndef NOWIPE
#define GENLEN 31
static UINT8 *wipe_scr_start; //screen 3 static UINT8 *wipe_scr_start; //screen 3
static UINT8 *wipe_scr_end; //screen 4 static UINT8 *wipe_scr_end; //screen 4
static UINT8 *wipe_scr; //screen 0 (main drawing) static UINT8 *wipe_scr; //screen 0 (main drawing)
static UINT8 pallen;
static fixed_t paldiv; static fixed_t paldiv;
/** Create fademask_t from lump /** Create fademask_t from lump
@ -181,7 +183,7 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
* *
* \param fademask pixels to change * \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! // Software mask wipe -- optimized; though it might not look like it!
// Okay, to save you wondering *how* this is more optimized than the simpler // Okay, to save you wondering *how* this is more optimized than the simpler
@ -199,6 +201,10 @@ static void F_DoWipe(fademask_t *fademask)
// look a little messy; sorry!) but it simultaneously runs at twice the speed. // 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 // 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. // 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 // wipe screen, start, end
UINT8 *w = wipe_scr; UINT8 *w = wipe_scr;
@ -242,6 +248,8 @@ static void F_DoWipe(fademask_t *fademask)
maskx = masky = 0; maskx = masky = 0;
do do
{ {
UINT8 m = *mask;
draw_rowstart = scrxpos[maskx]; draw_rowstart = scrxpos[maskx];
draw_rowend = scrxpos[maskx + 1]; draw_rowend = scrxpos[maskx + 1];
draw_linestart = scrypos[masky]; draw_linestart = scrypos[masky];
@ -250,28 +258,31 @@ static void F_DoWipe(fademask_t *fademask)
relativepos = (draw_linestart * vid.width) + draw_rowstart; relativepos = (draw_linestart * vid.width) + draw_rowstart;
draw_linestogo = draw_lineend - draw_linestart; draw_linestogo = draw_lineend - draw_linestart;
if (*mask == 0) if (reverse)
m = ((pallen-1) - m);
if (m == 0)
{ {
// shortcut - memcpy source to work // shortcut - memcpy source to work
while (draw_linestogo--) 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; relativepos += vid.width;
} }
} }
else if (*mask == 10) else if (m >= (pallen-1))
{ {
// shortcut - memcpy target to work // shortcut - memcpy target to work
while (draw_linestogo--) 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; relativepos += vid.width;
} }
} }
else else
{ {
// pointer to transtable that this mask would use // pointer to transtable that this mask would use
transtbl = transtables + ((9 - *mask)<<FF_TRANSSHIFT); transtbl = transtables + ((9 - m)<<FF_TRANSSHIFT);
// DRAWING LOOP // DRAWING LOOP
while (draw_linestogo--) while (draw_linestogo--)
@ -282,7 +293,17 @@ static void F_DoWipe(fademask_t *fademask)
draw_rowstogo = draw_rowend - draw_rowstart; draw_rowstogo = draw_rowend - draw_rowstart;
while (draw_rowstogo--) while (draw_rowstogo--)
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ]; {
if (fadecolormap != NULL)
{
if (reverse)
*w++ = fadecolormap[ ( m << 8 ) + *e++ ];
else
*w++ = fadecolormap[ ( m << 8 ) + *s++ ];
}
else
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
}
relativepos += vid.width; relativepos += vid.width;
} }
@ -334,20 +355,86 @@ void F_WipeEndScreen(void)
#endif #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, /** After setting up the screens you want to wipe,
* calling this will do a 'typical' 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, boolean encorewiggle)
{ {
#ifdef NOWIPE #ifdef NOWIPE
(void)wipetype; (void)wipetype;
(void)drawMenu; (void)drawMenu;
(void)colormap;
(void)reverse;
(void)encorewiggle;
#else #else
tic_t nowtime; tic_t nowtime;
UINT8 wipeframe = 0; UINT8 wipeframe = 0;
fademask_t *fmask; fademask_t *fmask;
paldiv = FixedDiv(257<<FRACBITS, 11<<FRACBITS); 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);
// Init the wipe // Init the wipe
WipeInAction = true; WipeInAction = true;
@ -372,7 +459,14 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
HWR_DoWipe(wipetype, wipeframe-1); // send in the wipe type and wipeframe because we need to cache the graphic HWR_DoWipe(wipetype, wipeframe-1); // send in the wipe type and wipeframe because we need to cache the graphic
else else
#endif #endif
F_DoWipe(fmask); 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_OsPolling();
I_UpdateNoBlit(); I_UpdateNoBlit();
@ -386,6 +480,13 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
NetKeepAlive(); // Update the network so we don't cause timeouts NetKeepAlive(); // Update the network so we don't cause timeouts
} }
WipeInAction = false; WipeInAction = false;
if (fcolor)
{
Z_Free(fcolor);
fcolor = NULL;
}
#endif #endif
} }

View file

@ -2780,7 +2780,7 @@ boolean P_SetupLevel(boolean skipprecip)
// use gamemap to get map number. // use gamemap to get map number.
// 99% of the things already did, so. // 99% of the things already did, so.
// Map header should always be in place at this point // Map header should always be in place at this point
INT32 i, loadprecip = 1, ranspecialwipe = 0; INT32 i, loadprecip = 1;
INT32 loademblems = 1; INT32 loademblems = 1;
INT32 fromnetsave = 0; INT32 fromnetsave = 0;
boolean loadedbm = false; boolean loadedbm = false;
@ -2859,36 +2859,50 @@ boolean P_SetupLevel(boolean skipprecip)
S_StartSound(NULL, sfx_ruby1); S_StartSound(NULL, sfx_ruby1);
// Fade to an inverted screen, with a circle fade...
F_WipeStartScreen(); F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 209);
V_EncoreInvertScreen();
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(wipedefs[wipe_speclevel_towhite], 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)
#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(); F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0);
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(wipedefs[wipe_level_final], false);
locstarttime = nowtime = lastwipetic; F_RunWipe(wipedefs[wipe_encore_towhite], false, "FADEMAP1", false, true); // wiggle the screen during this!
endtime = locstarttime + (3*TICRATE)/2;
// Hold on white for extra effect. // THEN fade to a black screen.
while (nowtime < endtime) F_WipeStartScreen();
{
// 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();
// Keep the network alive V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31);
NetKeepAlive(); F_WipeEndScreen();
}
ranspecialwipe = 1; F_RunWipe(wipedefs[wipe_level_toblack], false, "FADEMAP0", false, false);
// Wait a bit longer.
WAIT((3*TICRATE)/4);
} }
// Make sure all sounds are stopped before Z_FreeTags. // Make sure all sounds are stopped before Z_FreeTags.
@ -2899,17 +2913,18 @@ boolean P_SetupLevel(boolean skipprecip)
// We should be fine starting it here. // We should be fine starting it here.
S_Start(); S_Start();
levelfadecol = (encoremode && !ranspecialwipe ? 209 : 0); levelfadecol = (encoremode ? 0 : 31);
// Let's fade to white here // Let's fade to white here
// But only if we didn't do the encore startup wipe // 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(); F_WipeStartScreen();
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol);
F_WipeEndScreen(); F_WipeEndScreen();
F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false);
F_RunWipe(wipedefs[wipe_level_toblack], false, ((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), false, false);
} }
// Reset the palette now all fades have been done // Reset the palette now all fades have been done

View file

@ -1177,7 +1177,6 @@ void R_ClearColormaps(void)
// //
static double deltas[256][3], map[256][3]; static double deltas[256][3], map[256][3];
static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
static int RoundUp(double number); static int RoundUp(double number);
#ifdef HASINVERT #ifdef HASINVERT
@ -1403,7 +1402,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
// Thanks to quake2 source! // Thanks to quake2 source!
// utils3/qdata/images.c // utils3/qdata/images.c
static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b)
{ {
int dr, dg, db; int dr, dg, db;
int distortion, bestdistortion = 256 * 256 * 4, bestcolor = 0, i; int distortion, bestdistortion = 256 * 256 * 4, bestcolor = 0, i;

View file

@ -93,6 +93,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap);
void R_ClearColormaps(void); void R_ClearColormaps(void);
INT32 R_ColormapNumForName(char *name); INT32 R_ColormapNumForName(char *name);
INT32 R_CreateColormap(char *p1, char *p2, char *p3); INT32 R_CreateColormap(char *p1, char *p2, char *p3);
UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b);
#ifdef HASINVERT #ifdef HASINVERT
void R_MakeInvertmap(void); void R_MakeInvertmap(void);
#endif #endif

View file

@ -2134,12 +2134,7 @@ void ST_Drawer(void)
ST_MayonakaStatic(); ST_MayonakaStatic();
} }
// Draw a white fade on level opening // Draw a fade on level opening
if (timeinmap < 15) if (timeinmap < 16)
{ V_DrawCustomFadeScreen(((levelfadecol == 0) ? "FADEMAP1" : "FADEMAP0"), 32-(timeinmap*2)); // Then gradually fade out from there
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
}
} }

View file

@ -1287,28 +1287,75 @@ void V_DrawVhsEffect(boolean rewind)
void V_DrawFadeScreen(UINT16 color, UINT8 strength) void V_DrawFadeScreen(UINT16 color, UINT8 strength)
{ {
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none) if (rendermode != render_soft && rendermode != render_none)
{ {
HWR_FadeScreenMenuBack(color, strength); HWR_FadeScreenMenuBack(color, strength);
return; return;
} }
#endif #endif
{ {
const UINT8 *fadetable = const UINT8 *fadetable =
(color > 0xFFF0) // Grab a specific colormap palette? (color > 0xFFF0) // Grab a specific colormap palette?
? R_GetTranslationColormap(color | 0xFFFF0000, strength, GTC_CACHE) ? R_GetTranslationColormap(color | 0xFFFF0000, strength, GTC_CACHE)
: ((color & 0xFF00) // Color is not palette index? : ((color & 0xFF00) // Color is not palette index?
? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade.
: ((UINT8 *)transtables + ((9-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade. : ((UINT8 *)transtables + ((9-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
UINT8 *buf = screens[0]; UINT8 *buf = screens[0];
// heavily simplified -- we don't need to know x or y // heavily simplified -- we don't need to know x or y
// position when we're doing a full screen fade // position when we're doing a full screen fade
for (; buf < deststop; ++buf) for (; buf < deststop; ++buf)
*buf = fadetable[*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. // 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]; *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 // Gets string colormap, used for 0x80 color codes
// //
UINT8 *V_GetStringColormap(INT32 colorflags) 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 // fade down the screen buffer before drawing the menu over
void V_DrawFadeScreen(UINT16 color, UINT8 strength); void V_DrawFadeScreen(UINT16 color, UINT8 strength);
void V_DrawCustomFadeScreen(const char *lump, UINT8 strength);
void V_DrawFadeConsBack(INT32 plines); void V_DrawFadeConsBack(INT32 plines);
void V_EncoreInvertScreen(void);
// draw a single character // draw a single character
void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed); void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed);