diff options
author | Eugene Sandulenko | 2010-08-09 11:38:01 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2010-08-09 11:38:01 +0000 |
commit | 327d30d71962d793e773b147d940e50d06539364 (patch) | |
tree | ba4bcb686bc43b69c652f2801f3f00c5474f27fe /engines/cine | |
parent | 15b881386aa81bf60919486c5eab9f81c6b9d6ae (diff) | |
download | scummvm-rg350-327d30d71962d793e773b147d940e50d06539364.tar.gz scummvm-rg350-327d30d71962d793e773b147d940e50d06539364.tar.bz2 scummvm-rg350-327d30d71962d793e773b147d940e50d06539364.zip |
CINE: eliminate global variables
svn-id: r51937
Diffstat (limited to 'engines/cine')
-rw-r--r-- | engines/cine/anim.cpp | 16 | ||||
-rw-r--r-- | engines/cine/anim.h | 2 | ||||
-rw-r--r-- | engines/cine/bg_list.cpp | 21 | ||||
-rw-r--r-- | engines/cine/bg_list.h | 1 | ||||
-rw-r--r-- | engines/cine/cine.cpp | 30 | ||||
-rw-r--r-- | engines/cine/cine.h | 33 | ||||
-rw-r--r-- | engines/cine/gfx.cpp | 118 | ||||
-rw-r--r-- | engines/cine/main_loop.cpp | 28 | ||||
-rw-r--r-- | engines/cine/msg.cpp | 10 | ||||
-rw-r--r-- | engines/cine/msg.h | 2 | ||||
-rw-r--r-- | engines/cine/object.cpp | 85 | ||||
-rw-r--r-- | engines/cine/object.h | 3 | ||||
-rw-r--r-- | engines/cine/pal.cpp | 23 | ||||
-rw-r--r-- | engines/cine/pal.h | 2 | ||||
-rw-r--r-- | engines/cine/part.cpp | 54 | ||||
-rw-r--r-- | engines/cine/part.h | 2 | ||||
-rw-r--r-- | engines/cine/prc.cpp | 13 | ||||
-rw-r--r-- | engines/cine/prc.h | 3 | ||||
-rw-r--r-- | engines/cine/rel.cpp | 16 | ||||
-rw-r--r-- | engines/cine/rel.h | 2 | ||||
-rw-r--r-- | engines/cine/saveload.cpp | 92 | ||||
-rw-r--r-- | engines/cine/script.h | 3 | ||||
-rw-r--r-- | engines/cine/script_fw.cpp | 73 | ||||
-rw-r--r-- | engines/cine/script_os.cpp | 12 | ||||
-rw-r--r-- | engines/cine/various.cpp | 312 | ||||
-rw-r--r-- | engines/cine/various.h | 6 |
26 files changed, 474 insertions, 488 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp index 5ddc5d625f..747c9221ee 100644 --- a/engines/cine/anim.cpp +++ b/engines/cine/anim.cpp @@ -49,8 +49,6 @@ struct AnimHeader2Struct { uint16 field_E; }; -Common::Array<AnimData> animDataTable; - static const AnimDataEntry transparencyData[] = { {"ALPHA", 0xF}, {"TITRE2", 0xF}, @@ -400,7 +398,7 @@ void AnimData::save(Common::OutSaveFile &fHandle) const { */ void freeAnimDataRange(byte startIdx, byte numIdx) { for (byte i = 0; i < numIdx; i++) { - animDataTable[startIdx + i].clear(); + g_cine->_animDataTable[startIdx + i].clear(); } } @@ -514,7 +512,7 @@ void loadAnimHeader(AnimHeaderStruct &animHeader, Common::MemoryReadStream readS */ int emptyAnimSpace(int start = 0) { for (; start < NUM_MAX_ANIMDATA; start++) { - if (!animDataTable[start].data()) { + if (!g_cine->_animDataTable[start].data()) { return start; } } @@ -540,7 +538,7 @@ int loadSpl(const char *resourceName, int16 idx) { entry = idx < 0 ? emptyAnimSpace() : idx; assert(entry >= 0); - animDataTable[entry].load(dataPtr, ANIM_RAW, partBuffer[foundFileIdx].unpackedSize, 1, foundFileIdx, 0, currentPartName); + g_cine->_animDataTable[entry].load(dataPtr, ANIM_RAW, g_cine->_partBuffer[foundFileIdx].unpackedSize, 1, foundFileIdx, 0, currentPartName); free(dataPtr); return entry + 1; @@ -570,7 +568,7 @@ int loadMsk(const char *resourceName, int16 idx) { entry = idx < 0 ? emptyAnimSpace() : idx; assert(entry >= 0); for (int16 i = 0; i < animHeader.numFrames; i++, entry++) { - animDataTable[entry].load(ptr, ANIM_MASK, animHeader.frameWidth, animHeader.frameHeight, foundFileIdx, i, currentPartName); + g_cine->_animDataTable[entry].load(ptr, ANIM_MASK, animHeader.frameWidth, animHeader.frameHeight, foundFileIdx, i, currentPartName); ptr += animHeader.frameWidth * animHeader.frameHeight; } @@ -621,7 +619,7 @@ int loadAni(const char *resourceName, int16 idx) { transparentColor = i < 1 ? 0xE : 0; } - animDataTable[entry].load(ptr, ANIM_MASKSPRITE, animHeader.frameWidth, animHeader.frameHeight, foundFileIdx, i, currentPartName, transparentColor); + g_cine->_animDataTable[entry].load(ptr, ANIM_MASKSPRITE, animHeader.frameWidth, animHeader.frameHeight, foundFileIdx, i, currentPartName, transparentColor); ptr += animHeader.frameWidth * animHeader.frameHeight; } @@ -737,7 +735,7 @@ int loadSet(const char *resourceName, int16 idx) { type = ANIM_FULLSPRITE; } - animDataTable[entry].load(dataPtr, type, header2.width, header2.height, foundFileIdx, i, currentPartName); + g_cine->_animDataTable[entry].load(dataPtr, type, header2.width, header2.height, foundFileIdx, i, currentPartName); } free(origDataPtr); @@ -759,7 +757,7 @@ int loadSeq(const char *resourceName, int16 idx) { byte *dataPtr = readBundleFile(foundFileIdx); int entry = idx < 0 ? emptyAnimSpace() : idx; - animDataTable[entry].load(dataPtr+0x16, ANIM_RAW, partBuffer[foundFileIdx].unpackedSize-0x16, 1, foundFileIdx, 0, currentPartName); + g_cine->_animDataTable[entry].load(dataPtr+0x16, ANIM_RAW, g_cine->_partBuffer[foundFileIdx].unpackedSize-0x16, 1, foundFileIdx, 0, currentPartName); free(dataPtr); return entry + 1; } diff --git a/engines/cine/anim.h b/engines/cine/anim.h index e67237aac0..2012ef875e 100644 --- a/engines/cine/anim.h +++ b/engines/cine/anim.h @@ -99,8 +99,6 @@ public: #define NUM_MAX_ANIMDATA 255 -extern Common::Array<AnimData> animDataTable; - void freeAnimDataTable(); void freeAnimDataRange(byte startIdx, byte numIdx); int loadResource(const char *resourceName, int16 idx = -1); diff --git a/engines/cine/bg_list.cpp b/engines/cine/bg_list.cpp index 26351becf1..3ecda4125d 100644 --- a/engines/cine/bg_list.cpp +++ b/engines/cine/bg_list.cpp @@ -36,14 +36,13 @@ namespace Cine { uint32 var8; -Common::List<BGIncrust> bgIncrustList; /** * Add masked sprite to the background * @param objIdx Sprite description */ void addToBGList(int16 objIdx) { - renderer->incrustSprite(objectTable[objIdx]); + renderer->incrustSprite(g_cine->_objectTable[objIdx]); createBgIncrustListElement(objIdx, 0); } @@ -53,7 +52,7 @@ void addToBGList(int16 objIdx) { * @param objIdx Sprite description */ void addSpriteFilledToBGList(int16 objIdx) { - renderer->incrustMask(objectTable[objIdx]); + renderer->incrustMask(g_cine->_objectTable[objIdx]); createBgIncrustListElement(objIdx, 1); } @@ -69,12 +68,12 @@ void createBgIncrustListElement(int16 objIdx, int16 param) { tmp.unkPtr = 0; tmp.objIdx = objIdx; tmp.param = param; - tmp.x = objectTable[objIdx].x; - tmp.y = objectTable[objIdx].y; - tmp.frame = objectTable[objIdx].frame; - tmp.part = objectTable[objIdx].part; + tmp.x = g_cine->_objectTable[objIdx].x; + tmp.y = g_cine->_objectTable[objIdx].y; + tmp.frame = g_cine->_objectTable[objIdx].frame; + tmp.part = g_cine->_objectTable[objIdx].part; - bgIncrustList.push_back(tmp); + g_cine->_bgIncrustList.push_back(tmp); } /** @@ -104,12 +103,12 @@ void loadBgIncrustFromSave(Common::SeekableReadStream &fHandle) { tmp.frame = fHandle.readUint16BE(); tmp.part = fHandle.readUint16BE(); - bgIncrustList.push_back(tmp); + g_cine->_bgIncrustList.push_back(tmp); if (tmp.param == 0) { - renderer->incrustSprite(objectTable[tmp.objIdx]); + renderer->incrustSprite(g_cine->_objectTable[tmp.objIdx]); } else { - renderer->incrustMask(objectTable[tmp.objIdx]); + renderer->incrustMask(g_cine->_objectTable[tmp.objIdx]); } } } diff --git a/engines/cine/bg_list.h b/engines/cine/bg_list.h index 409b16dbd5..8c1b3cb6ec 100644 --- a/engines/cine/bg_list.h +++ b/engines/cine/bg_list.h @@ -42,7 +42,6 @@ struct BGIncrust { int16 part; }; -extern Common::List<BGIncrust> bgIncrustList; extern uint32 var8; void addToBGList(int16 objIdx); diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp index e6ac2859cf..5c2119c1e4 100644 --- a/engines/cine/cine.cpp +++ b/engines/cine/cine.cpp @@ -123,24 +123,26 @@ int CineEngine::modifyGameSpeed(int speedChange) { } void CineEngine::initialize() { + _globalVars.reinit(NUM_MAX_VAR + 1); + // Initialize all savegames' descriptions to empty strings memset(currentSaveName, 0, sizeof(currentSaveName)); // Resize object table to its correct size and reset all its elements - objectTable.resize(NUM_MAX_OBJECT); + g_cine->_objectTable.resize(NUM_MAX_OBJECT); resetObjectTable(); // Resize animation data table to its correct size and reset all its elements - animDataTable.resize(NUM_MAX_ANIMDATA); + g_cine->_animDataTable.resize(NUM_MAX_ANIMDATA); freeAnimDataTable(); // Resize zone data table to its correct size and reset all its elements - zoneData.resize(NUM_MAX_ZONE); - Common::set_to(zoneData.begin(), zoneData.end(), 0); + g_cine->_zoneData.resize(NUM_MAX_ZONE); + Common::set_to(g_cine->_zoneData.begin(), g_cine->_zoneData.end(), 0); // Resize zone query table to its correct size and reset all its elements - zoneQuery.resize(NUM_MAX_ZONE); - Common::set_to(zoneQuery.begin(), zoneQuery.end(), 0); + g_cine->_zoneQuery.resize(NUM_MAX_ZONE); + Common::set_to(g_cine->_zoneQuery.begin(), g_cine->_zoneQuery.end(), 0); _timerDelayMultiplier = 12; // Set default speed setupOpcodes(); @@ -159,7 +161,7 @@ void CineEngine::initialize() { // Clear part buffer as there's nothing loaded into it yet. // Its size will change when loading data into it with the loadPart function. - partBuffer.clear(); + g_cine->_partBuffer.clear(); if (getGameType() == Cine::GType_OS) { readVolCnf(); @@ -173,14 +175,14 @@ void CineEngine::initialize() { } // in case ScummVM engines can be restarted in the future - scriptTable.clear(); - relTable.clear(); - objectScripts.clear(); - globalScripts.clear(); - bgIncrustList.clear(); + g_cine->_scriptTable.clear(); + g_cine->_relTable.clear(); + g_cine->_objectScripts.clear(); + g_cine->_globalScripts.clear(); + g_cine->_bgIncrustList.clear(); freeAnimDataTable(); - overlayList.clear(); - messageTable.clear(); + g_cine->_overlayList.clear(); + g_cine->_messageTable.clear(); resetObjectTable(); var8 = 0; diff --git a/engines/cine/cine.h b/engines/cine/cine.h index 6f2c2243e2..114d98d442 100644 --- a/engines/cine/cine.h +++ b/engines/cine/cine.h @@ -47,6 +47,8 @@ #include "cine/pal.h" #include "cine/gfx.h" #include "cine/anim.h" +#include "cine/bg_list.h" +#include "cine/various.h" //#define DUMP_SCRIPTS @@ -93,6 +95,7 @@ enum CineGameFeatures { }; struct CINEGameDescription; +struct SeqListElement; typedef Common::HashMap<Common::String, const char *> StringPtrHashMap; @@ -150,6 +153,36 @@ private: bool _preLoad; int _timerDelayMultiplier; + + public: + // TODO: These are pseudo-global vars + // They better belong to appropriate classes + Common::Array<AnimData> _animDataTable; + Common::List<BGIncrust> _bgIncrustList; + Common::StringArray _messageTable; + Common::Array<ObjectStruct> _objectTable; + Common::List<overlay> _overlayList; + Common::Array<PalEntry> _palArray; + Common::Array<PartBuffer> _partBuffer; + ScriptList _globalScripts; + ScriptList _objectScripts; + RawObjectScriptArray _relTable; ///< Object script bytecode table + + /** + * Global variables. + * 255 of these are saved, but there's one more that's used for bypassing the copy protection. + * In CineEngine::mainLoop(int bootScriptIdx) there's this code: globalVars[VAR_BYPASS_PROTECTION] = 0; + * And as VAR_BYPASS_PROTECTION is 255 that's why we're allocating one more than we otherwise would. + */ + ScriptVars _globalVars; + RawScriptArray _scriptTable; ///< Table of script bytecode + + Common::Array<uint16> _zoneData; + Common::Array<uint16> _zoneQuery; ///< Only exists in Operation Stealth + + Common::List<SeqListElement> _seqList; + + Common::String _commandBuffer; }; extern CineEngine *g_cine; diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index 1f747c5a01..4d61be102b 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -160,13 +160,13 @@ void FWRenderer::clear() { * @param fillColor Sprite color */ void FWRenderer::fillSprite(const ObjectStruct &obj, uint8 color) { - const byte *data = animDataTable[obj.frame].data(); + const byte *data = g_cine->_animDataTable[obj.frame].data(); int x, y, width, height; x = obj.x; y = obj.y; - width = animDataTable[obj.frame]._realWidth; - height = animDataTable[obj.frame]._height; + width = g_cine->_animDataTable[obj.frame]._realWidth; + height = g_cine->_animDataTable[obj.frame]._height; gfxFillSprite(data, width, height, _backBuffer, x, y, color); } @@ -177,13 +177,13 @@ void FWRenderer::fillSprite(const ObjectStruct &obj, uint8 color) { * @param fillColor Sprite color */ void FWRenderer::incrustMask(const ObjectStruct &obj, uint8 color) { - const byte *data = animDataTable[obj.frame].data(); + const byte *data = g_cine->_animDataTable[obj.frame].data(); int x, y, width, height; x = obj.x; y = obj.y; - width = animDataTable[obj.frame]._realWidth; - height = animDataTable[obj.frame]._height; + width = g_cine->_animDataTable[obj.frame]._realWidth; + height = g_cine->_animDataTable[obj.frame]._height; gfxFillSprite(data, width, height, _background, x, y, color); } @@ -194,13 +194,13 @@ void FWRenderer::incrustMask(const ObjectStruct &obj, uint8 color) { * @param mask External mask */ void FWRenderer::drawMaskedSprite(const ObjectStruct &obj, const byte *mask) { - const byte *data = animDataTable[obj.frame].data(); + const byte *data = g_cine->_animDataTable[obj.frame].data(); int x, y, width, height; x = obj.x; y = obj.y; - width = animDataTable[obj.frame]._realWidth; - height = animDataTable[obj.frame]._height; + width = g_cine->_animDataTable[obj.frame]._realWidth; + height = g_cine->_animDataTable[obj.frame]._height; assert(mask); @@ -212,7 +212,7 @@ void FWRenderer::drawMaskedSprite(const ObjectStruct &obj, const byte *mask) { * @param obj Object info */ void FWRenderer::drawSprite(const ObjectStruct &obj) { - const byte *mask = animDataTable[obj.frame].mask(); + const byte *mask = g_cine->_animDataTable[obj.frame].mask(); drawMaskedSprite(obj, mask); } @@ -221,14 +221,14 @@ void FWRenderer::drawSprite(const ObjectStruct &obj) { * @param obj Object info */ void FWRenderer::incrustSprite(const ObjectStruct &obj) { - const byte *data = animDataTable[obj.frame].data(); - const byte *mask = animDataTable[obj.frame].mask(); + const byte *data = g_cine->_animDataTable[obj.frame].data(); + const byte *mask = g_cine->_animDataTable[obj.frame].mask(); int x, y, width, height; x = obj.x; y = obj.y; - width = animDataTable[obj.frame]._realWidth; - height = animDataTable[obj.frame]._height; + width = g_cine->_animDataTable[obj.frame]._realWidth; + height = g_cine->_animDataTable[obj.frame]._height; // There was an assert(mask) here before but it made savegame loading // in Future Wars sometimes fail the assertion (e.g. see bug #2055912). @@ -502,27 +502,27 @@ void FWRenderer::drawLine(int x, int y, int width, int height, byte color) { * @param it Overlay info from overlayList */ void FWRenderer::remaskSprite(byte *mask, Common::List<overlay>::iterator it) { - AnimData &sprite = animDataTable[objectTable[it->objIdx].frame]; + AnimData &sprite = g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame]; int x, y, width, height, idx; int mx, my, mw, mh; - x = objectTable[it->objIdx].x; - y = objectTable[it->objIdx].y; + x = g_cine->_objectTable[it->objIdx].x; + y = g_cine->_objectTable[it->objIdx].y; width = sprite._realWidth; height = sprite._height; - for (++it; it != overlayList.end(); ++it) { + for (++it; it != g_cine->_overlayList.end(); ++it) { if (it->type != 5) { continue; } - idx = ABS(objectTable[it->objIdx].frame); - mx = objectTable[it->objIdx].x; - my = objectTable[it->objIdx].y; - mw = animDataTable[idx]._realWidth; - mh = animDataTable[idx]._height; + idx = ABS(g_cine->_objectTable[it->objIdx].frame); + mx = g_cine->_objectTable[it->objIdx].x; + my = g_cine->_objectTable[it->objIdx].y; + mw = g_cine->_animDataTable[idx]._realWidth; + mh = g_cine->_animDataTable[idx]._height; - gfxUpdateSpriteMask(mask, x, y, width, height, animDataTable[idx].data(), mx, my, mw, mh); + gfxUpdateSpriteMask(mask, x, y, width, height, g_cine->_animDataTable[idx].data(), mx, my, mw, mh); } } @@ -547,26 +547,26 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { switch (it->type) { // color sprite case 0: - if (objectTable[it->objIdx].frame < 0) { + if (g_cine->_objectTable[it->objIdx].frame < 0) { return; } - sprite = &animDataTable[objectTable[it->objIdx].frame]; + sprite = &g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame]; len = sprite->_realWidth * sprite->_height; mask = new byte[len]; memcpy(mask, sprite->mask(), len); remaskSprite(mask, it); - drawMaskedSprite(objectTable[it->objIdx], mask); + drawMaskedSprite(g_cine->_objectTable[it->objIdx], mask); delete[] mask; break; // game message case 2: - if (it->objIdx >= messageTable.size()) { + if (it->objIdx >= g_cine->_messageTable.size()) { return; } - _messageLen += messageTable[it->objIdx].size(); - drawMessage(messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); + _messageLen += g_cine->_messageTable[it->objIdx].size(); + drawMessage(g_cine->_messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); waitForPlayerClick = 1; break; @@ -585,13 +585,13 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { // bitmap case 4: assert(it->objIdx < NUM_MAX_OBJECT); - obj = &objectTable[it->objIdx]; + obj = &g_cine->_objectTable[it->objIdx]; if (obj->frame < 0) { return; } - if (!animDataTable[obj->frame].data()) { + if (!g_cine->_animDataTable[obj->frame].data()) { return; } @@ -606,7 +606,7 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { void FWRenderer::drawOverlays() { Common::List<overlay>::iterator it; - for (it = overlayList.begin(); it != overlayList.end(); ++it) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) { renderOverlay(it); } } @@ -1122,13 +1122,13 @@ void OSRenderer::clear() { * @param fillColor Sprite color */ void OSRenderer::incrustMask(const ObjectStruct &obj, uint8 color) { - const byte *data = animDataTable[obj.frame].data(); + const byte *data = g_cine->_animDataTable[obj.frame].data(); int x, y, width, height; x = obj.x; y = obj.y; - width = animDataTable[obj.frame]._realWidth; - height = animDataTable[obj.frame]._height; + width = g_cine->_animDataTable[obj.frame]._realWidth; + height = g_cine->_animDataTable[obj.frame]._height; if (_bgTable[_currentBg].bg) { gfxFillSprite(data, width, height, _bgTable[_currentBg].bg, x, y, color); @@ -1140,14 +1140,14 @@ void OSRenderer::incrustMask(const ObjectStruct &obj, uint8 color) { * @param obj Object info */ void OSRenderer::drawSprite(const ObjectStruct &obj) { - const byte *data = animDataTable[obj.frame].data(); + const byte *data = g_cine->_animDataTable[obj.frame].data(); int x, y, width, height, transColor; x = obj.x; y = obj.y; transColor = obj.part; - width = animDataTable[obj.frame]._realWidth; - height = animDataTable[obj.frame]._height; + width = g_cine->_animDataTable[obj.frame]._realWidth; + height = g_cine->_animDataTable[obj.frame]._height; drawSpriteRaw2(data, transColor, width, height, _backBuffer, x, y); } @@ -1157,14 +1157,14 @@ void OSRenderer::drawSprite(const ObjectStruct &obj) { * @param obj Object info */ void OSRenderer::incrustSprite(const ObjectStruct &obj) { - const byte *data = animDataTable[obj.frame].data(); + const byte *data = g_cine->_animDataTable[obj.frame].data(); int x, y, width, height, transColor; x = obj.x; y = obj.y; transColor = obj.part; - width = animDataTable[obj.frame]._realWidth; - height = animDataTable[obj.frame]._height; + width = g_cine->_animDataTable[obj.frame]._realWidth; + height = g_cine->_animDataTable[obj.frame]._height; if (_bgTable[_currentBg].bg) { drawSpriteRaw2(data, transColor, width, height, _bgTable[_currentBg].bg, x, y); @@ -1233,26 +1233,26 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { switch (it->type) { // color sprite case 0: - if (objectTable[it->objIdx].frame < 0) { + if (g_cine->_objectTable[it->objIdx].frame < 0) { break; } - sprite = &animDataTable[objectTable[it->objIdx].frame]; + sprite = &g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame]; len = sprite->_realWidth * sprite->_height; mask = new byte[len]; - generateMask(sprite->data(), mask, len, objectTable[it->objIdx].part); + generateMask(sprite->data(), mask, len, g_cine->_objectTable[it->objIdx].part); remaskSprite(mask, it); - drawMaskedSprite(objectTable[it->objIdx], mask); + drawMaskedSprite(g_cine->_objectTable[it->objIdx], mask); delete[] mask; break; // game message case 2: - if (it->objIdx >= messageTable.size()) { + if (it->objIdx >= g_cine->_messageTable.size()) { return; } - _messageLen += messageTable[it->objIdx].size(); - drawMessage(messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); + _messageLen += g_cine->_messageTable[it->objIdx].size(); + drawMessage(g_cine->_messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); if (it->color >= 0) { // This test isn't in Future Wars's implementation waitForPlayerClick = 1; } @@ -1273,7 +1273,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { // bitmap case 4: - if (objectTable[it->objIdx].frame >= 0) { + if (g_cine->_objectTable[it->objIdx].frame >= 0) { FWRenderer::renderOverlay(it); } break; @@ -1282,8 +1282,8 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { case 20: assert(it->objIdx < NUM_MAX_OBJECT); var5 = it->x; // A global variable updated here! - obj = &objectTable[it->objIdx]; - sprite = &animDataTable[obj->frame]; + obj = &g_cine->_objectTable[it->objIdx]; + sprite = &g_cine->_animDataTable[obj->frame]; if (obj->frame < 0 || it->x < 0 || it->x > 8 || !_bgTable[it->x].bg || sprite->_bpp != 1) { break; @@ -1303,7 +1303,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) { case 22: // TODO: Check it this implementation really works correctly (Some things might be wrong, needs testing). assert(it->objIdx < NUM_MAX_OBJECT); - obj = &objectTable[it->objIdx]; + obj = &g_cine->_objectTable[it->objIdx]; color = obj->part & 0x0F; width = obj->frame; height = obj->costume; @@ -1797,17 +1797,17 @@ void maskBgOverlay(const byte *bgPtr, const byte *maskPtr, int16 width, int16 he maskPtr = backup; // incrust pass - for (it = bgIncrustList.begin(); it != bgIncrustList.end(); ++it) { - tmpWidth = animDataTable[it->frame]._realWidth; - tmpHeight = animDataTable[it->frame]._height; + for (it = g_cine->_bgIncrustList.begin(); it != g_cine->_bgIncrustList.end(); ++it) { + tmpWidth = g_cine->_animDataTable[it->frame]._realWidth; + tmpHeight = g_cine->_animDataTable[it->frame]._height; mask = (byte*)malloc(tmpWidth * tmpHeight); if (it->param == 0) { - generateMask(animDataTable[it->frame].data(), mask, tmpWidth * tmpHeight, it->part); + generateMask(g_cine->_animDataTable[it->frame].data(), mask, tmpWidth * tmpHeight, it->part); gfxUpdateIncrustMask(mask, it->x, it->y, tmpWidth, tmpHeight, maskPtr, x, y, width, height); - gfxDrawMaskedSprite(animDataTable[it->frame].data(), mask, tmpWidth, tmpHeight, page, it->x, it->y); + gfxDrawMaskedSprite(g_cine->_animDataTable[it->frame].data(), mask, tmpWidth, tmpHeight, page, it->x, it->y); } else { - memcpy(mask, animDataTable[it->frame].data(), tmpWidth * tmpHeight); + memcpy(mask, g_cine->_animDataTable[it->frame].data(), tmpWidth * tmpHeight); gfxUpdateIncrustMask(mask, it->x, it->y, tmpWidth, tmpHeight, maskPtr, x, y, width, height); gfxFillSprite(mask, tmpWidth, tmpHeight, page, it->x, it->y); } diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp index 414aed394c..3d280c20ef 100644 --- a/engines/cine/main_loop.cpp +++ b/engines/cine/main_loop.cpp @@ -241,11 +241,11 @@ int getKeyData() { /** Removes elements from seqList that have their member variable var4 set to value -1. */ void purgeSeqList() { - Common::List<SeqListElement>::iterator it = seqList.begin(); - while (it != seqList.end()) { + Common::List<SeqListElement>::iterator it = g_cine->_seqList.begin(); + while (it != g_cine->_seqList.end()) { if (it->var4 == -1) { // Erase the element and jump to the next element - it = seqList.erase(it); + it = g_cine->_seqList.erase(it); } else { // Let the element be and jump to the next element it++; @@ -283,15 +283,15 @@ void CineEngine::mainLoop(int bootScriptIdx) { menuCommandLen = 0; playerCommand = -1; - commandBuffer = ""; + g_cine->_commandBuffer = ""; - globalVars[VAR_MOUSE_X_POS] = 0; - globalVars[VAR_MOUSE_Y_POS] = 0; + g_cine->_globalVars[VAR_MOUSE_X_POS] = 0; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = 0; if (g_cine->getGameType() == Cine::GType_OS) { - globalVars[VAR_MOUSE_X_POS_2ND] = 0; - globalVars[VAR_MOUSE_Y_POS_2ND] = 0; - globalVars[VAR_BYPASS_PROTECTION] = 0; // set to 1 to bypass the copy protection - globalVars[VAR_LOW_MEMORY] = 0; // set to 1 to disable some animations, sounds etc. + g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = 0; + g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = 0; + g_cine->_globalVars[VAR_BYPASS_PROTECTION] = 0; // set to 1 to bypass the copy protection + g_cine->_globalVars[VAR_LOW_MEMORY] = 0; // set to 1 to disable some animations, sounds etc. } strcpy(newPrcName, ""); @@ -315,7 +315,7 @@ void CineEngine::mainLoop(int bootScriptIdx) { if (bgName == "28.PI1" || bgName == "29.PI1" || bgName == "30.PI1") { static const uint oxygenObjNum = 202, maxOxygen = 264; // Force the amount of oxygen left to the maximum. - objectTable[oxygenObjNum].x = maxOxygen; + g_cine->_objectTable[oxygenObjNum].x = maxOxygen; } } @@ -332,8 +332,8 @@ void CineEngine::mainLoop(int bootScriptIdx) { // flower shop scene is AIRPORT.PRC's 13th script. // FIXME: Remove the hack and solve what's really causing the problem in the first place. if (g_cine->getGameType() == Cine::GType_OS) { - if (scumm_stricmp(renderer->getBgName(), "21.PI1") == 0 && objectTable[1].x == 204 && objectTable[1].y == 110) { - objectTable[1].y--; // Move the player character upward on-screen by one pixel + if (scumm_stricmp(renderer->getBgName(), "21.PI1") == 0 && g_cine->_objectTable[1].x == 204 && g_cine->_objectTable[1].y == 110) { + g_cine->_objectTable[1].y--; // Move the player character upward on-screen by one pixel } } @@ -342,7 +342,7 @@ void CineEngine::mainLoop(int bootScriptIdx) { // Clear the zoneQuery table (Operation Stealth specific) if (g_cine->getGameType() == Cine::GType_OS) { - Common::set_to(zoneQuery.begin(), zoneQuery.end(), 0); + Common::set_to(g_cine->_zoneQuery.begin(), g_cine->_zoneQuery.end(), 0); } if (g_cine->getGameType() == Cine::GType_OS) { diff --git a/engines/cine/msg.cpp b/engines/cine/msg.cpp index 45f81f7d05..a01afd147b 100644 --- a/engines/cine/msg.cpp +++ b/engines/cine/msg.cpp @@ -31,15 +31,11 @@ namespace Cine { -// FIXME: Global C++ objects affect portability negatively. -// Turn this into a class member instead. -Common::StringArray messageTable; - void loadMsg(char *pMsgName) { uint32 sourceSize; checkDataDisk(-1); - messageTable.clear(); + g_cine->_messageTable.clear(); byte *dataPtr = readBundleFile(findFileInBundle(pMsgName), &sourceSize); setMouseCursor(MOUSE_CURSOR_DISK); @@ -58,7 +54,7 @@ void loadMsg(char *pMsgName) { // This code works around input data that has empty strings residing outside the input // buffer (e.g. message indexes 58-254 in BATEAU.MSG in PROCS08 in Operation Stealth). if (messageDataPos < sourceSize) { - messageTable.push_back((const char *)(dataPtr + messageDataPos)); + g_cine->_messageTable.push_back((const char *)(dataPtr + messageDataPos)); } else { if (messageLen > 0) { // Only warn about overflowing non-empty strings warning("loadMsg(%s): message (%d. / %d) is overflowing the input buffer. Replacing it with an empty string", pMsgName, i + 1, count); @@ -66,7 +62,7 @@ void loadMsg(char *pMsgName) { debugC(5, kCineDebugPart, "loadMsg(%s): empty message (%d. / %d) resides outside input buffer", pMsgName, i + 1, count); } // Message resides outside the input buffer so we replace it with an empty string - messageTable.push_back(""); + g_cine->_messageTable.push_back(""); } // Jump to the next message messageDataPos += messageLen; diff --git a/engines/cine/msg.h b/engines/cine/msg.h index cf51cdb48f..fbf99d4b44 100644 --- a/engines/cine/msg.h +++ b/engines/cine/msg.h @@ -32,8 +32,6 @@ namespace Cine { #define NUM_MAX_MESSAGE 255 -extern Common::StringArray messageTable; - void loadMsg(char *pMsgName); } // End of namespace Cine diff --git a/engines/cine/object.cpp b/engines/cine/object.cpp index 116b57c267..82dc0a6ef1 100644 --- a/engines/cine/object.cpp +++ b/engines/cine/object.cpp @@ -35,12 +35,9 @@ namespace Cine { -Common::Array<ObjectStruct> objectTable; -Common::List<overlay> overlayList; - /** Resets all elements in the object table. */ void resetObjectTable() { - for (Common::Array<ObjectStruct>::iterator it = objectTable.begin(); it != objectTable.end(); ++it) { + for (Common::Array<ObjectStruct>::iterator it = g_cine->_objectTable.begin(); it != g_cine->_objectTable.end(); ++it) { it->clear(); } } @@ -64,23 +61,23 @@ void loadObject(char *pObjectName) { assert(numEntry <= NUM_MAX_OBJECT); for (i = 0; i < numEntry; i++) { - if (objectTable[i].costume != -2) { // flag is keep ? + if (g_cine->_objectTable[i].costume != -2) { // flag is keep ? Common::MemoryReadStream readS(ptr, entrySize); - objectTable[i].x = readS.readSint16BE(); - objectTable[i].y = readS.readSint16BE(); - objectTable[i].mask = readS.readUint16BE(); - objectTable[i].frame = readS.readSint16BE(); - objectTable[i].costume = readS.readSint16BE(); - readS.read(objectTable[i].name, 20); - objectTable[i].part = readS.readUint16BE(); + g_cine->_objectTable[i].x = readS.readSint16BE(); + g_cine->_objectTable[i].y = readS.readSint16BE(); + g_cine->_objectTable[i].mask = readS.readUint16BE(); + g_cine->_objectTable[i].frame = readS.readSint16BE(); + g_cine->_objectTable[i].costume = readS.readSint16BE(); + readS.read(g_cine->_objectTable[i].name, 20); + g_cine->_objectTable[i].part = readS.readUint16BE(); } ptr += entrySize; } if (!strcmp(pObjectName, "INTRO.OBJ")) { for (i = 0; i < 10; i++) { - objectTable[i].costume = 0; + g_cine->_objectTable[i].costume = 0; } } @@ -95,9 +92,9 @@ void loadObject(char *pObjectName) { int removeOverlay(uint16 objIdx, uint16 param) { Common::List<overlay>::iterator it; - for (it = overlayList.begin(); it != overlayList.end(); ++it) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) { if (it->objIdx == objIdx && it->type == param) { - overlayList.erase(it); + g_cine->_overlayList.erase(it); return 1; } } @@ -115,9 +112,9 @@ void addOverlay(uint16 objIdx, uint16 type) { Common::List<overlay>::iterator it; overlay tmp; - for (it = overlayList.begin(); it != overlayList.end(); ++it) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) { // This is done for both Future Wars and Operation Stealth - if (objectTable[it->objIdx].mask >= objectTable[objIdx].mask) { + if (g_cine->_objectTable[it->objIdx].mask >= g_cine->_objectTable[objIdx].mask) { break; } @@ -128,7 +125,7 @@ void addOverlay(uint16 objIdx, uint16 type) { } // In Operation Stealth's implementation we might bail out early - if (g_cine->getGameType() == Cine::GType_OS && it != overlayList.end() && it->objIdx == objIdx && it->type == type) { + if (g_cine->getGameType() == Cine::GType_OS && it != g_cine->_overlayList.end() && it->objIdx == objIdx && it->type == type) { return; } @@ -139,7 +136,7 @@ void addOverlay(uint16 objIdx, uint16 type) { tmp.width = 0; tmp.color = 0; - overlayList.insert(it, tmp); + g_cine->_overlayList.insert(it, tmp); } /** @@ -151,13 +148,13 @@ void addGfxElement(int16 objIdx, int16 param, int16 type) { Common::List<overlay>::iterator it; overlay tmp; - for (it = overlayList.begin(); it != overlayList.end(); ++it) { - if (objectTable[it->objIdx].mask >= objectTable[objIdx].mask || it->type == 2 || it->type == 3) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) { + if (g_cine->_objectTable[it->objIdx].mask >= g_cine->_objectTable[objIdx].mask || it->type == 2 || it->type == 3) { break; } } - if (it != overlayList.end() && it->objIdx == objIdx && it->type == type && it->x == param) { + if (it != g_cine->_overlayList.end() && it->objIdx == objIdx && it->type == type && it->x == param) { return; } @@ -168,7 +165,7 @@ void addGfxElement(int16 objIdx, int16 param, int16 type) { tmp.width = 0; tmp.color = 0; - overlayList.insert(it, tmp); + g_cine->_overlayList.insert(it, tmp); } /** @@ -180,19 +177,19 @@ void addGfxElement(int16 objIdx, int16 param, int16 type) { void removeGfxElement(int16 objIdx, int16 param, int16 type) { Common::List<overlay>::iterator it; - for (it = overlayList.begin(); it != overlayList.end(); ++it) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) { if (it->objIdx == objIdx && it->type == type && it->x == param) { - overlayList.erase(it); + g_cine->_overlayList.erase(it); return; } } } void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint16 param4) { - objectTable[objIdx].x = param1; - objectTable[objIdx].y = param2; - objectTable[objIdx].mask = param3; - objectTable[objIdx].frame = param4; + g_cine->_objectTable[objIdx].x = param1; + g_cine->_objectTable[objIdx].y = param2; + g_cine->_objectTable[objIdx].mask = param3; + g_cine->_objectTable[objIdx].frame = param4; if (g_cine->getGameType() == Cine::GType_OS) { resetGfxEntityEntry(objIdx); @@ -219,13 +216,13 @@ void modifyObjectParam(byte objIdx, byte paramIdx, int16 newValue) { switch (paramIdx) { case 1: - objectTable[objIdx].x = newValue; + g_cine->_objectTable[objIdx].x = newValue; break; case 2: - objectTable[objIdx].y = newValue; + g_cine->_objectTable[objIdx].y = newValue; break; case 3: - objectTable[objIdx].mask = newValue; + g_cine->_objectTable[objIdx].mask = newValue; if (g_cine->getGameType() == Cine::GType_OS) { // Operation Stealth specific resetGfxEntityEntry(objIdx); @@ -236,18 +233,18 @@ void modifyObjectParam(byte objIdx, byte paramIdx, int16 newValue) { } break; case 4: - objectTable[objIdx].frame = newValue; + g_cine->_objectTable[objIdx].frame = newValue; break; case 5: // TODO: Test if this really breaks the newspaper machine on the airport in Operation Stealth. if (g_cine->getGameType() == Cine::GType_FW && newValue == -1) { - objectTable[objIdx].costume = globalVars[0]; + g_cine->_objectTable[objIdx].costume = g_cine->_globalVars[0]; } else { - objectTable[objIdx].costume = newValue; + g_cine->_objectTable[objIdx].costume = newValue; } break; case 6: - objectTable[objIdx].part = newValue; + g_cine->_objectTable[objIdx].part = newValue; break; } } @@ -263,8 +260,8 @@ bool compareRanges(uint16 aStart, uint16 aEnd, uint16 bStart, uint16 bEnd) { uint16 compareObjectParamRanges(uint16 objIdx1, uint16 xAdd1, uint16 yAdd1, uint16 maskAdd1, uint16 objIdx2, uint16 xAdd2, uint16 yAdd2, uint16 maskAdd2) { assert(objIdx1 < NUM_MAX_OBJECT && objIdx2 < NUM_MAX_OBJECT); - const ObjectStruct &obj1 = objectTable[objIdx1]; - const ObjectStruct &obj2 = objectTable[objIdx2]; + const ObjectStruct &obj1 = g_cine->_objectTable[objIdx1]; + const ObjectStruct &obj2 = g_cine->_objectTable[objIdx2]; if (compareRanges(obj1.x, obj1.x + xAdd1, obj2.x, obj2.x + xAdd2) && compareRanges(obj1.y, obj1.y + yAdd1, obj2.y, obj2.y + yAdd2) && @@ -304,17 +301,17 @@ int16 getObjectParam(uint16 objIdx, uint16 paramIdx) { switch (paramIdx) { case 0: - return objectTable[objIdx].x; + return g_cine->_objectTable[objIdx].x; case 1: - return objectTable[objIdx].y; + return g_cine->_objectTable[objIdx].y; case 2: - return objectTable[objIdx].mask; + return g_cine->_objectTable[objIdx].mask; case 3: - return objectTable[objIdx].frame; + return g_cine->_objectTable[objIdx].frame; case 4: - return objectTable[objIdx].costume; + return g_cine->_objectTable[objIdx].costume; case 5: - return objectTable[objIdx].part; + return g_cine->_objectTable[objIdx].part; } return 0; diff --git a/engines/cine/object.h b/engines/cine/object.h index daf515bf0f..5a5ea91286 100644 --- a/engines/cine/object.h +++ b/engines/cine/object.h @@ -63,9 +63,6 @@ struct overlay { #define NUM_MAX_OBJECT 255 #define NUM_MAX_VAR 255 -extern Common::Array<ObjectStruct> objectTable; -extern Common::List<overlay> overlayList; - void resetObjectTable(); void loadObject(char *pObjectName); void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint16 param4); diff --git a/engines/cine/pal.cpp b/engines/cine/pal.cpp index 6e730aedd9..27d0e593da 100644 --- a/engines/cine/pal.cpp +++ b/engines/cine/pal.cpp @@ -30,7 +30,6 @@ namespace Cine { -Common::Array<PalEntry> palArray; static byte paletteBuffer1[16]; static byte paletteBuffer2[16]; @@ -40,7 +39,7 @@ void loadPal(const char *fileName) { removeExtention(buffer, fileName); strcat(buffer, ".PAL"); - palArray.clear(); + g_cine->_palArray.clear(); Common::File palFileHandle; if (!palFileHandle.open(buffer)) @@ -49,11 +48,11 @@ void loadPal(const char *fileName) { uint16 palEntriesCount = palFileHandle.readUint16LE(); palFileHandle.readUint16LE(); // entry size - palArray.resize(palEntriesCount); - for (uint i = 0; i < palArray.size(); ++i) { - palFileHandle.read(palArray[i].name, 10); - palFileHandle.read(palArray[i].pal1, 16); - palFileHandle.read(palArray[i].pal2, 16); + g_cine->_palArray.resize(palEntriesCount); + for (uint i = 0; i < g_cine->_palArray.size(); ++i) { + palFileHandle.read(g_cine->_palArray[i].name, 10); + palFileHandle.read(g_cine->_palArray[i].pal1, 16); + palFileHandle.read(g_cine->_palArray[i].pal2, 16); } palFileHandle.close(); } @@ -73,8 +72,8 @@ int16 findPaletteFromName(const char *fileName) { position++; } - for (i = 0; i < palArray.size(); i++) { - if (!strcmp(buffer, palArray[i].name)) { + for (i = 0; i < g_cine->_palArray.size(); i++) { + if (!strcmp(buffer, g_cine->_palArray[i].name)) { return i; } } @@ -97,9 +96,9 @@ void loadRelatedPalette(const char *fileName) { paletteBuffer1[i] = paletteBuffer2[i] = (i << 4) + i; } } else { - assert(paletteIndex < (int32)palArray.size()); - memcpy(paletteBuffer1, palArray[paletteIndex].pal1, 16); - memcpy(paletteBuffer2, palArray[paletteIndex].pal2, 16); + assert(paletteIndex < (int32)g_cine->_palArray.size()); + memcpy(paletteBuffer1, g_cine->_palArray[paletteIndex].pal1, 16); + memcpy(paletteBuffer2, g_cine->_palArray[paletteIndex].pal2, 16); } } diff --git a/engines/cine/pal.h b/engines/cine/pal.h index 0086711636..e5b318b24d 100644 --- a/engines/cine/pal.h +++ b/engines/cine/pal.h @@ -49,8 +49,6 @@ struct PalEntry { byte pal2[16]; }; -extern Common::Array<PalEntry> palArray; - void loadPal(const char *fileName); void loadRelatedPalette(const char *fileName); diff --git a/engines/cine/part.cpp b/engines/cine/part.cpp index ad5aaf54b0..95f3789abd 100644 --- a/engines/cine/part.cpp +++ b/engines/cine/part.cpp @@ -32,10 +32,8 @@ namespace Cine { -Common::Array<PartBuffer> partBuffer; - void loadPart(const char *partName) { - partBuffer.clear(); + g_cine->_partBuffer.clear(); g_cine->_partFileHandle.close(); @@ -47,17 +45,17 @@ void loadPart(const char *partName) { setMouseCursor(MOUSE_CURSOR_DISK); uint16 numElementInPart = g_cine->_partFileHandle.readUint16BE(); - partBuffer.resize(numElementInPart); + g_cine->_partBuffer.resize(numElementInPart); g_cine->_partFileHandle.readUint16BE(); // entry size if (currentPartName != partName) strcpy(currentPartName, partName); - for (uint16 i = 0; i < partBuffer.size(); i++) { - g_cine->_partFileHandle.read(partBuffer[i].partName, 14); - partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE(); - partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE(); - partBuffer[i].unpackedSize = g_cine->_partFileHandle.readUint32BE(); + for (uint16 i = 0; i < g_cine->_partBuffer.size(); i++) { + g_cine->_partFileHandle.read(g_cine->_partBuffer[i].partName, 14); + g_cine->_partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE(); + g_cine->_partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE(); + g_cine->_partBuffer[i].unpackedSize = g_cine->_partFileHandle.readUint32BE(); g_cine->_partFileHandle.readUint32BE(); // unused } @@ -189,8 +187,8 @@ void CineEngine::readVolCnf() { int16 findFileInBundle(const char *fileName) { if (g_cine->getGameType() == Cine::GType_OS) { // look first in currently loaded resource file - for (uint i = 0; i < partBuffer.size(); i++) { - if (!scumm_stricmp(fileName, partBuffer[i].partName)) { + for (uint i = 0; i < g_cine->_partBuffer.size(); i++) { + if (!scumm_stricmp(fileName, g_cine->_partBuffer[i].partName)) { return i; } } @@ -203,8 +201,8 @@ int16 findFileInBundle(const char *fileName) { const char *part = (*it)._value; loadPart(part); } - for (uint i = 0; i < partBuffer.size(); i++) { - if (!scumm_stricmp(fileName, partBuffer[i].partName)) { + for (uint i = 0; i < g_cine->_partBuffer.size(); i++) { + if (!scumm_stricmp(fileName, g_cine->_partBuffer[i].partName)) { return i; } } @@ -212,31 +210,31 @@ int16 findFileInBundle(const char *fileName) { } void readFromPart(int16 idx, byte *dataPtr, uint32 maxSize) { - assert(maxSize >= partBuffer[idx].packedSize); + assert(maxSize >= g_cine->_partBuffer[idx].packedSize); setMouseCursor(MOUSE_CURSOR_DISK); - g_cine->_partFileHandle.seek(partBuffer[idx].offset, SEEK_SET); - g_cine->_partFileHandle.read(dataPtr, partBuffer[idx].packedSize); + g_cine->_partFileHandle.seek(g_cine->_partBuffer[idx].offset, SEEK_SET); + g_cine->_partFileHandle.read(dataPtr, g_cine->_partBuffer[idx].packedSize); } byte *readBundleFile(int16 foundFileIdx, uint32 *size) { - assert(foundFileIdx >= 0 && foundFileIdx < (int32)partBuffer.size()); + assert(foundFileIdx >= 0 && foundFileIdx < (int32)g_cine->_partBuffer.size()); bool error = false; - byte *dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1); - byte *packedData = (byte *)calloc(partBuffer[foundFileIdx].packedSize, 1); + byte *dataPtr = (byte *)calloc(g_cine->_partBuffer[foundFileIdx].unpackedSize, 1); + byte *packedData = (byte *)calloc(g_cine->_partBuffer[foundFileIdx].packedSize, 1); assert(dataPtr && packedData); - readFromPart(foundFileIdx, packedData, partBuffer[foundFileIdx].packedSize); + readFromPart(foundFileIdx, packedData, g_cine->_partBuffer[foundFileIdx].packedSize); CineUnpacker cineUnpacker; - error = !cineUnpacker.unpack(packedData, partBuffer[foundFileIdx].packedSize, dataPtr, partBuffer[foundFileIdx].unpackedSize); + error = !cineUnpacker.unpack(packedData, g_cine->_partBuffer[foundFileIdx].packedSize, dataPtr, g_cine->_partBuffer[foundFileIdx].unpackedSize); free(packedData); if (error) { - warning("Error unpacking '%s' from bundle file '%s'", partBuffer[foundFileIdx].partName, currentPartName); + warning("Error unpacking '%s' from bundle file '%s'", g_cine->_partBuffer[foundFileIdx].partName, currentPartName); } // Set the size variable if a pointer to it has been given if (size != NULL) { - *size = partBuffer[foundFileIdx].unpackedSize; + *size = g_cine->_partBuffer[foundFileIdx].unpackedSize; } return dataPtr; @@ -255,7 +253,7 @@ byte *readBundleSoundFile(const char *entryName, uint32 *size) { if (index != -1) { data = readBundleFile(index); if (size) { - *size = partBuffer[index].unpackedSize; + *size = g_cine->_partBuffer[index].unpackedSize; } } if (g_cine->getGameType() == Cine::GType_FW) { @@ -305,14 +303,14 @@ void dumpBundle(const char *fileName) { strcpy(tmpPart, currentPartName); loadPart(fileName); - for (uint i = 0; i < partBuffer.size(); i++) { + for (uint i = 0; i < g_cine->_partBuffer.size(); i++) { byte *data = readBundleFile(i); - debug(0, "%s", partBuffer[i].partName); + debug(0, "%s", g_cine->_partBuffer[i].partName); Common::DumpFile out; - if (out.open(Common::String("dumps/") + partBuffer[i].partName)) { - out.write(data, partBuffer[i].unpackedSize); + if (out.open(Common::String("dumps/") + g_cine->_partBuffer[i].partName)) { + out.write(data, g_cine->_partBuffer[i].unpackedSize); out.close(); } diff --git a/engines/cine/part.h b/engines/cine/part.h index 2f1af7141f..53ebafaa37 100644 --- a/engines/cine/part.h +++ b/engines/cine/part.h @@ -37,8 +37,6 @@ struct PartBuffer { #define NUM_MAX_PARTDATA 255 -extern Common::Array<PartBuffer> partBuffer; - void loadPart(const char *partName); void closePart(); diff --git a/engines/cine/prc.cpp b/engines/cine/prc.cpp index e1ef14bbbf..183a537416 100644 --- a/engines/cine/prc.cpp +++ b/engines/cine/prc.cpp @@ -35,9 +35,6 @@ namespace Cine { -ScriptList globalScripts; -ScriptList objectScripts; - //char currentPrcName[20]; /** @@ -52,8 +49,8 @@ bool loadPrc(const char *pPrcName) { assert(pPrcName); - globalScripts.clear(); - scriptTable.clear(); + g_cine->_globalScripts.clear(); + g_cine->_scriptTable.clear(); // This is copy protection. Used to hang the machine if (!scumm_stricmp(pPrcName, COPY_PROT_FAIL_PRC_NAME)) { @@ -83,14 +80,14 @@ bool loadPrc(const char *pPrcName) { RawScriptPtr tmp(new RawScript(READ_BE_UINT16(scriptPtr))); scriptPtr += 2; assert(tmp); - scriptTable.push_back(tmp); + g_cine->_scriptTable.push_back(tmp); } for (i = 0; i < numScripts; i++) { - uint16 size = scriptTable[i]->_size; + uint16 size = g_cine->_scriptTable[i]->_size; // TODO: delete the test? if (size) { - scriptTable[i]->setData(*scriptInfo, scriptPtr); + g_cine->_scriptTable[i]->setData(*scriptInfo, scriptPtr); scriptPtr += size; } } diff --git a/engines/cine/prc.h b/engines/cine/prc.h index 05bb240372..84058426fa 100644 --- a/engines/cine/prc.h +++ b/engines/cine/prc.h @@ -28,9 +28,6 @@ namespace Cine { -extern ScriptList globalScripts; -extern ScriptList objectScripts; - bool loadPrc(const char *pPrcName); } // End of namespace Cine diff --git a/engines/cine/rel.cpp b/engines/cine/rel.cpp index 17ab14bfe5..4a11995ee1 100644 --- a/engines/cine/rel.cpp +++ b/engines/cine/rel.cpp @@ -31,8 +31,6 @@ namespace Cine { -RawObjectScriptArray relTable; ///< Object script bytecode table - /** * @todo Is script size of 0 valid? * @todo Fix script dump code @@ -45,8 +43,8 @@ void loadRel(char *pRelName) { checkDataDisk(-1); - objectScripts.clear(); - relTable.clear(); + g_cine->_objectScripts.clear(); + g_cine->_relTable.clear(); ptr = dataPtr = readBundleFile(findFileInBundle(pRelName)); @@ -61,14 +59,14 @@ void loadRel(char *pRelName) { p3 = READ_BE_UINT16(ptr); ptr += 2; RawObjectScriptPtr tmp(new RawObjectScript(size, p1, p2, p3)); assert(tmp); - relTable.push_back(tmp); + g_cine->_relTable.push_back(tmp); } for (i = 0; i < numEntry; i++) { - size = relTable[i]->_size; + size = g_cine->_relTable[i]->_size; // TODO: delete the test? if (size) { - relTable[i]->setData(*scriptInfo, ptr); + g_cine->_relTable[i]->setData(*scriptInfo, ptr); ptr += size; } } @@ -82,10 +80,10 @@ void loadRel(char *pRelName) { char buffer[256]; for (s = 0; s < numEntry; s++) { - if (relTable[s]->_size) { + if (g_cine->_relTable[s]->_size) { sprintf(buffer, "%s_%03d.txt", pRelName, s); - decompileScript((const byte *)relTable[s]->getString(0), relTable[s]->_size, s); + decompileScript((const byte *)g_cine->_relTable[s]->getString(0), g_cine->_relTable[s]->_size, s); dumpScript(buffer); } } diff --git a/engines/cine/rel.h b/engines/cine/rel.h index 84926f76c4..8d712dc416 100644 --- a/engines/cine/rel.h +++ b/engines/cine/rel.h @@ -29,8 +29,6 @@ #include "cine/script.h" namespace Cine { -extern RawObjectScriptArray relTable; - void loadRel(char *pRelName); } // End of namespace Cine diff --git a/engines/cine/saveload.cpp b/engines/cine/saveload.cpp index f9dfcc7737..0f7c50b7e5 100644 --- a/engines/cine/saveload.cpp +++ b/engines/cine/saveload.cpp @@ -200,13 +200,13 @@ void loadScriptFromSave(Common::SeekableReadStream &fHandle, bool isGlobal) { // original code loaded everything into globalScripts, this should be // the correct behavior if (isGlobal) { - ScriptPtr tmp(scriptInfo->create(*scriptTable[idx], idx, labels, localVars, compare, pos)); + ScriptPtr tmp(scriptInfo->create(*g_cine->_scriptTable[idx], idx, labels, localVars, compare, pos)); assert(tmp); - globalScripts.push_back(tmp); + g_cine->_globalScripts.push_back(tmp); } else { - ScriptPtr tmp(scriptInfo->create(*relTable[idx], idx, labels, localVars, compare, pos)); + ScriptPtr tmp(scriptInfo->create(*g_cine->_relTable[idx], idx, labels, localVars, compare, pos)); assert(tmp); - objectScripts.push_back(tmp); + g_cine->_objectScripts.push_back(tmp); } } @@ -227,7 +227,7 @@ void loadOverlayFromSave(Common::SeekableReadStream &fHandle) { tmp.width = fHandle.readSint16BE(); tmp.color = fHandle.readSint16BE(); - overlayList.push_back(tmp); + g_cine->_overlayList.push_back(tmp); } bool loadObjectTable(Common::SeekableReadStream &in) { @@ -235,20 +235,20 @@ bool loadObjectTable(Common::SeekableReadStream &in) { in.readUint16BE(); // Entry size for (int i = 0; i < NUM_MAX_OBJECT; i++) { - objectTable[i].x = in.readSint16BE(); - objectTable[i].y = in.readSint16BE(); - objectTable[i].mask = in.readUint16BE(); - objectTable[i].frame = in.readSint16BE(); - objectTable[i].costume = in.readSint16BE(); - in.read(objectTable[i].name, 20); - objectTable[i].part = in.readUint16BE(); + g_cine->_objectTable[i].x = in.readSint16BE(); + g_cine->_objectTable[i].y = in.readSint16BE(); + g_cine->_objectTable[i].mask = in.readUint16BE(); + g_cine->_objectTable[i].frame = in.readSint16BE(); + g_cine->_objectTable[i].costume = in.readSint16BE(); + in.read(g_cine->_objectTable[i].name, 20); + g_cine->_objectTable[i].part = in.readUint16BE(); } return !(in.eos() || in.err()); } bool loadZoneData(Common::SeekableReadStream &in) { for (int i = 0; i < 16; i++) { - zoneData[i] = in.readUint16BE(); + g_cine->_zoneData[i] = in.readUint16BE(); } return !(in.eos() || in.err()); } @@ -313,14 +313,14 @@ bool loadSeqList(Common::SeekableReadStream &in) { tmp.var1A = in.readSint16BE(); tmp.var1C = in.readSint16BE(); tmp.var1E = in.readSint16BE(); - seqList.push_back(tmp); + g_cine->_seqList.push_back(tmp); } return !(in.eos() || in.err()); } bool loadZoneQuery(Common::SeekableReadStream &in) { for (int i = 0; i < 16; i++) { - zoneQuery[i] = in.readUint16BE(); + g_cine->_zoneQuery[i] = in.readUint16BE(); } return !(in.eos() || in.err()); } @@ -330,19 +330,19 @@ void saveObjectTable(Common::OutSaveFile &out) { out.writeUint16BE(0x20); // Entry size for (int i = 0; i < NUM_MAX_OBJECT; i++) { - out.writeUint16BE(objectTable[i].x); - out.writeUint16BE(objectTable[i].y); - out.writeUint16BE(objectTable[i].mask); - out.writeUint16BE(objectTable[i].frame); - out.writeUint16BE(objectTable[i].costume); - out.write(objectTable[i].name, 20); - out.writeUint16BE(objectTable[i].part); + out.writeUint16BE(g_cine->_objectTable[i].x); + out.writeUint16BE(g_cine->_objectTable[i].y); + out.writeUint16BE(g_cine->_objectTable[i].mask); + out.writeUint16BE(g_cine->_objectTable[i].frame); + out.writeUint16BE(g_cine->_objectTable[i].costume); + out.write(g_cine->_objectTable[i].name, 20); + out.writeUint16BE(g_cine->_objectTable[i].part); } } void saveZoneData(Common::OutSaveFile &out) { for (int i = 0; i < 16; i++) { - out.writeUint16BE(zoneData[i]); + out.writeUint16BE(g_cine->_zoneData[i]); } } @@ -356,8 +356,8 @@ void saveCommandVariables(Common::OutSaveFile &out) { void saveCommandBuffer(Common::OutSaveFile &out) { // Let's make sure there's space for the trailing zero // (That's why we subtract one from the maximum command buffer size here). - uint32 size = MIN<uint32>(commandBuffer.size(), kMaxCommandBufferSize - 1); - out.write(commandBuffer.c_str(), size); + uint32 size = MIN<uint32>(g_cine->_commandBuffer.size(), kMaxCommandBufferSize - 1); + out.write(g_cine->_commandBuffer.c_str(), size); // Write the rest as zeroes (Here we also write the string's trailing zero) for (uint i = 0; i < kMaxCommandBufferSize - size; i++) { out.writeByte(0); @@ -369,7 +369,7 @@ void saveAnimDataTable(Common::OutSaveFile &out) { out.writeUint16BE(0x1E); // Entry size for (int i = 0; i < NUM_MAX_ANIMDATA; i++) { - animDataTable[i].save(out); + g_cine->_animDataTable[i].save(out); } } @@ -385,16 +385,16 @@ void saveScreenParams(Common::OutSaveFile &out) { void saveGlobalScripts(Common::OutSaveFile &out) { ScriptList::const_iterator it; - out.writeUint16BE(globalScripts.size()); - for (it = globalScripts.begin(); it != globalScripts.end(); ++it) { + out.writeUint16BE(g_cine->_globalScripts.size()); + for (it = g_cine->_globalScripts.begin(); it != g_cine->_globalScripts.end(); ++it) { (*it)->save(out); } } void saveObjectScripts(Common::OutSaveFile &out) { ScriptList::const_iterator it; - out.writeUint16BE(objectScripts.size()); - for (it = objectScripts.begin(); it != objectScripts.end(); ++it) { + out.writeUint16BE(g_cine->_objectScripts.size()); + for (it = g_cine->_objectScripts.begin(); it != g_cine->_objectScripts.end(); ++it) { (*it)->save(out); } } @@ -402,9 +402,9 @@ void saveObjectScripts(Common::OutSaveFile &out) { void saveOverlayList(Common::OutSaveFile &out) { Common::List<overlay>::const_iterator it; - out.writeUint16BE(overlayList.size()); + out.writeUint16BE(g_cine->_overlayList.size()); - for (it = overlayList.begin(); it != overlayList.end(); ++it) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) { out.writeUint32BE(0); // next out.writeUint32BE(0); // previous? out.writeUint16BE(it->objIdx); @@ -418,9 +418,9 @@ void saveOverlayList(Common::OutSaveFile &out) { void saveBgIncrustList(Common::OutSaveFile &out) { Common::List<BGIncrust>::const_iterator it; - out.writeUint16BE(bgIncrustList.size()); + out.writeUint16BE(g_cine->_bgIncrustList.size()); - for (it = bgIncrustList.begin(); it != bgIncrustList.end(); ++it) { + for (it = g_cine->_bgIncrustList.begin(); it != g_cine->_bgIncrustList.end(); ++it) { out.writeUint32BE(0); // next out.writeUint32BE(0); // previous? out.writeUint16BE(it->objIdx); @@ -434,15 +434,15 @@ void saveBgIncrustList(Common::OutSaveFile &out) { void saveZoneQuery(Common::OutSaveFile &out) { for (int i = 0; i < 16; i++) { - out.writeUint16BE(zoneQuery[i]); + out.writeUint16BE(g_cine->_zoneQuery[i]); } } void saveSeqList(Common::OutSaveFile &out) { Common::List<SeqListElement>::const_iterator it; - out.writeUint16BE(seqList.size()); + out.writeUint16BE(g_cine->_seqList.size()); - for (it = seqList.begin(); it != seqList.end(); ++it) { + for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) { out.writeSint16BE(it->var4); out.writeUint16BE(it->objIdx); out.writeSint16BE(it->var8); @@ -567,13 +567,13 @@ bool CineEngine::loadTempSaveOS(Common::SeekableReadStream &in) { loadObjectTable(in); renderer->restorePalette(in, hdr.version); - globalVars.load(in, NUM_MAX_VAR); + g_cine->_globalVars.load(in, NUM_MAX_VAR); loadZoneData(in); loadCommandVariables(in); char tempCommandBuffer[kMaxCommandBufferSize]; in.read(tempCommandBuffer, kMaxCommandBufferSize); - commandBuffer = tempCommandBuffer; - renderer->setCommand(commandBuffer); + g_cine->_commandBuffer = tempCommandBuffer; + renderer->setCommand(g_cine->_commandBuffer); loadZoneQuery(in); // TODO: Use the loaded string (Current music name (String, 13 bytes)). @@ -701,7 +701,7 @@ bool CineEngine::loadPlainSaveFW(Common::SeekableReadStream &in, CineSaveGameFor renderer->restorePalette(in, 0); // At 0x2083 (i.e. 0x2043 + 16 * 2 * 2): - globalVars.load(in, NUM_MAX_VAR); + g_cine->_globalVars.load(in, NUM_MAX_VAR); // At 0x2281 (i.e. 0x2083 + 255 * 2): loadZoneData(in); @@ -712,8 +712,8 @@ bool CineEngine::loadPlainSaveFW(Common::SeekableReadStream &in, CineSaveGameFor // At 0x22A9 (i.e. 0x22A1 + 4 * 2): char tempCommandBuffer[kMaxCommandBufferSize]; in.read(tempCommandBuffer, kMaxCommandBufferSize); - commandBuffer = tempCommandBuffer; - renderer->setCommand(commandBuffer); + g_cine->_commandBuffer = tempCommandBuffer; + renderer->setCommand(g_cine->_commandBuffer); // At 0x22F9 (i.e. 0x22A9 + 0x50): renderer->_cmdY = in.readUint16BE(); @@ -855,7 +855,7 @@ void CineEngine::makeSaveFW(Common::OutSaveFile &out) { saveObjectTable(out); renderer->savePalette(out); - globalVars.save(out, NUM_MAX_VAR); + g_cine->_globalVars.save(out, NUM_MAX_VAR); saveZoneData(out); saveCommandVariables(out); saveCommandBuffer(out); @@ -912,7 +912,7 @@ void CineEngine::makeSaveOS(Common::OutSaveFile &out) { saveObjectTable(out); renderer->savePalette(out); - globalVars.save(out, NUM_MAX_VAR); + g_cine->_globalVars.save(out, NUM_MAX_VAR); saveZoneData(out); saveCommandVariables(out); saveCommandBuffer(out); @@ -1045,7 +1045,7 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam loadPart(name); } - animName = partBuffer[foundFileIdx].partName; + animName = g_cine->_partBuffer[foundFileIdx].partName; loadRelatedPalette(animName); // Is this for Future Wars only? const int16 prevAnim = currentAnim; currentAnim = loadResource(animName, currentAnim); diff --git a/engines/cine/script.h b/engines/cine/script.h index 1c3b496375..756bc930e8 100644 --- a/engines/cine/script.h +++ b/engines/cine/script.h @@ -67,6 +67,7 @@ public: ScriptVars(const ScriptVars &src); ~ScriptVars(); + void reinit(unsigned int len); ScriptVars &operator=(const ScriptVars &src); int16 &operator[](unsigned int idx); int16 operator[](unsigned int idx) const; @@ -368,9 +369,7 @@ typedef Common::Array<RawObjectScriptPtr> RawObjectScriptArray; #define NUM_MAX_SCRIPT 50 -extern RawScriptArray scriptTable; extern FWScriptInfo *scriptInfo; -extern ScriptVars globalVars; void setupOpcodes(); diff --git a/engines/cine/script_fw.cpp b/engines/cine/script_fw.cpp index e71fec8898..430a32ac69 100644 --- a/engines/cine/script_fw.cpp +++ b/engines/cine/script_fw.cpp @@ -38,14 +38,6 @@ namespace Cine { -/** - * Global variables. - * 255 of these are saved, but there's one more that's used for bypassing the copy protection. - * In CineEngine::mainLoop(int bootScriptIdx) there's this code: globalVars[VAR_BYPASS_PROTECTION] = 0; - * And as VAR_BYPASS_PROTECTION is 255 that's why we're allocating one more than we otherwise would. - */ -ScriptVars globalVars(NUM_MAX_VAR + 1); - uint16 compareVars(int16 a, int16 b); @@ -216,7 +208,6 @@ void FWScript::setupTable() { } FWScriptInfo *scriptInfo; ///< Script factory -RawScriptArray scriptTable; ///< Table of script bytecode /** * @todo replace with script subsystem @@ -257,6 +248,14 @@ ScriptVars::ScriptVars(Common::SeekableReadStream &fHandle, unsigned int len) load(fHandle); } +void ScriptVars::reinit(unsigned int len) { + delete _vars; + + _size = len; + _vars = new int16[len]; + reset(); +} + /** * Copy constructor */ @@ -606,7 +605,7 @@ RawObjectScript::RawObjectScript(const FWScriptInfo &info, const byte *data, FWScript::FWScript(const RawScript &script, int16 idx) : _script(script), _pos(0), _line(0), _compare(0), _index(idx), _labels(script.labels()), _localVars(LOCAL_VARS_SIZE), - _globalVars(globalVars), _info(new FWScriptInfo) { } + _globalVars(g_cine->_globalVars), _info(new FWScriptInfo) { } /** * Copy constructor @@ -624,7 +623,7 @@ FWScript::FWScript(const FWScript &src) : _script(src._script), _pos(src._pos), FWScript::FWScript(const RawScript &script, int16 idx, FWScriptInfo *info) : _script(script), _pos(0), _line(0), _compare(0), _index(idx), _labels(script.labels()), _localVars(LOCAL_VARS_SIZE), - _globalVars(globalVars), _info(info) { } + _globalVars(g_cine->_globalVars), _info(info) { } /** * Constructor for object scripts in derived classes @@ -634,7 +633,7 @@ FWScript::FWScript(const RawScript &script, int16 idx, FWScriptInfo *info) : FWScript::FWScript(RawObjectScript &script, int16 idx, FWScriptInfo *info) : _script(script), _pos(0), _line(0), _compare(0), _index(idx), _labels(script.labels()), _localVars(LOCAL_VARS_SIZE), - _globalVars(globalVars), _info(info) { + _globalVars(g_cine->_globalVars), _info(info) { _localVars[0] = script.run(); } @@ -964,11 +963,11 @@ int FWScript::o1_loadVar() { break; case 8: debugC(5, kCineDebugScript, "Line: %d: var[%d] = file[%d].packedSize", _line, varIdx, dataIdx); - _localVars[varIdx] = partBuffer[dataIdx].packedSize; + _localVars[varIdx] = g_cine->_partBuffer[dataIdx].packedSize; break; case 9: debugC(5, kCineDebugScript, "Line: %d: var[%d] = file[%d].unpackedSize", _line, varIdx, dataIdx); - _localVars[varIdx] = partBuffer[dataIdx].unpackedSize; + _localVars[varIdx] = g_cine->_partBuffer[dataIdx].unpackedSize; break; default: error("executeScript: o1_loadVar: Unknown variable type %d", varType); @@ -1196,7 +1195,7 @@ int FWScript::o1_addSpriteFilledToBgList() { int FWScript::o1_op1B() { debugC(5, kCineDebugScript, "Line: %d: freeBgIncrustList", _line); - bgIncrustList.clear(); + g_cine->_bgIncrustList.clear(); return 0; } @@ -1343,9 +1342,9 @@ int FWScript::o1_endGlobalScript() { debugC(5, kCineDebugScript, "Line: %d: stopGlobalScript(%d)", _line, scriptIdx); - ScriptList::iterator it = globalScripts.begin(); + ScriptList::iterator it = g_cine->_globalScripts.begin(); - for (; it != globalScripts.end(); ++it) { + for (; it != g_cine->_globalScripts.end(); ++it) { if ((*it)->_index == scriptIdx) { (*it)->_index = -1; } @@ -1369,7 +1368,7 @@ int FWScript::o1_loadBg() { debugC(5, kCineDebugScript, "Line: %d: loadBg(\"%s\")", _line, param); loadBg(param); - bgIncrustList.clear(); + g_cine->_bgIncrustList.clear(); bgVar0 = 0; return 0; } @@ -1627,7 +1626,7 @@ int FWScript::o1_freePartRange() { int FWScript::o1_unloadAllMasks() { debugC(5, kCineDebugScript, "Line: %d: unloadAllMasks()", _line); - overlayList.clear(); + g_cine->_overlayList.clear(); return 0; } @@ -1656,7 +1655,7 @@ int FWScript::o1_initializeZoneData() { debugC(5, kCineDebugScript, "Line: %d: initializeZoneData()", _line); for (int i = 0; i < NUM_MAX_ZONE; i++) { - zoneData[i] = i; + g_cine->_zoneData[i] = i; } return 0; } @@ -1666,7 +1665,7 @@ int FWScript::o1_setZoneDataEntry() { uint16 var = getNextWord(); debugC(5, kCineDebugScript, "Line: %d: setZone[%d] = %d", _line, zoneIdx, var); - zoneData[zoneIdx] = var; + g_cine->_zoneData[zoneIdx] = var; return 0; } @@ -1674,7 +1673,7 @@ int FWScript::o1_getZoneDataEntry() { byte zoneIdx = getNextByte(); byte var = getNextByte(); - _localVars[var] = zoneData[zoneIdx]; + _localVars[var] = g_cine->_zoneData[zoneIdx]; return 0; } @@ -1796,7 +1795,7 @@ int FWScript::o1_playSample() { int16 volume = getNextWord(); uint16 size = getNextWord(); - const byte *data = animDataTable[anim].data(); + const byte *data = g_cine->_animDataTable[anim].data(); if (!data) { return 0; @@ -1804,7 +1803,7 @@ int FWScript::o1_playSample() { if (g_cine->getPlatform() == Common::kPlatformAmiga || g_cine->getPlatform() == Common::kPlatformAtariST) { if (size == 0xFFFF) { - size = animDataTable[anim]._width * animDataTable[anim]._height; + size = g_cine->_animDataTable[anim]._width * g_cine->_animDataTable[anim]._height; } if (channel < 10) { // || _currentOpcode == 0x78 int channel1, channel2; @@ -1874,9 +1873,9 @@ int FWScript::o1_unloadMask5() { //----------------------------------------------------------------------- void addScriptToGlobalScripts(uint16 idx) { - ScriptPtr tmp(scriptInfo->create(*scriptTable[idx], idx)); + ScriptPtr tmp(scriptInfo->create(*g_cine->_scriptTable[idx], idx)); assert(tmp); - globalScripts.push_back(tmp); + g_cine->_globalScripts.push_back(tmp); } int16 getZoneFromPosition(byte *page, int16 x, int16 y, int16 width) { @@ -1916,8 +1915,8 @@ int16 getZoneFromPositionRaw(byte *page, int16 x, int16 y, int16 width) { } int16 checkCollision(int16 objIdx, int16 x, int16 y, int16 numZones, int16 zoneIdx) { - int16 lx = objectTable[objIdx].x + x; - int16 ly = objectTable[objIdx].y + y; + int16 lx = g_cine->_objectTable[objIdx].x + x; + int16 ly = g_cine->_objectTable[objIdx].y + y; int16 idx; int16 result = 0; @@ -1935,12 +1934,12 @@ int16 checkCollision(int16 objIdx, int16 x, int16 y, int16 numZones, int16 zoneI // The zoneQuery table is updated here only in Operation Stealth if (g_cine->getGameType() == Cine::GType_OS) { - if (zoneData[idx] < NUM_MAX_ZONE) { - zoneQuery[zoneData[idx]]++; + if (g_cine->_zoneData[idx] < NUM_MAX_ZONE) { + g_cine->_zoneQuery[g_cine->_zoneData[idx]]++; } } - if (zoneData[idx] == zoneIdx) { + if (g_cine->_zoneData[idx] == zoneIdx) { result = 1; // Future Wars breaks out early on the first match, but // Operation Stealth doesn't because it needs to update @@ -1969,10 +1968,10 @@ uint16 compareVars(int16 a, int16 b) { } void executeObjectScripts() { - ScriptList::iterator it = objectScripts.begin(); - for (; it != objectScripts.end();) { + ScriptList::iterator it = g_cine->_objectScripts.begin(); + for (; it != g_cine->_objectScripts.end();) { if ((*it)->_index < 0 || (*it)->execute() < 0) { - it = objectScripts.erase(it); + it = g_cine->_objectScripts.erase(it); } else { ++it; } @@ -1980,10 +1979,10 @@ void executeObjectScripts() { } void executeGlobalScripts() { - ScriptList::iterator it = globalScripts.begin(); - for (; it != globalScripts.end();) { + ScriptList::iterator it = g_cine->_globalScripts.begin(); + for (; it != g_cine->_globalScripts.end();) { if ((*it)->_index < 0 || (*it)->execute() < 0) { - it = globalScripts.erase(it); + it = g_cine->_globalScripts.erase(it); } else { ++it; } diff --git a/engines/cine/script_os.cpp b/engines/cine/script_os.cpp index d03b118443..ab1ad7ff9c 100644 --- a/engines/cine/script_os.cpp +++ b/engines/cine/script_os.cpp @@ -420,16 +420,16 @@ int FWScript::o2_playSampleAlt() { uint16 size = getNextWord(); if (size == 0xFFFF) { - size = animDataTable[num]._width * animDataTable[num]._height; + size = g_cine->_animDataTable[num]._width * g_cine->_animDataTable[num]._height; } - if (animDataTable[num].data()) { + if (g_cine->_animDataTable[num].data()) { if (g_cine->getPlatform() == Common::kPlatformPC) { // if speaker output is available, play sound on it // if it's another device, don't play anything // TODO: implement this, it's used in the introduction for example // on each letter displayed } else { - g_sound->playSound(channel, frequency, animDataTable[num].data(), size, 0, 0, 63, 0); + g_sound->playSound(channel, frequency, g_cine->_animDataTable[num].data(), size, 0, 0, 63, 0); } } return 0; @@ -611,9 +611,9 @@ int FWScript::o2_stopObjectScript() { byte param = getNextByte(); debugC(5, kCineDebugScript, "Line: %d: stopObjectScript(%d)", _line, param); - ScriptList::iterator it = objectScripts.begin(); + ScriptList::iterator it = g_cine->_objectScripts.begin(); - for (; it != objectScripts.end(); ++it) { + for (; it != g_cine->_objectScripts.end(); ++it) { if ((*it)->_index == param) { (*it)->_index = -1; } @@ -699,7 +699,7 @@ int FWScript::o2_loadBg() { int FWScript::o2_wasZoneChecked() { byte param = getNextByte(); - _compare = (param < NUM_MAX_ZONE && zoneQuery[param]) ? 1 : 0; + _compare = (param < NUM_MAX_ZONE && g_cine->_zoneQuery[param]) ? 1 : 0; debugC(5, kCineDebugScript, "Line: %d: o2_wasZoneChecked(%d)", _line, param); return 0; } diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp index 82c40a2f50..cf7135a6b5 100644 --- a/engines/cine/various.cpp +++ b/engines/cine/various.cpp @@ -81,7 +81,6 @@ uint16 _messageLen; int16 playerCommand; -Common::String commandBuffer; char currentPrcName[20]; char currentRelName[20]; char currentObjectName[20]; @@ -137,9 +136,6 @@ static const int16 canUseOnItemTable[] = { 1, 0, 0, 1, 1, 0, 0 }; CommandeType objectListCommand[20]; int16 objListTab[20]; -Common::Array<uint16> zoneData; -Common::Array<uint16> zoneQuery; ///< Only exists in Operation Stealth - /** * Move the player character using the keyboard * @param x Negative values move left, positive right, zero not at all @@ -174,9 +170,9 @@ void stopMusicAfterFadeOut() { } void runObjectScript(int16 entryIdx) { - ScriptPtr tmp(scriptInfo->create(*relTable[entryIdx], entryIdx)); + ScriptPtr tmp(scriptInfo->create(*g_cine->_relTable[entryIdx], entryIdx)); assert(tmp); - objectScripts.push_back(tmp); + g_cine->_objectScripts.push_back(tmp); } /** @@ -190,19 +186,19 @@ void addPlayerCommandMessage(int16 cmd) { tmp.objIdx = cmd; tmp.type = 3; - overlayList.push_back(tmp); + g_cine->_overlayList.push_back(tmp); } int16 getRelEntryForObject(uint16 param1, uint16 param2, SelectedObjStruct *pSelectedObject) { int16 i; int16 found = -1; - for (i = 0; i < (int16)relTable.size(); i++) { - if (relTable[i]->_param1 == param1 && relTable[i]->_param2 == pSelectedObject->idx) { + for (i = 0; i < (int16)g_cine->_relTable.size(); i++) { + if (g_cine->_relTable[i]->_param1 == param1 && g_cine->_relTable[i]->_param2 == pSelectedObject->idx) { if (param2 == 1) { found = i; } else if (param2 == 2) { - if (relTable[i]->_param3 == pSelectedObject->param) { + if (g_cine->_relTable[i]->_param3 == pSelectedObject->param) { found = i; } } @@ -228,19 +224,19 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) { int width; // reverse_iterator would be nice - for (it = overlayList.reverse_begin(); it != overlayList.end(); --it) { - if (it->type >= 2 || !objectTable[it->objIdx].name[0]) { + for (it = g_cine->_overlayList.reverse_begin(); it != g_cine->_overlayList.end(); --it) { + if (it->type >= 2 || !g_cine->_objectTable[it->objIdx].name[0]) { continue; } - objX = objectTable[it->objIdx].x; - objY = objectTable[it->objIdx].y; + objX = g_cine->_objectTable[it->objIdx].x; + objY = g_cine->_objectTable[it->objIdx].y; - frame = ABS((int16)(objectTable[it->objIdx].frame)); - part = objectTable[it->objIdx].part; + frame = ABS((int16)(g_cine->_objectTable[it->objIdx].frame)); + part = g_cine->_objectTable[it->objIdx].part; // Additional case for negative frame values in Operation Stealth - if (g_cine->getGameType() == Cine::GType_OS && objectTable[it->objIdx].frame < 0) { + if (g_cine->getGameType() == Cine::GType_OS && g_cine->_objectTable[it->objIdx].frame < 0) { if ((it->type == 1) && (x >= objX) && (objX + frame >= x) && (y >= objY) && (objY + part >= y)) { return it->objIdx; } else { @@ -249,18 +245,18 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) { } if (it->type == 0) { - threshold = animDataTable[frame]._var1; + threshold = g_cine->_animDataTable[frame]._var1; } else { - threshold = animDataTable[frame]._width / 2; + threshold = g_cine->_animDataTable[frame]._width / 2; } - height = animDataTable[frame]._height; - width = animDataTable[frame]._realWidth; + height = g_cine->_animDataTable[frame]._height; + width = g_cine->_animDataTable[frame]._realWidth; xdif = x - objX; ydif = y - objY; - if ((xdif < 0) || ((threshold << 4) <= xdif) || (ydif <= 0) || (ydif >= height) || !animDataTable[frame].data()) { + if ((xdif < 0) || ((threshold << 4) <= xdif) || (ydif <= 0) || (ydif >= height) || !g_cine->_animDataTable[frame].data()) { continue; } @@ -272,17 +268,17 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) { continue; } - if (it->type == 0 && animDataTable[frame].getColor(xdif, ydif) != (part & 0x0F)) { + if (it->type == 0 && g_cine->_animDataTable[frame].getColor(xdif, ydif) != (part & 0x0F)) { return it->objIdx; - } else if (it->type == 1 && gfxGetBit(xdif, ydif, animDataTable[frame].data(), animDataTable[frame]._width * 4)) { + } else if (it->type == 1 && gfxGetBit(xdif, ydif, g_cine->_animDataTable[frame].data(), g_cine->_animDataTable[frame]._width * 4)) { return it->objIdx; } } else if (it->type == 0) { // use generated mask - if (gfxGetBit(xdif, ydif, animDataTable[frame].mask(), animDataTable[frame]._width)) { + if (gfxGetBit(xdif, ydif, g_cine->_animDataTable[frame].mask(), g_cine->_animDataTable[frame]._width)) { return it->objIdx; } } else if (it->type == 1) { // is mask - if (gfxGetBit(xdif, ydif, animDataTable[frame].data(), animDataTable[frame]._width * 4)) { + if (gfxGetBit(xdif, ydif, g_cine->_animDataTable[frame].data(), g_cine->_animDataTable[frame]._width * 4)) { return it->objIdx; } } @@ -294,18 +290,18 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) { void CineEngine::resetEngine() { g_sound->stopMusic(); freeAnimDataTable(); - overlayList.clear(); - bgIncrustList.clear(); + g_cine->_overlayList.clear(); + g_cine->_bgIncrustList.clear(); closePart(); - objectScripts.clear(); - globalScripts.clear(); - relTable.clear(); - scriptTable.clear(); - messageTable.clear(); + g_cine->_objectScripts.clear(); + g_cine->_globalScripts.clear(); + g_cine->_relTable.clear(); + g_cine->_scriptTable.clear(); + g_cine->_messageTable.clear(); resetObjectTable(); - globalVars.reset(); + g_cine->_globalVars.reset(); var2 = var3 = var4 = var5 = 0; @@ -320,10 +316,10 @@ void CineEngine::resetEngine() { playerCommand = -1; isDrawCommandEnabled = 0; - commandBuffer = ""; + g_cine->_commandBuffer = ""; - globalVars[VAR_MOUSE_X_POS] = 0; - globalVars[VAR_MOUSE_Y_POS] = 0; + g_cine->_globalVars[VAR_MOUSE_X_POS] = 0; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = 0; fadeRequired = false; @@ -332,7 +328,7 @@ void CineEngine::resetEngine() { checkForPendingDataLoadSwitch = 0; if (g_cine->getGameType() == Cine::GType_OS) { - seqList.clear(); + g_cine->_seqList.clear(); currentAdditionalBgIdx = 0; currentAdditionalBgIdx2 = 0; // TODO: Add resetting of the following variables @@ -539,8 +535,8 @@ int16 buildObjectListCommand(int16 param) { } for (i = 0; i < 255; i++) { - if (objectTable[i].name[0] && objectTable[i].costume == param) { - strcpy(objectListCommand[j], objectTable[i].name); + if (g_cine->_objectTable[i].name[0] && g_cine->_objectTable[i].costume == param) { + strcpy(objectListCommand[j], g_cine->_objectTable[i].name); objListTab[j] = i; j++; } @@ -581,9 +577,9 @@ void makeCommandLine() { commandVar2 = -10; if (playerCommand != -1) { - commandBuffer = defaultActionCommand[playerCommand]; + g_cine->_commandBuffer = defaultActionCommand[playerCommand]; } else { - commandBuffer = ""; + g_cine->_commandBuffer = ""; } if ((playerCommand != -1) && (choiceResultTable[playerCommand] == 2)) { // need object selection ? @@ -602,7 +598,7 @@ void makeCommandLine() { canUseOnObject = 0; } else { // Future Wars playerCommand = -1; - commandBuffer = ""; + g_cine->_commandBuffer = ""; } } else { if (g_cine->getGameType() == Cine::GType_OS) { @@ -616,13 +612,13 @@ void makeCommandLine() { commandVar3[0] = si; commandVar1 = 1; - commandBuffer += " "; - commandBuffer += objectTable[commandVar3[0]].name; - commandBuffer += " "; + g_cine->_commandBuffer += " "; + g_cine->_commandBuffer += g_cine->_objectTable[commandVar3[0]].name; + g_cine->_commandBuffer += " "; if (g_cine->getGameType() == Cine::GType_OS) { - commandBuffer += commandPrepositionTable[playerCommand]; + g_cine->_commandBuffer += commandPrepositionTable[playerCommand]; } else { // Future Wars - commandBuffer += defaultCommandPreposition; + g_cine->_commandBuffer += defaultCommandPreposition; } } } @@ -634,7 +630,7 @@ void makeCommandLine() { processInventory(x, y + 8); playerCommand = -1; commandVar1 = 0; - commandBuffer = ""; + g_cine->_commandBuffer = ""; CursorMan.showMouse(true); } } @@ -654,8 +650,8 @@ void makeCommandLine() { commandVar3[commandVar1] = si; commandVar1++; - commandBuffer += " "; - commandBuffer += objectTable[si].name; + g_cine->_commandBuffer += " "; + g_cine->_commandBuffer += g_cine->_objectTable[si].name; } } @@ -673,13 +669,13 @@ void makeCommandLine() { playerCommand = -1; commandVar1 = 0; - commandBuffer = ""; + g_cine->_commandBuffer = ""; } } if (g_cine->getGameType() == Cine::GType_OS || !disableSystemMenu) { isDrawCommandEnabled = 1; - renderer->setCommand(commandBuffer); + renderer->setCommand(g_cine->_commandBuffer); } } @@ -858,7 +854,7 @@ uint16 executePlayerInput() { if (allowPlayerInput) { // Player input is allowed if (isDrawCommandEnabled) { - renderer->setCommand(commandBuffer); + renderer->setCommand(g_cine->_commandBuffer); } isDrawCommandEnabled = 0; limitMouseCheckCount = true; @@ -906,8 +902,8 @@ uint16 executePlayerInput() { commandVar3[commandVar1] = si; commandVar1++; - commandBuffer += " "; - commandBuffer += objectTable[si].name; + g_cine->_commandBuffer += " "; + g_cine->_commandBuffer += g_cine->_objectTable[si].name; isDrawCommandEnabled = 1; @@ -929,27 +925,27 @@ uint16 executePlayerInput() { playerCommand = -1; commandVar1 = 0; - commandBuffer = ""; + g_cine->_commandBuffer = ""; } else if (g_cine->getGameType() == Cine::GType_OS) { isDrawCommandEnabled = 1; - commandBuffer += commandPrepositionTable[playerCommand]; + g_cine->_commandBuffer += commandPrepositionTable[playerCommand]; } - renderer->setCommand(commandBuffer); + renderer->setCommand(g_cine->_commandBuffer); } else { - globalVars[VAR_MOUSE_X_POS] = mouseX; + g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX; if (!mouseX) { - globalVars[VAR_MOUSE_X_POS]++; + g_cine->_globalVars[VAR_MOUSE_X_POS]++; } - globalVars[VAR_MOUSE_Y_POS] = mouseY; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = mouseY; if (g_cine->getGameType() == Cine::GType_OS) { if (!mouseY) { - globalVars[VAR_MOUSE_Y_POS]++; + g_cine->_globalVars[VAR_MOUSE_Y_POS]++; } - globalVars[VAR_MOUSE_X_POS_2ND] = globalVars[VAR_MOUSE_X_POS]; - globalVars[VAR_MOUSE_Y_POS_2ND] = globalVars[VAR_MOUSE_Y_POS]; + g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = g_cine->_globalVars[VAR_MOUSE_X_POS]; + g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = g_cine->_globalVars[VAR_MOUSE_Y_POS]; } } } @@ -961,7 +957,7 @@ uint16 executePlayerInput() { if (g_cine->getGameType() == Cine::GType_OS || commandVar2 != objIdx) { if (objIdx != -1) { - renderer->setCommand(commandBuffer + " " + objectTable[objIdx].name); + renderer->setCommand(g_cine->_commandBuffer + " " + g_cine->_objectTable[objIdx].name); } else { isDrawCommandEnabled = 1; } @@ -976,19 +972,19 @@ uint16 executePlayerInput() { int16 objIdx; int16 relEntry; - globalVars[VAR_MOUSE_X_POS] = mouseX; + g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX; if (!mouseX) { - globalVars[VAR_MOUSE_X_POS]++; + g_cine->_globalVars[VAR_MOUSE_X_POS]++; } - globalVars[VAR_MOUSE_Y_POS] = mouseY; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = mouseY; if (g_cine->getGameType() == Cine::GType_OS) { if (!mouseY) { - globalVars[VAR_MOUSE_Y_POS]++; + g_cine->_globalVars[VAR_MOUSE_Y_POS]++; } - globalVars[VAR_MOUSE_X_POS_2ND] = globalVars[VAR_MOUSE_X_POS]; - globalVars[VAR_MOUSE_Y_POS_2ND] = globalVars[VAR_MOUSE_Y_POS]; + g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = g_cine->_globalVars[VAR_MOUSE_X_POS]; + g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = g_cine->_globalVars[VAR_MOUSE_Y_POS]; } objIdx = getObjectUnderCursor(mouseX, mouseY); @@ -1020,97 +1016,97 @@ uint16 executePlayerInput() { // Handle possible horizontal movement by keyboard if (xMoveKeyb != kKeybMoveCenterX && allowPlayerInput) { if (xMoveKeyb == kKeybMoveRight) { // moving right - const int16 playerFrame = objectTable[1].frame; - const int16 playerX = objectTable[1].x; + const int16 playerFrame = g_cine->_objectTable[1].frame; + const int16 playerX = g_cine->_objectTable[1].x; // TODO: Check if multiplying _width by two here is correct or not - const int16 newX = animDataTable[playerFrame]._width * 2 + playerX + 8; - globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = newX; + const int16 newX = g_cine->_animDataTable[playerFrame]._width * 2 + playerX + 8; + g_cine->_globalVars[VAR_MOUSE_X_POS] = g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = newX; } else { // moving left - const int16 playerX = objectTable[1].x; + const int16 playerX = g_cine->_objectTable[1].x; const int16 newX = playerX - 8; - globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = newX; + g_cine->_globalVars[VAR_MOUSE_X_POS] = g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = newX; } // Restrain horizontal position to range 0-319 - if (globalVars[VAR_MOUSE_X_POS] < 0) { - globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = 0; - } else if (globalVars[VAR_MOUSE_X_POS] > 319) { - globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = 319; + if (g_cine->_globalVars[VAR_MOUSE_X_POS] < 0) { + g_cine->_globalVars[VAR_MOUSE_X_POS] = g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = 0; + } else if (g_cine->_globalVars[VAR_MOUSE_X_POS] > 319) { + g_cine->_globalVars[VAR_MOUSE_X_POS] = g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = 319; } } // Handle possible vertical movement by keyboard if (yMoveKeyb != kKeybMoveCenterY && allowPlayerInput) { if (yMoveKeyb == kKeybMoveDown) { // moving down - const int16 playerFrame = objectTable[1].frame; - const int16 playerY = objectTable[1].y; + const int16 playerFrame = g_cine->_objectTable[1].frame; + const int16 playerY = g_cine->_objectTable[1].y; // TODO: Check if multiplying _height by two here is correct or not - const int16 newY = animDataTable[playerFrame]._height * 2 + playerY - 1; - globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = newY; + const int16 newY = g_cine->_animDataTable[playerFrame]._height * 2 + playerY - 1; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = newY; } else { // moving up - const int16 playerY = objectTable[1].y; + const int16 playerY = g_cine->_objectTable[1].y; const int16 newY = playerY - 8; - globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = newY; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = newY; } // Restrain vertical position to range 0-199 - if (globalVars[VAR_MOUSE_Y_POS] < 0) { - globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = 0; - } else if (globalVars[VAR_MOUSE_Y_POS] > 199) { - globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = 199; + if (g_cine->_globalVars[VAR_MOUSE_Y_POS] < 0) { + g_cine->_globalVars[VAR_MOUSE_Y_POS] = g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = 0; + } else if (g_cine->_globalVars[VAR_MOUSE_Y_POS] > 199) { + g_cine->_globalVars[VAR_MOUSE_Y_POS] = g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = 199; } } } else if (egoMovedWithKeyboard && allowPlayerInput) { // FW: Move using keyboard egoMovedWithKeyboard = false; - switch (globalVars[VAR_MOUSE_X_MODE]) { + switch (g_cine->_globalVars[VAR_MOUSE_X_MODE]) { case 1: - mouseX = objectTable[1].x + 12; + mouseX = g_cine->_objectTable[1].x + 12; break; case 2: - mouseX = objectTable[1].x + 7; + mouseX = g_cine->_objectTable[1].x + 7; break; default: - mouseX = globalVars[VAR_MOUSE_X_POS]; + mouseX = g_cine->_globalVars[VAR_MOUSE_X_POS]; break; } - switch (globalVars[VAR_MOUSE_Y_MODE]) { + switch (g_cine->_globalVars[VAR_MOUSE_Y_MODE]) { case 1: - mouseY = objectTable[1].y + 34; + mouseY = g_cine->_objectTable[1].y + 34; break; case 2: - mouseY = objectTable[1].y + 28; + mouseY = g_cine->_objectTable[1].y + 28; break; default: - mouseY = globalVars[VAR_MOUSE_Y_POS]; + mouseY = g_cine->_globalVars[VAR_MOUSE_Y_POS]; break; } if (var_5E == bgVar0) { var_5E = 0; - globalVars[VAR_MOUSE_X_POS] = mouseX; - globalVars[VAR_MOUSE_Y_POS] = mouseY; + g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = mouseY; } else { if (xMoveKeyb) { if (xMoveKeyb == kKeybMoveLeft) { - globalVars[VAR_MOUSE_X_POS] = 1; + g_cine->_globalVars[VAR_MOUSE_X_POS] = 1; } else { - globalVars[VAR_MOUSE_X_POS] = 320; + g_cine->_globalVars[VAR_MOUSE_X_POS] = 320; } } else { - globalVars[VAR_MOUSE_X_POS] = mouseX; + g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX; } if (yMoveKeyb) { if (yMoveKeyb == kKeybMoveUp) { - globalVars[VAR_MOUSE_Y_POS] = 1; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = 1; } else { - globalVars[VAR_MOUSE_Y_POS] = 200; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = 200; } } else { - globalVars[VAR_MOUSE_Y_POS] = mouseY; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = mouseY; } } @@ -1167,27 +1163,27 @@ void drawSprite(Common::List<overlay>::iterator it, const byte *spritePtr, const msk = (byte *)malloc(width * height); if (g_cine->getGameType() == Cine::GType_OS) { - generateMask(spritePtr, msk, width * height, objectTable[it->objIdx].part); + generateMask(spritePtr, msk, width * height, g_cine->_objectTable[it->objIdx].part); } else { memcpy(msk, maskPtr, width * height); } - for (++it; it != overlayList.end(); ++it) { + for (++it; it != g_cine->_overlayList.end(); ++it) { if (it->type != 5) { continue; } - maskX = objectTable[it->objIdx].x; - maskY = objectTable[it->objIdx].y; + maskX = g_cine->_objectTable[it->objIdx].x; + maskY = g_cine->_objectTable[it->objIdx].y; - maskSpriteIdx = ABS((int16)(objectTable[it->objIdx].frame)); + maskSpriteIdx = ABS((int16)(g_cine->_objectTable[it->objIdx].frame)); - maskWidth = animDataTable[maskSpriteIdx]._realWidth; - maskHeight = animDataTable[maskSpriteIdx]._height; - gfxUpdateSpriteMask(msk, x, y, width, height, animDataTable[maskSpriteIdx].data(), maskX, maskY, maskWidth, maskHeight); + maskWidth = g_cine->_animDataTable[maskSpriteIdx]._realWidth; + maskHeight = g_cine->_animDataTable[maskSpriteIdx]._height; + gfxUpdateSpriteMask(msk, x, y, width, height, g_cine->_animDataTable[maskSpriteIdx].data(), maskX, maskY, maskWidth, maskHeight); #ifdef DEBUG_SPRITE_MASK - gfxFillSprite(animDataTable[maskSpriteIdx].data(), maskWidth, maskHeight, page, maskX, maskY, 1); + gfxFillSprite(g_cine->_animDataTable[maskSpriteIdx].data(), maskWidth, maskHeight, page, maskX, maskY, 1); #endif } @@ -1199,7 +1195,7 @@ void removeMessages() { Common::List<overlay>::iterator it; bool remove; - for (it = overlayList.begin(); it != overlayList.end(); ) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ) { if (g_cine->getGameType() == Cine::GType_OS) { // NOTE: These are really removeOverlay calls that have been deferred. // In Operation Stealth's disassembly elements are removed from the @@ -1213,7 +1209,7 @@ void removeMessages() { } if (remove) { - it = overlayList.erase(it); + it = g_cine->_overlayList.erase(it); } else { ++it; } @@ -1255,7 +1251,7 @@ void checkForPendingDataLoad() { } if (newObjectName[0] != 0) { - overlayList.clear(); + g_cine->_overlayList.clear(); loadObject(newObjectName); @@ -1294,15 +1290,13 @@ void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 par tmp.width = param4; tmp.color = param5; - overlayList.push_back(tmp); + g_cine->_overlayList.push_back(tmp); } -Common::List<SeqListElement> seqList; - void removeSeq(uint16 param1, uint16 param2, uint16 param3) { Common::List<SeqListElement>::iterator it; - for (it = seqList.begin(); it != seqList.end(); ++it) { + for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) { if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) { it->var4 = -1; break; @@ -1313,7 +1307,7 @@ void removeSeq(uint16 param1, uint16 param2, uint16 param3) { bool isSeqRunning(uint16 param1, uint16 param2, uint16 param3) { Common::List<SeqListElement>::iterator it; - for (it = seqList.begin(); it != seqList.end(); ++it) { + for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) { if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) { // Just to be on the safe side there's a restriction of the // addition's result to 16-bit arithmetic here like in the @@ -1329,7 +1323,7 @@ void addSeqListElement(uint16 objIdx, int16 param1, int16 param2, int16 frame, i Common::List<SeqListElement>::iterator it; SeqListElement tmp; - for (it = seqList.begin(); it != seqList.end() && it->varE < param7; ++it) ; + for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end() && it->varE < param7; ++it) ; tmp.objIdx = objIdx; tmp.var4 = param1; @@ -1346,12 +1340,12 @@ void addSeqListElement(uint16 objIdx, int16 param1, int16 param2, int16 frame, i tmp.var1C = 0; tmp.var1E = 0; - seqList.insert(it, tmp); + g_cine->_seqList.insert(it, tmp); } void modifySeqListElement(uint16 objIdx, int16 var4Test, int16 param1, int16 param2, int16 param3, int16 param4) { // Find a suitable list element and modify it - for (Common::List<SeqListElement>::iterator it = seqList.begin(); it != seqList.end(); ++it) { + for (Common::List<SeqListElement>::iterator it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) { if (it->objIdx == objIdx && it->var4 == var4Test) { it->varC = param1; it->var18 = param2; @@ -1425,7 +1419,7 @@ uint16 addAni(uint16 param1, uint16 objIdx, const int8 *ptr, SeqListElement &ele // In the original an error string is set and 0 is returned if the following doesn't hold assert(*ptrData); - di = (objectTable[objIdx].costume + 1) % (*ptrData); + di = (g_cine->_objectTable[objIdx].costume + 1) % (*ptrData); ++ptrData; // Jump over the just read byte // Here ptr2 seems to be indexing a table of structs (8 bytes per struct): // struct { @@ -1446,18 +1440,18 @@ uint16 addAni(uint16 param1, uint16 objIdx, const int8 *ptr, SeqListElement &ele return 0; } - objectTable[objIdx].x += ptr2[4]; - objectTable[objIdx].y += ptr2[5]; - objectTable[objIdx].mask += ptr2[6]; + g_cine->_objectTable[objIdx].x += ptr2[4]; + g_cine->_objectTable[objIdx].y += ptr2[5]; + g_cine->_objectTable[objIdx].mask += ptr2[6]; if (ptr2[6]) { resetGfxEntityEntry(objIdx); } - objectTable[objIdx].frame = ptr2[7] + element.var8; + g_cine->_objectTable[objIdx].frame = ptr2[7] + element.var8; if (param3 || !element.var14) { - objectTable[objIdx].costume = di; + g_cine->_objectTable[objIdx].costume = di; } else { assert(param4); *param4 = di; @@ -1476,7 +1470,7 @@ void resetGfxEntityEntry(uint16 objIdx) { bool foundCutPoint = false; // Go through the overlay list and partition the whole list into two categories (Type A and type B objects) - for (it = overlayList.begin(); it != overlayList.end(); ++it) { + for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) { if (it->objIdx == objIdx && it->type != 2 && it->type != 3) { // Type A object aReverseObjs.push_front(*it); } else { // Type B object @@ -1485,10 +1479,10 @@ void resetGfxEntityEntry(uint16 objIdx) { if (it->type == 2 || it->type == 3) { objectMask = 10000; } else { - objectMask = objectTable[it->objIdx].mask; + objectMask = g_cine->_objectTable[it->objIdx].mask; } - if (objectTable[objIdx].mask > objectMask) { // Check for B objects' cut point + if (g_cine->_objectTable[objIdx].mask > objectMask) { // Check for B objects' cut point bObjsCutPoint = bObjs.reverse_begin(); foundCutPoint = true; } @@ -1496,26 +1490,26 @@ void resetGfxEntityEntry(uint16 objIdx) { } // Recreate the overlay list in a different order. - overlayList.clear(); + g_cine->_overlayList.clear(); if (foundCutPoint) { // If a cut point was found the order is: // B objects before the cut point, the cut point, A objects in reverse order, B objects after cut point. ++bObjsCutPoint; // Include the cut point in the first list insertion - overlayList.insert(overlayList.end(), bObjs.begin(), bObjsCutPoint); - overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end()); - overlayList.insert(overlayList.end(), bObjsCutPoint, bObjs.end()); + g_cine->_overlayList.insert(g_cine->_overlayList.end(), bObjs.begin(), bObjsCutPoint); + g_cine->_overlayList.insert(g_cine->_overlayList.end(), aReverseObjs.begin(), aReverseObjs.end()); + g_cine->_overlayList.insert(g_cine->_overlayList.end(), bObjsCutPoint, bObjs.end()); } else { // If no cut point was found the order is: // A objects in reverse order, B objects. - overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end()); - overlayList.insert(overlayList.end(), bObjs.begin(), bObjs.end()); + g_cine->_overlayList.insert(g_cine->_overlayList.end(), aReverseObjs.begin(), aReverseObjs.end()); + g_cine->_overlayList.insert(g_cine->_overlayList.end(), bObjs.begin(), bObjs.end()); } } void processSeqListElement(SeqListElement &element) { - int16 x = objectTable[element.objIdx].x; - int16 y = objectTable[element.objIdx].y; - const int8 *ptr1 = (const int8 *) animDataTable[element.frame].data(); + int16 x = g_cine->_objectTable[element.objIdx].x; + int16 y = g_cine->_objectTable[element.objIdx].y; + const int8 *ptr1 = (const int8 *) g_cine->_animDataTable[element.frame].data(); int16 var_10; int16 var_4; int16 var_2; @@ -1548,8 +1542,8 @@ void processSeqListElement(SeqListElement &element) { int16 x2 = element.var18; int16 y2 = element.var1A; if (element.varC) { - x2 += objectTable[element.varC].x; - y2 += objectTable[element.varC].y; + x2 += g_cine->_objectTable[element.varC].x; + y2 += g_cine->_objectTable[element.varC].y; } computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, x2, y2); } else { @@ -1558,7 +1552,7 @@ void processSeqListElement(SeqListElement &element) { if (xMoveKeyb != kKeybMoveRight) { adder = -adder; } - globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = ptr1[4] + x + adder; + g_cine->_globalVars[VAR_MOUSE_X_POS] = g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = ptr1[4] + x + adder; } if (yMoveKeyb && allowPlayerInput) { @@ -1566,11 +1560,11 @@ void processSeqListElement(SeqListElement &element) { if (yMoveKeyb != kKeybMoveDown) { adder = -adder; } - globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = ptr1[5] + y + adder; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = ptr1[5] + y + adder; } - if (globalVars[VAR_MOUSE_X_POS] || globalVars[VAR_MOUSE_Y_POS]) { - computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, globalVars[VAR_MOUSE_X_POS], globalVars[VAR_MOUSE_Y_POS]); + if (g_cine->_globalVars[VAR_MOUSE_X_POS] || g_cine->_globalVars[VAR_MOUSE_Y_POS]) { + computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, g_cine->_globalVars[VAR_MOUSE_X_POS], g_cine->_globalVars[VAR_MOUSE_Y_POS]); } else { element.var16 = 0; element.var14 = 0; @@ -1590,27 +1584,27 @@ void processSeqListElement(SeqListElement &element) { && !addAni(3, element.objIdx, ptr1, element, 0, &var_4)) || (element.var16 == 2 && !addAni(2, element.objIdx, ptr1, element, 0, &var_4))) { if (element.varC == 255) { - globalVars[VAR_MOUSE_Y_POS] = 0; + g_cine->_globalVars[VAR_MOUSE_Y_POS] = 0; } } if ((element.var14 == 1 && !addAni(0, element.objIdx, ptr1, element, 1, &var_2))) { if (element.varC == 255) { - globalVars[VAR_MOUSE_X_POS] = 0; + g_cine->_globalVars[VAR_MOUSE_X_POS] = 0; if (var_4 != -1) { - objectTable[element.objIdx].costume = var_4; + g_cine->_objectTable[element.objIdx].costume = var_4; } } } if ((element.var14 == 2 && !addAni(1, element.objIdx, ptr1, element, 1, &var_2))) { if (element.varC == 255) { - globalVars[VAR_MOUSE_X_POS] = 0; + g_cine->_globalVars[VAR_MOUSE_X_POS] = 0; if (var_4 != -1) { - objectTable[element.objIdx].costume = var_4; + g_cine->_objectTable[element.objIdx].costume = var_4; } } } @@ -1618,7 +1612,7 @@ void processSeqListElement(SeqListElement &element) { if (element.var16 + element.var14 == 0) { if (element.var1C) { if (element.var1E) { - objectTable[element.objIdx].costume = 0; + g_cine->_objectTable[element.objIdx].costume = 0; element.var1E = 0; } @@ -1633,7 +1627,7 @@ void processSeqListElement(SeqListElement &element) { void processSeqList() { Common::List<SeqListElement>::iterator it; - for (it = seqList.begin(); it != seqList.end(); ++it) { + for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) { if (it->var4 == -1) { continue; } diff --git a/engines/cine/various.h b/engines/cine/various.h index 3f362b1ad6..3a14328035 100644 --- a/engines/cine/various.h +++ b/engines/cine/various.h @@ -66,8 +66,6 @@ struct SeqListElement { int16 var1E; }; -extern Common::List<SeqListElement> seqList; - extern uint16 var2; extern uint16 var3; extern uint16 var4; @@ -95,8 +93,6 @@ extern uint16 _messageLen; extern int16 playerCommand; -extern Common::String commandBuffer; - extern char currentPrcName[20]; extern char currentRelName[20]; extern char currentObjectName[20]; @@ -137,8 +133,6 @@ struct SelectedObjStruct { }; #define NUM_MAX_ZONE 16 -extern Common::Array<uint16> zoneData; -extern Common::Array<uint16> zoneQuery; void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 param5); |