diff options
author | Max Horn | 2003-05-08 15:48:50 +0000 |
---|---|---|
committer | Max Horn | 2003-05-08 15:48:50 +0000 |
commit | 98881c3a6a513c27a06e596c29e0b40b355844f6 (patch) | |
tree | a6ddbd3a2e3aa483bae3d82e63fa2ccb6fc40f13 /scumm | |
parent | 6ab104cc3ca433b672318b3e9bde26f7e882940c (diff) | |
download | scummvm-rg350-98881c3a6a513c27a06e596c29e0b40b355844f6.tar.gz scummvm-rg350-98881c3a6a513c27a06e596c29e0b40b355844f6.tar.bz2 scummvm-rg350-98881c3a6a513c27a06e596c29e0b40b355844f6.zip |
init all VAR_* variables to 0xFF; replaced access to _vars in the form _vars[VAR_*] by VARS(VAR_*) which performs a validity checK; renamed _vars to _scummVars to make sure I updated all places; fixed two places where V6 and newer games would access V5 vars (but there are still some left, it seems); checked VAR access for now only generates a warning
svn-id: r7393
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/actor.cpp | 20 | ||||
-rw-r--r-- | scumm/akos.cpp | 2 | ||||
-rw-r--r-- | scumm/costume.cpp | 4 | ||||
-rw-r--r-- | scumm/debug.cpp | 2 | ||||
-rw-r--r-- | scumm/debugger.cpp | 20 | ||||
-rw-r--r-- | scumm/dialogs.cpp | 4 | ||||
-rw-r--r-- | scumm/gfx.cpp | 146 | ||||
-rw-r--r-- | scumm/intern.h | 12 | ||||
-rw-r--r-- | scumm/object.cpp | 2 | ||||
-rw-r--r-- | scumm/resource.cpp | 12 | ||||
-rw-r--r-- | scumm/saveload.cpp | 14 | ||||
-rw-r--r-- | scumm/script.cpp | 60 | ||||
-rw-r--r-- | scumm/script_v2.cpp | 28 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 46 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 54 | ||||
-rw-r--r-- | scumm/script_v8.cpp | 14 | ||||
-rw-r--r-- | scumm/scumm.h | 12 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 270 | ||||
-rw-r--r-- | scumm/sound.cpp | 30 | ||||
-rw-r--r-- | scumm/string.cpp | 22 | ||||
-rw-r--r-- | scumm/vars.cpp | 62 |
21 files changed, 486 insertions, 350 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 15027e3093..812bb5025e 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -549,7 +549,7 @@ void Actor::setDirection(int direction) { } void Actor::putActor(int dstX, int dstY, byte newRoom) { - if (visible && _vm->_currentRoom != newRoom && _vm->_vars[_vm->VAR_TALK_ACTOR] == number) { + if (visible && _vm->_currentRoom != newRoom && _vm->VAR(_vm->VAR_TALK_ACTOR) == number) { _vm->clearMsgQueue(); } @@ -559,7 +559,7 @@ void Actor::putActor(int dstX, int dstY, byte newRoom) { needRedraw = true; needBgReset = true; - if (_vm->_vars[_vm->VAR_EGO] == number) { + if (_vm->VAR(_vm->VAR_EGO) == number) { _vm->_egoPositioned = true; } @@ -788,14 +788,14 @@ void Scumm::stopTalk() { _haveMsg = 0; _talkDelay = 0; - act = _vars[VAR_TALK_ACTOR]; + act = VAR(VAR_TALK_ACTOR); if (act && act < 0x80) { Actor *a = derefActorSafe(act, "stopTalk"); if ((a->isInCurrentRoom() && _useTalkAnims) || (_features & GF_NEW_COSTUMES)) { a->startAnimActor(a->talkFrame2); _useTalkAnims = false; } - _vars[VAR_TALK_ACTOR] = 0xFF; + VAR(VAR_TALK_ACTOR) = 0xFF; } _keepText = false; restoreCharsetBg(); @@ -1159,7 +1159,7 @@ void Scumm::actorTalk() { if (_actorToPrintStrFor == 0xFF) { if (!_keepText) stopTalk(); - _vars[VAR_TALK_ACTOR] = 0xFF; + VAR(VAR_TALK_ACTOR) = 0xFF; oldact = 0; } else { a = derefActorSafe(_actorToPrintStrFor, "actorTalk"); @@ -1168,27 +1168,27 @@ void Scumm::actorTalk() { } else { if (!_keepText) stopTalk(); - _vars[VAR_TALK_ACTOR] = a->number; + VAR(VAR_TALK_ACTOR) = a->number; if (!_string[0].no_talk_anim) { a->startAnimActor(a->talkFrame1); _useTalkAnims = true; } - oldact = _vars[VAR_TALK_ACTOR]; + oldact = VAR(VAR_TALK_ACTOR); } } if (oldact >= 0x80) return; - if (_vars[VAR_TALK_ACTOR] > 0x7F) { + if (VAR(VAR_TALK_ACTOR) > 0x7F) { _charsetColor = (byte)_string[0].color; } else { - a = derefActorSafe(_vars[VAR_TALK_ACTOR], "actorTalk(2)"); + a = derefActorSafe(VAR(VAR_TALK_ACTOR), "actorTalk(2)"); _charsetColor = a->talkColor; } _charsetBufPos = 0; _talkDelay = 0; _haveMsg = 0xFF; - _vars[VAR_HAVE_MSG] = 0xFF; + VAR(VAR_HAVE_MSG) = 0xFF; CHARSET_1(); } diff --git a/scumm/akos.cpp b/scumm/akos.cpp index 302411532a..64a95074eb 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -644,7 +644,7 @@ void AkosRenderer::codec1() { v1.scaletable = default_scale_table; // FIXME - which value for VAR_CUSTOMSCALETABLE in V8 ? - if (_vm->isGlobInMemory(rtString, _vm->_vars[_vm->VAR_CUSTOMSCALETABLE])) { + if (_vm->isGlobInMemory(rtString, _vm->VAR(_vm->VAR_CUSTOMSCALETABLE))) { v1.scaletable = _vm->getStringAddressVar(_vm->VAR_CUSTOMSCALETABLE); } diff --git a/scumm/costume.cpp b/scumm/costume.cpp index 002a00e40f..3ec9092145 100644 --- a/scumm/costume.cpp +++ b/scumm/costume.cpp @@ -1319,7 +1319,7 @@ void CostumeRenderer::setPalette(byte *palette) { byte color; if (_vm->_features & GF_OLD_BUNDLE) { - if ((_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_actor_color)) { + if ((_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_actor_color)) { memcpy(_palette, palette, 16); } else { memset(_palette, 8, 16); @@ -1332,7 +1332,7 @@ void CostumeRenderer::setPalette(byte *palette) { _palette[_loaded._ptr[8]] = _palette[0]; } else { for (i = 0; i < _loaded._numColors; i++) { - if ((_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_actor_color) || (_vm->_features & GF_AFTER_V6)) { + if ((_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_actor_color) || (_vm->_features & GF_AFTER_V6)) { color = palette[i]; if (color == 255) color = _loaded._ptr[8 + i]; diff --git a/scumm/debug.cpp b/scumm/debug.cpp index a92653dabe..e019e73896 100644 --- a/scumm/debug.cpp +++ b/scumm/debug.cpp @@ -113,7 +113,7 @@ bool ScummDebugger::do_command(int cmd) printf("Current room: %d [%d]\n", _s->_currentRoom, _s->_roomResource); } else { int room = atoi(_parameters); - _s->_actors[_s->_vars[_s->VAR_EGO]].room = room; + _s->_actors[_s->VAR(_s->VAR_EGO)].room = room; _s->startScene(room, 0, 0); _s->_fullRedraw = 1; } diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index 68605ad777..fe2a16a747 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -68,7 +68,7 @@ void ScummDebugger::attach(Scumm *s, char *entry) { DVar_Register("scumm_speed", &_s->_fastMode, DVAR_INT, 0); DVar_Register("scumm_room", &_s->_currentRoom, DVAR_INT, 0); DVar_Register("scumm_roomresource", &_s->_roomResource, DVAR_INT, 0); - DVar_Register("scumm_vars", &_s->_vars, DVAR_INTARRAY, _s->_numVariables); + DVar_Register("scumm_vars", &_s->_scummVars, DVAR_INTARRAY, _s->_numVariables); DVar_Register("scumm_gamename", &_s->_game_name, DVAR_STRING, 0); DVar_Register("scumm_exename", &_s->_exe_name, DVAR_STRING, 0); @@ -338,7 +338,7 @@ bool ScummDebugger::Cmd_Restart(int argc, const char **argv) { bool ScummDebugger::Cmd_Room(int argc, const char **argv) { if (argc > 1) { int room = atoi(argv[1]); - _s->_actors[_s->_vars[_s->VAR_EGO]].room = room; + _s->_actors[_s->VAR(_s->VAR_EGO)].room = room; _s->startScene(room, 0, 0); _s->_fullRedraw = 1; return false; @@ -594,7 +594,7 @@ bool ScummDebugger::Cmd_Object(int argc, const char **argv) { if (!strcmp(argv[2], "pickup")) { for (i = 1; i < _s->_maxInventoryItems; i++) { if (_s->_inventory[i] == (uint16)obj) { - _s->putOwner(obj, _s->_vars[_s->VAR_EGO]); + _s->putOwner(obj, _s->VAR(_s->VAR_EGO)); _s->runHook(obj); return true; } @@ -605,7 +605,7 @@ bool ScummDebugger::Cmd_Object(int argc, const char **argv) { else _s->addObjectToInventory(obj, atoi(argv[3])); - _s->putOwner(obj, _s->_vars[_s->VAR_EGO]); + _s->putOwner(obj, _s->VAR(_s->VAR_EGO)); _s->putClass(obj, 32, 1); _s->putState(obj, 1); _s->removeObjectFromRoom(obj); @@ -769,8 +769,8 @@ bool ScummDebugger::Cmd_PrintDraft(int argc, const char **argv) { if (strcmp(argv[1], "learn") == 0) { for (i = 0; i < 16; i++) - _s->_vars[base + 2 * i] |= 0x2000; - _s->_vars[base + 72] = 8; + _s->_scummVars[base + 2 * i] |= 0x2000; + _s->_scummVars[base + 72] = 8; // In theory, we could run script 18 here to redraw // the distaff, but I don't know if that's a safe @@ -787,7 +787,7 @@ bool ScummDebugger::Cmd_PrintDraft(int argc, const char **argv) { if (strcmp(argv[1], "fix") == 0) { for (i = 0; i < 16; i++) - _s->_vars[base + 2 * i + 1] = odds[i]; + _s->_scummVars[base + 2 * i + 1] = odds[i]; Debug_Printf( "An attempt has been made to repair\n" "the internal drafts data structure.\n" @@ -799,7 +799,7 @@ bool ScummDebugger::Cmd_PrintDraft(int argc, const char **argv) { // Probably the most useful command for ordinary use: list the drafts. for (i = 0; i < 16; i++) { - draft = _s->_vars[base + i * 2]; + draft = _s->_scummVars[base + i * 2]; Debug_Printf("%d %-13s %c%c%c%c %c%c %5d %c\n", base + 2 * i, names[i], @@ -809,8 +809,8 @@ bool ScummDebugger::Cmd_PrintDraft(int argc, const char **argv) { notes[(draft & 0x0e00) >> 9], (draft & 0x2000) ? 'K' : ' ', (draft & 0x4000) ? 'U' : ' ', - _s->_vars[base + 2 * i + 1], - (_s->_vars[base + 2 * i + 1] != odds[i]) ? '!' : ' '); + _s->_scummVars[base + 2 * i + 1], + (_s->_scummVars[base + 2 * i + 1] != odds[i]) ? '!' : ' '); } return true; diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index f27505ff5e..9544330f9f 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -177,9 +177,9 @@ const ScummVM::String ScummDialog::queryResString(int stringno) { return String(); if (_scumm->_features & GF_AFTER_V7) - string = _scumm->_vars[string_map_table_v7[stringno - 1].num]; + string = _scumm->readVar(string_map_table_v7[stringno - 1].num); else if (_scumm->_features & GF_AFTER_V6) - string = _scumm->_vars[string_map_table_v6[stringno - 1].num]; + string = _scumm->readVar(string_map_table_v6[stringno - 1].num); else string = string_map_table_v5[stringno - 1].num; diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 7c997d9b63..e0b50e1966 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -204,7 +204,7 @@ void Scumm::getGraphicsPerformance() { } if (!(_features & GF_SMALL_HEADER)) // Variable is reserved for game scripts in earlier games - _vars[VAR_PERFORMANCE_1] = 0; + VAR(VAR_PERFORMANCE_1) = 0; for (i = 10; i != 0; i--) { setDirtyRange(0, 0, _realHeight); //ender @@ -212,7 +212,7 @@ void Scumm::getGraphicsPerformance() { } if (!(_features & GF_SMALL_HEADER)) // Variable is reserved for game scripts in earlier games - _vars[VAR_PERFORMANCE_2] = 0; + VAR(VAR_PERFORMANCE_2) = 0; if (_features & GF_AFTER_V7) initScreens(0, 0, _realWidth, _realHeight); @@ -497,7 +497,7 @@ void Gdi::resetBackground(int top, int bottom, int strip) { numLinesToProcess = bottom - top; if (numLinesToProcess) { - if ((_vm->_features & GF_AFTER_V6) || (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_screen)) { + if ((_vm->_features & GF_AFTER_V6) || (_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_screen)) { if (_vm->hasCharsetMask(strip << 3, top, (strip + 1) << 3, bottom)) draw8ColWithMasking(backbuff_ptr, bgbak_ptr, numLinesToProcess, _mask_ptr); else @@ -602,7 +602,7 @@ void Scumm::drawFlashlight() { x = _virtual_mouse_x; y = _virtual_mouse_y; } else { - Actor *a = a = derefActorSafe(_vars[VAR_EGO], "drawFlashlight"); + Actor *a = a = derefActorSafe(VAR(VAR_EGO), "drawFlashlight"); x = a->x; y = a->y; } @@ -774,7 +774,7 @@ void Scumm::restoreBG(int left, int top, int right, int bottom, byte backColor) width = right - left; // Check whether lights are turned on or not - lightsOn = (_features & GF_AFTER_V6) || (vs->number != 0) || (_vars[VAR_CURRENT_LIGHTS] & LIGHTMODE_screen); + lightsOn = (_features & GF_AFTER_V6) || (vs->number != 0) || (VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_screen); if (vs->alloctwobuffers && _currentRoom != 0 && lightsOn ) { blit(backbuff, bgbak, width, height); @@ -853,7 +853,7 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, const int h, bool useOrDecompress = false; // Check whether lights are turned on or not - lightsOn = (_vm->_features & GF_AFTER_V6) || (vs->number != 0) || (_vm->_vars[_vm->VAR_CURRENT_LIGHTS] & LIGHTMODE_screen); + lightsOn = (_vm->_features & GF_AFTER_V6) || (vs->number != 0) || (_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_screen); CHECK_HEAP; if (_vm->_features & GF_SMALL_HEADER) @@ -1958,16 +1958,16 @@ void Scumm::setCameraAt(int pos_x, int pos_y) { clampCameraPos(&camera._cur); camera._dest = camera._cur; - _vars[VAR_CAMERA_DEST_X] = camera._dest.x; - _vars[VAR_CAMERA_DEST_Y] = camera._dest.y; + VAR(VAR_CAMERA_DEST_X) = camera._dest.x; + VAR(VAR_CAMERA_DEST_Y) = camera._dest.y; assert(camera._cur.x >= (_realWidth / 2) && camera._cur.y >= (_realHeight / 2)); if ((camera._cur.x != old.x || camera._cur.y != old.y) - && _vars[VAR_SCROLL_SCRIPT]) { - _vars[VAR_CAMERA_POS_X] = camera._cur.x; - _vars[VAR_CAMERA_POS_Y] = camera._cur.y; - runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0); + && VAR(VAR_SCROLL_SCRIPT)) { + VAR(VAR_CAMERA_POS_X) = camera._cur.x; + VAR(VAR_CAMERA_POS_Y) = camera._cur.y; + runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0); } } else { @@ -1976,15 +1976,15 @@ void Scumm::setCameraAt(int pos_x, int pos_y) { } camera._dest.x = pos_x; - if (camera._cur.x < _vars[VAR_CAMERA_MIN_X]) - camera._cur.x = _vars[VAR_CAMERA_MIN_X]; + if (camera._cur.x < VAR(VAR_CAMERA_MIN_X)) + camera._cur.x = VAR(VAR_CAMERA_MIN_X); - if (camera._cur.x > _vars[VAR_CAMERA_MAX_X]) - camera._cur.x = _vars[VAR_CAMERA_MAX_X]; + if (camera._cur.x > VAR(VAR_CAMERA_MAX_X)) + camera._cur.x = VAR(VAR_CAMERA_MAX_X); - if (_vars[VAR_SCROLL_SCRIPT]) { - _vars[VAR_CAMERA_POS_X] = camera._cur.x; - runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0); + if (VAR(VAR_SCROLL_SCRIPT)) { + VAR(VAR_CAMERA_POS_X) = camera._cur.x; + runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0); } if (camera._cur.x != camera._last.x && _charset->_hasMask) @@ -1998,7 +1998,7 @@ void Scumm::setCameraFollows(Actor *a) { int ax, ay; camera._follows = a->number; - _vars[VAR_CAMERA_FOLLOWED_ACTOR] = a->number; + VAR(VAR_CAMERA_FOLLOWED_ACTOR) = a->number; if (!a->isInCurrentRoom()) { startScene(a->getRoom(), 0, 0); @@ -2007,7 +2007,7 @@ void Scumm::setCameraFollows(Actor *a) { ax = abs(a->x - camera._cur.x); ay = abs(a->y - camera._cur.y); - if (ax > _vars[VAR_CAMERA_THRESHOLD_X] || ay > _vars[VAR_CAMERA_THRESHOLD_Y] || ax > (_realWidth / 2) || ay > (_realHeight / 2)) { + if (ax > VAR(VAR_CAMERA_THRESHOLD_X) || ay > VAR(VAR_CAMERA_THRESHOLD_Y) || ax > (_realWidth / 2) || ay > (_realHeight / 2)) { setCameraAt(a->x, a->y); } @@ -2041,17 +2041,17 @@ void Scumm::setCameraFollows(Actor *a) { } void Scumm::clampCameraPos(ScummPoint *pt) { - if (pt->x < _vars[VAR_CAMERA_MIN_X]) - pt->x = _vars[VAR_CAMERA_MIN_X]; + if (pt->x < VAR(VAR_CAMERA_MIN_X)) + pt->x = VAR(VAR_CAMERA_MIN_X); - if (pt->x > _vars[VAR_CAMERA_MAX_X]) - pt->x = _vars[VAR_CAMERA_MAX_X]; + if (pt->x > VAR(VAR_CAMERA_MAX_X)) + pt->x = VAR(VAR_CAMERA_MAX_X); - if (pt->y < _vars[VAR_CAMERA_MIN_Y]) - pt->y = _vars[VAR_CAMERA_MIN_Y]; + if (pt->y < VAR(VAR_CAMERA_MIN_Y)) + pt->y = VAR(VAR_CAMERA_MIN_Y); - if (pt->y > _vars[VAR_CAMERA_MAX_Y]) - pt->y = _vars[VAR_CAMERA_MAX_Y]; + if (pt->y > VAR(VAR_CAMERA_MAX_Y)) + pt->y = VAR(VAR_CAMERA_MAX_Y); } void Scumm::moveCamera() { @@ -2061,12 +2061,12 @@ void Scumm::moveCamera() { if (camera._follows) { a = derefActorSafe(camera._follows, "moveCamera"); - if (abs(camera._cur.x - a->x) > _vars[VAR_CAMERA_THRESHOLD_X] || - abs(camera._cur.y - a->y) > _vars[VAR_CAMERA_THRESHOLD_Y]) { + if (abs(camera._cur.x - a->x) > VAR(VAR_CAMERA_THRESHOLD_X) || + abs(camera._cur.y - a->y) > VAR(VAR_CAMERA_THRESHOLD_Y)) { camera._movingToActor = true; - if (_vars[VAR_CAMERA_THRESHOLD_X] == 0) + if (VAR(VAR_CAMERA_THRESHOLD_X) == 0) camera._cur.x = a->x; - if (_vars[VAR_CAMERA_THRESHOLD_Y] == 0) + if (VAR(VAR_CAMERA_THRESHOLD_Y) == 0) camera._cur.y = a->y; clampCameraPos(&camera._cur); } @@ -2075,8 +2075,8 @@ void Scumm::moveCamera() { } if (camera._movingToActor) { - _vars[VAR_CAMERA_DEST_X] = camera._dest.x = a->x; - _vars[VAR_CAMERA_DEST_Y] = camera._dest.y = a->y; + VAR(VAR_CAMERA_DEST_X) = camera._dest.x = a->x; + VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = a->y; } assert(camera._cur.x >= (_realWidth / 2) && camera._cur.y >= (_realHeight / 2)); @@ -2084,25 +2084,25 @@ void Scumm::moveCamera() { clampCameraPos(&camera._dest); if (camera._cur.x < camera._dest.x) { - camera._cur.x += _vars[VAR_CAMERA_SPEED_X]; + camera._cur.x += VAR(VAR_CAMERA_SPEED_X); if (camera._cur.x > camera._dest.x) camera._cur.x = camera._dest.x; } if (camera._cur.x > camera._dest.x) { - camera._cur.x -= _vars[VAR_CAMERA_SPEED_X]; + camera._cur.x -= VAR(VAR_CAMERA_SPEED_X); if (camera._cur.x < camera._dest.x) camera._cur.x = camera._dest.x; } if (camera._cur.y < camera._dest.y) { - camera._cur.y += _vars[VAR_CAMERA_SPEED_Y]; + camera._cur.y += VAR(VAR_CAMERA_SPEED_Y); if (camera._cur.y > camera._dest.y) camera._cur.y = camera._dest.y; } if (camera._cur.y > camera._dest.y) { - camera._cur.y -= _vars[VAR_CAMERA_SPEED_Y]; + camera._cur.y -= VAR(VAR_CAMERA_SPEED_Y); if (camera._cur.y < camera._dest.y) camera._cur.y = camera._dest.y; } @@ -2111,31 +2111,31 @@ void Scumm::moveCamera() { camera._movingToActor = false; camera._accel.x = camera._accel.y = 0; - _vars[VAR_CAMERA_SPEED_X] = _vars[VAR_CAMERA_SPEED_Y] = 0; + VAR(VAR_CAMERA_SPEED_X) = VAR(VAR_CAMERA_SPEED_Y) = 0; } else { - camera._accel.x += _vars[VAR_CAMERA_ACCEL_X]; - camera._accel.y += _vars[VAR_CAMERA_ACCEL_Y]; + camera._accel.x += VAR(VAR_CAMERA_ACCEL_X); + camera._accel.y += VAR(VAR_CAMERA_ACCEL_Y); - _vars[VAR_CAMERA_SPEED_X] += camera._accel.x / 100; - _vars[VAR_CAMERA_SPEED_Y] += camera._accel.y / 100; + VAR(VAR_CAMERA_SPEED_X) += camera._accel.x / 100; + VAR(VAR_CAMERA_SPEED_Y) += camera._accel.y / 100; - if (_vars[VAR_CAMERA_SPEED_X] < 8) - _vars[VAR_CAMERA_SPEED_X] = 8; + if (VAR(VAR_CAMERA_SPEED_X) < 8) + VAR(VAR_CAMERA_SPEED_X) = 8; - if (_vars[VAR_CAMERA_SPEED_Y] < 8) - _vars[VAR_CAMERA_SPEED_Y] = 8; + if (VAR(VAR_CAMERA_SPEED_Y) < 8) + VAR(VAR_CAMERA_SPEED_Y) = 8; } cameraMoved(); if (camera._cur.x != old.x || camera._cur.y != old.y) { - _vars[VAR_CAMERA_POS_X] = camera._cur.x; - _vars[VAR_CAMERA_POS_Y] = camera._cur.y; + VAR(VAR_CAMERA_POS_X) = camera._cur.x; + VAR(VAR_CAMERA_POS_Y) = camera._cur.y; - if (_vars[VAR_SCROLL_SCRIPT]) - runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0); + if (VAR(VAR_SCROLL_SCRIPT)) + runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0); } } else { int pos = camera._cur.x; @@ -2144,18 +2144,18 @@ void Scumm::moveCamera() { camera._cur.x &= 0xFFF8; - if (camera._cur.x < _vars[VAR_CAMERA_MIN_X]) { - if (_vars[VAR_CAMERA_FAST_X]) - camera._cur.x = _vars[VAR_CAMERA_MIN_X]; + if (camera._cur.x < VAR(VAR_CAMERA_MIN_X)) { + if (VAR(VAR_CAMERA_FAST_X)) + camera._cur.x = VAR(VAR_CAMERA_MIN_X); else camera._cur.x += 8; cameraMoved(); return; } - if (camera._cur.x > _vars[VAR_CAMERA_MAX_X]) { - if (_vars[VAR_CAMERA_FAST_X]) - camera._cur.x = _vars[VAR_CAMERA_MAX_X]; + if (camera._cur.x > VAR(VAR_CAMERA_MAX_X)) { + if (VAR(VAR_CAMERA_FAST_X)) + camera._cur.x = VAR(VAR_CAMERA_MAX_X); else camera._cur.x -= 8; cameraMoved(); @@ -2169,7 +2169,7 @@ void Scumm::moveCamera() { t = (actorx >> 3) - _screenStartStrip; if (t < camera._leftTrigger || t > camera._rightTrigger) { - if (_vars[VAR_CAMERA_FAST_X]) { + if (VAR(VAR_CAMERA_FAST_X)) { if (t > 35) camera._dest.x = actorx + 80; if (t < 5) @@ -2184,13 +2184,13 @@ void Scumm::moveCamera() { camera._dest.x = a->x; } - if (camera._dest.x < _vars[VAR_CAMERA_MIN_X]) - camera._dest.x = _vars[VAR_CAMERA_MIN_X]; + if (camera._dest.x < VAR(VAR_CAMERA_MIN_X)) + camera._dest.x = VAR(VAR_CAMERA_MIN_X); - if (camera._dest.x > _vars[VAR_CAMERA_MAX_X]) - camera._dest.x = _vars[VAR_CAMERA_MAX_X]; + if (camera._dest.x > VAR(VAR_CAMERA_MAX_X)) + camera._dest.x = VAR(VAR_CAMERA_MAX_X); - if (_vars[VAR_CAMERA_FAST_X]) { + if (VAR(VAR_CAMERA_FAST_X)) { camera._cur.x = camera._dest.x; } else { if (camera._cur.x < camera._dest.x) @@ -2206,9 +2206,9 @@ void Scumm::moveCamera() { cameraMoved(); - if (pos != camera._cur.x && _vars[VAR_SCROLL_SCRIPT]) { - _vars[VAR_CAMERA_POS_X] = camera._cur.x; - runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0); + if (pos != camera._cur.x && VAR(VAR_SCROLL_SCRIPT)) { + VAR(VAR_CAMERA_POS_X) = camera._cur.x; + runScript(VAR(VAR_SCROLL_SCRIPT), 0, 0, 0); } } } @@ -2249,9 +2249,9 @@ void Scumm::cameraMoved() { void Scumm::panCameraTo(int x, int y) { if (_features & GF_AFTER_V7) { - _vars[VAR_CAMERA_FOLLOWED_ACTOR] = camera._follows = 0; - _vars[VAR_CAMERA_DEST_X] = camera._dest.x = x; - _vars[VAR_CAMERA_DEST_Y] = camera._dest.y = y; + VAR(VAR_CAMERA_FOLLOWED_ACTOR) = camera._follows = 0; + VAR(VAR_CAMERA_DEST_X) = camera._dest.x = x; + VAR(VAR_CAMERA_DEST_Y) = camera._dest.y = y; } else { camera._dest.x = x; @@ -2759,9 +2759,9 @@ void Scumm::cyclePalette() { byte *start, *end; byte tmp[3]; - valueToAdd = _vars[VAR_TIMER]; - if (valueToAdd < _vars[VAR_TIMER_NEXT]) - valueToAdd = _vars[VAR_TIMER_NEXT]; + valueToAdd = VAR(VAR_TIMER); + if (valueToAdd < VAR(VAR_TIMER_NEXT)) + valueToAdd = VAR(VAR_TIMER_NEXT); if (!_colorCycle) // FIXME return; diff --git a/scumm/intern.h b/scumm/intern.h index ce43e1a56b..738634ec85 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -294,7 +294,17 @@ protected: const OpcodeEntryV6 *_opcodesV6; public: - Scumm_v6(GameDetector *detector, OSystem *syst) : Scumm(detector, syst) {} + Scumm_v6(GameDetector *detector, OSystem *syst) : Scumm(detector, syst) + { + VAR_VIDEONAME = 0xFF; + + VAR_TIMEDATE_YEAR = 0xFF; + VAR_TIMEDATE_MONTH = 0xFF; + VAR_TIMEDATE_DAY = 0xFF; + VAR_TIMEDATE_HOUR = 0xFF; + VAR_TIMEDATE_MINUTE = 0xFF; + VAR_TIMEDATE_SECOND = 0xFF; + } protected: virtual void setupOpcodes(); diff --git a/scumm/object.cpp b/scumm/object.cpp index 8ef03152df..fd33c4a140 100644 --- a/scumm/object.cpp +++ b/scumm/object.cpp @@ -1099,7 +1099,7 @@ void Scumm::SamInventoryHack(int obj) { if (value == obj) return; if (value == 0) { - _vars[179]++; + _scummVars[179]++; writeArray(178, 0, base, obj); return; } diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 1ca9b5e1e0..1e070eb601 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -77,8 +77,8 @@ void Scumm::openRoom(int room) { if (!(_features & GF_SMALL_HEADER)) { if (_features & GF_AFTER_V7) { - if (room > 0) - _vars[VAR_CURRENTDISK] = res.roomno[rtRoom][room]; + if (room > 0 && (_features & GF_AFTER_V8)) + VAR(VAR_CURRENTDISK) = res.roomno[rtRoom][room]; sprintf(buf, "%s.la%d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]); sprintf(buf2, "%s.%.3d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]); } else if (_features & GF_HUMONGOUS) @@ -586,7 +586,7 @@ void Scumm::ensureResourceLoaded(int type, int i) { if (!(_features & GF_AFTER_V7) && !(_features & GF_SMALL_HEADER)) if (type == rtRoom && i == _roomResource) - _vars[VAR_ROOM_FLAG] = 1; + VAR(VAR_ROOM_FLAG) = 1; } int Scumm::loadResource(int type, int idx) { @@ -1253,9 +1253,9 @@ byte *Scumm::getStringAddress(int i) { byte *Scumm::getStringAddressVar(int i) { byte *addr; - addr = getResourceAddress(rtString, _vars[i]); + addr = getResourceAddress(rtString, _scummVars[i]); if (addr == NULL) - error("NULL string var %d slot %d", i, _vars[i]); + error("NULL string var %d slot %d", i, _scummVars[i]); if (_features & GF_NEW_OPCODES) return ((ArrayHeader *)addr)->data; @@ -1745,7 +1745,7 @@ void Scumm::allocateArrays() { _verbs = (VerbSlot *)calloc(_numVerbs, sizeof(VerbSlot)); _objs = (ObjectData *)calloc(_numLocalObjects, sizeof(ObjectData)); debug(2, "Allocated %d space in numObjects\n", _numLocalObjects); - _vars = (int32 *)calloc(_numVariables, sizeof(int32)); + _scummVars = (int32 *)calloc(_numVariables, sizeof(int32)); _bitVars = (byte *)calloc(_numBitVariables >> 3, 1); allocResTypeData(rtCostume, (_features & GF_NEW_COSTUMES) ? MKID('AKOS') : MKID('COST'), diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index c578f59dfc..bd030f89a6 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -195,7 +195,7 @@ bool Scumm::loadState(int slot, bool compat, SaveFileManager *mgr) { initBGBuffers(_scrHeight); - if ((_features & GF_AUDIOTRACKS) && _vars[VAR_MUSIC_TIMER] > 0) + if ((_features & GF_AUDIOTRACKS) && VAR(VAR_MUSIC_TIMER) > 0) _sound->startCDTimer(); CHECK_HEAP debug(1, "State loaded from '%s'", filename); @@ -659,19 +659,19 @@ void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion) { s->saveLoadArrayOf(_classData, _numGlobalObjects, sizeof(_classData[0]), sleUint32); - var120Backup = _vars[120]; - var98Backup = _vars[98]; + var120Backup = _scummVars[120]; + var98Backup = _scummVars[98]; // The variables grew from 16 to 32 bit. if (savegameVersion < VER_V15) - s->saveLoadArrayOf(_vars, _numVariables, sizeof(_vars[0]), sleInt16); + s->saveLoadArrayOf(_scummVars, _numVariables, sizeof(_scummVars[0]), sleInt16); else - s->saveLoadArrayOf(_vars, _numVariables, sizeof(_vars[0]), sleInt32); + s->saveLoadArrayOf(_scummVars, _numVariables, sizeof(_scummVars[0]), sleInt32); if (_gameId == GID_TENTACLE) // Maybe misplaced, but that's the main idea - _vars[120] = var120Backup; + _scummVars[120] = var120Backup; if (_gameId == GID_INDY4) - _vars[98] = var98Backup;; + _scummVars[98] = var98Backup;; s->saveLoadArrayOf(_bitVars, _numBitVariables >> 3, 1, sleByte); diff --git a/scumm/script.cpp b/scumm/script.cpp index b1ccf99b43..f1a741d795 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -362,7 +362,7 @@ int Scumm::readVar(uint var) { } #endif checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)"); - return _vars[var]; + return _scummVars[var]; } if (var & 0x8000) { @@ -380,7 +380,7 @@ int Scumm::readVar(uint var) { } #endif checkRange(_numVariables - 1, 0, var, "Variable %d out of range(rzb)"); - return (_vars[ var ] & ( 1 << bit ) ) ? 1 : 0; + return (_scummVars[ var ] & ( 1 << bit ) ) ? 1 : 0; } else { var &= 0x7FFF; checkRange(_numBitVariables - 1, 0, var, "Bit variable %d out of range(r)"); @@ -408,9 +408,9 @@ void Scumm::writeVar(uint var, int value) { // FIXME: Find some better place to put this. if (var == VAR_CHARINC) - _vars[VAR_CHARINC] = _defaultTalkDelay / 20; + VAR(VAR_CHARINC) = _defaultTalkDelay / 20; else - _vars[var] = value; + _scummVars[var] = value; if ((_varwatch == (int)var) || (_varwatch == 0)) { if (vm.slot[_currentScript].number < 100) @@ -430,9 +430,9 @@ void Scumm::writeVar(uint var, int value) { var = (var >> 4) & 0xFF; checkRange(_numVariables - 1, 0, var, "Variable %d out of range(wzb)"); if(value) - _vars[var] |= ( 1 << bit ); + _scummVars[var] |= ( 1 << bit ); else - _vars[var] &= ~( 1 << bit ); + _scummVars[var] &= ~( 1 << bit ); } else { var &= 0x7FFF; checkRange(_numBitVariables - 1, 0, var, "Bit variable %d out of range(w)"); @@ -591,8 +591,8 @@ bool Scumm::isScriptInUse(int script) { void Scumm::runHook(int i) { int tmp[16]; tmp[0] = i; - if (_vars[VAR_HOOK_SCRIPT]) { - runScript(_vars[VAR_HOOK_SCRIPT], 0, 0, tmp); + if (VAR(VAR_HOOK_SCRIPT)) { + runScript(VAR(VAR_HOOK_SCRIPT), 0, 0, tmp); } } @@ -653,8 +653,8 @@ void Scumm::runAllScripts() { } void Scumm::runExitScript() { - if (!(_features & GF_AFTER_V2) && _vars[VAR_EXIT_SCRIPT]) - runScript(_vars[VAR_EXIT_SCRIPT], 0, 0, 0); + if (!(_features & GF_AFTER_V2) && VAR(VAR_EXIT_SCRIPT)) + runScript(VAR(VAR_EXIT_SCRIPT), 0, 0, 0); if (_EXCD_offs) { int slot = getScriptSlot(); vm.slot[slot].status = ssRunning; @@ -684,13 +684,13 @@ void Scumm::runExitScript() { runScriptNested(slot); } - if (!(_features & GF_AFTER_V2) && _vars[VAR_EXIT_SCRIPT2]) - runScript(_vars[VAR_EXIT_SCRIPT2], 0, 0, 0); + if (!(_features & GF_AFTER_V2) && VAR(VAR_EXIT_SCRIPT2)) + runScript(VAR(VAR_EXIT_SCRIPT2), 0, 0, 0); } void Scumm::runEntryScript() { - if (!(_features & GF_AFTER_V2) && _vars[VAR_ENTRY_SCRIPT]) - runScript(_vars[VAR_ENTRY_SCRIPT], 0, 0, 0); + if (!(_features & GF_AFTER_V2) && VAR(VAR_ENTRY_SCRIPT)) + runScript(VAR(VAR_ENTRY_SCRIPT), 0, 0, 0); if (_ENCD_offs) { int slot = getScriptSlot(); vm.slot[slot].status = ssRunning; @@ -703,8 +703,8 @@ void Scumm::runEntryScript() { vm.slot[slot].delayFrameCount = 0; runScriptNested(slot); } - if (!(_features & GF_AFTER_V2) && _vars[VAR_ENTRY_SCRIPT2]) - runScript(_vars[VAR_ENTRY_SCRIPT2], 0, 0, 0); + if (!(_features & GF_AFTER_V2) && VAR(VAR_ENTRY_SCRIPT2)) + runScript(VAR(VAR_ENTRY_SCRIPT2), 0, 0, 0); } void Scumm::killScriptsAndResources() { @@ -786,10 +786,10 @@ void Scumm::checkAndRunSentenceScript() { ScriptSlot *ss; memset(_localParamList, 0, sizeof(_localParamList)); - if (isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) { + if (isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) { ss = vm.slot; for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) - if (ss->number == _vars[VAR_SENTENCE_SCRIPT] && ss->status != ssDead && ss->freezeCount == 0) + if (ss->number == VAR(VAR_SENTENCE_SCRIPT) && ss->status != ssDead && ss->freezeCount == 0) return; } @@ -806,8 +806,8 @@ void Scumm::checkAndRunSentenceScript() { _localParamList[1] = _sentence[_sentenceNum].unk4; _localParamList[2] = _sentence[_sentenceNum].unk3; _currentScript = 0xFF; - if (_vars[VAR_SENTENCE_SCRIPT]) - runScript(_vars[VAR_SENTENCE_SCRIPT], 0, 0, _localParamList); + if (VAR(VAR_SENTENCE_SCRIPT)) + runScript(VAR(VAR_SENTENCE_SCRIPT), 0, 0, _localParamList); } void Scumm::runInputScript(int a, int cmd, int mode) { @@ -816,8 +816,8 @@ void Scumm::runInputScript(int a, int cmd, int mode) { args[0] = a; args[1] = cmd; args[2] = mode; - if (_vars[VAR_VERB_SCRIPT]) - runScript(_vars[VAR_VERB_SCRIPT], 0, 0, args); + if (VAR(VAR_VERB_SCRIPT)) + runScript(VAR(VAR_VERB_SCRIPT), 0, 0, args); } void Scumm::decreaseScriptDelay(int amount) { @@ -1074,8 +1074,8 @@ void Scumm::cutscene(int *args) { vm.cutScenePtr[vm.cutSceneStackPointer] = 0; vm.cutSceneScriptIndex = scr; - if (_vars[VAR_CUTSCENE_START_SCRIPT]) - runScript(_vars[VAR_CUTSCENE_START_SCRIPT], 0, 0, args); + if (VAR(VAR_CUTSCENE_START_SCRIPT)) + runScript(VAR(VAR_CUTSCENE_START_SCRIPT), 0, 0, args); vm.cutSceneScriptIndex = 0xFF; } @@ -1089,7 +1089,7 @@ void Scumm::endCutscene() { ss->cutsceneOverride--; args[0] = vm.cutSceneData[vm.cutSceneStackPointer]; - _vars[VAR_OVERRIDE] = 0; + VAR(VAR_OVERRIDE) = 0; if (vm.cutScenePtr[vm.cutSceneStackPointer] && (ss->cutsceneOverride > 0)) // Only terminate if active ss->cutsceneOverride--; @@ -1098,8 +1098,8 @@ void Scumm::endCutscene() { vm.cutScenePtr[vm.cutSceneStackPointer] = 0; vm.cutSceneStackPointer--; - if (_vars[VAR_CUTSCENE_END_SCRIPT]) - runScript(_vars[VAR_CUTSCENE_END_SCRIPT], 0, 0, args); + if (VAR(VAR_CUTSCENE_END_SCRIPT)) + runScript(VAR(VAR_CUTSCENE_END_SCRIPT), 0, 0, args); } void Scumm::exitCutscene() { @@ -1113,7 +1113,7 @@ void Scumm::exitCutscene() { if (ss->cutsceneOverride > 0) ss->cutsceneOverride--; - _vars[VAR_OVERRIDE] = 1; + VAR(VAR_OVERRIDE) = 1; vm.cutScenePtr[vm.cutSceneStackPointer] = 0; } } @@ -1132,7 +1132,7 @@ void Scumm::beginOverride() { // why we record the current script position in vm.cutScenePtr). fetchScriptByte(); fetchScriptWord(); - _vars[VAR_OVERRIDE] = 0; + VAR(VAR_OVERRIDE) = 0; } void Scumm::endOverride() { @@ -1143,5 +1143,5 @@ void Scumm::endOverride() { vm.cutScenePtr[idx] = 0; vm.cutSceneScript[idx] = 0; - _vars[VAR_OVERRIDE] = 0; + VAR(VAR_OVERRIDE) = 0; } diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index c5ad383732..ae6ea37aaa 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -399,15 +399,15 @@ void Scumm_v2::decodeParseString() { int Scumm_v2::readVar(uint var) { if (var >= 14 && var <= 16) - var = _vars[var]; + var = _scummVars[var]; checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)"); - debug(6, "readvar(%d) = %d", var, _vars[var]); - return _vars[var]; + debug(6, "readvar(%d) = %d", var, _scummVars[var]); + return _scummVars[var]; } void Scumm_v2::getResultPosIndirect() { - _resultVarNumber = _vars[fetchScriptByte()]; + _resultVarNumber = _scummVars[fetchScriptByte()]; } void Scumm_v2::getResultPos() { @@ -504,9 +504,9 @@ void Scumm_v2::o2_setBitVar() { bit_var >>= 4; if (getVarOrDirectByte(0x40)) - _vars[bit_var] |= (1 << bit_offset); + _scummVars[bit_var] |= (1 << bit_offset); else - _vars[bit_var] &= ~(1 << bit_offset); + _scummVars[bit_var] &= ~(1 << bit_offset); } void Scumm_v2::o2_getBitVar() { @@ -519,7 +519,7 @@ void Scumm_v2::o2_getBitVar() { int bit_offset = bit_var & 0x0f; bit_var >>= 4; - setResult((_vars[bit_var] & (1 << bit_offset)) ? 1 : 0); + setResult((_scummVars[bit_var] & (1 << bit_offset)) ? 1 : 0); } void Scumm_v2::ifStateCommon(byte type) { @@ -576,14 +576,14 @@ void Scumm_v2::o2_addIndirect() { int a; getResultPosIndirect(); a = getVarOrDirectWord(0x80); - _vars[_resultVarNumber] += a; + _scummVars[_resultVarNumber] += a; } void Scumm_v2::o2_subIndirect() { int a; getResultPosIndirect(); a = getVarOrDirectWord(0x80); - _vars[_resultVarNumber] -= a; + _scummVars[_resultVarNumber] -= a; } void Scumm_v2::o2_waitForActor() { @@ -595,7 +595,7 @@ void Scumm_v2::o2_waitForActor() { void Scumm_v2::o2_waitForMessage() { - if (_vars[VAR_HAVE_MSG]) { + if (VAR(VAR_HAVE_MSG)) { _scriptPointer--; o5_breakHere(); } @@ -927,7 +927,7 @@ void Scumm_v2::o2_loadRoomWithEgo() { obj = getVarOrDirectWord(0x80); room = getVarOrDirectByte(0x40); - a = derefActorSafe(_vars[VAR_EGO], "o2_loadRoomWithEgo"); + a = derefActorSafe(VAR(VAR_EGO), "o2_loadRoomWithEgo"); a->putActor(0, 0, room); _egoPositioned = false; @@ -997,8 +997,8 @@ void Scumm_v2::o2_roomOps() { a = _scrWidth - (_realWidth / 2); if (b > _scrWidth - (_realWidth / 2)) b = _scrWidth - (_realWidth / 2); - _vars[VAR_CAMERA_MIN_X] = a; - _vars[VAR_CAMERA_MAX_X] = b; + VAR(VAR_CAMERA_MIN_X) = a; + VAR(VAR_CAMERA_MAX_X) = b; break; case 2: /* room color */ _shadowPalette[b] = a; @@ -1041,7 +1041,7 @@ void Scumm_v2::o2_pickupObject() { addObjectToInventory(obj, _roomResource); removeObjectFromRoom(obj); - putOwner(obj, _vars[VAR_EGO]); + putOwner(obj, VAR(VAR_EGO)); putClass(obj, 32, 1); putState(obj, 1); clearDrawObjectQueue(); diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index e68991da45..c79c60e8fc 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -679,8 +679,8 @@ void Scumm_v5::o5_cursorCommand() { } if (!(_features & GF_OLD_BUNDLE) && _gameId != GID_INDY3_256) { - _vars[VAR_CURSORSTATE] = _cursor.state; - _vars[VAR_USERPUT] = _userPut; + VAR(VAR_CURSORSTATE) = _cursor.state; + VAR(VAR_USERPUT) = _userPut; } } @@ -737,7 +737,7 @@ void Scumm_v5::o5_doSentence() { a = getVarOrDirectByte(0x80); if (a == 0xFE) { _sentenceNum = 0; - stopScriptNr(_vars[VAR_SENTENCE_SCRIPT]); + stopScriptNr(VAR(VAR_SENTENCE_SCRIPT)); clearClickedStatus(); return; } @@ -876,7 +876,7 @@ void Scumm_v5::o5_expression() { case 6: /* normal opcode */ _opcode = fetchScriptByte(); executeOpcode(_opcode); - push(_vars[0]); + push(_scummVars[0]); break; } } @@ -1082,7 +1082,7 @@ void Scumm_v5::o5_getClosestObjActor() { getResultPos(); act = getVarOrDirectWord(0x80); - obj = _vars[VAR_ACTOR_RANGE_MAX]; + obj = VAR(VAR_ACTOR_RANGE_MAX); do { dist = getObjActToObjActDist(act, obj); @@ -1090,7 +1090,7 @@ void Scumm_v5::o5_getClosestObjActor() { closest_dist = dist; closest_obj = obj; } - } while (--obj >= _vars[VAR_ACTOR_RANGE_MIN]); + } while (--obj >= VAR(VAR_ACTOR_RANGE_MIN)); setResult(closest_dist); } @@ -1309,7 +1309,7 @@ void Scumm_v5::o5_lights() { c = fetchScriptByte(); if (c == 0) - _vars[VAR_CURRENT_LIGHTS] = a; + VAR(VAR_CURRENT_LIGHTS) = a; else if (c == 1) { _flashlightXStrips = a; _flashlightYStrips = b; @@ -1337,7 +1337,7 @@ void Scumm_v5::o5_loadRoomWithEgo() { obj = getVarOrDirectWord(0x80); room = getVarOrDirectByte(0x40); - a = derefActorSafe(_vars[VAR_EGO], "o5_loadRoomWithEgo"); + a = derefActorSafe(VAR(VAR_EGO), "o5_loadRoomWithEgo"); a->putActor(0, 0, room); _egoPositioned = false; @@ -1345,9 +1345,9 @@ void Scumm_v5::o5_loadRoomWithEgo() { x = (int16)fetchScriptWord(); y = (int16)fetchScriptWord(); - _vars[VAR_WALKTO_OBJ] = obj; + VAR(VAR_WALKTO_OBJ) = obj; startScene(a->room, a, obj); - _vars[VAR_WALKTO_OBJ] = 0; + VAR(VAR_WALKTO_OBJ) = 0; // FIXME: Can this be removed? camera._cur.x = a->x; @@ -1437,7 +1437,7 @@ void Scumm_v5::o5_pickupObject() { if (room == 0) room = _roomResource; addObjectToInventory(obj, room); - putOwner(obj, _vars[VAR_EGO]); + putOwner(obj, VAR(VAR_EGO)); putClass(obj, 32, 1); putState(obj, 1); removeObjectFromRoom(obj); @@ -1451,7 +1451,7 @@ void Scumm_v5::o5_print() { } void Scumm_v5::o5_printEgo() { - _actorToPrintStrFor = (byte)_vars[VAR_EGO]; + _actorToPrintStrFor = (byte)VAR(VAR_EGO); decodeParseString(); } @@ -1500,7 +1500,7 @@ void Scumm_v5::o5_putActorInRoom() { room = getVarOrDirectByte(0x40); if (a == NULL) return; // FIXME - yet another null dref hack, see bug 639201 - if (a->visible && _currentRoom != room && _vars[VAR_TALK_ACTOR] == a->number) { + if (a->visible && _currentRoom != room && VAR(VAR_TALK_ACTOR) == a->number) { clearMsgQueue(); } a->room = room; @@ -1668,8 +1668,8 @@ void Scumm_v5::o5_roomOps() { a = _scrWidth - (_realWidth / 2); if (b > _scrWidth - (_realWidth / 2)) b = _scrWidth - (_realWidth / 2); - _vars[VAR_CAMERA_MIN_X] = a; - _vars[VAR_CAMERA_MAX_X] = b; + VAR(VAR_CAMERA_MIN_X) = a; + VAR(VAR_CAMERA_MAX_X) = b; break; case 2: /* room color */ if (_features & GF_SMALL_HEADER) { @@ -2007,7 +2007,7 @@ void Scumm_v5::o5_startMusic() { } void Scumm_v5::o5_startSound() { - _vars[VAR_MUSIC_TIMER] = 0; + VAR(VAR_MUSIC_TIMER) = 0; _sound->addSoundToQueue(getVarOrDirectByte(0x80)); } @@ -2034,9 +2034,9 @@ void Scumm_v5::o5_soundKludge() { if (_features & GF_SMALL_HEADER) { // Is WaitForSentence in SCUMM V3 if (_sentenceNum) { - if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; - } else if (!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + } else if (!isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; _scriptPointer--; @@ -2320,7 +2320,7 @@ void Scumm_v5::o5_wait() { return; } case 2: /* wait for message */ - if (_vars[VAR_HAVE_MSG]) + if (VAR(VAR_HAVE_MSG)) break; return; case 3: /* wait for camera */ @@ -2329,11 +2329,11 @@ void Scumm_v5::o5_wait() { return; case 4: /* wait for sentence */ if (_sentenceNum) { - if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; break; } - if (!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + if (!isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; break; default: @@ -2491,7 +2491,7 @@ void Scumm_v5::decodeParseString() { int delay = (uint16)getVarOrDirectWord(0x40); if (_gameId == GID_LOOM256) { - _vars[VAR_MUSIC_TIMER] = 0; + VAR(VAR_MUSIC_TIMER) = 0; if (offset == 0 && delay == 0) { _sound->stopCD(); } else { @@ -2639,7 +2639,7 @@ void Scumm_v5::o5_pickupObjectOld() { // warning("adding %d from %d to inventoryOld", obj, _currentRoom); addObjectToInventory(obj, _roomResource); removeObjectFromRoom(obj); - putOwner(obj, _vars[VAR_EGO]); + putOwner(obj, VAR(VAR_EGO)); putClass(obj, 32, 1); putState(obj, 1); clearDrawObjectQueue(); diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index 6323a19352..b3a4e90804 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -836,8 +836,8 @@ void Scumm_v6::o6_cursorCommand() { error("o6_cursorCommand: default case"); } - _vars[VAR_CURSORSTATE] = _cursor.state; - _vars[VAR_USERPUT] = _userPut; + VAR(VAR_CURSORSTATE) = _cursor.state; + VAR(VAR_USERPUT) = _userPut; } void Scumm_v6::o6_breakHere() { @@ -953,7 +953,7 @@ void Scumm_v6::o6_setCameraAt() { int x, y; camera._follows = 0; - _vars[VAR_CAMERA_FOLLOWED_ACTOR] = 0; + VAR(VAR_CAMERA_FOLLOWED_ACTOR) = 0; y = pop(); x = pop(); @@ -1037,7 +1037,7 @@ void Scumm_v6::o6_putActorInRoom() { if (room == 0xFF || room == 0x7FFFFFFF) { room = a->room; } else { - if (a->visible && _currentRoom != room && _vars[VAR_TALK_ACTOR] == a->number) { + if (a->visible && _currentRoom != room && VAR(VAR_TALK_ACTOR) == a->number) { clearMsgQueue(); } if (room != 0) @@ -1104,14 +1104,14 @@ void Scumm_v6::o6_pickupObject() { for (i = 1; i < _maxInventoryItems; i++) { if (_inventory[i] == (uint16)obj) { - putOwner(obj, _vars[VAR_EGO]); + putOwner(obj, VAR(VAR_EGO)); runHook(obj); return; } } addObjectToInventory(obj, room); - putOwner(obj, _vars[VAR_EGO]); + putOwner(obj, VAR(VAR_EGO)); putClass(obj, 32, 1); putState(obj, 1); removeObjectFromRoom(obj); @@ -1128,15 +1128,15 @@ void Scumm_v6::o6_loadRoomWithEgo() { obj = popRoomAndObj(&room); - a = derefActorSafe(_vars[VAR_EGO], "o6_loadRoomWithEgo"); + a = derefActorSafe(VAR(VAR_EGO), "o6_loadRoomWithEgo"); assert(a); a->putActor(0, 0, room); _egoPositioned = false; - _vars[VAR_WALKTO_OBJ] = obj; + VAR(VAR_WALKTO_OBJ) = obj; startScene(a->room, a, obj); - _vars[VAR_WALKTO_OBJ] = 0; + VAR(VAR_WALKTO_OBJ) = 0; /* startScene maybe modifies VAR_EGO, i hope not */ @@ -1155,7 +1155,7 @@ void Scumm_v6::o6_loadRoomWithEgo() { void Scumm_v6::o6_getRandomNumber() { int rnd; rnd = _rnd.getRandomNumber(pop()); - _vars[VAR_V6_RANDOM_NR] = rnd; + VAR(VAR_V6_RANDOM_NR) = rnd; push(rnd); } @@ -1163,7 +1163,7 @@ void Scumm_v6::o6_getRandomNumberRange() { int max = pop(); int min = pop(); int rnd = _rnd.getRandomNumberRng(min, max); - _vars[VAR_V6_RANDOM_NR] = rnd; + VAR(VAR_V6_RANDOM_NR) = rnd; push(rnd); } @@ -1468,8 +1468,8 @@ void Scumm_v6::o6_roomOps() { a = _scrWidth - (_realWidth / 2); if (b > _scrWidth - (_realWidth / 2)) b = _scrWidth - (_realWidth / 2); - _vars[VAR_CAMERA_MIN_X] = a; - _vars[VAR_CAMERA_MAX_X] = b; + VAR(VAR_CAMERA_MIN_X) = a; + VAR(VAR_CAMERA_MAX_X) = b; break; case 174: /* set screen */ @@ -2028,7 +2028,7 @@ void Scumm_v6::o6_wait() { return; } - if (_vars[VAR_HAVE_MSG]) + if (VAR(VAR_HAVE_MSG)) break; return; case 170: @@ -2043,11 +2043,11 @@ void Scumm_v6::o6_wait() { return; case 171: if (_sentenceNum) { - if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; break; } - if (!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + if (!isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; break; case 226:{ /* wait until actor drawn */ @@ -2151,7 +2151,7 @@ void Scumm_v6::o6_delayMinutes() { void Scumm_v6::o6_stopSentence() { _sentenceNum = 0; - stopScriptNr(_vars[VAR_SENTENCE_SCRIPT]); + stopScriptNr(VAR(VAR_SENTENCE_SCRIPT)); clearClickedStatus(); } @@ -2177,7 +2177,7 @@ void Scumm_v6::o6_printActor() { } void Scumm_v6::o6_printEgo() { - push(_vars[VAR_EGO]); + push(VAR(VAR_EGO)); decodeParseString(0, 1); } @@ -2214,7 +2214,7 @@ void Scumm_v6::o6_talkActor() { } void Scumm_v6::o6_talkEgo() { - push(_vars[VAR_EGO]); + push(VAR(VAR_EGO)); o6_talkActor(); } @@ -2624,7 +2624,7 @@ void Scumm_v6::o6_kernelSetFunctions() { case 122: - _vars[VAR_SOUNDRESULT] = + VAR(VAR_SOUNDRESULT) = (short)_imuse->doCommand(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); break; @@ -2707,7 +2707,7 @@ void Scumm_v6::o6_kernelGetFunctions() { } if( ((args[1] == 328) || (args[1] == 336) || (args[1] == 13)) && - ((_vars[VAR_LEFTBTN_HOLD]) || (_lastKeyHit == 13) || (_lastKeyHit == 274) || + ((VAR(VAR_LEFTBTN_HOLD)) || (_lastKeyHit == 13) || (_lastKeyHit == 274) || (_lastKeyHit == 273)) ) { push(1); // thrust return; @@ -2937,14 +2937,14 @@ void Scumm_v6::o6_getDateTime() { t = localtime(&now); - _vars[VAR_TIMEDATE_YEAR] = t->tm_year; - _vars[VAR_TIMEDATE_MONTH] = t->tm_mon; - _vars[VAR_TIMEDATE_DAY] = t->tm_mday; - _vars[VAR_TIMEDATE_HOUR] = t->tm_hour; - _vars[VAR_TIMEDATE_MINUTE] = t->tm_min; + VAR(VAR_TIMEDATE_YEAR) = t->tm_year; + VAR(VAR_TIMEDATE_MONTH) = t->tm_mon; + VAR(VAR_TIMEDATE_DAY) = t->tm_mday; + VAR(VAR_TIMEDATE_HOUR) = t->tm_hour; + VAR(VAR_TIMEDATE_MINUTE) = t->tm_min; if (_features & GF_AFTER_V8) - _vars[VAR_TIMEDATE_SECOND] = t->tm_sec; + VAR(VAR_TIMEDATE_SECOND) = t->tm_sec; } void Scumm_v6::o6_unknownE1() { diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp index 2e8c2e37ea..f30a9fd0ed 100644 --- a/scumm/script_v8.cpp +++ b/scumm/script_v8.cpp @@ -392,7 +392,7 @@ int Scumm_v8::readVar(uint var) { if (!(var & 0xF0000000)) { checkRange(_numVariables - 1, 0, var, "Variable %d out of range(r)"); - return _vars[var]; + return _scummVars[var]; } if (var & 0x80000000) { @@ -417,7 +417,7 @@ void Scumm_v8::writeVar(uint var, int value) { if (!(var & 0xF0000000)) { checkRange(_numVariables - 1, 0, var, "Variable %d out of range(w)"); - _vars[var] = value; + _scummVars[var] = value; if ((_varwatch == (int)var) || (_varwatch == 0)) { if (vm.slot[_currentScript].number < 100) @@ -650,7 +650,7 @@ void Scumm_v8::o8_wait() { } return; case 0x1F: // SO_WAIT_FOR_MESSAGE Wait for message - if (_vars[VAR_HAVE_MSG]) + if (VAR(VAR_HAVE_MSG)) break; return; case 0x20: // SO_WAIT_FOR_CAMERA Wait for camera (to finish current action?) @@ -659,11 +659,11 @@ void Scumm_v8::o8_wait() { return; case 0x21: // SO_WAIT_FOR_SENTENCE if (_sentenceNum) { - if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + if (_sentence[_sentenceNum - 1].freezeCount && !isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; break; } - if (!isScriptInUse(_vars[VAR_SENTENCE_SCRIPT])) + if (!isScriptInUse(VAR(VAR_SENTENCE_SCRIPT))) return; break; case 0x22: // SO_WAIT_FOR_ANIMATION @@ -858,8 +858,8 @@ void Scumm_v8::o8_cursorCommand() { error("o8_cursorCommand: default case 0x%x", subOp); } - _vars[VAR_CURSORSTATE] = _cursor.state; - _vars[VAR_USERPUT] = _userPut; + VAR(VAR_CURSORSTATE) = _cursor.state; + VAR(VAR_USERPUT) = _userPut; } void Scumm_v8::o8_createBoxMatrix() { diff --git a/scumm/scumm.h b/scumm/scumm.h index be6cc8b911..0f0a976241 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -388,9 +388,19 @@ protected: byte *_arrays; uint16 *_newNames; public: - int32 *_vars; + // VAR is a wrapper around scummVar, which attempts to include additional + // useful information should an illegal var access be detected. + #define VAR(x) scummVar(x, #x, __FILE__, __LINE__) + inline int32& scummVar(byte var, const char *varName, const char *file, int line) + { + if (var == 0xFF) + warning("Illegal access to variable %s in file %s, line %d", varName, file, line); + return _scummVars[var]; + } + protected: int16 _varwatch; + int32 *_scummVars; byte *_bitVars; /* Global resource tables */ diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 234a827064..548fecc87a 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -215,7 +215,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _inventory = NULL; _arrays = NULL; _newNames = NULL; - _vars = NULL; + _scummVars = NULL; _varwatch = 0; _bitVars = NULL; _numVariables = 0; @@ -396,6 +396,121 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst) _languageStrCount = 0; memset(_transText,0,sizeof(_transText)); + // + // Init all VARS to 0xFF + // + VAR_LANGUAGE = 0xFF; + VAR_KEYPRESS = 0xFF; + VAR_EGO = 0xFF; + VAR_CAMERA_POS_X = 0xFF; + VAR_HAVE_MSG = 0xFF; + VAR_ROOM = 0xFF; + VAR_OVERRIDE = 0xFF; + VAR_MACHINE_SPEED = 0xFF; + VAR_ME = 0xFF; + VAR_NUM_ACTOR = 0xFF; + VAR_CURRENT_LIGHTS = 0xFF; + VAR_CURRENTDRIVE = 0xFF; // How about merging this with VAR_CURRENTDISK? + VAR_CURRENTDISK = 0xFF; + VAR_TMR_1 = 0xFF; + VAR_TMR_2 = 0xFF; + VAR_TMR_3 = 0xFF; + VAR_MUSIC_TIMER = 0xFF; + VAR_ACTOR_RANGE_MIN = 0xFF; + VAR_ACTOR_RANGE_MAX = 0xFF; + VAR_CAMERA_MIN_X = 0xFF; + VAR_CAMERA_MAX_X = 0xFF; + VAR_TIMER_NEXT = 0xFF; + VAR_VIRT_MOUSE_X = 0xFF; + VAR_VIRT_MOUSE_Y = 0xFF; + VAR_ROOM_RESOURCE = 0xFF; + VAR_LAST_SOUND = 0xFF; + VAR_CUTSCENEEXIT_KEY = 0xFF; + VAR_OPTIONS_KEY = 0xFF; + VAR_TALK_ACTOR = 0xFF; + VAR_CAMERA_FAST_X = 0xFF; + VAR_SCROLL_SCRIPT = 0xFF; + VAR_ENTRY_SCRIPT = 0xFF; + VAR_ENTRY_SCRIPT2 = 0xFF; + VAR_EXIT_SCRIPT = 0xFF; + VAR_EXIT_SCRIPT2 = 0xFF; + VAR_VERB_SCRIPT = 0xFF; + VAR_SENTENCE_SCRIPT = 0xFF; + VAR_HOOK_SCRIPT = 0xFF; + VAR_CUTSCENE_START_SCRIPT = 0xFF; + VAR_CUTSCENE_END_SCRIPT = 0xFF; + VAR_CHARINC = 0xFF; + VAR_WALKTO_OBJ = 0xFF; + VAR_DEBUGMODE = 0xFF; + VAR_HEAPSPACE = 0xFF; + VAR_RESTART_KEY = 0xFF; + VAR_PAUSE_KEY = 0xFF; + VAR_MOUSE_X = 0xFF; + VAR_MOUSE_Y = 0xFF; + VAR_TIMER = 0xFF; + VAR_TMR_4 = 0xFF; + VAR_SOUNDCARD = 0xFF; + VAR_VIDEOMODE = 0xFF; + VAR_SAVELOADDIALOG_KEY = 0xFF; + VAR_FIXEDDISK = 0xFF; + VAR_CURSORSTATE = 0xFF; + VAR_USERPUT = 0xFF; + VAR_SOUNDRESULT = 0xFF; + VAR_TALKSTOP_KEY = 0xFF; + VAR_59 = 0xFF; + + VAR_SOUNDPARAM = 0xFF; + VAR_SOUNDPARAM2 = 0xFF; + VAR_SOUNDPARAM3 = 0xFF; + VAR_MOUSEPRESENT = 0xFF; + VAR_PERFORMANCE_1 = 0xFF; + VAR_PERFORMANCE_2 = 0xFF; + VAR_ROOM_FLAG = 0xFF; + VAR_GAME_LOADED = 0xFF; + VAR_NEW_ROOM = 0xFF; + VAR_VERSION = 0xFF; + + VAR_V5_TALK_STRING_Y = 0xFF; + + VAR_V6_SCREEN_WIDTH = 0xFF; + VAR_V6_SCREEN_HEIGHT = 0xFF; + VAR_V6_EMSSPACE = 0xFF; + VAR_V6_RANDOM_NR = 0xFF; + + VAR_STRING2DRAW = 0xFF; + VAR_CAMERA_POS_Y = 0xFF; + + VAR_CAMERA_MIN_Y = 0xFF; + VAR_CAMERA_MAX_Y = 0xFF; + VAR_CAMERA_THRESHOLD_X = 0xFF; + VAR_CAMERA_THRESHOLD_Y = 0xFF; + VAR_CAMERA_SPEED_X = 0xFF; + VAR_CAMERA_SPEED_Y = 0xFF; + VAR_CAMERA_ACCEL_X = 0xFF; + VAR_CAMERA_ACCEL_Y = 0xFF; + + VAR_CAMERA_DEST_X = 0xFF; + + VAR_CAMERA_DEST_Y = 0xFF; + + VAR_CAMERA_FOLLOWED_ACTOR = 0xFF; + + VAR_LEFTBTN_DOWN = 0xFF; + VAR_RIGHTBTN_DOWN = 0xFF; + VAR_LEFTBTN_HOLD = 0xFF; + VAR_RIGHTBTN_HOLD = 0xFF; + VAR_MOUSE_BUTTONS = 0xFF; + VAR_MOUSE_HOLD = 0xFF; + VAR_UNK_SCRIPT = 0xFF; + VAR_UNK_SCRIPT_2 = 0xFF; + + VAR_DEFAULT_TALK_DELAY = 0xFF; + VAR_CHARSET_MASK = 0xFF; + + VAR_CUSTOMSCALETABLE = 0xFF; + VAR_V6_SOUNDMODE = 0xFF; + + // Use g_scumm from error() ONLY g_scumm = this; @@ -672,39 +787,39 @@ void Scumm::scummInit() { void Scumm::initScummVars() { if (!(_features & GF_AFTER_V6)) - _vars[VAR_V5_TALK_STRING_Y] = -0x50; + VAR(VAR_V5_TALK_STRING_Y) = -0x50; if (!(_features & GF_AFTER_V7)) { - _vars[VAR_CURRENTDRIVE] = 0; - _vars[VAR_FIXEDDISK] = true; - _vars[VAR_SOUNDCARD] = 3; - _vars[VAR_VIDEOMODE] = 0x13; - _vars[VAR_HEAPSPACE] = 1400; - _vars[VAR_MOUSEPRESENT] = true; // FIXME - used to be 0, but that seems odd?!? + VAR(VAR_CURRENTDRIVE) = 0; + VAR(VAR_FIXEDDISK) = true; + VAR(VAR_SOUNDCARD) = 3; + VAR(VAR_VIDEOMODE) = 0x13; + VAR(VAR_HEAPSPACE) = 1400; + VAR(VAR_MOUSEPRESENT) = true; // FIXME - used to be 0, but that seems odd?!? // if (_features & GF_HUMONGOUS) // FIXME uncomment when XMI support is added -// _vars[VAR_SOUNDPARAM] = 1; // soundblaster for music +// VAR(VAR_SOUNDPARAM) = 1; // soundblaster for music // else - _vars[VAR_SOUNDPARAM] = 0; - _vars[VAR_SOUNDPARAM2] = 0; - _vars[VAR_SOUNDPARAM3] = 0; + VAR(VAR_SOUNDPARAM) = 0; + VAR(VAR_SOUNDPARAM2) = 0; + VAR(VAR_SOUNDPARAM3) = 0; if (_features & GF_AFTER_V6) - _vars[VAR_V6_EMSSPACE] = 10000; + VAR(VAR_V6_EMSSPACE) = 10000; - _vars[VAR_59] = 3; + VAR(VAR_59) = 3; // Setup light - _vars[VAR_CURRENT_LIGHTS] = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen; + VAR(VAR_CURRENT_LIGHTS) = LIGHTMODE_actor_base | LIGHTMODE_actor_color | LIGHTMODE_screen; } else { - _vars[VAR_V6_EMSSPACE] = 10000; + VAR(VAR_V6_EMSSPACE) = 10000; } if (_features & GF_AFTER_V8) { // Fixme: How do we deal with non-cd installs? - _vars[VAR_CURRENTDISK] = 1; - _vars[VAR_LANGUAGE] = _language; + VAR(VAR_CURRENTDISK) = 1; + VAR(VAR_LANGUAGE) = _language; } - _vars[VAR_CHARINC] = 4; - _vars[VAR_TALK_ACTOR] = 0; + VAR(VAR_CHARINC) = 4; + VAR(VAR_TALK_ACTOR) = 0; } void Scumm::checkRange(int max, int min, int no, const char *str) { @@ -730,10 +845,10 @@ int Scumm::scummLoop(int delta) { // that it will be in a different state each time you run the program. _rnd.getRandomNumber(2); - _vars[VAR_TMR_1] += delta; - _vars[VAR_TMR_2] += delta; - _vars[VAR_TMR_3] += delta; - _vars[VAR_TMR_4] += delta; + VAR(VAR_TMR_1) += delta; + VAR(VAR_TMR_2) += delta; + VAR(VAR_TMR_3) += delta; + VAR(VAR_TMR_4) += delta; if (delta > 15) delta = 15; @@ -753,17 +868,17 @@ int Scumm::scummLoop(int delta) { processKbd(); if (_features & GF_AFTER_V7) { - _vars[VAR_CAMERA_POS_X] = camera._cur.x; - _vars[VAR_CAMERA_POS_Y] = camera._cur.y; + VAR(VAR_CAMERA_POS_X) = camera._cur.x; + VAR(VAR_CAMERA_POS_Y) = camera._cur.y; } else { - _vars[VAR_CAMERA_POS_X] = camera._cur.x; + VAR(VAR_CAMERA_POS_X) = camera._cur.x; } - _vars[VAR_HAVE_MSG] = (_haveMsg == 0xFE) ? 0xFF : _haveMsg; - _vars[VAR_VIRT_MOUSE_X] = _virtual_mouse_x; - _vars[VAR_VIRT_MOUSE_Y] = _virtual_mouse_y; - _vars[VAR_MOUSE_X] = mouse.x; - _vars[VAR_MOUSE_Y] = mouse.y; - _vars[VAR_DEBUGMODE] = _debugMode; + VAR(VAR_HAVE_MSG) = (_haveMsg == 0xFE) ? 0xFF : _haveMsg; + VAR(VAR_VIRT_MOUSE_X) = _virtual_mouse_x; + VAR(VAR_VIRT_MOUSE_Y) = _virtual_mouse_y; + VAR(VAR_MOUSE_X) = mouse.x; + VAR(VAR_MOUSE_Y) = mouse.y; + VAR(VAR_DEBUGMODE) = _debugMode; if (_features & GF_AUDIOTRACKS) { // Covered automatically by the Sound class @@ -775,7 +890,7 @@ int Scumm::scummLoop(int delta) { tempMusic += delta * 15; // Convert delta to milliseconds if (tempMusic >= MUSIC_DELAY) { tempMusic %= MUSIC_DELAY; - _vars[VAR_MUSIC_TIMER] += 1; + VAR(VAR_MUSIC_TIMER) += 1; } } @@ -788,7 +903,7 @@ int Scumm::scummLoop(int delta) { } if (!(_features & GF_SMALL_HEADER) && !(_features && GF_AFTER_V8)) - _vars[VAR_GAME_LOADED] = 0; + VAR(VAR_GAME_LOADED) = 0; if (_saveLoadFlag) { load_game: bool success; @@ -804,7 +919,7 @@ load_game: // variables (eg, Zak256 cashcard values). Temp disabled for V8 // because of odd timing issue with scripts and the variable reset if (success && _saveLoadCompatible && !(_features & GF_SMALL_HEADER) && !(_features & GF_AFTER_V8)) - _vars[VAR_GAME_LOADED] = 201; + VAR(VAR_GAME_LOADED) = 201; } else { success = loadState(_saveLoadSlot, _saveLoadCompatible); if (!success) @@ -813,7 +928,7 @@ load_game: // Ender: Disabled for small_header games, as can overwrite game // variables (eg, Zak256 cashcard values). if (success && _saveLoadCompatible && !(_features & GF_SMALL_HEADER)) - _vars[VAR_GAME_LOADED] = 203; + VAR(VAR_GAME_LOADED) = 203; } makeSavegameName(filename, _saveLoadSlot, _saveLoadCompatible); @@ -885,8 +1000,9 @@ load_game: setActorRedrawFlags(true, true); resetActorBgs(); - if (!(_vars[VAR_CURRENT_LIGHTS] & LIGHTMODE_screen) && - _vars[VAR_CURRENT_LIGHTS] & LIGHTMODE_flashlight) { + if (!(_features & GF_AFTER_V7) && + !(VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_screen) && + VAR(VAR_CURRENT_LIGHTS) & LIGHTMODE_flashlight) { drawFlashlight(); setActorRedrawFlags(true, false); } @@ -931,8 +1047,8 @@ load_game: /* show or hide mouse */ _system->show_mouse(_cursor.state > 0); - _vars[VAR_TIMER] = 0; - return _vars[VAR_TIMER_NEXT]; + VAR(VAR_TIMER) = 0; + return VAR(VAR_TIMER_NEXT); } @@ -964,7 +1080,7 @@ void Scumm::startScene(int room, Actor * a, int objectNr) { } if (!(_features & GF_SMALL_HEADER)) // Disable for SH games. Overwrites - _vars[VAR_NEW_ROOM] = room; // gamevars, eg Zak cashcards + VAR(VAR_NEW_ROOM) = room; // gamevars, eg Zak cashcards runExitScript(); killScriptsAndResources(); @@ -985,20 +1101,20 @@ void Scumm::startScene(int room, Actor * a, int objectNr) { clearDrawObjectQueue(); - _vars[VAR_ROOM] = room; + VAR(VAR_ROOM) = room; _fullRedraw = true; increaseResourceCounter(); _currentRoom = room; - _vars[VAR_ROOM] = room; + VAR(VAR_ROOM) = room; if (room >= 0x80 && !(_features & GF_AFTER_V7)) _roomResource = _resourceMapper[room & 0x7F]; else _roomResource = room; - _vars[VAR_ROOM_RESOURCE] = _roomResource; + VAR(VAR_ROOM_RESOURCE) = _roomResource; if (room != 0) ensureResourceLoaded(rtRoom, room); @@ -1026,16 +1142,16 @@ void Scumm::startScene(int room, Actor * a, int objectNr) { } if (_features & GF_AFTER_V6) { - _vars[VAR_V6_SCREEN_WIDTH] = _scrWidth; - _vars[VAR_V6_SCREEN_HEIGHT] = _scrHeight; + VAR(VAR_V6_SCREEN_WIDTH) = _scrWidth; + VAR(VAR_V6_SCREEN_HEIGHT) = _scrHeight; } - _vars[VAR_CAMERA_MIN_X] = _realWidth / 2; - _vars[VAR_CAMERA_MAX_X] = _scrWidth - (_realWidth / 2); + VAR(VAR_CAMERA_MIN_X) = _realWidth / 2; + VAR(VAR_CAMERA_MAX_X) = _scrWidth - (_realWidth / 2); if (_features & GF_AFTER_V7) { - _vars[VAR_CAMERA_MIN_Y] = _realHeight / 2; - _vars[VAR_CAMERA_MAX_Y] = _scrHeight - (_realHeight / 2); + VAR(VAR_CAMERA_MIN_Y) = _realHeight / 2; + VAR(VAR_CAMERA_MAX_Y) = _scrHeight - (_realHeight / 2); setCameraAt(_realWidth / 2, _realHeight / 2); } @@ -1578,7 +1694,7 @@ void Scumm::processKbd() { if ((_features & GF_OLD256) || (_gameId == GID_CMI) || (_features & GF_OLD_BUNDLE)) /* FIXME: Support ingame screen */ saveloadkey = 319; else - saveloadkey = _vars[VAR_SAVELOADDIALOG_KEY]; + saveloadkey = VAR(VAR_SAVELOADDIALOG_KEY); _virtual_mouse_x = mouse.x + virtscr[0].xstart; @@ -1608,33 +1724,33 @@ void Scumm::processKbd() { return; } - if (_lastKeyHit == _vars[VAR_RESTART_KEY]) { + if (_lastKeyHit == VAR(VAR_RESTART_KEY)) { warning("Restart not implemented"); // pauseGame(true); return; } - if (_lastKeyHit == _vars[VAR_PAUSE_KEY]) { + if (_lastKeyHit == VAR(VAR_PAUSE_KEY)) { pauseGame(true); /* pause */ return; } - if (_lastKeyHit == _vars[VAR_CUTSCENEEXIT_KEY]) { + if (_lastKeyHit == VAR(VAR_CUTSCENEEXIT_KEY)) { if (_insaneState) { _videoFinished = true; } else exitCutscene(); } else if (_lastKeyHit == saveloadkey && _currentRoom != 0) { if (_features & GF_AFTER_V7) - runScript(_vars[VAR_UNK_SCRIPT], 0, 0, 0); + runScript(VAR(VAR_UNK_SCRIPT), 0, 0, 0); saveloadDialog(); // Display NewGui if (_features & GF_AFTER_V7) - runScript(_vars[VAR_UNK_SCRIPT_2], 0, 0, 0); + runScript(VAR(VAR_UNK_SCRIPT_2), 0, 0, 0); return; - } else if (_lastKeyHit == _vars[VAR_TALKSTOP_KEY]) { + } else if (_lastKeyHit == VAR(VAR_TALKSTOP_KEY)) { _talkDelay = 0; if (_sound->_sfxMode & 2) stopTalk(); @@ -1659,13 +1775,13 @@ void Scumm::processKbd() { if (_defaultTalkDelay > 90) _defaultTalkDelay = 90; - _vars[VAR_CHARINC] = _defaultTalkDelay / 20; + VAR(VAR_CHARINC) = _defaultTalkDelay / 20; } else if (_lastKeyHit == '+') { // + text speed up _defaultTalkDelay -= 5; if (_defaultTalkDelay < 5) _defaultTalkDelay = 5; - _vars[VAR_CHARINC] = _defaultTalkDelay / 20; + VAR(VAR_CHARINC) = _defaultTalkDelay / 20; } else if (_lastKeyHit == '~' || _lastKeyHit == '#') { // Debug console g_debugger->attach(this, NULL); } @@ -1690,7 +1806,7 @@ int Scumm::getKeyInput() { if (_leftBtnPressed & msClicked && _rightBtnPressed & msClicked) { _mouseButStat = 0; - _lastKeyHit = (uint)_vars[VAR_CUTSCENEEXIT_KEY]; + _lastKeyHit = (uint)VAR(VAR_CUTSCENEEXIT_KEY); } else if (_leftBtnPressed & msClicked) { _mouseButStat = MBS_LEFT_CLICK; } else if (_rightBtnPressed & msClicked) { @@ -1698,28 +1814,28 @@ int Scumm::getKeyInput() { } if (_features & GF_AFTER_V8) { - _vars[VAR_MOUSE_BUTTONS] = 0; - _vars[VAR_MOUSE_HOLD] = 0; - _vars[VAR_RIGHTBTN_HOLD] = 0; + VAR(VAR_MOUSE_BUTTONS) = 0; + VAR(VAR_MOUSE_HOLD) = 0; + VAR(VAR_RIGHTBTN_HOLD) = 0; if (_leftBtnPressed & msClicked) - _vars[VAR_MOUSE_BUTTONS] += 1; + VAR(VAR_MOUSE_BUTTONS) += 1; if (_rightBtnPressed & msClicked) - _vars[VAR_MOUSE_BUTTONS] += 2; + VAR(VAR_MOUSE_BUTTONS) += 2; if (_leftBtnPressed & msDown) - _vars[VAR_MOUSE_HOLD] += 1; + VAR(VAR_MOUSE_HOLD) += 1; if (_rightBtnPressed & msDown) { - _vars[VAR_RIGHTBTN_HOLD] = 1; - _vars[VAR_MOUSE_HOLD] += 2; + VAR(VAR_RIGHTBTN_HOLD) = 1; + VAR(VAR_MOUSE_HOLD) += 2; } } else if (_features & GF_AFTER_V7) { -// _vars[VAR_LEFTBTN_DOWN] = (_leftBtnPressed&msClicked) != 0; - _vars[VAR_LEFTBTN_HOLD] = (_leftBtnPressed & msDown) != 0; -// _vars[VAR_RIGHTBTN_DOWN] = (_rightBtnPressed&msClicked) != 0; - _vars[VAR_RIGHTBTN_HOLD] = (_rightBtnPressed & msDown) != 0; +// VAR(VAR_LEFTBTN_DOWN) = (_leftBtnPressed&msClicked) != 0; + VAR(VAR_LEFTBTN_HOLD) = (_leftBtnPressed & msDown) != 0; +// VAR(VAR_RIGHTBTN_DOWN) = (_rightBtnPressed&msClicked) != 0; + VAR(VAR_RIGHTBTN_HOLD) = (_rightBtnPressed & msDown) != 0; } _leftBtnPressed &= ~msClicked; @@ -1779,7 +1895,7 @@ void Scumm::destroy() { free(_arrays); free(_verbs); free(_objs); - free(_vars); + free(_scummVars); free(_bitVars); free(_newNames); free(_classData); @@ -2093,12 +2209,12 @@ void Scumm::launch() { scummInit(); if (!(_features & GF_AFTER_V7)) - _vars[VAR_VERSION] = 21; + VAR(VAR_VERSION) = 21; - _vars[VAR_DEBUGMODE] = _debugMode; + VAR(VAR_DEBUGMODE) = _debugMode; if (_gameId == GID_MONKEY) - _vars[74] = 1225; + _scummVars[74] = 1225; _sound->setupSound(); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index c95f829f21..f087e1a346 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -51,7 +51,7 @@ Sound::~Sound() { void Sound::addSoundToQueue(int sound) { if (!(_scumm->_features & GF_AFTER_V7)) { - _scumm->_vars[_scumm->VAR_LAST_SOUND] = sound; + _scumm->VAR(_scumm->VAR_LAST_SOUND) = sound; _scumm->ensureResourceLoaded(rtSound, sound); addSoundToQueue2(sound); } else { @@ -103,12 +103,12 @@ void Sound::processSoundQues() { if (!(_scumm->_features & GF_AFTER_V7)) { if (_scumm->_imuse) - _scumm->_vars[_scumm->VAR_SOUNDRESULT] = + _scumm->VAR(_scumm->VAR_SOUNDRESULT) = (short)_scumm->_imuse->doCommand(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); } else { if (_scumm->_imuseDigital) - _scumm->_vars[_scumm->VAR_SOUNDRESULT] = + _scumm->VAR(_scumm->VAR_SOUNDRESULT) = (short)_scumm->_imuseDigital->doCommand(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]); } @@ -190,7 +190,7 @@ void Sound::playSound(int soundID) { } else if (READ_UINT32_UNALIGNED(ptr) == MKID('SOUN')) { ptr += 8; - _scumm->_vars[_scumm->VAR_MUSIC_TIMER] = 0; + _scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0; playCDTrack(ptr[16], ptr[17] == 0xff ? -1 : ptr[17], (ptr[18] * 60 + ptr[19]) * 75 + ptr[20], 0); @@ -456,8 +456,8 @@ void Sound::processSfxQueues() { _talk_sound_mode = 0; } - if (_scumm->_vars[_scumm->VAR_TALK_ACTOR]) { //_sfxMode & 2) { - act = _scumm->_vars[_scumm->VAR_TALK_ACTOR]; + if (_scumm->VAR(_scumm->VAR_TALK_ACTOR)) { //_sfxMode & 2) { + act = _scumm->VAR(_scumm->VAR_TALK_ACTOR); if (_talkChannel < 0) finished = false; else if (_scumm->_mixer->_channels[_talkChannel] == NULL) { @@ -796,7 +796,7 @@ void Sound::pauseSounds(bool pause) { _scumm->_imuseDigital->pause(pause); } - if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->_vars[_scumm->VAR_MUSIC_TIMER] > 0) { + if ((_scumm->_features & GF_AUDIOTRACKS) && _scumm->VAR(_scumm->VAR_MUSIC_TIMER) > 0) { if (pause) stopCDTimer(); else @@ -1009,8 +1009,8 @@ void Sound::playBundleMusic(char *song) { _outputMixerSize = 66150; // ((22050 * 2 * 2) / 4) * 3 if (_scumm->_gameId == GID_CMI) { char bunfile[20]; - sprintf(bunfile, "musdisk%d.bun", _scumm->_vars[_scumm->VAR_CURRENTDISK]); - if (_musicDisk != _scumm->_vars[_scumm->VAR_CURRENTDISK]) + sprintf(bunfile, "musdisk%d.bun", _scumm->VAR(_scumm->VAR_CURRENTDISK)); + if (_musicDisk != _scumm->VAR(_scumm->VAR_CURRENTDISK)) _scumm->_bundle->_musicFile.close(); if (_scumm->_bundle->openMusicFile(bunfile, _scumm->getGameDataPath()) == false) { @@ -1020,7 +1020,7 @@ void Sound::playBundleMusic(char *song) { } } - _musicDisk = (byte)_scumm->_vars[_scumm->VAR_CURRENTDISK]; + _musicDisk = (byte)_scumm->VAR(_scumm->VAR_CURRENTDISK); _outputMixerSize = 88140; // ((22050 * 2 * 2) } else { if (_scumm->_bundle->openMusicFile("digmusic.bun", _scumm->getGameDataPath()) == false) @@ -1194,15 +1194,15 @@ int Sound::playBundleSound(char *sound) { if (_scumm->_gameId == GID_CMI) { char voxfile[20]; - sprintf(voxfile, "voxdisk%d.bun", _scumm->_vars[_scumm->VAR_CURRENTDISK]); - if (_voiceDisk != _scumm->_vars[_scumm->VAR_CURRENTDISK]) + sprintf(voxfile, "voxdisk%d.bun", _scumm->VAR(_scumm->VAR_CURRENTDISK)); + if (_voiceDisk != _scumm->VAR(_scumm->VAR_CURRENTDISK)) _scumm->_bundle->_voiceFile.close(); result = _scumm->_bundle->openVoiceFile(voxfile, _scumm->getGameDataPath()); if (result == false) result = _scumm->_bundle->openVoiceFile("voice.bun", _scumm->getGameDataPath()); - _voiceDisk = (byte)_scumm->_vars[_scumm->VAR_CURRENTDISK]; + _voiceDisk = (byte)_scumm->VAR(_scumm->VAR_CURRENTDISK); } else if (_scumm->_gameId == GID_DIG) result = _scumm->_bundle->openVoiceFile("digvoice.bun", _scumm->getGameDataPath()); else @@ -1406,7 +1406,7 @@ static void cd_timer_handler(void *ptr) { // should be possible to check with pollCD(), but since CD sound isn't // properly restarted when reloading a saved game, I don't dare to. - scumm->_vars[scumm->VAR_MUSIC_TIMER] += 6; + scumm->VAR(scumm->VAR_MUSIC_TIMER) += 6; } void Sound::startCDTimer() { @@ -1522,7 +1522,7 @@ int Sound::getCachedTrack(int track) { int Sound::playMP3CDTrack(int track, int num_loops, int start, int delay) { int index; - _scumm->_vars[_scumm->VAR_MUSIC_TIMER] = 0; + _scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0; if (_soundsPaused) return 0; diff --git a/scumm/string.cpp b/scumm/string.cpp index 929468d27b..7c425ba6b7 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -49,7 +49,7 @@ void Scumm::unkMessage1() { // and setting VAR_V6_SOUNDMODE beforehand. See patch 609791. // FIXME: There are other VAR_V6_SOUNDMODE states, as // mentioned in the patch. FIXME after iMUSE is done. - if (_gameId != GID_SAMNMAX || (_vars[VAR_V6_SOUNDMODE] != 2)) + if (_gameId != GID_SAMNMAX || (VAR(VAR_V6_SOUNDMODE) != 2)) _sound->talkSound(a, b, 1, -1); } } @@ -66,7 +66,7 @@ void Scumm::unkMessage2() { InfoDialog* dialog = new InfoDialog(_newgui, this, (char*)buf); // FIXME: I know this is the right thing to do for MI1 and MI2. For // all other games it's just a guess. - _vars[VAR_KEYPRESS] = runDialog (dialog); + VAR(VAR_KEYPRESS) = runDialog (dialog); delete dialog; _messagePtr = tmp; @@ -89,24 +89,24 @@ void Scumm::CHARSET_1() { // 'secret room while walking' hang. It doesn't do the camera check // when the talk target isn't an actor. The question is, can we make // this a more general case? Does it really need to be Zak specific? - if (!(_features & GF_AFTER_V7) && !(_gameId==GID_ZAK256 && _vars[VAR_TALK_ACTOR] == 0xFF)) { + if (!(_features & GF_AFTER_V7) && !(_gameId==GID_ZAK256 && VAR(VAR_TALK_ACTOR) == 0xFF)) { if ((camera._dest.x >> 3) != (camera._cur.x >> 3) || camera._cur.x != camera._last.x) return; } a = NULL; - if (_vars[VAR_TALK_ACTOR] != 0xFF) - a = derefActorSafe(_vars[VAR_TALK_ACTOR], "CHARSET_1"); + if (VAR(VAR_TALK_ACTOR) != 0xFF) + a = derefActorSafe(VAR(VAR_TALK_ACTOR), "CHARSET_1"); if (a && _string[0].overhead != 0) { if (!(_features & GF_AFTER_V6)) { _string[0].xpos = a->x - camera._cur.x + (_realWidth / 2); - if (_vars[VAR_V5_TALK_STRING_Y] < 0) { - s = (a->scaley * (int)_vars[VAR_V5_TALK_STRING_Y]) / 0xFF; - _string[0].ypos = ((_vars[VAR_V5_TALK_STRING_Y] - s) >> 1) + s - a->elevation + a->y; + if (VAR(VAR_V5_TALK_STRING_Y) < 0) { + s = (a->scaley * (int)VAR(VAR_V5_TALK_STRING_Y)) / 0xFF; + _string[0].ypos = ((VAR(VAR_V5_TALK_STRING_Y) - s) >> 1) + s - a->elevation + a->y; } else { - _string[0].ypos = (int)_vars[VAR_V5_TALK_STRING_Y]; + _string[0].ypos = (int)VAR(VAR_V5_TALK_STRING_Y); } if (_string[0].ypos < 1) _string[0].ypos = 1; @@ -182,7 +182,7 @@ void Scumm::CHARSET_1() { if (_gameId == GID_LOOM256) { _defaultTalkDelay = 100; - _vars[VAR_CHARINC] = 5; + VAR(VAR_CHARINC) = 5; } _talkDelay = _defaultTalkDelay; @@ -264,7 +264,7 @@ void Scumm::CHARSET_1() { _charset->_nextLeft = _charset->_left; _charset->_nextTop = _charset->_top; - _talkDelay += (int)_vars[VAR_CHARINC]; + _talkDelay += (int)VAR(VAR_CHARINC); continue; } diff --git a/scumm/vars.cpp b/scumm/vars.cpp index cd2024fc73..0678734d4a 100644 --- a/scumm/vars.cpp +++ b/scumm/vars.cpp @@ -79,6 +79,7 @@ void Scumm::setupScummVars() { VAR_FIXEDDISK = 51; VAR_CURSORSTATE = 52; VAR_USERPUT = 53; + VAR_V5_TALK_STRING_Y = 54; VAR_SOUNDRESULT = 56; VAR_TALKSTOP_KEY = 57; VAR_59 = 59; @@ -88,13 +89,38 @@ void Scumm::setupScummVars() { VAR_SOUNDPARAM3 = 66; VAR_MOUSEPRESENT = 67; VAR_PERFORMANCE_1 = 68; - VAR_PERFORMANCE_2 = 69; // Zak256 Note: Cashcard for Zak - VAR_ROOM_FLAG = 70; // Zak256 Note: Cashcard for Annie - VAR_GAME_LOADED = 71; // Zak256 Note: Cashcard for Melissa - VAR_NEW_ROOM = 72; // Zak256 Note: Cashcard for Leslie + if (!(_features & GF_SMALL_HEADER)) { + VAR_PERFORMANCE_2 = 69; // Zak256 Note: Cashcard for Zak + VAR_ROOM_FLAG = 70; // Zak256 Note: Cashcard for Annie + VAR_GAME_LOADED = 71; // Zak256 Note: Cashcard for Melissa + VAR_NEW_ROOM = 72; // Zak256 Note: Cashcard for Leslie + } VAR_VERSION = 75; +} - VAR_V5_TALK_STRING_Y = 54; +void Scumm_v2::setupScummVars() { + VAR_EGO = 0; + VAR_CAMERA_POS_X = 2; + VAR_HAVE_MSG = 3; + VAR_ROOM = 4; + VAR_OVERRIDE = 5; + VAR_MACHINE_SPEED = 6; + VAR_NUM_ACTOR = 11; + VAR_CURRENT_LIGHTS = 12; + VAR_CURRENTDRIVE = 13; + VAR_MUSIC_TIMER = 17; + VAR_ACTOR_RANGE_MIN = 19; + VAR_ACTOR_RANGE_MAX = 20; + VAR_CAMERA_MIN_X = 23; + VAR_CAMERA_MAX_X = 24; + VAR_TIMER_NEXT = 25; + VAR_VIRT_MOUSE_X = 30; + VAR_VIRT_MOUSE_Y = 31; + VAR_ROOM_RESOURCE = 36; + VAR_LAST_SOUND = 37; + VAR_KEYPRESS = 39; + VAR_CUTSCENEEXIT_KEY = 40; + VAR_TALK_ACTOR = 41; } void Scumm_v6::setupScummVars() { @@ -285,29 +311,3 @@ void Scumm_v8::setupScummVars() { VAR_CHARINC = 221; } - -void Scumm_v2::setupScummVars() { - VAR_EGO = 0; - VAR_CAMERA_POS_X = 2; - VAR_HAVE_MSG = 3; - VAR_ROOM = 4; - VAR_OVERRIDE = 5; - VAR_MACHINE_SPEED = 6; - VAR_NUM_ACTOR = 11; - VAR_CURRENT_LIGHTS = 12; - VAR_CURRENTDRIVE = 13; - VAR_MUSIC_TIMER = 17; - VAR_ACTOR_RANGE_MIN = 19; - VAR_ACTOR_RANGE_MAX = 20; - VAR_CAMERA_MIN_X = 23; - VAR_CAMERA_MAX_X = 24; - VAR_TIMER_NEXT = 25; - VAR_VIRT_MOUSE_X = 30; - VAR_VIRT_MOUSE_Y = 31; - VAR_ROOM_RESOURCE = 36; - VAR_LAST_SOUND = 37; - VAR_KEYPRESS = 39; - VAR_CUTSCENEEXIT_KEY = 40; - VAR_TALK_ACTOR = 41; - -} |