1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
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
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 * Mission begin melt/wipe screen special effect.
30 *-----------------------------------------------------------------------------
33 #include "rockmacros.h"
44 // SCREEN WIPE PACKAGE
47 // CPhipps - macros for the source and destination screens
51 static byte
*wipe_scr_start
;
52 static byte
*wipe_scr_end
;
53 static byte
*wipe_scr
;
55 static void wipe_shittyColMajorXform(short *array
, int width
, int height
)
57 short *dest
= Z_Malloc(width
*height
*sizeof(short), PU_STATIC
, 0);
62 dest
[x
*height
+y
] = array
[y
*width
+x
];
63 memcpy(array
, dest
, width
*height
*sizeof(short));
69 static int wipe_initMelt(int width
, int height
, int ticks
)
74 // copy start screen to main screen
75 memcpy(wipe_scr
, wipe_scr_start
, width
*height
);
77 // makes this wipe faster (in theory)
78 // to have stuff in column-major format
79 wipe_shittyColMajorXform((short*)wipe_scr_start
, width
/2, height
);
80 wipe_shittyColMajorXform((short*)wipe_scr_end
, width
/2, height
);
82 // setup initial column positions (y<0 => not ready to scroll yet)
83 y
= (int *) malloc(width
*sizeof(int));
84 y
[0] = -(M_Random()%16);
87 int r
= (M_Random()%3) - 1;
98 static int wipe_doMelt(int width
, int height
, int ticks
)
106 for (i
=0;i
<width
;i
++)
118 dy
= (y
[i
] < 16) ? y
[i
]+1 : 8;
119 if (y
[i
]+dy
>= height
)
121 s
= &((short *)wipe_scr_end
)[i
*height
+y
[i
]];
122 d
= &((short *)wipe_scr
)[y
[i
]*width
+i
];
130 s
= &((short *)wipe_scr_start
)[i
*height
];
131 d
= &((short *)wipe_scr
)[y
[i
]*width
+i
];
133 for (j
=height
-y
[i
];j
;j
--)
143 // CPhipps - modified to allocate and deallocate d_screens[2 to 3] as needed, saving memory
145 static int wipe_exitMelt(int width
, int height
, int ticks
)
151 free(wipe_scr_start
);
155 wipe_scr_start
= wipe_scr_end
= d_screens
[SRC_SCR
] = d_screens
[DEST_SCR
] = NULL
;
159 int wipe_StartScreen(int x
, int y
, int width
, int height
)
161 wipe_scr_start
= d_screens
[SRC_SCR
] = malloc(SCREENWIDTH
* SCREENHEIGHT
);
162 V_CopyRect(x
, y
, 0, width
, height
, x
, y
, SRC_SCR
, VPT_NONE
); // Copy start screen to buffer
166 int wipe_EndScreen(int x
, int y
, int width
, int height
)
168 wipe_scr_end
= d_screens
[DEST_SCR
] = malloc(SCREENWIDTH
* SCREENHEIGHT
);
169 V_CopyRect(x
, y
, 0, width
, height
, x
, y
, DEST_SCR
, VPT_NONE
); // Copy end screen to buffer
170 V_CopyRect(x
, y
, SRC_SCR
, width
, height
, x
, y
, 0 , VPT_NONE
); // restore start screen
174 // killough 3/5/98: reformatted and cleaned up
175 int wipe_ScreenWipe(int x
, int y
, int width
, int height
, int ticks
)
179 static boolean go
; // when zero, stop the wipe
180 if (!go
) // initial stuff
183 wipe_scr
= d_screens
[0];
184 wipe_initMelt(width
, height
, ticks
);
186 V_MarkRect(0, 0, width
, height
); // do a piece of wipe-in
187 if (wipe_doMelt(width
, height
, ticks
)) // final stuff
189 wipe_exitMelt(width
, height
, ticks
);