2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2020-01-06 22:16:27 +00:00
|
|
|
// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh.
|
2022-03-03 19:24:46 +00:00
|
|
|
// Copyright (C) 1999-2022 by Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// This program is free software distributed under the
|
|
|
|
// terms of the GNU General Public License, version 2.
|
|
|
|
// See the 'LICENSE' file for more details.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// \file f_wipe.c
|
|
|
|
/// \brief SRB2 2.1 custom fade mask "wipe" behavior.
|
|
|
|
|
|
|
|
#include "f_finale.h"
|
|
|
|
#include "i_video.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
|
2020-03-09 13:54:56 +00:00
|
|
|
#include "r_state.h" // fadecolormap
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "r_draw.h" // transtable
|
|
|
|
#include "p_pspr.h" // tr_transxxx
|
2019-11-15 22:36:25 +00:00
|
|
|
#include "p_local.h"
|
2019-11-18 14:39:54 +00:00
|
|
|
#include "st_stuff.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "w_wad.h"
|
|
|
|
#include "z_zone.h"
|
|
|
|
|
|
|
|
#include "i_system.h"
|
2020-04-27 02:46:35 +00:00
|
|
|
#include "i_threads.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "m_menu.h"
|
|
|
|
#include "console.h"
|
|
|
|
#include "d_main.h"
|
2019-11-15 22:36:25 +00:00
|
|
|
#include "g_game.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "m_misc.h" // movie mode
|
|
|
|
|
2019-09-10 02:31:48 +00:00
|
|
|
#include "doomstat.h"
|
|
|
|
|
|
|
|
#include "lua_hud.h" // level title
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
#ifdef HWRENDER
|
|
|
|
#include "hardware/hw_main.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if NUMSCREENS < 5
|
|
|
|
#define NOWIPE // do not enable wipe image post processing for ARM, SH and MIPS CPUs
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct fademask_s {
|
|
|
|
UINT8* mask;
|
|
|
|
UINT16 width, height;
|
|
|
|
size_t size;
|
|
|
|
fixed_t xscale, yscale;
|
|
|
|
} fademask_t;
|
|
|
|
|
|
|
|
UINT8 wipedefs[NUMWIPEDEFS] = {
|
|
|
|
99, // wipe_credits_intermediate (0)
|
|
|
|
|
|
|
|
0, // wipe_level_toblack
|
|
|
|
UINT8_MAX, // wipe_intermission_toblack
|
2019-12-05 04:47:51 +00:00
|
|
|
0, // wipe_continuing_toblack
|
2014-03-15 16:59:03 +00:00
|
|
|
0, // wipe_titlescreen_toblack
|
|
|
|
0, // wipe_timeattack_toblack
|
|
|
|
99, // wipe_credits_toblack
|
|
|
|
0, // wipe_evaluation_toblack
|
|
|
|
0, // wipe_gameend_toblack
|
|
|
|
99, // wipe_intro_toblack (hardcoded)
|
A good and bad ending cutscene now exist.
Also:
* SPR2_XTRA - instead of defining lumpnames in S_SKIN, those kinds of assets can just be bundled into the spriteset. Required for ending cutscene stuff, I guess, but also done for HUD life icon and character select image (aside from Sonic&Tails, still SOC'd in).
* Minor oversights in SPR2 support corrected.
* Better evaluation, featuring ending assets.
* Intro has warping-in blackrock, reusing ending assets.
* Cutscene text now supports lowercase (intro and custom).
* Disable the asset-fucking "gamma correction" I put in over two years ago when implementing colour cube. (This is the only thing I could move into another branch if you MUST, but it's basically invisble in the diff so w/e.)
* Don't blank the screen if the top left pixel of a screen-covering patch is transparent. (Checked via nonzero topdelta for first column)
Bugs:
* OPENGL ONLY: The first ~20 frames of both endings are fucked. A little help here? Might be HWR_DrawFadeFill's fault, which I just created. OR it could be in f_finale, but I doubt it, since it doesn't appear in Software.
2019-07-27 23:32:57 +00:00
|
|
|
0, // wipe_ending_toblack
|
2014-03-15 16:59:03 +00:00
|
|
|
99, // wipe_cutscene_toblack (hardcoded)
|
|
|
|
|
|
|
|
0, // wipe_specinter_toblack
|
|
|
|
0, // wipe_multinter_toblack
|
2016-01-05 13:03:00 +00:00
|
|
|
0, // wipe_speclevel_towhite
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
0, // wipe_level_final
|
|
|
|
0, // wipe_intermission_final
|
|
|
|
0, // wipe_continuing_final
|
|
|
|
0, // wipe_titlescreen_final
|
|
|
|
0, // wipe_timeattack_final
|
|
|
|
99, // wipe_credits_final
|
|
|
|
0, // wipe_evaluation_final
|
|
|
|
0, // wipe_gameend_final
|
|
|
|
99, // wipe_intro_final (hardcoded)
|
A good and bad ending cutscene now exist.
Also:
* SPR2_XTRA - instead of defining lumpnames in S_SKIN, those kinds of assets can just be bundled into the spriteset. Required for ending cutscene stuff, I guess, but also done for HUD life icon and character select image (aside from Sonic&Tails, still SOC'd in).
* Minor oversights in SPR2 support corrected.
* Better evaluation, featuring ending assets.
* Intro has warping-in blackrock, reusing ending assets.
* Cutscene text now supports lowercase (intro and custom).
* Disable the asset-fucking "gamma correction" I put in over two years ago when implementing colour cube. (This is the only thing I could move into another branch if you MUST, but it's basically invisble in the diff so w/e.)
* Don't blank the screen if the top left pixel of a screen-covering patch is transparent. (Checked via nonzero topdelta for first column)
Bugs:
* OPENGL ONLY: The first ~20 frames of both endings are fucked. A little help here? Might be HWR_DrawFadeFill's fault, which I just created. OR it could be in f_finale, but I doubt it, since it doesn't appear in Software.
2019-07-27 23:32:57 +00:00
|
|
|
0, // wipe_ending_final
|
2014-03-15 16:59:03 +00:00
|
|
|
99, // wipe_cutscene_final (hardcoded)
|
|
|
|
|
|
|
|
0, // wipe_specinter_final
|
|
|
|
0 // wipe_multinter_final
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
// SCREEN WIPE PACKAGE
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
boolean WipeInAction = false;
|
2019-11-18 14:39:54 +00:00
|
|
|
boolean WipeStageTitle = false;
|
2014-03-15 16:59:03 +00:00
|
|
|
INT32 lastwipetic = 0;
|
|
|
|
|
2019-09-10 02:31:48 +00:00
|
|
|
wipestyle_t wipestyle = WIPESTYLE_NORMAL;
|
2019-11-22 20:44:42 +00:00
|
|
|
wipestyleflags_t wipestyleflags = WSF_CROSSFADE;
|
2019-09-10 02:31:48 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
#ifndef NOWIPE
|
|
|
|
static UINT8 *wipe_scr_start; //screen 3
|
|
|
|
static UINT8 *wipe_scr_end; //screen 4
|
|
|
|
static UINT8 *wipe_scr; //screen 0 (main drawing)
|
2017-04-29 15:40:07 +00:00
|
|
|
static fixed_t paldiv = 0;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
/** Create fademask_t from lump
|
|
|
|
*
|
|
|
|
* \param lump Lump name to get data from
|
|
|
|
* \return fademask_t for lump
|
|
|
|
*/
|
|
|
|
static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
|
2017-09-28 13:13:46 +00:00
|
|
|
static char lumpname[10] = "FADEmmss";
|
2014-03-15 16:59:03 +00:00
|
|
|
static fademask_t fm = {NULL,0,0,0,0,0};
|
|
|
|
lumpnum_t lumpnum;
|
|
|
|
UINT8 *lump, *mask;
|
|
|
|
size_t lsize;
|
|
|
|
RGBA_t *pcolor;
|
|
|
|
|
|
|
|
if (masknum > 99 || scrnnum > 99)
|
|
|
|
goto freemask;
|
|
|
|
|
|
|
|
sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum);
|
|
|
|
|
|
|
|
lumpnum = W_CheckNumForName(lumpname);
|
|
|
|
if (lumpnum == LUMPERROR)
|
|
|
|
goto freemask;
|
|
|
|
|
|
|
|
lump = W_CacheLumpNum(lumpnum, PU_CACHE);
|
|
|
|
lsize = W_LumpLength(lumpnum);
|
|
|
|
switch (lsize)
|
|
|
|
{
|
|
|
|
case 256000: // 640x400
|
|
|
|
fm.width = 640;
|
|
|
|
fm.height = 400;
|
|
|
|
break;
|
|
|
|
case 64000: // 320x200
|
|
|
|
fm.width = 320;
|
|
|
|
fm.height = 200;
|
|
|
|
break;
|
|
|
|
case 16000: // 160x100
|
|
|
|
fm.width = 160;
|
|
|
|
fm.height = 100;
|
|
|
|
break;
|
|
|
|
case 4000: // 80x50 (minimum)
|
|
|
|
fm.width = 80;
|
|
|
|
fm.height = 50;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // bad lump
|
|
|
|
CONS_Alert(CONS_WARNING, "Fade mask lump %s of incorrect size, ignored\n", lumpname);
|
|
|
|
case 0: // end marker (not bad!, but still need clearing)
|
|
|
|
goto freemask;
|
|
|
|
}
|
|
|
|
if (lsize != fm.size)
|
|
|
|
fm.mask = Z_Realloc(fm.mask, lsize, PU_STATIC, NULL);
|
|
|
|
fm.size = lsize;
|
|
|
|
|
|
|
|
mask = fm.mask;
|
|
|
|
|
|
|
|
while (lsize--)
|
|
|
|
{
|
|
|
|
// Determine pixel to use from fademask
|
2017-04-29 15:40:07 +00:00
|
|
|
pcolor = &pMasterPalette[*lump++];
|
2019-12-04 22:25:39 +00:00
|
|
|
if (wipestyle == WIPESTYLE_COLORMAP)
|
2019-09-10 19:54:40 +00:00
|
|
|
*mask++ = pcolor->s.red / FADECOLORMAPDIV;
|
2019-09-10 02:31:48 +00:00
|
|
|
else
|
|
|
|
*mask++ = FixedDiv((pcolor->s.red+1)<<FRACBITS, paldiv)>>FRACBITS;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
|
2014-08-27 03:56:30 +00:00
|
|
|
fm.xscale = FixedDiv(vid.width<<FRACBITS, fm.width<<FRACBITS);
|
|
|
|
fm.yscale = FixedDiv(vid.height<<FRACBITS, fm.height<<FRACBITS);
|
2014-03-15 16:59:03 +00:00
|
|
|
return &fm;
|
|
|
|
|
|
|
|
// Landing point for freeing data -- do this instead of just returning NULL
|
|
|
|
// this ensures the fade data isn't remaining in memory, unused
|
|
|
|
// (could be up to 256,000 bytes if it's a HQ fade!)
|
|
|
|
freemask:
|
|
|
|
if (fm.mask)
|
|
|
|
{
|
|
|
|
Z_Free(fm.mask);
|
|
|
|
fm.mask = NULL;
|
|
|
|
fm.size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-11-15 22:36:25 +00:00
|
|
|
/** Draw the stage title.
|
|
|
|
*/
|
|
|
|
void F_WipeStageTitle(void)
|
2019-09-10 02:31:48 +00:00
|
|
|
{
|
2019-11-18 21:48:19 +00:00
|
|
|
// draw level title
|
|
|
|
if ((WipeStageTitle && st_overlay)
|
2019-12-04 22:25:39 +00:00
|
|
|
&& (wipestyle == WIPESTYLE_COLORMAP)
|
2020-02-08 17:13:20 +00:00
|
|
|
&& G_IsTitleCardAvailable())
|
2019-11-15 22:36:25 +00:00
|
|
|
{
|
2019-11-18 21:48:19 +00:00
|
|
|
ST_runTitleCard();
|
|
|
|
ST_drawWipeTitleCard();
|
2019-11-15 22:36:25 +00:00
|
|
|
}
|
2019-09-10 02:31:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
/** Wipe ticker
|
|
|
|
*
|
|
|
|
* \param fademask pixels to change
|
|
|
|
*/
|
|
|
|
static void F_DoWipe(fademask_t *fademask)
|
|
|
|
{
|
2014-08-27 03:56:30 +00:00
|
|
|
// Software mask wipe -- optimized; though it might not look like it!
|
|
|
|
// Okay, to save you wondering *how* this is more optimized than the simpler
|
|
|
|
// version that came before it...
|
|
|
|
// ---
|
|
|
|
// The previous code did two FixedMul calls for every single pixel on the
|
|
|
|
// screen, of which there are hundreds of thousands -- if not millions -- of.
|
|
|
|
// This worked fine for smaller screen sizes, but with excessively large
|
|
|
|
// (1920x1200) screens that meant 4 million+ calls out to FixedMul, and that
|
|
|
|
// would take /just/ long enough that fades would start to noticably lag.
|
|
|
|
// ---
|
|
|
|
// This code iterates over the fade mask's pixels instead of the screen's,
|
|
|
|
// and deals with drawing over each rectangular area before it moves on to
|
|
|
|
// the next pixel in the fade mask. As a result, it's more complex (and might
|
|
|
|
// 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.
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2014-08-27 03:56:30 +00:00
|
|
|
// 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.
|
2015-01-29 00:03:41 +00:00
|
|
|
UINT16* scrxpos = (UINT16*)malloc((fademask->width + 1) * sizeof(UINT16));
|
|
|
|
UINT16* scrypos = (UINT16*)malloc((fademask->height + 1) * sizeof(UINT16));
|
2014-08-27 03:56:30 +00:00
|
|
|
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
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2014-08-27 03:56:30 +00:00
|
|
|
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;
|
2016-01-08 16:16:16 +00:00
|
|
|
|
2019-11-15 21:21:12 +00:00
|
|
|
if (*mask == 0)
|
2014-08-27 03:56:30 +00:00
|
|
|
{
|
2016-01-08 16:16:16 +00:00
|
|
|
// shortcut - memcpy source to work
|
|
|
|
while (draw_linestogo--)
|
2014-08-27 03:56:30 +00:00
|
|
|
{
|
2016-01-08 16:16:16 +00:00
|
|
|
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
|
|
|
|
relativepos += vid.width;
|
|
|
|
}
|
|
|
|
}
|
2019-12-11 16:09:27 +00:00
|
|
|
else if (*mask >= 10)
|
2016-01-08 16:16:16 +00:00
|
|
|
{
|
|
|
|
// shortcut - memcpy target to work
|
|
|
|
while (draw_linestogo--)
|
|
|
|
{
|
|
|
|
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
|
|
|
|
relativepos += vid.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-11 16:09:27 +00:00
|
|
|
// pointer to transtable that this mask would use
|
2020-10-27 03:03:41 +00:00
|
|
|
transtbl = R_GetTranslucencyTable((9 - *mask) + 1);
|
2019-12-11 16:09:27 +00:00
|
|
|
|
|
|
|
// DRAWING LOOP
|
|
|
|
while (draw_linestogo--)
|
2019-09-10 02:31:48 +00:00
|
|
|
{
|
2019-12-11 16:09:27 +00:00
|
|
|
w = w_base + relativepos;
|
|
|
|
s = s_base + relativepos;
|
|
|
|
e = e_base + relativepos;
|
|
|
|
draw_rowstogo = draw_rowend - draw_rowstart;
|
|
|
|
|
|
|
|
while (draw_rowstogo--)
|
|
|
|
*w++ = transtbl[ ( *e++ << 8 ) + *s++ ];
|
|
|
|
|
|
|
|
relativepos += vid.width;
|
|
|
|
}
|
|
|
|
// END DRAWING LOOP
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2019-09-10 02:31:48 +00:00
|
|
|
|
2019-12-11 16:09:27 +00:00
|
|
|
// rectangle draw hints
|
|
|
|
UINT32 draw_linestart, draw_rowstart;
|
|
|
|
UINT32 draw_lineend, draw_rowend;
|
|
|
|
UINT32 draw_linestogo, draw_rowstogo;
|
2019-09-10 02:31:48 +00:00
|
|
|
|
2019-12-11 16:09:27 +00:00
|
|
|
// 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;
|
2019-09-10 02:31:48 +00:00
|
|
|
|
2019-12-11 16:09:27 +00:00
|
|
|
// ---
|
|
|
|
// 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;
|
2019-09-10 02:31:48 +00:00
|
|
|
}
|
2019-12-11 16:09:27 +00:00
|
|
|
}
|
|
|
|
else if (*mask >= FADECOLORMAPROWS)
|
|
|
|
{
|
|
|
|
// shortcut - memcpy target to work
|
|
|
|
while (draw_linestogo--)
|
2019-09-10 02:31:48 +00:00
|
|
|
{
|
2019-12-11 16:09:27 +00:00
|
|
|
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
|
|
|
|
relativepos += vid.width;
|
2019-09-10 02:31:48 +00:00
|
|
|
}
|
2019-12-11 16:09:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int nmask = *mask;
|
|
|
|
if (wipestyleflags & WSF_FADEIN)
|
|
|
|
nmask = (FADECOLORMAPROWS-1) - nmask;
|
|
|
|
|
|
|
|
transtbl = colormap + (nmask * 256);
|
2016-01-08 16:16:16 +00:00
|
|
|
|
|
|
|
// DRAWING LOOP
|
|
|
|
while (draw_linestogo--)
|
|
|
|
{
|
|
|
|
w = w_base + relativepos;
|
|
|
|
s = s_base + relativepos;
|
|
|
|
e = e_base + relativepos;
|
|
|
|
draw_rowstogo = draw_rowend - draw_rowstart;
|
|
|
|
|
2019-12-11 16:09:27 +00:00
|
|
|
while (draw_rowstogo--)
|
|
|
|
*w++ = transtbl[*e++];
|
2016-01-08 16:16:16 +00:00
|
|
|
|
|
|
|
relativepos += vid.width;
|
2014-08-27 03:56:30 +00:00
|
|
|
}
|
2016-01-08 16:16:16 +00:00
|
|
|
// END DRAWING LOOP
|
2014-08-27 03:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (++maskx >= fademask->width)
|
|
|
|
++masky, maskx = 0;
|
|
|
|
} while (++mask < maskend);
|
2015-01-28 08:09:03 +00:00
|
|
|
|
|
|
|
free(scrxpos);
|
|
|
|
free(scrypos);
|
2014-08-27 03:56:30 +00:00
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Save the "before" screen of a wipe.
|
|
|
|
*/
|
|
|
|
void F_WipeStartScreen(void)
|
|
|
|
{
|
|
|
|
#ifndef NOWIPE
|
|
|
|
#ifdef HWRENDER
|
|
|
|
if(rendermode != render_soft)
|
|
|
|
{
|
|
|
|
HWR_StartScreenWipe();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
wipe_scr_start = screens[3];
|
|
|
|
I_ReadScreen(wipe_scr_start);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Save the "after" screen of a wipe.
|
|
|
|
*/
|
|
|
|
void F_WipeEndScreen(void)
|
|
|
|
{
|
|
|
|
#ifndef NOWIPE
|
|
|
|
#ifdef HWRENDER
|
|
|
|
if(rendermode != render_soft)
|
|
|
|
{
|
|
|
|
HWR_EndScreenWipe();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
wipe_scr_end = screens[4];
|
|
|
|
I_ReadScreen(wipe_scr_end);
|
|
|
|
V_DrawBlock(0, 0, 0, vid.width, vid.height, wipe_scr_start);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-12-04 22:25:39 +00:00
|
|
|
/** Verifies every condition for a colormapped fade.
|
|
|
|
*/
|
|
|
|
boolean F_ShouldColormapFade(void)
|
|
|
|
{
|
2020-05-24 01:23:45 +00:00
|
|
|
#ifndef NOWIPE
|
2019-12-04 22:25:39 +00:00
|
|
|
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);
|
|
|
|
}
|
2020-05-24 01:23:45 +00:00
|
|
|
#endif
|
2019-12-04 22:25:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Decides what wipe style to use.
|
|
|
|
*/
|
2020-05-24 01:23:45 +00:00
|
|
|
#ifndef NOWIPE
|
2019-12-04 22:25:39 +00:00
|
|
|
void F_DecideWipeStyle(void)
|
|
|
|
{
|
|
|
|
// Set default wipe style
|
|
|
|
wipestyle = WIPESTYLE_NORMAL;
|
|
|
|
|
|
|
|
// Check for colormap wipe style
|
|
|
|
if (F_ShouldColormapFade())
|
|
|
|
wipestyle = WIPESTYLE_COLORMAP;
|
|
|
|
}
|
2020-05-24 01:23:45 +00:00
|
|
|
#endif
|
2019-12-04 22:25:39 +00:00
|
|
|
|
|
|
|
/** 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)
|
|
|
|
{
|
2020-05-24 01:23:45 +00:00
|
|
|
#ifndef NOWIPE
|
2019-12-04 22:25:39 +00:00
|
|
|
if (F_ShouldColormapFade())
|
|
|
|
{
|
|
|
|
#ifdef HWRENDER
|
|
|
|
if (rendermode == render_opengl)
|
|
|
|
F_WipeColorFill(wipecolor);
|
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
2020-05-24 01:23:45 +00:00
|
|
|
#endif
|
2019-12-04 22:25:39 +00:00
|
|
|
{
|
|
|
|
F_WipeColorFill(wipecolor);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
/** After setting up the screens you want to wipe,
|
|
|
|
* calling this will do a 'typical' wipe.
|
|
|
|
*/
|
|
|
|
void F_RunWipe(UINT8 wipetype, boolean drawMenu)
|
|
|
|
{
|
|
|
|
#ifdef NOWIPE
|
|
|
|
(void)wipetype;
|
|
|
|
(void)drawMenu;
|
|
|
|
#else
|
|
|
|
tic_t nowtime;
|
|
|
|
UINT8 wipeframe = 0;
|
|
|
|
fademask_t *fmask;
|
|
|
|
|
2017-04-29 15:40:07 +00:00
|
|
|
if (!paldiv)
|
|
|
|
paldiv = FixedDiv(257<<FRACBITS, 11<<FRACBITS);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
// Init the wipe
|
2019-12-04 22:25:39 +00:00
|
|
|
F_DecideWipeStyle();
|
2014-03-15 16:59:03 +00:00
|
|
|
WipeInAction = true;
|
|
|
|
wipe_scr = screens[0];
|
|
|
|
|
|
|
|
// lastwipetic should either be 0 or the tic we last wiped
|
|
|
|
// on for fade-to-black
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
// get fademask first so we can tell if it exists or not
|
|
|
|
fmask = F_GetFadeMask(wipetype, wipeframe++);
|
|
|
|
if (!fmask)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// wait loop
|
|
|
|
while (!((nowtime = I_GetTime()) - lastwipetic))
|
|
|
|
I_Sleep();
|
|
|
|
lastwipetic = nowtime;
|
|
|
|
|
2019-12-11 16:26:28 +00:00
|
|
|
// Wipe styles
|
|
|
|
if (wipestyle == WIPESTYLE_COLORMAP)
|
2019-11-05 15:10:42 +00:00
|
|
|
{
|
2019-12-11 16:26:28 +00:00
|
|
|
#ifdef HWRENDER
|
|
|
|
if (rendermode == render_opengl)
|
|
|
|
{
|
|
|
|
// send in the wipe type and wipe frame because we need to cache the graphic
|
2019-11-05 15:10:42 +00:00
|
|
|
HWR_DoTintedWipe(wipetype, wipeframe-1);
|
2019-12-11 16:26:28 +00:00
|
|
|
}
|
2019-11-05 15:10:42 +00:00
|
|
|
else
|
2014-09-04 00:35:29 +00:00
|
|
|
#endif
|
2019-12-11 16:09:27 +00:00
|
|
|
{
|
|
|
|
UINT8 *colormap = fadecolormap;
|
|
|
|
if (wipestyleflags & WSF_TOWHITE)
|
|
|
|
colormap += (FADECOLORMAPROWS * 256);
|
|
|
|
F_DoColormapWipe(fmask, colormap);
|
|
|
|
}
|
2019-12-11 16:26:28 +00:00
|
|
|
|
|
|
|
// Draw the title card above the wipe
|
|
|
|
F_WipeStageTitle();
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
2019-12-11 16:09:27 +00:00
|
|
|
else
|
2019-12-11 16:26:28 +00:00
|
|
|
#endif
|
2019-12-11 16:09:27 +00:00
|
|
|
F_DoWipe(fmask);
|
|
|
|
}
|
2019-11-05 15:10:42 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
I_OsPolling();
|
|
|
|
I_UpdateNoBlit();
|
|
|
|
|
|
|
|
if (drawMenu)
|
2020-04-27 02:46:35 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
I_lock_mutex(&m_menu_mutex);
|
|
|
|
#endif
|
2014-03-15 16:59:03 +00:00
|
|
|
M_Drawer(); // menu is drawn even on top of wipes
|
2020-04-27 02:46:35 +00:00
|
|
|
#ifdef HAVE_THREADS
|
|
|
|
I_unlock_mutex(m_menu_mutex);
|
|
|
|
#endif
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2014-03-31 22:47:12 +00:00
|
|
|
I_FinishUpdate(); // page flip or blit buffer
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
if (moviemode)
|
|
|
|
M_SaveFrame();
|
|
|
|
}
|
2019-11-18 14:39:54 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
WipeInAction = false;
|
2019-11-18 14:39:54 +00:00
|
|
|
WipeStageTitle = false;
|
2019-11-15 21:21:12 +00:00
|
|
|
#endif
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2018-11-17 21:32:30 +00:00
|
|
|
|
|
|
|
/** Returns tic length of wipe
|
|
|
|
* One lump equals one tic
|
|
|
|
*/
|
|
|
|
tic_t F_GetWipeLength(UINT8 wipetype)
|
|
|
|
{
|
|
|
|
#ifdef NOWIPE
|
2020-05-24 02:47:30 +00:00
|
|
|
(void)wipetype;
|
2018-11-17 21:32:30 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-11-15 22:36:25 +00:00
|
|
|
/** Does the specified wipe exist?
|
|
|
|
*/
|
2018-11-17 21:32:30 +00:00
|
|
|
boolean F_WipeExists(UINT8 wipetype)
|
|
|
|
{
|
|
|
|
#ifdef NOWIPE
|
2020-05-24 02:47:30 +00:00
|
|
|
(void)wipetype;
|
2018-11-17 21:32:30 +00:00
|
|
|
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
|
|
|
|
}
|