aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-09-14 14:00:12 -0500
committerColin Snover2016-09-29 19:39:16 -0500
commitb5d0fffb8b111c5d8154a37ba9a0d7b18866c7dd (patch)
tree12bba6c41bc031c570c2777ad6c1c0c0f7d4b688
parenta96dc1a7b879994ab5111ed223e9831ea81054b9 (diff)
downloadscummvm-rg350-b5d0fffb8b111c5d8154a37ba9a0d7b18866c7dd.tar.gz
scummvm-rg350-b5d0fffb8b111c5d8154a37ba9a0d7b18866c7dd.tar.bz2
scummvm-rg350-b5d0fffb8b111c5d8154a37ba9a0d7b18866c7dd.zip
SCI: Replace magic numbers for globals with named constants
-rw-r--r--engines/sci/engine/kscripts.cpp4
-rw-r--r--engines/sci/engine/state.cpp4
-rw-r--r--engines/sci/engine/vm.cpp6
-rw-r--r--engines/sci/engine/vm.h15
-rw-r--r--engines/sci/graphics/animate.cpp4
-rw-r--r--engines/sci/graphics/frameout.cpp4
-rw-r--r--engines/sci/sci.cpp10
7 files changed, 31 insertions, 16 deletions
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index 6fd130bceb..749af67580 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -238,8 +238,8 @@ reg_t kScriptID(EngineState *s, int argc, reg_t *argv) {
// initialized to 0, whereas it's 6 in other versions. Thus, we assign it
// to 6 here, fixing the speed of the introduction. Refer to bug #3102071.
if (g_sci->getGameId() == GID_PQ2 && script == 200 &&
- s->variables[VAR_GLOBAL][3].isNull()) {
- s->variables[VAR_GLOBAL][3] = make_reg(0, 6);
+ s->variables[VAR_GLOBAL][kSpeed].isNull()) {
+ s->variables[VAR_GLOBAL][kSpeed] = make_reg(0, 6);
}
return make_reg(scriptSeg, address);
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index d253d316ca..5d4eba7c95 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -159,11 +159,11 @@ void EngineState::initGlobals() {
}
uint16 EngineState::currentRoomNumber() const {
- return variables[VAR_GLOBAL][13].toUint16();
+ return variables[VAR_GLOBAL][kNewRoomNo].toUint16();
}
void EngineState::setRoomNumber(uint16 roomNumber) {
- variables[VAR_GLOBAL][13] = make_reg(0, roomNumber);
+ variables[VAR_GLOBAL][kNewRoomNo] = make_reg(0, roomNumber);
}
void EngineState::shrinkStackToBase() {
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 72e340dd5c..7c7f75c180 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -179,7 +179,7 @@ static void write_var(EngineState *s, int type, int index, reg_t value) {
// stopGroop object, which points to ego, to the new ego object. If this is not
// done, ego's movement will not be updated properly, so the result is
// unpredictable (for example in LSL5, Patti spins around instead of walking).
- if (index == 0 && type == VAR_GLOBAL && getSciVersion() > SCI_VERSION_0_EARLY) { // global 0 is ego
+ if (index == kEgo && type == VAR_GLOBAL && getSciVersion() > SCI_VERSION_0_EARLY) {
reg_t stopGroopPos = s->_segMan->findObjectByName("stopGroop");
if (!stopGroopPos.isNull()) { // does the game have a stopGroop object?
// Find the "client" member variable of the stopGroop object, and update it
@@ -200,9 +200,9 @@ static void write_var(EngineState *s, int type, int index, reg_t value) {
s->variables[type][index] = value;
- if (type == VAR_GLOBAL && index == 90) {
+ if (type == VAR_GLOBAL && index == kMessageType) {
// The game is trying to change its speech/subtitle settings
- if (!g_sci->getEngineState()->_syncedAudioOptions || s->variables[VAR_GLOBAL][4] == TRUE_REG) {
+ if (!g_sci->getEngineState()->_syncedAudioOptions || s->variables[VAR_GLOBAL][kQuit] == TRUE_REG) {
// ScummVM audio options haven't been applied yet, so apply them.
// We also force the ScummVM audio options when loading a game from
// the launcher.
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index c41060dc32..e127706d58 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -136,6 +136,21 @@ enum {
VAR_PARAM = 3
};
+enum GlobalVar {
+ kEgo = 0,
+ kGame = 1,
+ kCurrentRoom = 2,
+ kSpeed = 3, // SCI16
+ kDefaultPlane = 3, // SCI32
+ kQuit = 4,
+ kPlanes = 10, // SCI32
+ kCurrentRoomNo = 11,
+ kPreviousRoomNo = 12,
+ kNewRoomNo = 13,
+ kFastCast = 84, // SCI16
+ kMessageType = 90
+};
+
/** Number of kernel calls in between gcs; should be < 50000 */
enum {
GC_INTERVAL = 0x8000
diff --git a/engines/sci/graphics/animate.cpp b/engines/sci/graphics/animate.cpp
index 98278397b7..e593484d8b 100644
--- a/engines/sci/graphics/animate.cpp
+++ b/engines/sci/graphics/animate.cpp
@@ -145,7 +145,7 @@ bool GfxAnimate::invoke(List *list, int argc, reg_t *argv) {
if (_fastCastEnabled) {
// Check if the game has a fastCast object set
// if we don't abort kAnimate processing, at least in kq5 there will be animation cels drawn into speech boxes.
- if (!_s->variables[VAR_GLOBAL][84].isNull()) {
+ if (!_s->variables[VAR_GLOBAL][kFastCast].isNull()) {
// This normally points to an object called "fastCast",
// but for example in Eco Quest 1 it may also point to an object called "EventHandler" (see bug #5170)
// Original SCI only checked, if this global was not 0.
@@ -338,7 +338,7 @@ void GfxAnimate::applyGlobalScaling(AnimateList::iterator entry, GfxView *view)
int16 maxScale = readSelectorValue(_s->_segMan, entry->object, SELECTOR(maxScale));
int16 celHeight = view->getHeight(entry->loopNo, entry->celNo);
int16 maxCelHeight = (maxScale * celHeight) >> 7;
- reg_t globalVar2 = _s->variables[VAR_GLOBAL][2]; // current room object
+ reg_t globalVar2 = _s->variables[VAR_GLOBAL][kCurrentRoom]; // current room object
int16 vanishingY = readSelectorValue(_s->_segMan, globalVar2, SELECTOR(vanishingY));
int16 fixedPortY = _ports->getPort()->rect.bottom - vanishingY;
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 7d38d01f02..7410bdabac 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -141,7 +141,7 @@ void GfxFrameout::syncWithScripts(bool addElements) {
return;
// Get planes list object
- reg_t planesListObject = engineState->variables[VAR_GLOBAL][10];
+ reg_t planesListObject = engineState->variables[VAR_GLOBAL][kPlanes];
reg_t planesListElements = readSelector(segMan, planesListObject, SELECTOR(elements));
List *planesList = segMan->lookupList(planesListElements);
@@ -565,7 +565,7 @@ void GfxFrameout::palMorphFrameOut(const int8 *styleRanges, PlaneShowStyle *show
Palette sourcePalette(_palette->getNextPalette());
alterVmap(sourcePalette, sourcePalette, -1, styleRanges);
- int16 prevRoom = g_sci->getEngineState()->variables[VAR_GLOBAL][12].toSint16();
+ int16 prevRoom = g_sci->getEngineState()->variables[VAR_GLOBAL][kPreviousRoomNo].toSint16();
Common::Rect rect(_currentBuffer.screenWidth, _currentBuffer.screenHeight);
_showList.add(rect);
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index eb314a9208..bdfb6ccc9c 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -1088,9 +1088,9 @@ void SciEngine::syncIngameAudioOptions() {
if (useGlobal90) {
if (subtitlesOn && !speechOn) {
- _gamestate->variables[VAR_GLOBAL][90] = make_reg(0, 1); // subtitles
+ _gamestate->variables[VAR_GLOBAL][kMessageType] = make_reg(0, 1); // subtitles
} else if (!subtitlesOn && speechOn) {
- _gamestate->variables[VAR_GLOBAL][90] = make_reg(0, 2); // speech
+ _gamestate->variables[VAR_GLOBAL][kMessageType] = make_reg(0, 2); // speech
} else if (subtitlesOn && speechOn) {
// Is it a game that supports simultaneous speech and subtitles?
switch (_gameId) {
@@ -1111,11 +1111,11 @@ void SciEngine::syncIngameAudioOptions() {
// Phantasmagoria does not support simultaneous speech + subtitles
// Mixed Up Mother Goose Deluxe does not support simultaneous speech + subtitles
#endif // ENABLE_SCI32
- _gamestate->variables[VAR_GLOBAL][90] = make_reg(0, 3); // speech + subtitles
+ _gamestate->variables[VAR_GLOBAL][kMessageType] = make_reg(0, 3); // speech + subtitles
break;
default:
// Game does not support speech and subtitles, set it to speech
- _gamestate->variables[VAR_GLOBAL][90] = make_reg(0, 2); // speech
+ _gamestate->variables[VAR_GLOBAL][kMessageType] = make_reg(0, 2); // speech
}
}
}
@@ -1126,7 +1126,7 @@ void SciEngine::updateScummVMAudioOptions() {
// Update ScummVM's speech/subtitles settings for SCI1.1 CD games,
// depending on the in-game settings
if (isCD() && getSciVersion() == SCI_VERSION_1_1) {
- uint16 ingameSetting = _gamestate->variables[VAR_GLOBAL][90].getOffset();
+ uint16 ingameSetting = _gamestate->variables[VAR_GLOBAL][kMessageType].getOffset();
switch (ingameSetting) {
case 1: