From 4b271c6e7cb70313c498cbf6b9f888f95b77d918 Mon Sep 17 00:00:00 2001 From: Simei Yin Date: Sun, 29 Apr 2018 09:52:48 +0200 Subject: SLUDGE: Remove global variable fadeMode and move transition functions to GraphicsManager --- engines/sludge/backdrop.cpp | 3 +++ engines/sludge/builtin.cpp | 4 +--- engines/sludge/graphics.cpp | 7 +++++++ engines/sludge/graphics.h | 4 ++++ engines/sludge/loadsave.cpp | 4 ---- engines/sludge/main_loop.cpp | 1 - engines/sludge/sludger.cpp | 8 -------- engines/sludge/transition.cpp | 8 +++----- engines/sludge/transition.h | 32 -------------------------------- 9 files changed, 18 insertions(+), 53 deletions(-) delete mode 100644 engines/sludge/transition.h (limited to 'engines') diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp index 1c618c7da1..04f484715a 100644 --- a/engines/sludge/backdrop.cpp +++ b/engines/sludge/backdrop.cpp @@ -422,6 +422,7 @@ void GraphicsManager::saveLightMap(Common::WriteStream *stream) { stream->writeByte(0); } stream->writeByte(_lightMapMode); + stream->writeByte(_fadeMode); } bool GraphicsManager::loadLightMap(int ssgVersion, Common::SeekableReadStream *stream) { @@ -434,6 +435,8 @@ bool GraphicsManager::loadLightMap(int ssgVersion, Common::SeekableReadStream *s _lightMapMode = stream->readByte() % 3; } + _fadeMode = stream->readByte(); + return true; } diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp index 376849a7f9..4ea9caddde 100644 --- a/engines/sludge/builtin.cpp +++ b/engines/sludge/builtin.cpp @@ -65,8 +65,6 @@ extern int numBIFNames, numUserFunc; extern Common::String *allUserFunc; extern Common::String *allBIFNames; -extern byte fadeMode; - int paramNum[] = { -1, 0, 1, 1, -1, -1, 1, 3, 4, 1, 0, 0, 8, -1, // SAY->MOVEMOUSE -1, 0, 0, -1, -1, 1, 1, 1, 1, 4, 1, 1, 2, 1,// FOCUS->REMOVEREGION 2, 2, 0, 0, 2, // ANIMATE->SETSCALE @@ -2202,7 +2200,7 @@ builtIn(transitionMode) { int n; if (!getValueType(n, SVT_INT, fun->stack->thisVar)) return BR_ERROR; - fadeMode = n; + g_sludge->_gfxMan->setFadeMode(n); trimStack(fun->stack); setVariable(fun->reg, SVT_INT, 1); return BR_CONTINUE; diff --git a/engines/sludge/graphics.cpp b/engines/sludge/graphics.cpp index 580124f513..72301b3475 100644 --- a/engines/sludge/graphics.cpp +++ b/engines/sludge/graphics.cpp @@ -87,6 +87,11 @@ void GraphicsManager::init() { // Thumbnail _thumbWidth = 0; _thumbHeight = 0; + + // Transition + resetRandW(); + _brightnessLevel = 255; + _fadeMode = 2; } void GraphicsManager::kill() { @@ -161,6 +166,8 @@ bool GraphicsManager::initGfx() { void GraphicsManager::display() { g_system->copyRectToScreen((byte *)_renderSurface.getPixels(), _renderSurface.pitch, 0, 0, _renderSurface.w, _renderSurface.h); g_system->updateScreen(); + if (_brightnessLevel < 255) + fixBrightness(); } void GraphicsManager::clear() { diff --git a/engines/sludge/graphics.h b/engines/sludge/graphics.h index f7ed7d0026..8bc47cdab4 100644 --- a/engines/sludge/graphics.h +++ b/engines/sludge/graphics.h @@ -172,6 +172,9 @@ public: // Transition void setBrightnessLevel(int brightnessLevel); + void setFadeMode(int fadeMode) { _fadeMode = fadeMode; }; + void fixBrightness(); + void resetRandW(); private: SludgeEngine *_vm; @@ -230,6 +233,7 @@ private: // Transition byte _brightnessLevel; + byte _fadeMode; }; } // End of namespace Sludge diff --git a/engines/sludge/loadsave.cpp b/engines/sludge/loadsave.cpp index a962019226..f1dfb6cf42 100644 --- a/engines/sludge/loadsave.cpp +++ b/engines/sludge/loadsave.cpp @@ -61,7 +61,6 @@ extern int numGlobals; // In sludger.cpp extern Variable *globalVars; // In sludger.cpp extern Floor *currentFloor; // In floor.cpp extern FILETIME fileTime; // In sludger.cpp -extern byte fadeMode; // In transition.cpp extern bool allowAnyFilename; //---------------------------------------------------------------------- @@ -403,8 +402,6 @@ bool saveGame(const Common::String &fname) { g_sludge->_gfxMan->saveZBuffer(fp); g_sludge->_gfxMan->saveLightMap(fp); - fp->writeByte(fadeMode); - g_sludge->_speechMan->save(fp); saveStatusBars(fp); g_sludge->_soundMan->saveSounds(fp); @@ -539,7 +536,6 @@ bool loadGame(const Common::String &fname) { return false; } - fadeMode = fp->readByte(); g_sludge->_speechMan->load(fp); loadStatusBars(fp); g_sludge->_soundMan->loadSounds(fp); diff --git a/engines/sludge/main_loop.cpp b/engines/sludge/main_loop.cpp index eac8610cc7..6341c3ef21 100644 --- a/engines/sludge/main_loop.cpp +++ b/engines/sludge/main_loop.cpp @@ -39,7 +39,6 @@ #include "sludge/sludge.h" #include "sludge/sludger.h" #include "sludge/speech.h" -#include "sludge/transition.h" #include "sludge/timing.h" namespace Sludge { diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp index 64727dfeb0..e363ab6634 100644 --- a/engines/sludge/sludger.cpp +++ b/engines/sludge/sludger.cpp @@ -49,7 +49,6 @@ #include "sludge/sludge.h" #include "sludge/sludger.h" #include "sludge/speech.h" -#include "sludge/transition.h" #include "sludge/variable.h" #include "sludge/version.h" #include "sludge/zbuffer.h" @@ -69,8 +68,6 @@ int selectedLanguage = 0; int gameVersion; FILETIME fileTime; -byte brightnessLevel = 255; - extern LoadedFunction *saverFunc; LoadedFunction *allRunningFunctions = NULL; @@ -83,7 +80,6 @@ extern Variable *launchResult; extern int lastFramesPerSecond; extern bool allowAnyFilename; -extern byte fadeMode; const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO", "SET_GLOBAL", "SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL", "PLUS", "MINUS", @@ -152,7 +148,6 @@ void initSludge() { g_sludge->_objMan->init(); g_sludge->_speechMan->init(); initStatusBar(); - resetRandW(); g_sludge->_evtMan->init(); g_sludge->_txtMan->init(); g_sludge->_cursorMan->init(); @@ -173,8 +168,6 @@ void initSludge() { noStack = nullptr; numBIFNames = numUserFunc = 0; allUserFunc = allBIFNames = nullptr; - brightnessLevel = 255; - fadeMode = 2; } void killSludge() { @@ -340,7 +333,6 @@ void sludgeDisplay() { drawStatusBar(); g_sludge->_cursorMan->displayCursor(); g_sludge->_gfxMan->display(); - if (brightnessLevel < 255) fixBrightness();// This is for transitionLevel special effects } void pauseFunction(LoadedFunction *fun) { diff --git a/engines/sludge/transition.cpp b/engines/sludge/transition.cpp index ddefbe9861..35f650e8e4 100644 --- a/engines/sludge/transition.cpp +++ b/engines/sludge/transition.cpp @@ -29,8 +29,6 @@ namespace Sludge { extern float snapTexW, snapTexH; -byte fadeMode = 2; - void GraphicsManager::setBrightnessLevel(int brightnessLevel) { if (brightnessLevel < 0) @@ -151,7 +149,7 @@ void transitionSnapshotBox() { uint32 randbuffer[KK][2]; // history buffer int p1, p2; -void resetRandW() { +void GraphicsManager::resetRandW() { int32 seed = 12345; for (int i = 0; i < KK; i++) { @@ -382,8 +380,8 @@ void transitionBlinds() { //---------------------------------------------------- -void fixBrightness() { - switch (fadeMode) { +void GraphicsManager::fixBrightness() { + switch (_fadeMode) { case 0: transitionFader(); break; diff --git a/engines/sludge/transition.h b/engines/sludge/transition.h deleted file mode 100644 index 5ce556870d..0000000000 --- a/engines/sludge/transition.h +++ /dev/null @@ -1,32 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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 2 - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ -#ifndef SLUDGE_TRANSITION_H -#define SLUDGE_TRANSITION_H - -namespace Sludge { - -void fixBrightness(); -void resetRandW(); - -} // End of namespace Sludge - -#endif -- cgit v1.2.3