| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2000 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* Mission begin melt/wipe screen special effect. |
| 31 |
* |
| 32 |
*----------------------------------------------------------------------------- |
| 33 |
*/ |
| 34 |
|
| 35 |
|
| 36 |
#ifdef HAVE_CONFIG_H |
| 37 |
#include "config.h" |
| 38 |
#endif |
| 39 |
|
| 40 |
#include "z_zone.h" |
| 41 |
#include "doomdef.h" |
| 42 |
#include "i_video.h" |
| 43 |
#include "v_video.h" |
| 44 |
#include "m_random.h" |
| 45 |
#include "f_wipe.h" |
| 46 |
#include "gl_struct.h" |
| 47 |
#include "e6y.h"//e6y |
| 48 |
|
| 49 |
#include "dsda/settings.h" |
| 50 |
|
| 51 |
// |
| 52 |
// SCREEN WIPE PACKAGE |
| 53 |
// |
| 54 |
|
| 55 |
// Parts re-written to support true-color video modes. Column-major |
| 56 |
// formatting removed. - POPE |
| 57 |
|
| 58 |
// CPhipps - macros for the source and destination screens |
| 59 |
#define SRC_SCR 2 |
| 60 |
#define DEST_SCR 3 |
| 61 |
|
| 62 |
static screeninfo_t wipe_scr_start; |
| 63 |
static screeninfo_t wipe_scr_end; |
| 64 |
static screeninfo_t wipe_scr; |
| 65 |
|
| 66 |
// e6y: resolution limitation is removed |
| 67 |
static int *y_lookup = NULL; |
| 68 |
|
| 69 |
// e6y: resolution limitation is removed |
| 70 |
void R_InitMeltRes(void) |
| 71 |
{ |
| 72 |
if (y_lookup) Z_Free(y_lookup); |
| 73 |
|
| 74 |
y_lookup = Z_Calloc(1, SCREENWIDTH * sizeof(*y_lookup)); |
| 75 |
} |
| 76 |
|
| 77 |
static int wipe_initMelt(int ticks) |
| 78 |
{ |
| 79 |
int i; |
| 80 |
|
| 81 |
if (V_IsSoftwareMode()) |
| 82 |
{ |
| 83 |
// copy start screen to main screen |
| 84 |
for(i=0;i<SCREENHEIGHT;i++) |
| 85 |
memcpy(wipe_scr.data+i*wipe_scr.pitch, |
| 86 |
wipe_scr_start.data+i*wipe_scr_start.pitch, |
| 87 |
SCREENWIDTH); |
| 88 |
} |
| 89 |
|
| 90 |
// setup initial column positions (y<0 => not ready to scroll yet) |
| 91 |
y_lookup[0] = -(M_Random()%16); |
| 92 |
for (i=1;i<SCREENWIDTH;i++) |
| 93 |
{ |
| 94 |
int r = (M_Random()%3) - 1; |
| 95 |
y_lookup[i] = y_lookup[i-1] + r; |
| 96 |
if (y_lookup[i] > 0) |
| 97 |
y_lookup[i] = 0; |
| 98 |
else |
| 99 |
if (y_lookup[i] == -16) |
| 100 |
y_lookup[i] = -15; |
| 101 |
} |
| 102 |
return 0; |
| 103 |
} |
| 104 |
|
| 105 |
static int wipe_doMelt(int ticks) |
| 106 |
{ |
| 107 |
dboolean done = true; |
| 108 |
int i; |
| 109 |
|
| 110 |
while (ticks--) { |
| 111 |
for (i=0;i<(SCREENWIDTH);i++) { |
| 112 |
if (y_lookup[i]<0) { |
| 113 |
y_lookup[i]++; |
| 114 |
done = false; |
| 115 |
continue; |
| 116 |
} |
| 117 |
if (y_lookup[i] < SCREENHEIGHT) { |
| 118 |
byte *s, *d; |
| 119 |
int j, dy; |
| 120 |
|
| 121 |
/* cph 2001/07/29 - |
| 122 |
* The original melt rate was 8 pixels/sec, i.e. 25 frames to melt |
| 123 |
* the whole screen, so make the melt rate depend on SCREENHEIGHT |
| 124 |
* so it takes no longer in high res |
| 125 |
*/ |
| 126 |
dy = (y_lookup[i] < 16) ? y_lookup[i]+1 : SCREENHEIGHT/25; |
| 127 |
if (y_lookup[i]+dy >= SCREENHEIGHT) |
| 128 |
dy = SCREENHEIGHT - y_lookup[i]; |
| 129 |
|
| 130 |
if (V_IsSoftwareMode()) { |
| 131 |
s = wipe_scr_end.data + (y_lookup[i]*wipe_scr_end.pitch+i); |
| 132 |
d = wipe_scr.data + (y_lookup[i]*wipe_scr.pitch+i); |
| 133 |
for (j=dy;j;j--) { |
| 134 |
d[0] = s[0]; |
| 135 |
d += wipe_scr.pitch; |
| 136 |
s += wipe_scr_end.pitch; |
| 137 |
} |
| 138 |
} |
| 139 |
y_lookup[i] += dy; |
| 140 |
if (V_IsSoftwareMode()) { |
| 141 |
s = wipe_scr_start.data + i; |
| 142 |
d = wipe_scr.data + (y_lookup[i]*wipe_scr.pitch+i); |
| 143 |
for (j=SCREENHEIGHT-y_lookup[i];j;j--) { |
| 144 |
d[0] = s[0]; |
| 145 |
d += wipe_scr.pitch; |
| 146 |
s += wipe_scr_end.pitch; |
| 147 |
} |
| 148 |
} |
| 149 |
done = false; |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
if (V_IsOpenGLMode()) |
| 154 |
{ |
| 155 |
gld_wipe_doMelt(ticks, y_lookup); |
| 156 |
} |
| 157 |
return done; |
| 158 |
} |
| 159 |
|
| 160 |
// CPhipps - modified to allocate and deallocate screens[2 to 3] as needed, saving memory |
| 161 |
|
| 162 |
static int wipe_exitMelt(int ticks) |
| 163 |
{ |
| 164 |
if (V_IsOpenGLMode()) |
| 165 |
{ |
| 166 |
gld_wipe_exitMelt(ticks); |
| 167 |
return 0; |
| 168 |
} |
| 169 |
|
| 170 |
V_FreeScreen(&wipe_scr_start); |
| 171 |
wipe_scr_start.width = 0; |
| 172 |
wipe_scr_start.height = 0; |
| 173 |
V_FreeScreen(&wipe_scr_end); |
| 174 |
wipe_scr_end.width = 0; |
| 175 |
wipe_scr_end.height = 0; |
| 176 |
// Paranoia |
| 177 |
screens[SRC_SCR] = wipe_scr_start; |
| 178 |
screens[DEST_SCR] = wipe_scr_end; |
| 179 |
return 0; |
| 180 |
} |
| 181 |
|
| 182 |
int wipe_StartScreen(void) |
| 183 |
{ |
| 184 |
if(dsda_PendingSkipWipe() || wasWiped) return 0;//e6y |
| 185 |
wasWiped = true;//e6y |
| 186 |
|
| 187 |
if (V_IsOpenGLMode()) |
| 188 |
{ |
| 189 |
gld_wipe_StartScreen(); |
| 190 |
return 0; |
| 191 |
} |
| 192 |
|
| 193 |
wipe_scr_start.width = SCREENWIDTH; |
| 194 |
wipe_scr_start.height = SCREENHEIGHT; |
| 195 |
wipe_scr_start.pitch = screens[0].pitch; |
| 196 |
|
| 197 |
//e6y: fixed slowdown at 1024x768 on some systems |
| 198 |
if (!(wipe_scr_start.pitch % 1024)) |
| 199 |
wipe_scr_start.pitch += 32; |
| 200 |
|
| 201 |
wipe_scr_start.not_on_heap = false; |
| 202 |
V_AllocScreen(&wipe_scr_start); |
| 203 |
screens[SRC_SCR] = wipe_scr_start; |
| 204 |
V_CopyScreen(0, SRC_SCR); // Copy start screen to buffer |
| 205 |
return 0; |
| 206 |
} |
| 207 |
|
| 208 |
int wipe_EndScreen(void) |
| 209 |
{ |
| 210 |
if(dsda_PendingSkipWipe() || !wasWiped) return 0;//e6y |
| 211 |
wasWiped = false;//e6y |
| 212 |
|
| 213 |
if (V_IsOpenGLMode()) |
| 214 |
{ |
| 215 |
gld_wipe_EndScreen(); |
| 216 |
return 0; |
| 217 |
} |
| 218 |
|
| 219 |
wipe_scr_end.width = SCREENWIDTH; |
| 220 |
wipe_scr_end.height = SCREENHEIGHT; |
| 221 |
wipe_scr_end.pitch = screens[0].pitch; |
| 222 |
|
| 223 |
//e6y: fixed slowdown at 1024x768 on some systems |
| 224 |
if (!(wipe_scr_end.pitch % 1024)) |
| 225 |
wipe_scr_end.pitch += 32; |
| 226 |
|
| 227 |
wipe_scr_end.not_on_heap = false; |
| 228 |
V_AllocScreen(&wipe_scr_end); |
| 229 |
screens[DEST_SCR] = wipe_scr_end; |
| 230 |
V_CopyScreen(0, DEST_SCR); // Copy end screen to buffer |
| 231 |
V_CopyScreen(SRC_SCR, 0); // restore start screen |
| 232 |
return 0; |
| 233 |
} |
| 234 |
|
| 235 |
// killough 3/5/98: reformatted and cleaned up |
| 236 |
int wipe_ScreenWipe(int ticks) |
| 237 |
{ |
| 238 |
static dboolean go; // when zero, stop the wipe |
| 239 |
|
| 240 |
if (!dsda_RenderWipeScreen()) |
| 241 |
return 0;//e6y |
| 242 |
|
| 243 |
if (!go) // initial stuff |
| 244 |
{ |
| 245 |
go = 1; |
| 246 |
wipe_scr = screens[0]; |
| 247 |
wipe_initMelt(ticks); |
| 248 |
} |
| 249 |
|
| 250 |
// do a piece of wipe-in |
| 251 |
if (wipe_doMelt(ticks)) // final stuff |
| 252 |
{ |
| 253 |
wipe_exitMelt(ticks); |
| 254 |
go = 0; |
| 255 |
} |
| 256 |
return !go; |
| 257 |
} |