SLUDGE: Remove global variable fadeMode and move transition functions to GraphicsManager

This commit is contained in:
Simei Yin 2018-04-29 09:52:48 +02:00
parent 8b91fe536c
commit 4b271c6e7c
9 changed files with 18 additions and 53 deletions

View file

@ -422,6 +422,7 @@ void GraphicsManager::saveLightMap(Common::WriteStream *stream) {
stream->writeByte(0); stream->writeByte(0);
} }
stream->writeByte(_lightMapMode); stream->writeByte(_lightMapMode);
stream->writeByte(_fadeMode);
} }
bool GraphicsManager::loadLightMap(int ssgVersion, Common::SeekableReadStream *stream) { bool GraphicsManager::loadLightMap(int ssgVersion, Common::SeekableReadStream *stream) {
@ -434,6 +435,8 @@ bool GraphicsManager::loadLightMap(int ssgVersion, Common::SeekableReadStream *s
_lightMapMode = stream->readByte() % 3; _lightMapMode = stream->readByte() % 3;
} }
_fadeMode = stream->readByte();
return true; return true;
} }

View file

@ -65,8 +65,6 @@ extern int numBIFNames, numUserFunc;
extern Common::String *allUserFunc; extern Common::String *allUserFunc;
extern Common::String *allBIFNames; 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 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 -1, 0, 0, -1, -1, 1, 1, 1, 1, 4, 1, 1, 2, 1,// FOCUS->REMOVEREGION
2, 2, 0, 0, 2, // ANIMATE->SETSCALE 2, 2, 0, 0, 2, // ANIMATE->SETSCALE
@ -2202,7 +2200,7 @@ builtIn(transitionMode) {
int n; int n;
if (!getValueType(n, SVT_INT, fun->stack->thisVar)) if (!getValueType(n, SVT_INT, fun->stack->thisVar))
return BR_ERROR; return BR_ERROR;
fadeMode = n; g_sludge->_gfxMan->setFadeMode(n);
trimStack(fun->stack); trimStack(fun->stack);
setVariable(fun->reg, SVT_INT, 1); setVariable(fun->reg, SVT_INT, 1);
return BR_CONTINUE; return BR_CONTINUE;

View file

@ -87,6 +87,11 @@ void GraphicsManager::init() {
// Thumbnail // Thumbnail
_thumbWidth = 0; _thumbWidth = 0;
_thumbHeight = 0; _thumbHeight = 0;
// Transition
resetRandW();
_brightnessLevel = 255;
_fadeMode = 2;
} }
void GraphicsManager::kill() { void GraphicsManager::kill() {
@ -161,6 +166,8 @@ bool GraphicsManager::initGfx() {
void GraphicsManager::display() { void GraphicsManager::display() {
g_system->copyRectToScreen((byte *)_renderSurface.getPixels(), _renderSurface.pitch, 0, 0, _renderSurface.w, _renderSurface.h); g_system->copyRectToScreen((byte *)_renderSurface.getPixels(), _renderSurface.pitch, 0, 0, _renderSurface.w, _renderSurface.h);
g_system->updateScreen(); g_system->updateScreen();
if (_brightnessLevel < 255)
fixBrightness();
} }
void GraphicsManager::clear() { void GraphicsManager::clear() {

View file

@ -172,6 +172,9 @@ public:
// Transition // Transition
void setBrightnessLevel(int brightnessLevel); void setBrightnessLevel(int brightnessLevel);
void setFadeMode(int fadeMode) { _fadeMode = fadeMode; };
void fixBrightness();
void resetRandW();
private: private:
SludgeEngine *_vm; SludgeEngine *_vm;
@ -230,6 +233,7 @@ private:
// Transition // Transition
byte _brightnessLevel; byte _brightnessLevel;
byte _fadeMode;
}; };
} // End of namespace Sludge } // End of namespace Sludge

View file

@ -61,7 +61,6 @@ extern int numGlobals; // In sludger.cpp
extern Variable *globalVars; // In sludger.cpp extern Variable *globalVars; // In sludger.cpp
extern Floor *currentFloor; // In floor.cpp extern Floor *currentFloor; // In floor.cpp
extern FILETIME fileTime; // In sludger.cpp extern FILETIME fileTime; // In sludger.cpp
extern byte fadeMode; // In transition.cpp
extern bool allowAnyFilename; extern bool allowAnyFilename;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -403,8 +402,6 @@ bool saveGame(const Common::String &fname) {
g_sludge->_gfxMan->saveZBuffer(fp); g_sludge->_gfxMan->saveZBuffer(fp);
g_sludge->_gfxMan->saveLightMap(fp); g_sludge->_gfxMan->saveLightMap(fp);
fp->writeByte(fadeMode);
g_sludge->_speechMan->save(fp); g_sludge->_speechMan->save(fp);
saveStatusBars(fp); saveStatusBars(fp);
g_sludge->_soundMan->saveSounds(fp); g_sludge->_soundMan->saveSounds(fp);
@ -539,7 +536,6 @@ bool loadGame(const Common::String &fname) {
return false; return false;
} }
fadeMode = fp->readByte();
g_sludge->_speechMan->load(fp); g_sludge->_speechMan->load(fp);
loadStatusBars(fp); loadStatusBars(fp);
g_sludge->_soundMan->loadSounds(fp); g_sludge->_soundMan->loadSounds(fp);

View file

@ -39,7 +39,6 @@
#include "sludge/sludge.h" #include "sludge/sludge.h"
#include "sludge/sludger.h" #include "sludge/sludger.h"
#include "sludge/speech.h" #include "sludge/speech.h"
#include "sludge/transition.h"
#include "sludge/timing.h" #include "sludge/timing.h"
namespace Sludge { namespace Sludge {

View file

@ -49,7 +49,6 @@
#include "sludge/sludge.h" #include "sludge/sludge.h"
#include "sludge/sludger.h" #include "sludge/sludger.h"
#include "sludge/speech.h" #include "sludge/speech.h"
#include "sludge/transition.h"
#include "sludge/variable.h" #include "sludge/variable.h"
#include "sludge/version.h" #include "sludge/version.h"
#include "sludge/zbuffer.h" #include "sludge/zbuffer.h"
@ -69,8 +68,6 @@ int selectedLanguage = 0;
int gameVersion; int gameVersion;
FILETIME fileTime; FILETIME fileTime;
byte brightnessLevel = 255;
extern LoadedFunction *saverFunc; extern LoadedFunction *saverFunc;
LoadedFunction *allRunningFunctions = NULL; LoadedFunction *allRunningFunctions = NULL;
@ -83,7 +80,6 @@ extern Variable *launchResult;
extern int lastFramesPerSecond; extern int lastFramesPerSecond;
extern bool allowAnyFilename; extern bool allowAnyFilename;
extern byte fadeMode;
const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO", const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO",
"SET_GLOBAL", "SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL", "PLUS", "MINUS", "SET_GLOBAL", "SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL", "PLUS", "MINUS",
@ -152,7 +148,6 @@ void initSludge() {
g_sludge->_objMan->init(); g_sludge->_objMan->init();
g_sludge->_speechMan->init(); g_sludge->_speechMan->init();
initStatusBar(); initStatusBar();
resetRandW();
g_sludge->_evtMan->init(); g_sludge->_evtMan->init();
g_sludge->_txtMan->init(); g_sludge->_txtMan->init();
g_sludge->_cursorMan->init(); g_sludge->_cursorMan->init();
@ -173,8 +168,6 @@ void initSludge() {
noStack = nullptr; noStack = nullptr;
numBIFNames = numUserFunc = 0; numBIFNames = numUserFunc = 0;
allUserFunc = allBIFNames = nullptr; allUserFunc = allBIFNames = nullptr;
brightnessLevel = 255;
fadeMode = 2;
} }
void killSludge() { void killSludge() {
@ -340,7 +333,6 @@ void sludgeDisplay() {
drawStatusBar(); drawStatusBar();
g_sludge->_cursorMan->displayCursor(); g_sludge->_cursorMan->displayCursor();
g_sludge->_gfxMan->display(); g_sludge->_gfxMan->display();
if (brightnessLevel < 255) fixBrightness();// This is for transitionLevel special effects
} }
void pauseFunction(LoadedFunction *fun) { void pauseFunction(LoadedFunction *fun) {

View file

@ -29,8 +29,6 @@ namespace Sludge {
extern float snapTexW, snapTexH; extern float snapTexW, snapTexH;
byte fadeMode = 2;
void GraphicsManager::setBrightnessLevel(int brightnessLevel) void GraphicsManager::setBrightnessLevel(int brightnessLevel)
{ {
if (brightnessLevel < 0) if (brightnessLevel < 0)
@ -151,7 +149,7 @@ void transitionSnapshotBox() {
uint32 randbuffer[KK][2]; // history buffer uint32 randbuffer[KK][2]; // history buffer
int p1, p2; int p1, p2;
void resetRandW() { void GraphicsManager::resetRandW() {
int32 seed = 12345; int32 seed = 12345;
for (int i = 0; i < KK; i++) { for (int i = 0; i < KK; i++) {
@ -382,8 +380,8 @@ void transitionBlinds() {
//---------------------------------------------------- //----------------------------------------------------
void fixBrightness() { void GraphicsManager::fixBrightness() {
switch (fadeMode) { switch (_fadeMode) {
case 0: case 0:
transitionFader(); transitionFader();
break; break;

View file

@ -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