diff --git a/src/rendering/2d/f_wipe.cpp b/src/rendering/2d/f_wipe.cpp index ca0c86ae0..2dd40891f 100644 --- a/src/rendering/2d/f_wipe.cpp +++ b/src/rendering/2d/f_wipe.cpp @@ -1,27 +1,37 @@ -//----------------------------------------------------------------------------- -// -// Copyright 1993-1996 id Software -// Copyright 1999-2016 Randy Heit -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//----------------------------------------------------------------------------- -// -// DESCRIPTION: -// Mission begin melt/wipe screen special effect. -// -//----------------------------------------------------------------------------- +/* +** wipe.cpp +** Screen wipe implementation +** +**--------------------------------------------------------------------------- +** Copyright 1998-2016 Randy Heit +** Copyright 2005-2022 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +*/ #include "v_video.h" #include "m_random.h" @@ -252,15 +262,10 @@ bool Wiper_Crossfade::Run(int ticks) Wiper_Melt::Wiper_Melt() { - int i, r; - - // setup initial column positions - // (y<0 => not ready to scroll yet) y[0] = -(M_Random() & 15); - for (i = 1; i < WIDTH; ++i) + for (int i = 1; i < WIDTH; ++i) { - r = (M_Random()%3) - 1; - y[i] = clamp(y[i-1] + r, -15, 0); + y[i] = clamp(y[i-1] + (M_Random() % 3) - 1, -15, 0); } } @@ -283,15 +288,14 @@ bool Wiper_Melt::Run(int ticks) done = true; for (int i = 0; i < WIDTH; i++) { - if (y[i] < 0) + if (y[i] < HEIGHT) { - y[i]++; - done = false; - } - else if (y[i] < HEIGHT) - { - int dy = (y[i] < 16) ? y[i] + 1 : 8; - y[i] = min(y[i] + dy, HEIGHT); + if (y[i] < 0) + y[i]++; + else if (y[i] < 16) + y[i] += y[i] + 1; + else + y[i] = min(y[i] + 8, HEIGHT); done = false; } if (ticks == 0) @@ -308,7 +312,6 @@ bool Wiper_Melt::Run(int ticks) } rect; // Only draw for the final tick. - // No need for optimization. Wipes won't ever be drawn with anything else. int w = startScreen->GetTexelWidth(); int h = startScreen->GetTexelHeight(); diff --git a/src/rendering/2d/f_wipe.h b/src/rendering/2d/f_wipe.h index 81452b8d0..b87af09c2 100644 --- a/src/rendering/2d/f_wipe.h +++ b/src/rendering/2d/f_wipe.h @@ -1,32 +1,8 @@ -//----------------------------------------------------------------------------- -// -// Copyright 1993-1996 id Software -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//----------------------------------------------------------------------------- -// -// DESCRIPTION: -// Mission start screen wipe/melt, special effects. -// -//----------------------------------------------------------------------------- - - #ifndef __F_WIPE_H__ #define __F_WIPE_H__ #include "stdint.h" +#include class FTexture; int wipe_CalcBurn(uint8_t *buffer, int width, int height, int density);