CINE: eliminate global variables

svn-id: r51937
This commit is contained in:
Eugene Sandulenko 2010-08-09 11:38:01 +00:00
parent 15b881386a
commit 327d30d719
26 changed files with 474 additions and 488 deletions

View file

@ -49,8 +49,6 @@ struct AnimHeader2Struct {
uint16 field_E; uint16 field_E;
}; };
Common::Array<AnimData> animDataTable;
static const AnimDataEntry transparencyData[] = { static const AnimDataEntry transparencyData[] = {
{"ALPHA", 0xF}, {"ALPHA", 0xF},
{"TITRE2", 0xF}, {"TITRE2", 0xF},
@ -400,7 +398,7 @@ void AnimData::save(Common::OutSaveFile &fHandle) const {
*/ */
void freeAnimDataRange(byte startIdx, byte numIdx) { void freeAnimDataRange(byte startIdx, byte numIdx) {
for (byte i = 0; i < numIdx; i++) { 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) { int emptyAnimSpace(int start = 0) {
for (; start < NUM_MAX_ANIMDATA; start++) { for (; start < NUM_MAX_ANIMDATA; start++) {
if (!animDataTable[start].data()) { if (!g_cine->_animDataTable[start].data()) {
return start; return start;
} }
} }
@ -540,7 +538,7 @@ int loadSpl(const char *resourceName, int16 idx) {
entry = idx < 0 ? emptyAnimSpace() : idx; entry = idx < 0 ? emptyAnimSpace() : idx;
assert(entry >= 0); 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); free(dataPtr);
return entry + 1; return entry + 1;
@ -570,7 +568,7 @@ int loadMsk(const char *resourceName, int16 idx) {
entry = idx < 0 ? emptyAnimSpace() : idx; entry = idx < 0 ? emptyAnimSpace() : idx;
assert(entry >= 0); assert(entry >= 0);
for (int16 i = 0; i < animHeader.numFrames; i++, entry++) { 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; ptr += animHeader.frameWidth * animHeader.frameHeight;
} }
@ -621,7 +619,7 @@ int loadAni(const char *resourceName, int16 idx) {
transparentColor = i < 1 ? 0xE : 0; 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; ptr += animHeader.frameWidth * animHeader.frameHeight;
} }
@ -737,7 +735,7 @@ int loadSet(const char *resourceName, int16 idx) {
type = ANIM_FULLSPRITE; 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); free(origDataPtr);
@ -759,7 +757,7 @@ int loadSeq(const char *resourceName, int16 idx) {
byte *dataPtr = readBundleFile(foundFileIdx); byte *dataPtr = readBundleFile(foundFileIdx);
int entry = idx < 0 ? emptyAnimSpace() : idx; 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); free(dataPtr);
return entry + 1; return entry + 1;
} }

View file

@ -99,8 +99,6 @@ public:
#define NUM_MAX_ANIMDATA 255 #define NUM_MAX_ANIMDATA 255
extern Common::Array<AnimData> animDataTable;
void freeAnimDataTable(); void freeAnimDataTable();
void freeAnimDataRange(byte startIdx, byte numIdx); void freeAnimDataRange(byte startIdx, byte numIdx);
int loadResource(const char *resourceName, int16 idx = -1); int loadResource(const char *resourceName, int16 idx = -1);

View file

@ -36,14 +36,13 @@
namespace Cine { namespace Cine {
uint32 var8; uint32 var8;
Common::List<BGIncrust> bgIncrustList;
/** /**
* Add masked sprite to the background * Add masked sprite to the background
* @param objIdx Sprite description * @param objIdx Sprite description
*/ */
void addToBGList(int16 objIdx) { void addToBGList(int16 objIdx) {
renderer->incrustSprite(objectTable[objIdx]); renderer->incrustSprite(g_cine->_objectTable[objIdx]);
createBgIncrustListElement(objIdx, 0); createBgIncrustListElement(objIdx, 0);
} }
@ -53,7 +52,7 @@ void addToBGList(int16 objIdx) {
* @param objIdx Sprite description * @param objIdx Sprite description
*/ */
void addSpriteFilledToBGList(int16 objIdx) { void addSpriteFilledToBGList(int16 objIdx) {
renderer->incrustMask(objectTable[objIdx]); renderer->incrustMask(g_cine->_objectTable[objIdx]);
createBgIncrustListElement(objIdx, 1); createBgIncrustListElement(objIdx, 1);
} }
@ -69,12 +68,12 @@ void createBgIncrustListElement(int16 objIdx, int16 param) {
tmp.unkPtr = 0; tmp.unkPtr = 0;
tmp.objIdx = objIdx; tmp.objIdx = objIdx;
tmp.param = param; tmp.param = param;
tmp.x = objectTable[objIdx].x; tmp.x = g_cine->_objectTable[objIdx].x;
tmp.y = objectTable[objIdx].y; tmp.y = g_cine->_objectTable[objIdx].y;
tmp.frame = objectTable[objIdx].frame; tmp.frame = g_cine->_objectTable[objIdx].frame;
tmp.part = objectTable[objIdx].part; 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.frame = fHandle.readUint16BE();
tmp.part = fHandle.readUint16BE(); tmp.part = fHandle.readUint16BE();
bgIncrustList.push_back(tmp); g_cine->_bgIncrustList.push_back(tmp);
if (tmp.param == 0) { if (tmp.param == 0) {
renderer->incrustSprite(objectTable[tmp.objIdx]); renderer->incrustSprite(g_cine->_objectTable[tmp.objIdx]);
} else { } else {
renderer->incrustMask(objectTable[tmp.objIdx]); renderer->incrustMask(g_cine->_objectTable[tmp.objIdx]);
} }
} }
} }

View file

@ -42,7 +42,6 @@ struct BGIncrust {
int16 part; int16 part;
}; };
extern Common::List<BGIncrust> bgIncrustList;
extern uint32 var8; extern uint32 var8;
void addToBGList(int16 objIdx); void addToBGList(int16 objIdx);

View file

@ -123,24 +123,26 @@ int CineEngine::modifyGameSpeed(int speedChange) {
} }
void CineEngine::initialize() { void CineEngine::initialize() {
_globalVars.reinit(NUM_MAX_VAR + 1);
// Initialize all savegames' descriptions to empty strings // Initialize all savegames' descriptions to empty strings
memset(currentSaveName, 0, sizeof(currentSaveName)); memset(currentSaveName, 0, sizeof(currentSaveName));
// Resize object table to its correct size and reset all its elements // 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(); resetObjectTable();
// Resize animation data table to its correct size and reset all its elements // 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(); freeAnimDataTable();
// Resize zone data table to its correct size and reset all its elements // Resize zone data table to its correct size and reset all its elements
zoneData.resize(NUM_MAX_ZONE); g_cine->_zoneData.resize(NUM_MAX_ZONE);
Common::set_to(zoneData.begin(), zoneData.end(), 0); 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 // Resize zone query table to its correct size and reset all its elements
zoneQuery.resize(NUM_MAX_ZONE); g_cine->_zoneQuery.resize(NUM_MAX_ZONE);
Common::set_to(zoneQuery.begin(), zoneQuery.end(), 0); Common::set_to(g_cine->_zoneQuery.begin(), g_cine->_zoneQuery.end(), 0);
_timerDelayMultiplier = 12; // Set default speed _timerDelayMultiplier = 12; // Set default speed
setupOpcodes(); setupOpcodes();
@ -159,7 +161,7 @@ void CineEngine::initialize() {
// Clear part buffer as there's nothing loaded into it yet. // Clear part buffer as there's nothing loaded into it yet.
// Its size will change when loading data into it with the loadPart function. // Its size will change when loading data into it with the loadPart function.
partBuffer.clear(); g_cine->_partBuffer.clear();
if (getGameType() == Cine::GType_OS) { if (getGameType() == Cine::GType_OS) {
readVolCnf(); readVolCnf();
@ -173,14 +175,14 @@ void CineEngine::initialize() {
} }
// in case ScummVM engines can be restarted in the future // in case ScummVM engines can be restarted in the future
scriptTable.clear(); g_cine->_scriptTable.clear();
relTable.clear(); g_cine->_relTable.clear();
objectScripts.clear(); g_cine->_objectScripts.clear();
globalScripts.clear(); g_cine->_globalScripts.clear();
bgIncrustList.clear(); g_cine->_bgIncrustList.clear();
freeAnimDataTable(); freeAnimDataTable();
overlayList.clear(); g_cine->_overlayList.clear();
messageTable.clear(); g_cine->_messageTable.clear();
resetObjectTable(); resetObjectTable();
var8 = 0; var8 = 0;

View file

@ -47,6 +47,8 @@
#include "cine/pal.h" #include "cine/pal.h"
#include "cine/gfx.h" #include "cine/gfx.h"
#include "cine/anim.h" #include "cine/anim.h"
#include "cine/bg_list.h"
#include "cine/various.h"
//#define DUMP_SCRIPTS //#define DUMP_SCRIPTS
@ -93,6 +95,7 @@ enum CineGameFeatures {
}; };
struct CINEGameDescription; struct CINEGameDescription;
struct SeqListElement;
typedef Common::HashMap<Common::String, const char *> StringPtrHashMap; typedef Common::HashMap<Common::String, const char *> StringPtrHashMap;
@ -150,6 +153,36 @@ private:
bool _preLoad; bool _preLoad;
int _timerDelayMultiplier; 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; extern CineEngine *g_cine;

View file

@ -160,13 +160,13 @@ void FWRenderer::clear() {
* @param fillColor Sprite color * @param fillColor Sprite color
*/ */
void FWRenderer::fillSprite(const ObjectStruct &obj, uint8 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; int x, y, width, height;
x = obj.x; x = obj.x;
y = obj.y; y = obj.y;
width = animDataTable[obj.frame]._realWidth; width = g_cine->_animDataTable[obj.frame]._realWidth;
height = animDataTable[obj.frame]._height; height = g_cine->_animDataTable[obj.frame]._height;
gfxFillSprite(data, width, height, _backBuffer, x, y, color); gfxFillSprite(data, width, height, _backBuffer, x, y, color);
} }
@ -177,13 +177,13 @@ void FWRenderer::fillSprite(const ObjectStruct &obj, uint8 color) {
* @param fillColor Sprite color * @param fillColor Sprite color
*/ */
void FWRenderer::incrustMask(const ObjectStruct &obj, uint8 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; int x, y, width, height;
x = obj.x; x = obj.x;
y = obj.y; y = obj.y;
width = animDataTable[obj.frame]._realWidth; width = g_cine->_animDataTable[obj.frame]._realWidth;
height = animDataTable[obj.frame]._height; height = g_cine->_animDataTable[obj.frame]._height;
gfxFillSprite(data, width, height, _background, x, y, color); gfxFillSprite(data, width, height, _background, x, y, color);
} }
@ -194,13 +194,13 @@ void FWRenderer::incrustMask(const ObjectStruct &obj, uint8 color) {
* @param mask External mask * @param mask External mask
*/ */
void FWRenderer::drawMaskedSprite(const ObjectStruct &obj, const byte *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; int x, y, width, height;
x = obj.x; x = obj.x;
y = obj.y; y = obj.y;
width = animDataTable[obj.frame]._realWidth; width = g_cine->_animDataTable[obj.frame]._realWidth;
height = animDataTable[obj.frame]._height; height = g_cine->_animDataTable[obj.frame]._height;
assert(mask); assert(mask);
@ -212,7 +212,7 @@ void FWRenderer::drawMaskedSprite(const ObjectStruct &obj, const byte *mask) {
* @param obj Object info * @param obj Object info
*/ */
void FWRenderer::drawSprite(const ObjectStruct &obj) { 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); drawMaskedSprite(obj, mask);
} }
@ -221,14 +221,14 @@ void FWRenderer::drawSprite(const ObjectStruct &obj) {
* @param obj Object info * @param obj Object info
*/ */
void FWRenderer::incrustSprite(const ObjectStruct &obj) { void FWRenderer::incrustSprite(const ObjectStruct &obj) {
const byte *data = animDataTable[obj.frame].data(); const byte *data = g_cine->_animDataTable[obj.frame].data();
const byte *mask = animDataTable[obj.frame].mask(); const byte *mask = g_cine->_animDataTable[obj.frame].mask();
int x, y, width, height; int x, y, width, height;
x = obj.x; x = obj.x;
y = obj.y; y = obj.y;
width = animDataTable[obj.frame]._realWidth; width = g_cine->_animDataTable[obj.frame]._realWidth;
height = animDataTable[obj.frame]._height; height = g_cine->_animDataTable[obj.frame]._height;
// There was an assert(mask) here before but it made savegame loading // There was an assert(mask) here before but it made savegame loading
// in Future Wars sometimes fail the assertion (e.g. see bug #2055912). // 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 * @param it Overlay info from overlayList
*/ */
void FWRenderer::remaskSprite(byte *mask, Common::List<overlay>::iterator it) { 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 x, y, width, height, idx;
int mx, my, mw, mh; int mx, my, mw, mh;
x = objectTable[it->objIdx].x; x = g_cine->_objectTable[it->objIdx].x;
y = objectTable[it->objIdx].y; y = g_cine->_objectTable[it->objIdx].y;
width = sprite._realWidth; width = sprite._realWidth;
height = sprite._height; height = sprite._height;
for (++it; it != overlayList.end(); ++it) { for (++it; it != g_cine->_overlayList.end(); ++it) {
if (it->type != 5) { if (it->type != 5) {
continue; continue;
} }
idx = ABS(objectTable[it->objIdx].frame); idx = ABS(g_cine->_objectTable[it->objIdx].frame);
mx = objectTable[it->objIdx].x; mx = g_cine->_objectTable[it->objIdx].x;
my = objectTable[it->objIdx].y; my = g_cine->_objectTable[it->objIdx].y;
mw = animDataTable[idx]._realWidth; mw = g_cine->_animDataTable[idx]._realWidth;
mh = animDataTable[idx]._height; 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) { switch (it->type) {
// color sprite // color sprite
case 0: case 0:
if (objectTable[it->objIdx].frame < 0) { if (g_cine->_objectTable[it->objIdx].frame < 0) {
return; return;
} }
sprite = &animDataTable[objectTable[it->objIdx].frame]; sprite = &g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame];
len = sprite->_realWidth * sprite->_height; len = sprite->_realWidth * sprite->_height;
mask = new byte[len]; mask = new byte[len];
memcpy(mask, sprite->mask(), len); memcpy(mask, sprite->mask(), len);
remaskSprite(mask, it); remaskSprite(mask, it);
drawMaskedSprite(objectTable[it->objIdx], mask); drawMaskedSprite(g_cine->_objectTable[it->objIdx], mask);
delete[] mask; delete[] mask;
break; break;
// game message // game message
case 2: case 2:
if (it->objIdx >= messageTable.size()) { if (it->objIdx >= g_cine->_messageTable.size()) {
return; return;
} }
_messageLen += messageTable[it->objIdx].size(); _messageLen += g_cine->_messageTable[it->objIdx].size();
drawMessage(messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); drawMessage(g_cine->_messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color);
waitForPlayerClick = 1; waitForPlayerClick = 1;
break; break;
@ -585,13 +585,13 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
// bitmap // bitmap
case 4: case 4:
assert(it->objIdx < NUM_MAX_OBJECT); assert(it->objIdx < NUM_MAX_OBJECT);
obj = &objectTable[it->objIdx]; obj = &g_cine->_objectTable[it->objIdx];
if (obj->frame < 0) { if (obj->frame < 0) {
return; return;
} }
if (!animDataTable[obj->frame].data()) { if (!g_cine->_animDataTable[obj->frame].data()) {
return; return;
} }
@ -606,7 +606,7 @@ void FWRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
void FWRenderer::drawOverlays() { void FWRenderer::drawOverlays() {
Common::List<overlay>::iterator it; 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); renderOverlay(it);
} }
} }
@ -1122,13 +1122,13 @@ void OSRenderer::clear() {
* @param fillColor Sprite color * @param fillColor Sprite color
*/ */
void OSRenderer::incrustMask(const ObjectStruct &obj, uint8 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; int x, y, width, height;
x = obj.x; x = obj.x;
y = obj.y; y = obj.y;
width = animDataTable[obj.frame]._realWidth; width = g_cine->_animDataTable[obj.frame]._realWidth;
height = animDataTable[obj.frame]._height; height = g_cine->_animDataTable[obj.frame]._height;
if (_bgTable[_currentBg].bg) { if (_bgTable[_currentBg].bg) {
gfxFillSprite(data, width, height, _bgTable[_currentBg].bg, x, y, color); 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 * @param obj Object info
*/ */
void OSRenderer::drawSprite(const ObjectStruct &obj) { 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; int x, y, width, height, transColor;
x = obj.x; x = obj.x;
y = obj.y; y = obj.y;
transColor = obj.part; transColor = obj.part;
width = animDataTable[obj.frame]._realWidth; width = g_cine->_animDataTable[obj.frame]._realWidth;
height = animDataTable[obj.frame]._height; height = g_cine->_animDataTable[obj.frame]._height;
drawSpriteRaw2(data, transColor, width, height, _backBuffer, x, y); drawSpriteRaw2(data, transColor, width, height, _backBuffer, x, y);
} }
@ -1157,14 +1157,14 @@ void OSRenderer::drawSprite(const ObjectStruct &obj) {
* @param obj Object info * @param obj Object info
*/ */
void OSRenderer::incrustSprite(const ObjectStruct &obj) { 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; int x, y, width, height, transColor;
x = obj.x; x = obj.x;
y = obj.y; y = obj.y;
transColor = obj.part; transColor = obj.part;
width = animDataTable[obj.frame]._realWidth; width = g_cine->_animDataTable[obj.frame]._realWidth;
height = animDataTable[obj.frame]._height; height = g_cine->_animDataTable[obj.frame]._height;
if (_bgTable[_currentBg].bg) { if (_bgTable[_currentBg].bg) {
drawSpriteRaw2(data, transColor, width, height, _bgTable[_currentBg].bg, x, y); 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) { switch (it->type) {
// color sprite // color sprite
case 0: case 0:
if (objectTable[it->objIdx].frame < 0) { if (g_cine->_objectTable[it->objIdx].frame < 0) {
break; break;
} }
sprite = &animDataTable[objectTable[it->objIdx].frame]; sprite = &g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame];
len = sprite->_realWidth * sprite->_height; len = sprite->_realWidth * sprite->_height;
mask = new byte[len]; 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); remaskSprite(mask, it);
drawMaskedSprite(objectTable[it->objIdx], mask); drawMaskedSprite(g_cine->_objectTable[it->objIdx], mask);
delete[] mask; delete[] mask;
break; break;
// game message // game message
case 2: case 2:
if (it->objIdx >= messageTable.size()) { if (it->objIdx >= g_cine->_messageTable.size()) {
return; return;
} }
_messageLen += messageTable[it->objIdx].size(); _messageLen += g_cine->_messageTable[it->objIdx].size();
drawMessage(messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color); 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 if (it->color >= 0) { // This test isn't in Future Wars's implementation
waitForPlayerClick = 1; waitForPlayerClick = 1;
} }
@ -1273,7 +1273,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
// bitmap // bitmap
case 4: case 4:
if (objectTable[it->objIdx].frame >= 0) { if (g_cine->_objectTable[it->objIdx].frame >= 0) {
FWRenderer::renderOverlay(it); FWRenderer::renderOverlay(it);
} }
break; break;
@ -1282,8 +1282,8 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
case 20: case 20:
assert(it->objIdx < NUM_MAX_OBJECT); assert(it->objIdx < NUM_MAX_OBJECT);
var5 = it->x; // A global variable updated here! var5 = it->x; // A global variable updated here!
obj = &objectTable[it->objIdx]; obj = &g_cine->_objectTable[it->objIdx];
sprite = &animDataTable[obj->frame]; sprite = &g_cine->_animDataTable[obj->frame];
if (obj->frame < 0 || it->x < 0 || it->x > 8 || !_bgTable[it->x].bg || sprite->_bpp != 1) { if (obj->frame < 0 || it->x < 0 || it->x > 8 || !_bgTable[it->x].bg || sprite->_bpp != 1) {
break; break;
@ -1303,7 +1303,7 @@ void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
case 22: case 22:
// TODO: Check it this implementation really works correctly (Some things might be wrong, needs testing). // TODO: Check it this implementation really works correctly (Some things might be wrong, needs testing).
assert(it->objIdx < NUM_MAX_OBJECT); assert(it->objIdx < NUM_MAX_OBJECT);
obj = &objectTable[it->objIdx]; obj = &g_cine->_objectTable[it->objIdx];
color = obj->part & 0x0F; color = obj->part & 0x0F;
width = obj->frame; width = obj->frame;
height = obj->costume; height = obj->costume;
@ -1797,17 +1797,17 @@ void maskBgOverlay(const byte *bgPtr, const byte *maskPtr, int16 width, int16 he
maskPtr = backup; maskPtr = backup;
// incrust pass // incrust pass
for (it = bgIncrustList.begin(); it != bgIncrustList.end(); ++it) { for (it = g_cine->_bgIncrustList.begin(); it != g_cine->_bgIncrustList.end(); ++it) {
tmpWidth = animDataTable[it->frame]._realWidth; tmpWidth = g_cine->_animDataTable[it->frame]._realWidth;
tmpHeight = animDataTable[it->frame]._height; tmpHeight = g_cine->_animDataTable[it->frame]._height;
mask = (byte*)malloc(tmpWidth * tmpHeight); mask = (byte*)malloc(tmpWidth * tmpHeight);
if (it->param == 0) { 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); 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 { } 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); gfxUpdateIncrustMask(mask, it->x, it->y, tmpWidth, tmpHeight, maskPtr, x, y, width, height);
gfxFillSprite(mask, tmpWidth, tmpHeight, page, it->x, it->y); gfxFillSprite(mask, tmpWidth, tmpHeight, page, it->x, it->y);
} }

View file

@ -241,11 +241,11 @@ int getKeyData() {
/** Removes elements from seqList that have their member variable var4 set to value -1. */ /** Removes elements from seqList that have their member variable var4 set to value -1. */
void purgeSeqList() { void purgeSeqList() {
Common::List<SeqListElement>::iterator it = seqList.begin(); Common::List<SeqListElement>::iterator it = g_cine->_seqList.begin();
while (it != seqList.end()) { while (it != g_cine->_seqList.end()) {
if (it->var4 == -1) { if (it->var4 == -1) {
// Erase the element and jump to the next element // Erase the element and jump to the next element
it = seqList.erase(it); it = g_cine->_seqList.erase(it);
} else { } else {
// Let the element be and jump to the next element // Let the element be and jump to the next element
it++; it++;
@ -283,15 +283,15 @@ void CineEngine::mainLoop(int bootScriptIdx) {
menuCommandLen = 0; menuCommandLen = 0;
playerCommand = -1; playerCommand = -1;
commandBuffer = ""; g_cine->_commandBuffer = "";
globalVars[VAR_MOUSE_X_POS] = 0; g_cine->_globalVars[VAR_MOUSE_X_POS] = 0;
globalVars[VAR_MOUSE_Y_POS] = 0; g_cine->_globalVars[VAR_MOUSE_Y_POS] = 0;
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
globalVars[VAR_MOUSE_X_POS_2ND] = 0; g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = 0;
globalVars[VAR_MOUSE_Y_POS_2ND] = 0; g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = 0;
globalVars[VAR_BYPASS_PROTECTION] = 0; // set to 1 to bypass the copy protection g_cine->_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_LOW_MEMORY] = 0; // set to 1 to disable some animations, sounds etc.
} }
strcpy(newPrcName, ""); strcpy(newPrcName, "");
@ -315,7 +315,7 @@ void CineEngine::mainLoop(int bootScriptIdx) {
if (bgName == "28.PI1" || bgName == "29.PI1" || bgName == "30.PI1") { if (bgName == "28.PI1" || bgName == "29.PI1" || bgName == "30.PI1") {
static const uint oxygenObjNum = 202, maxOxygen = 264; static const uint oxygenObjNum = 202, maxOxygen = 264;
// Force the amount of oxygen left to the maximum. // 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. // 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. // FIXME: Remove the hack and solve what's really causing the problem in the first place.
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
if (scumm_stricmp(renderer->getBgName(), "21.PI1") == 0 && objectTable[1].x == 204 && objectTable[1].y == 110) { if (scumm_stricmp(renderer->getBgName(), "21.PI1") == 0 && g_cine->_objectTable[1].x == 204 && g_cine->_objectTable[1].y == 110) {
objectTable[1].y--; // Move the player character upward on-screen by one pixel 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) // Clear the zoneQuery table (Operation Stealth specific)
if (g_cine->getGameType() == Cine::GType_OS) { 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) { if (g_cine->getGameType() == Cine::GType_OS) {

View file

@ -31,15 +31,11 @@
namespace Cine { namespace Cine {
// FIXME: Global C++ objects affect portability negatively.
// Turn this into a class member instead.
Common::StringArray messageTable;
void loadMsg(char *pMsgName) { void loadMsg(char *pMsgName) {
uint32 sourceSize; uint32 sourceSize;
checkDataDisk(-1); checkDataDisk(-1);
messageTable.clear(); g_cine->_messageTable.clear();
byte *dataPtr = readBundleFile(findFileInBundle(pMsgName), &sourceSize); byte *dataPtr = readBundleFile(findFileInBundle(pMsgName), &sourceSize);
setMouseCursor(MOUSE_CURSOR_DISK); 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 // 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). // buffer (e.g. message indexes 58-254 in BATEAU.MSG in PROCS08 in Operation Stealth).
if (messageDataPos < sourceSize) { if (messageDataPos < sourceSize) {
messageTable.push_back((const char *)(dataPtr + messageDataPos)); g_cine->_messageTable.push_back((const char *)(dataPtr + messageDataPos));
} else { } else {
if (messageLen > 0) { // Only warn about overflowing non-empty strings 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); 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); 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 // 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 // Jump to the next message
messageDataPos += messageLen; messageDataPos += messageLen;

View file

@ -32,8 +32,6 @@ namespace Cine {
#define NUM_MAX_MESSAGE 255 #define NUM_MAX_MESSAGE 255
extern Common::StringArray messageTable;
void loadMsg(char *pMsgName); void loadMsg(char *pMsgName);
} // End of namespace Cine } // End of namespace Cine

View file

@ -35,12 +35,9 @@
namespace Cine { namespace Cine {
Common::Array<ObjectStruct> objectTable;
Common::List<overlay> overlayList;
/** Resets all elements in the object table. */ /** Resets all elements in the object table. */
void resetObjectTable() { 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(); it->clear();
} }
} }
@ -64,23 +61,23 @@ void loadObject(char *pObjectName) {
assert(numEntry <= NUM_MAX_OBJECT); assert(numEntry <= NUM_MAX_OBJECT);
for (i = 0; i < numEntry; i++) { 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); Common::MemoryReadStream readS(ptr, entrySize);
objectTable[i].x = readS.readSint16BE(); g_cine->_objectTable[i].x = readS.readSint16BE();
objectTable[i].y = readS.readSint16BE(); g_cine->_objectTable[i].y = readS.readSint16BE();
objectTable[i].mask = readS.readUint16BE(); g_cine->_objectTable[i].mask = readS.readUint16BE();
objectTable[i].frame = readS.readSint16BE(); g_cine->_objectTable[i].frame = readS.readSint16BE();
objectTable[i].costume = readS.readSint16BE(); g_cine->_objectTable[i].costume = readS.readSint16BE();
readS.read(objectTable[i].name, 20); readS.read(g_cine->_objectTable[i].name, 20);
objectTable[i].part = readS.readUint16BE(); g_cine->_objectTable[i].part = readS.readUint16BE();
} }
ptr += entrySize; ptr += entrySize;
} }
if (!strcmp(pObjectName, "INTRO.OBJ")) { if (!strcmp(pObjectName, "INTRO.OBJ")) {
for (i = 0; i < 10; i++) { 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) { int removeOverlay(uint16 objIdx, uint16 param) {
Common::List<overlay>::iterator it; 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) { if (it->objIdx == objIdx && it->type == param) {
overlayList.erase(it); g_cine->_overlayList.erase(it);
return 1; return 1;
} }
} }
@ -115,9 +112,9 @@ void addOverlay(uint16 objIdx, uint16 type) {
Common::List<overlay>::iterator it; Common::List<overlay>::iterator it;
overlay tmp; 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 // 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; break;
} }
@ -128,7 +125,7 @@ void addOverlay(uint16 objIdx, uint16 type) {
} }
// In Operation Stealth's implementation we might bail out early // 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; return;
} }
@ -139,7 +136,7 @@ void addOverlay(uint16 objIdx, uint16 type) {
tmp.width = 0; tmp.width = 0;
tmp.color = 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; Common::List<overlay>::iterator it;
overlay tmp; overlay tmp;
for (it = overlayList.begin(); it != overlayList.end(); ++it) { for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) {
if (objectTable[it->objIdx].mask >= objectTable[objIdx].mask || it->type == 2 || it->type == 3) { if (g_cine->_objectTable[it->objIdx].mask >= g_cine->_objectTable[objIdx].mask || it->type == 2 || it->type == 3) {
break; 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; return;
} }
@ -168,7 +165,7 @@ void addGfxElement(int16 objIdx, int16 param, int16 type) {
tmp.width = 0; tmp.width = 0;
tmp.color = 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) { void removeGfxElement(int16 objIdx, int16 param, int16 type) {
Common::List<overlay>::iterator it; 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) { if (it->objIdx == objIdx && it->type == type && it->x == param) {
overlayList.erase(it); g_cine->_overlayList.erase(it);
return; return;
} }
} }
} }
void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint16 param4) { void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint16 param4) {
objectTable[objIdx].x = param1; g_cine->_objectTable[objIdx].x = param1;
objectTable[objIdx].y = param2; g_cine->_objectTable[objIdx].y = param2;
objectTable[objIdx].mask = param3; g_cine->_objectTable[objIdx].mask = param3;
objectTable[objIdx].frame = param4; g_cine->_objectTable[objIdx].frame = param4;
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
resetGfxEntityEntry(objIdx); resetGfxEntityEntry(objIdx);
@ -219,13 +216,13 @@ void modifyObjectParam(byte objIdx, byte paramIdx, int16 newValue) {
switch (paramIdx) { switch (paramIdx) {
case 1: case 1:
objectTable[objIdx].x = newValue; g_cine->_objectTable[objIdx].x = newValue;
break; break;
case 2: case 2:
objectTable[objIdx].y = newValue; g_cine->_objectTable[objIdx].y = newValue;
break; break;
case 3: case 3:
objectTable[objIdx].mask = newValue; g_cine->_objectTable[objIdx].mask = newValue;
if (g_cine->getGameType() == Cine::GType_OS) { // Operation Stealth specific if (g_cine->getGameType() == Cine::GType_OS) { // Operation Stealth specific
resetGfxEntityEntry(objIdx); resetGfxEntityEntry(objIdx);
@ -236,18 +233,18 @@ void modifyObjectParam(byte objIdx, byte paramIdx, int16 newValue) {
} }
break; break;
case 4: case 4:
objectTable[objIdx].frame = newValue; g_cine->_objectTable[objIdx].frame = newValue;
break; break;
case 5: case 5:
// TODO: Test if this really breaks the newspaper machine on the airport in Operation Stealth. // TODO: Test if this really breaks the newspaper machine on the airport in Operation Stealth.
if (g_cine->getGameType() == Cine::GType_FW && newValue == -1) { if (g_cine->getGameType() == Cine::GType_FW && newValue == -1) {
objectTable[objIdx].costume = globalVars[0]; g_cine->_objectTable[objIdx].costume = g_cine->_globalVars[0];
} else { } else {
objectTable[objIdx].costume = newValue; g_cine->_objectTable[objIdx].costume = newValue;
} }
break; break;
case 6: case 6:
objectTable[objIdx].part = newValue; g_cine->_objectTable[objIdx].part = newValue;
break; 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) { 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); assert(objIdx1 < NUM_MAX_OBJECT && objIdx2 < NUM_MAX_OBJECT);
const ObjectStruct &obj1 = objectTable[objIdx1]; const ObjectStruct &obj1 = g_cine->_objectTable[objIdx1];
const ObjectStruct &obj2 = objectTable[objIdx2]; const ObjectStruct &obj2 = g_cine->_objectTable[objIdx2];
if (compareRanges(obj1.x, obj1.x + xAdd1, obj2.x, obj2.x + xAdd2) && if (compareRanges(obj1.x, obj1.x + xAdd1, obj2.x, obj2.x + xAdd2) &&
compareRanges(obj1.y, obj1.y + yAdd1, obj2.y, obj2.y + yAdd2) && compareRanges(obj1.y, obj1.y + yAdd1, obj2.y, obj2.y + yAdd2) &&
@ -304,17 +301,17 @@ int16 getObjectParam(uint16 objIdx, uint16 paramIdx) {
switch (paramIdx) { switch (paramIdx) {
case 0: case 0:
return objectTable[objIdx].x; return g_cine->_objectTable[objIdx].x;
case 1: case 1:
return objectTable[objIdx].y; return g_cine->_objectTable[objIdx].y;
case 2: case 2:
return objectTable[objIdx].mask; return g_cine->_objectTable[objIdx].mask;
case 3: case 3:
return objectTable[objIdx].frame; return g_cine->_objectTable[objIdx].frame;
case 4: case 4:
return objectTable[objIdx].costume; return g_cine->_objectTable[objIdx].costume;
case 5: case 5:
return objectTable[objIdx].part; return g_cine->_objectTable[objIdx].part;
} }
return 0; return 0;

View file

@ -63,9 +63,6 @@ struct overlay {
#define NUM_MAX_OBJECT 255 #define NUM_MAX_OBJECT 255
#define NUM_MAX_VAR 255 #define NUM_MAX_VAR 255
extern Common::Array<ObjectStruct> objectTable;
extern Common::List<overlay> overlayList;
void resetObjectTable(); void resetObjectTable();
void loadObject(char *pObjectName); void loadObject(char *pObjectName);
void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint16 param4); void setupObject(byte objIdx, uint16 param1, uint16 param2, uint16 param3, uint16 param4);

View file

@ -30,7 +30,6 @@
namespace Cine { namespace Cine {
Common::Array<PalEntry> palArray;
static byte paletteBuffer1[16]; static byte paletteBuffer1[16];
static byte paletteBuffer2[16]; static byte paletteBuffer2[16];
@ -40,7 +39,7 @@ void loadPal(const char *fileName) {
removeExtention(buffer, fileName); removeExtention(buffer, fileName);
strcat(buffer, ".PAL"); strcat(buffer, ".PAL");
palArray.clear(); g_cine->_palArray.clear();
Common::File palFileHandle; Common::File palFileHandle;
if (!palFileHandle.open(buffer)) if (!palFileHandle.open(buffer))
@ -49,11 +48,11 @@ void loadPal(const char *fileName) {
uint16 palEntriesCount = palFileHandle.readUint16LE(); uint16 palEntriesCount = palFileHandle.readUint16LE();
palFileHandle.readUint16LE(); // entry size palFileHandle.readUint16LE(); // entry size
palArray.resize(palEntriesCount); g_cine->_palArray.resize(palEntriesCount);
for (uint i = 0; i < palArray.size(); ++i) { for (uint i = 0; i < g_cine->_palArray.size(); ++i) {
palFileHandle.read(palArray[i].name, 10); palFileHandle.read(g_cine->_palArray[i].name, 10);
palFileHandle.read(palArray[i].pal1, 16); palFileHandle.read(g_cine->_palArray[i].pal1, 16);
palFileHandle.read(palArray[i].pal2, 16); palFileHandle.read(g_cine->_palArray[i].pal2, 16);
} }
palFileHandle.close(); palFileHandle.close();
} }
@ -73,8 +72,8 @@ int16 findPaletteFromName(const char *fileName) {
position++; position++;
} }
for (i = 0; i < palArray.size(); i++) { for (i = 0; i < g_cine->_palArray.size(); i++) {
if (!strcmp(buffer, palArray[i].name)) { if (!strcmp(buffer, g_cine->_palArray[i].name)) {
return i; return i;
} }
} }
@ -97,9 +96,9 @@ void loadRelatedPalette(const char *fileName) {
paletteBuffer1[i] = paletteBuffer2[i] = (i << 4) + i; paletteBuffer1[i] = paletteBuffer2[i] = (i << 4) + i;
} }
} else { } else {
assert(paletteIndex < (int32)palArray.size()); assert(paletteIndex < (int32)g_cine->_palArray.size());
memcpy(paletteBuffer1, palArray[paletteIndex].pal1, 16); memcpy(paletteBuffer1, g_cine->_palArray[paletteIndex].pal1, 16);
memcpy(paletteBuffer2, palArray[paletteIndex].pal2, 16); memcpy(paletteBuffer2, g_cine->_palArray[paletteIndex].pal2, 16);
} }
} }

View file

@ -49,8 +49,6 @@ struct PalEntry {
byte pal2[16]; byte pal2[16];
}; };
extern Common::Array<PalEntry> palArray;
void loadPal(const char *fileName); void loadPal(const char *fileName);
void loadRelatedPalette(const char *fileName); void loadRelatedPalette(const char *fileName);

View file

@ -32,10 +32,8 @@
namespace Cine { namespace Cine {
Common::Array<PartBuffer> partBuffer;
void loadPart(const char *partName) { void loadPart(const char *partName) {
partBuffer.clear(); g_cine->_partBuffer.clear();
g_cine->_partFileHandle.close(); g_cine->_partFileHandle.close();
@ -47,17 +45,17 @@ void loadPart(const char *partName) {
setMouseCursor(MOUSE_CURSOR_DISK); setMouseCursor(MOUSE_CURSOR_DISK);
uint16 numElementInPart = g_cine->_partFileHandle.readUint16BE(); uint16 numElementInPart = g_cine->_partFileHandle.readUint16BE();
partBuffer.resize(numElementInPart); g_cine->_partBuffer.resize(numElementInPart);
g_cine->_partFileHandle.readUint16BE(); // entry size g_cine->_partFileHandle.readUint16BE(); // entry size
if (currentPartName != partName) if (currentPartName != partName)
strcpy(currentPartName, partName); strcpy(currentPartName, partName);
for (uint16 i = 0; i < partBuffer.size(); i++) { for (uint16 i = 0; i < g_cine->_partBuffer.size(); i++) {
g_cine->_partFileHandle.read(partBuffer[i].partName, 14); g_cine->_partFileHandle.read(g_cine->_partBuffer[i].partName, 14);
partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE(); g_cine->_partBuffer[i].offset = g_cine->_partFileHandle.readUint32BE();
partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE(); g_cine->_partBuffer[i].packedSize = g_cine->_partFileHandle.readUint32BE();
partBuffer[i].unpackedSize = g_cine->_partFileHandle.readUint32BE(); g_cine->_partBuffer[i].unpackedSize = g_cine->_partFileHandle.readUint32BE();
g_cine->_partFileHandle.readUint32BE(); // unused g_cine->_partFileHandle.readUint32BE(); // unused
} }
@ -189,8 +187,8 @@ void CineEngine::readVolCnf() {
int16 findFileInBundle(const char *fileName) { int16 findFileInBundle(const char *fileName) {
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
// look first in currently loaded resource file // look first in currently loaded resource file
for (uint i = 0; i < partBuffer.size(); i++) { for (uint i = 0; i < g_cine->_partBuffer.size(); i++) {
if (!scumm_stricmp(fileName, partBuffer[i].partName)) { if (!scumm_stricmp(fileName, g_cine->_partBuffer[i].partName)) {
return i; return i;
} }
} }
@ -203,8 +201,8 @@ int16 findFileInBundle(const char *fileName) {
const char *part = (*it)._value; const char *part = (*it)._value;
loadPart(part); loadPart(part);
} }
for (uint i = 0; i < partBuffer.size(); i++) { for (uint i = 0; i < g_cine->_partBuffer.size(); i++) {
if (!scumm_stricmp(fileName, partBuffer[i].partName)) { if (!scumm_stricmp(fileName, g_cine->_partBuffer[i].partName)) {
return i; return i;
} }
} }
@ -212,31 +210,31 @@ int16 findFileInBundle(const char *fileName) {
} }
void readFromPart(int16 idx, byte *dataPtr, uint32 maxSize) { void readFromPart(int16 idx, byte *dataPtr, uint32 maxSize) {
assert(maxSize >= partBuffer[idx].packedSize); assert(maxSize >= g_cine->_partBuffer[idx].packedSize);
setMouseCursor(MOUSE_CURSOR_DISK); setMouseCursor(MOUSE_CURSOR_DISK);
g_cine->_partFileHandle.seek(partBuffer[idx].offset, SEEK_SET); g_cine->_partFileHandle.seek(g_cine->_partBuffer[idx].offset, SEEK_SET);
g_cine->_partFileHandle.read(dataPtr, partBuffer[idx].packedSize); g_cine->_partFileHandle.read(dataPtr, g_cine->_partBuffer[idx].packedSize);
} }
byte *readBundleFile(int16 foundFileIdx, uint32 *size) { 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; bool error = false;
byte *dataPtr = (byte *)calloc(partBuffer[foundFileIdx].unpackedSize, 1); byte *dataPtr = (byte *)calloc(g_cine->_partBuffer[foundFileIdx].unpackedSize, 1);
byte *packedData = (byte *)calloc(partBuffer[foundFileIdx].packedSize, 1); byte *packedData = (byte *)calloc(g_cine->_partBuffer[foundFileIdx].packedSize, 1);
assert(dataPtr && packedData); assert(dataPtr && packedData);
readFromPart(foundFileIdx, packedData, partBuffer[foundFileIdx].packedSize); readFromPart(foundFileIdx, packedData, g_cine->_partBuffer[foundFileIdx].packedSize);
CineUnpacker cineUnpacker; 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); free(packedData);
if (error) { 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 // Set the size variable if a pointer to it has been given
if (size != NULL) { if (size != NULL) {
*size = partBuffer[foundFileIdx].unpackedSize; *size = g_cine->_partBuffer[foundFileIdx].unpackedSize;
} }
return dataPtr; return dataPtr;
@ -255,7 +253,7 @@ byte *readBundleSoundFile(const char *entryName, uint32 *size) {
if (index != -1) { if (index != -1) {
data = readBundleFile(index); data = readBundleFile(index);
if (size) { if (size) {
*size = partBuffer[index].unpackedSize; *size = g_cine->_partBuffer[index].unpackedSize;
} }
} }
if (g_cine->getGameType() == Cine::GType_FW) { if (g_cine->getGameType() == Cine::GType_FW) {
@ -305,14 +303,14 @@ void dumpBundle(const char *fileName) {
strcpy(tmpPart, currentPartName); strcpy(tmpPart, currentPartName);
loadPart(fileName); loadPart(fileName);
for (uint i = 0; i < partBuffer.size(); i++) { for (uint i = 0; i < g_cine->_partBuffer.size(); i++) {
byte *data = readBundleFile(i); byte *data = readBundleFile(i);
debug(0, "%s", partBuffer[i].partName); debug(0, "%s", g_cine->_partBuffer[i].partName);
Common::DumpFile out; Common::DumpFile out;
if (out.open(Common::String("dumps/") + partBuffer[i].partName)) { if (out.open(Common::String("dumps/") + g_cine->_partBuffer[i].partName)) {
out.write(data, partBuffer[i].unpackedSize); out.write(data, g_cine->_partBuffer[i].unpackedSize);
out.close(); out.close();
} }

View file

@ -37,8 +37,6 @@ struct PartBuffer {
#define NUM_MAX_PARTDATA 255 #define NUM_MAX_PARTDATA 255
extern Common::Array<PartBuffer> partBuffer;
void loadPart(const char *partName); void loadPart(const char *partName);
void closePart(); void closePart();

View file

@ -35,9 +35,6 @@
namespace Cine { namespace Cine {
ScriptList globalScripts;
ScriptList objectScripts;
//char currentPrcName[20]; //char currentPrcName[20];
/** /**
@ -52,8 +49,8 @@ bool loadPrc(const char *pPrcName) {
assert(pPrcName); assert(pPrcName);
globalScripts.clear(); g_cine->_globalScripts.clear();
scriptTable.clear(); g_cine->_scriptTable.clear();
// This is copy protection. Used to hang the machine // This is copy protection. Used to hang the machine
if (!scumm_stricmp(pPrcName, COPY_PROT_FAIL_PRC_NAME)) { 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))); RawScriptPtr tmp(new RawScript(READ_BE_UINT16(scriptPtr)));
scriptPtr += 2; scriptPtr += 2;
assert(tmp); assert(tmp);
scriptTable.push_back(tmp); g_cine->_scriptTable.push_back(tmp);
} }
for (i = 0; i < numScripts; i++) { for (i = 0; i < numScripts; i++) {
uint16 size = scriptTable[i]->_size; uint16 size = g_cine->_scriptTable[i]->_size;
// TODO: delete the test? // TODO: delete the test?
if (size) { if (size) {
scriptTable[i]->setData(*scriptInfo, scriptPtr); g_cine->_scriptTable[i]->setData(*scriptInfo, scriptPtr);
scriptPtr += size; scriptPtr += size;
} }
} }

View file

@ -28,9 +28,6 @@
namespace Cine { namespace Cine {
extern ScriptList globalScripts;
extern ScriptList objectScripts;
bool loadPrc(const char *pPrcName); bool loadPrc(const char *pPrcName);
} // End of namespace Cine } // End of namespace Cine

View file

@ -31,8 +31,6 @@
namespace Cine { namespace Cine {
RawObjectScriptArray relTable; ///< Object script bytecode table
/** /**
* @todo Is script size of 0 valid? * @todo Is script size of 0 valid?
* @todo Fix script dump code * @todo Fix script dump code
@ -45,8 +43,8 @@ void loadRel(char *pRelName) {
checkDataDisk(-1); checkDataDisk(-1);
objectScripts.clear(); g_cine->_objectScripts.clear();
relTable.clear(); g_cine->_relTable.clear();
ptr = dataPtr = readBundleFile(findFileInBundle(pRelName)); ptr = dataPtr = readBundleFile(findFileInBundle(pRelName));
@ -61,14 +59,14 @@ void loadRel(char *pRelName) {
p3 = READ_BE_UINT16(ptr); ptr += 2; p3 = READ_BE_UINT16(ptr); ptr += 2;
RawObjectScriptPtr tmp(new RawObjectScript(size, p1, p2, p3)); RawObjectScriptPtr tmp(new RawObjectScript(size, p1, p2, p3));
assert(tmp); assert(tmp);
relTable.push_back(tmp); g_cine->_relTable.push_back(tmp);
} }
for (i = 0; i < numEntry; i++) { for (i = 0; i < numEntry; i++) {
size = relTable[i]->_size; size = g_cine->_relTable[i]->_size;
// TODO: delete the test? // TODO: delete the test?
if (size) { if (size) {
relTable[i]->setData(*scriptInfo, ptr); g_cine->_relTable[i]->setData(*scriptInfo, ptr);
ptr += size; ptr += size;
} }
} }
@ -82,10 +80,10 @@ void loadRel(char *pRelName) {
char buffer[256]; char buffer[256];
for (s = 0; s < numEntry; s++) { for (s = 0; s < numEntry; s++) {
if (relTable[s]->_size) { if (g_cine->_relTable[s]->_size) {
sprintf(buffer, "%s_%03d.txt", pRelName, s); 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); dumpScript(buffer);
} }
} }

View file

@ -29,8 +29,6 @@
#include "cine/script.h" #include "cine/script.h"
namespace Cine { namespace Cine {
extern RawObjectScriptArray relTable;
void loadRel(char *pRelName); void loadRel(char *pRelName);
} // End of namespace Cine } // End of namespace Cine

View file

@ -200,13 +200,13 @@ void loadScriptFromSave(Common::SeekableReadStream &fHandle, bool isGlobal) {
// original code loaded everything into globalScripts, this should be // original code loaded everything into globalScripts, this should be
// the correct behavior // the correct behavior
if (isGlobal) { 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); assert(tmp);
globalScripts.push_back(tmp); g_cine->_globalScripts.push_back(tmp);
} else { } 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); 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.width = fHandle.readSint16BE();
tmp.color = fHandle.readSint16BE(); tmp.color = fHandle.readSint16BE();
overlayList.push_back(tmp); g_cine->_overlayList.push_back(tmp);
} }
bool loadObjectTable(Common::SeekableReadStream &in) { bool loadObjectTable(Common::SeekableReadStream &in) {
@ -235,20 +235,20 @@ bool loadObjectTable(Common::SeekableReadStream &in) {
in.readUint16BE(); // Entry size in.readUint16BE(); // Entry size
for (int i = 0; i < NUM_MAX_OBJECT; i++) { for (int i = 0; i < NUM_MAX_OBJECT; i++) {
objectTable[i].x = in.readSint16BE(); g_cine->_objectTable[i].x = in.readSint16BE();
objectTable[i].y = in.readSint16BE(); g_cine->_objectTable[i].y = in.readSint16BE();
objectTable[i].mask = in.readUint16BE(); g_cine->_objectTable[i].mask = in.readUint16BE();
objectTable[i].frame = in.readSint16BE(); g_cine->_objectTable[i].frame = in.readSint16BE();
objectTable[i].costume = in.readSint16BE(); g_cine->_objectTable[i].costume = in.readSint16BE();
in.read(objectTable[i].name, 20); in.read(g_cine->_objectTable[i].name, 20);
objectTable[i].part = in.readUint16BE(); g_cine->_objectTable[i].part = in.readUint16BE();
} }
return !(in.eos() || in.err()); return !(in.eos() || in.err());
} }
bool loadZoneData(Common::SeekableReadStream &in) { bool loadZoneData(Common::SeekableReadStream &in) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
zoneData[i] = in.readUint16BE(); g_cine->_zoneData[i] = in.readUint16BE();
} }
return !(in.eos() || in.err()); return !(in.eos() || in.err());
} }
@ -313,14 +313,14 @@ bool loadSeqList(Common::SeekableReadStream &in) {
tmp.var1A = in.readSint16BE(); tmp.var1A = in.readSint16BE();
tmp.var1C = in.readSint16BE(); tmp.var1C = in.readSint16BE();
tmp.var1E = in.readSint16BE(); tmp.var1E = in.readSint16BE();
seqList.push_back(tmp); g_cine->_seqList.push_back(tmp);
} }
return !(in.eos() || in.err()); return !(in.eos() || in.err());
} }
bool loadZoneQuery(Common::SeekableReadStream &in) { bool loadZoneQuery(Common::SeekableReadStream &in) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
zoneQuery[i] = in.readUint16BE(); g_cine->_zoneQuery[i] = in.readUint16BE();
} }
return !(in.eos() || in.err()); return !(in.eos() || in.err());
} }
@ -330,19 +330,19 @@ void saveObjectTable(Common::OutSaveFile &out) {
out.writeUint16BE(0x20); // Entry size out.writeUint16BE(0x20); // Entry size
for (int i = 0; i < NUM_MAX_OBJECT; i++) { for (int i = 0; i < NUM_MAX_OBJECT; i++) {
out.writeUint16BE(objectTable[i].x); out.writeUint16BE(g_cine->_objectTable[i].x);
out.writeUint16BE(objectTable[i].y); out.writeUint16BE(g_cine->_objectTable[i].y);
out.writeUint16BE(objectTable[i].mask); out.writeUint16BE(g_cine->_objectTable[i].mask);
out.writeUint16BE(objectTable[i].frame); out.writeUint16BE(g_cine->_objectTable[i].frame);
out.writeUint16BE(objectTable[i].costume); out.writeUint16BE(g_cine->_objectTable[i].costume);
out.write(objectTable[i].name, 20); out.write(g_cine->_objectTable[i].name, 20);
out.writeUint16BE(objectTable[i].part); out.writeUint16BE(g_cine->_objectTable[i].part);
} }
} }
void saveZoneData(Common::OutSaveFile &out) { void saveZoneData(Common::OutSaveFile &out) {
for (int i = 0; i < 16; i++) { 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) { void saveCommandBuffer(Common::OutSaveFile &out) {
// Let's make sure there's space for the trailing zero // Let's make sure there's space for the trailing zero
// (That's why we subtract one from the maximum command buffer size here). // (That's why we subtract one from the maximum command buffer size here).
uint32 size = MIN<uint32>(commandBuffer.size(), kMaxCommandBufferSize - 1); uint32 size = MIN<uint32>(g_cine->_commandBuffer.size(), kMaxCommandBufferSize - 1);
out.write(commandBuffer.c_str(), size); out.write(g_cine->_commandBuffer.c_str(), size);
// Write the rest as zeroes (Here we also write the string's trailing zero) // Write the rest as zeroes (Here we also write the string's trailing zero)
for (uint i = 0; i < kMaxCommandBufferSize - size; i++) { for (uint i = 0; i < kMaxCommandBufferSize - size; i++) {
out.writeByte(0); out.writeByte(0);
@ -369,7 +369,7 @@ void saveAnimDataTable(Common::OutSaveFile &out) {
out.writeUint16BE(0x1E); // Entry size out.writeUint16BE(0x1E); // Entry size
for (int i = 0; i < NUM_MAX_ANIMDATA; i++) { 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) { void saveGlobalScripts(Common::OutSaveFile &out) {
ScriptList::const_iterator it; ScriptList::const_iterator it;
out.writeUint16BE(globalScripts.size()); out.writeUint16BE(g_cine->_globalScripts.size());
for (it = globalScripts.begin(); it != globalScripts.end(); ++it) { for (it = g_cine->_globalScripts.begin(); it != g_cine->_globalScripts.end(); ++it) {
(*it)->save(out); (*it)->save(out);
} }
} }
void saveObjectScripts(Common::OutSaveFile &out) { void saveObjectScripts(Common::OutSaveFile &out) {
ScriptList::const_iterator it; ScriptList::const_iterator it;
out.writeUint16BE(objectScripts.size()); out.writeUint16BE(g_cine->_objectScripts.size());
for (it = objectScripts.begin(); it != objectScripts.end(); ++it) { for (it = g_cine->_objectScripts.begin(); it != g_cine->_objectScripts.end(); ++it) {
(*it)->save(out); (*it)->save(out);
} }
} }
@ -402,9 +402,9 @@ void saveObjectScripts(Common::OutSaveFile &out) {
void saveOverlayList(Common::OutSaveFile &out) { void saveOverlayList(Common::OutSaveFile &out) {
Common::List<overlay>::const_iterator it; 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); // next
out.writeUint32BE(0); // previous? out.writeUint32BE(0); // previous?
out.writeUint16BE(it->objIdx); out.writeUint16BE(it->objIdx);
@ -418,9 +418,9 @@ void saveOverlayList(Common::OutSaveFile &out) {
void saveBgIncrustList(Common::OutSaveFile &out) { void saveBgIncrustList(Common::OutSaveFile &out) {
Common::List<BGIncrust>::const_iterator it; 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); // next
out.writeUint32BE(0); // previous? out.writeUint32BE(0); // previous?
out.writeUint16BE(it->objIdx); out.writeUint16BE(it->objIdx);
@ -434,15 +434,15 @@ void saveBgIncrustList(Common::OutSaveFile &out) {
void saveZoneQuery(Common::OutSaveFile &out) { void saveZoneQuery(Common::OutSaveFile &out) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
out.writeUint16BE(zoneQuery[i]); out.writeUint16BE(g_cine->_zoneQuery[i]);
} }
} }
void saveSeqList(Common::OutSaveFile &out) { void saveSeqList(Common::OutSaveFile &out) {
Common::List<SeqListElement>::const_iterator it; 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.writeSint16BE(it->var4);
out.writeUint16BE(it->objIdx); out.writeUint16BE(it->objIdx);
out.writeSint16BE(it->var8); out.writeSint16BE(it->var8);
@ -567,13 +567,13 @@ bool CineEngine::loadTempSaveOS(Common::SeekableReadStream &in) {
loadObjectTable(in); loadObjectTable(in);
renderer->restorePalette(in, hdr.version); renderer->restorePalette(in, hdr.version);
globalVars.load(in, NUM_MAX_VAR); g_cine->_globalVars.load(in, NUM_MAX_VAR);
loadZoneData(in); loadZoneData(in);
loadCommandVariables(in); loadCommandVariables(in);
char tempCommandBuffer[kMaxCommandBufferSize]; char tempCommandBuffer[kMaxCommandBufferSize];
in.read(tempCommandBuffer, kMaxCommandBufferSize); in.read(tempCommandBuffer, kMaxCommandBufferSize);
commandBuffer = tempCommandBuffer; g_cine->_commandBuffer = tempCommandBuffer;
renderer->setCommand(commandBuffer); renderer->setCommand(g_cine->_commandBuffer);
loadZoneQuery(in); loadZoneQuery(in);
// TODO: Use the loaded string (Current music name (String, 13 bytes)). // 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); renderer->restorePalette(in, 0);
// At 0x2083 (i.e. 0x2043 + 16 * 2 * 2): // 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): // At 0x2281 (i.e. 0x2083 + 255 * 2):
loadZoneData(in); loadZoneData(in);
@ -712,8 +712,8 @@ bool CineEngine::loadPlainSaveFW(Common::SeekableReadStream &in, CineSaveGameFor
// At 0x22A9 (i.e. 0x22A1 + 4 * 2): // At 0x22A9 (i.e. 0x22A1 + 4 * 2):
char tempCommandBuffer[kMaxCommandBufferSize]; char tempCommandBuffer[kMaxCommandBufferSize];
in.read(tempCommandBuffer, kMaxCommandBufferSize); in.read(tempCommandBuffer, kMaxCommandBufferSize);
commandBuffer = tempCommandBuffer; g_cine->_commandBuffer = tempCommandBuffer;
renderer->setCommand(commandBuffer); renderer->setCommand(g_cine->_commandBuffer);
// At 0x22F9 (i.e. 0x22A9 + 0x50): // At 0x22F9 (i.e. 0x22A9 + 0x50):
renderer->_cmdY = in.readUint16BE(); renderer->_cmdY = in.readUint16BE();
@ -855,7 +855,7 @@ void CineEngine::makeSaveFW(Common::OutSaveFile &out) {
saveObjectTable(out); saveObjectTable(out);
renderer->savePalette(out); renderer->savePalette(out);
globalVars.save(out, NUM_MAX_VAR); g_cine->_globalVars.save(out, NUM_MAX_VAR);
saveZoneData(out); saveZoneData(out);
saveCommandVariables(out); saveCommandVariables(out);
saveCommandBuffer(out); saveCommandBuffer(out);
@ -912,7 +912,7 @@ void CineEngine::makeSaveOS(Common::OutSaveFile &out) {
saveObjectTable(out); saveObjectTable(out);
renderer->savePalette(out); renderer->savePalette(out);
globalVars.save(out, NUM_MAX_VAR); g_cine->_globalVars.save(out, NUM_MAX_VAR);
saveZoneData(out); saveZoneData(out);
saveCommandVariables(out); saveCommandVariables(out);
saveCommandBuffer(out); saveCommandBuffer(out);
@ -1045,7 +1045,7 @@ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGam
loadPart(name); loadPart(name);
} }
animName = partBuffer[foundFileIdx].partName; animName = g_cine->_partBuffer[foundFileIdx].partName;
loadRelatedPalette(animName); // Is this for Future Wars only? loadRelatedPalette(animName); // Is this for Future Wars only?
const int16 prevAnim = currentAnim; const int16 prevAnim = currentAnim;
currentAnim = loadResource(animName, currentAnim); currentAnim = loadResource(animName, currentAnim);

View file

@ -67,6 +67,7 @@ public:
ScriptVars(const ScriptVars &src); ScriptVars(const ScriptVars &src);
~ScriptVars(); ~ScriptVars();
void reinit(unsigned int len);
ScriptVars &operator=(const ScriptVars &src); ScriptVars &operator=(const ScriptVars &src);
int16 &operator[](unsigned int idx); int16 &operator[](unsigned int idx);
int16 operator[](unsigned int idx) const; int16 operator[](unsigned int idx) const;
@ -368,9 +369,7 @@ typedef Common::Array<RawObjectScriptPtr> RawObjectScriptArray;
#define NUM_MAX_SCRIPT 50 #define NUM_MAX_SCRIPT 50
extern RawScriptArray scriptTable;
extern FWScriptInfo *scriptInfo; extern FWScriptInfo *scriptInfo;
extern ScriptVars globalVars;
void setupOpcodes(); void setupOpcodes();

View file

@ -38,14 +38,6 @@
namespace Cine { 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); uint16 compareVars(int16 a, int16 b);
@ -216,7 +208,6 @@ void FWScript::setupTable() {
} }
FWScriptInfo *scriptInfo; ///< Script factory FWScriptInfo *scriptInfo; ///< Script factory
RawScriptArray scriptTable; ///< Table of script bytecode
/** /**
* @todo replace with script subsystem * @todo replace with script subsystem
@ -257,6 +248,14 @@ ScriptVars::ScriptVars(Common::SeekableReadStream &fHandle, unsigned int len)
load(fHandle); load(fHandle);
} }
void ScriptVars::reinit(unsigned int len) {
delete _vars;
_size = len;
_vars = new int16[len];
reset();
}
/** /**
* Copy constructor * Copy constructor
*/ */
@ -606,7 +605,7 @@ RawObjectScript::RawObjectScript(const FWScriptInfo &info, const byte *data,
FWScript::FWScript(const RawScript &script, int16 idx) : _script(script), FWScript::FWScript(const RawScript &script, int16 idx) : _script(script),
_pos(0), _line(0), _compare(0), _index(idx), _pos(0), _line(0), _compare(0), _index(idx),
_labels(script.labels()), _localVars(LOCAL_VARS_SIZE), _labels(script.labels()), _localVars(LOCAL_VARS_SIZE),
_globalVars(globalVars), _info(new FWScriptInfo) { } _globalVars(g_cine->_globalVars), _info(new FWScriptInfo) { }
/** /**
* Copy constructor * 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) : FWScript::FWScript(const RawScript &script, int16 idx, FWScriptInfo *info) :
_script(script), _pos(0), _line(0), _compare(0), _index(idx), _script(script), _pos(0), _line(0), _compare(0), _index(idx),
_labels(script.labels()), _localVars(LOCAL_VARS_SIZE), _labels(script.labels()), _localVars(LOCAL_VARS_SIZE),
_globalVars(globalVars), _info(info) { } _globalVars(g_cine->_globalVars), _info(info) { }
/** /**
* Constructor for object scripts in derived classes * 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) : FWScript::FWScript(RawObjectScript &script, int16 idx, FWScriptInfo *info) :
_script(script), _pos(0), _line(0), _compare(0), _index(idx), _script(script), _pos(0), _line(0), _compare(0), _index(idx),
_labels(script.labels()), _localVars(LOCAL_VARS_SIZE), _labels(script.labels()), _localVars(LOCAL_VARS_SIZE),
_globalVars(globalVars), _info(info) { _globalVars(g_cine->_globalVars), _info(info) {
_localVars[0] = script.run(); _localVars[0] = script.run();
} }
@ -964,11 +963,11 @@ int FWScript::o1_loadVar() {
break; break;
case 8: case 8:
debugC(5, kCineDebugScript, "Line: %d: var[%d] = file[%d].packedSize", _line, varIdx, dataIdx); 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; break;
case 9: case 9:
debugC(5, kCineDebugScript, "Line: %d: var[%d] = file[%d].unpackedSize", _line, varIdx, dataIdx); 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; break;
default: default:
error("executeScript: o1_loadVar: Unknown variable type %d", varType); error("executeScript: o1_loadVar: Unknown variable type %d", varType);
@ -1196,7 +1195,7 @@ int FWScript::o1_addSpriteFilledToBgList() {
int FWScript::o1_op1B() { int FWScript::o1_op1B() {
debugC(5, kCineDebugScript, "Line: %d: freeBgIncrustList", _line); debugC(5, kCineDebugScript, "Line: %d: freeBgIncrustList", _line);
bgIncrustList.clear(); g_cine->_bgIncrustList.clear();
return 0; return 0;
} }
@ -1343,9 +1342,9 @@ int FWScript::o1_endGlobalScript() {
debugC(5, kCineDebugScript, "Line: %d: stopGlobalScript(%d)", _line, scriptIdx); 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) { if ((*it)->_index == scriptIdx) {
(*it)->_index = -1; (*it)->_index = -1;
} }
@ -1369,7 +1368,7 @@ int FWScript::o1_loadBg() {
debugC(5, kCineDebugScript, "Line: %d: loadBg(\"%s\")", _line, param); debugC(5, kCineDebugScript, "Line: %d: loadBg(\"%s\")", _line, param);
loadBg(param); loadBg(param);
bgIncrustList.clear(); g_cine->_bgIncrustList.clear();
bgVar0 = 0; bgVar0 = 0;
return 0; return 0;
} }
@ -1627,7 +1626,7 @@ int FWScript::o1_freePartRange() {
int FWScript::o1_unloadAllMasks() { int FWScript::o1_unloadAllMasks() {
debugC(5, kCineDebugScript, "Line: %d: unloadAllMasks()", _line); debugC(5, kCineDebugScript, "Line: %d: unloadAllMasks()", _line);
overlayList.clear(); g_cine->_overlayList.clear();
return 0; return 0;
} }
@ -1656,7 +1655,7 @@ int FWScript::o1_initializeZoneData() {
debugC(5, kCineDebugScript, "Line: %d: initializeZoneData()", _line); debugC(5, kCineDebugScript, "Line: %d: initializeZoneData()", _line);
for (int i = 0; i < NUM_MAX_ZONE; i++) { for (int i = 0; i < NUM_MAX_ZONE; i++) {
zoneData[i] = i; g_cine->_zoneData[i] = i;
} }
return 0; return 0;
} }
@ -1666,7 +1665,7 @@ int FWScript::o1_setZoneDataEntry() {
uint16 var = getNextWord(); uint16 var = getNextWord();
debugC(5, kCineDebugScript, "Line: %d: setZone[%d] = %d", _line, zoneIdx, var); debugC(5, kCineDebugScript, "Line: %d: setZone[%d] = %d", _line, zoneIdx, var);
zoneData[zoneIdx] = var; g_cine->_zoneData[zoneIdx] = var;
return 0; return 0;
} }
@ -1674,7 +1673,7 @@ int FWScript::o1_getZoneDataEntry() {
byte zoneIdx = getNextByte(); byte zoneIdx = getNextByte();
byte var = getNextByte(); byte var = getNextByte();
_localVars[var] = zoneData[zoneIdx]; _localVars[var] = g_cine->_zoneData[zoneIdx];
return 0; return 0;
} }
@ -1796,7 +1795,7 @@ int FWScript::o1_playSample() {
int16 volume = getNextWord(); int16 volume = getNextWord();
uint16 size = getNextWord(); uint16 size = getNextWord();
const byte *data = animDataTable[anim].data(); const byte *data = g_cine->_animDataTable[anim].data();
if (!data) { if (!data) {
return 0; return 0;
@ -1804,7 +1803,7 @@ int FWScript::o1_playSample() {
if (g_cine->getPlatform() == Common::kPlatformAmiga || g_cine->getPlatform() == Common::kPlatformAtariST) { if (g_cine->getPlatform() == Common::kPlatformAmiga || g_cine->getPlatform() == Common::kPlatformAtariST) {
if (size == 0xFFFF) { 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 if (channel < 10) { // || _currentOpcode == 0x78
int channel1, channel2; int channel1, channel2;
@ -1874,9 +1873,9 @@ int FWScript::o1_unloadMask5() {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
void addScriptToGlobalScripts(uint16 idx) { void addScriptToGlobalScripts(uint16 idx) {
ScriptPtr tmp(scriptInfo->create(*scriptTable[idx], idx)); ScriptPtr tmp(scriptInfo->create(*g_cine->_scriptTable[idx], idx));
assert(tmp); assert(tmp);
globalScripts.push_back(tmp); g_cine->_globalScripts.push_back(tmp);
} }
int16 getZoneFromPosition(byte *page, int16 x, int16 y, int16 width) { 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 checkCollision(int16 objIdx, int16 x, int16 y, int16 numZones, int16 zoneIdx) {
int16 lx = objectTable[objIdx].x + x; int16 lx = g_cine->_objectTable[objIdx].x + x;
int16 ly = objectTable[objIdx].y + y; int16 ly = g_cine->_objectTable[objIdx].y + y;
int16 idx; int16 idx;
int16 result = 0; 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 // The zoneQuery table is updated here only in Operation Stealth
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
if (zoneData[idx] < NUM_MAX_ZONE) { if (g_cine->_zoneData[idx] < NUM_MAX_ZONE) {
zoneQuery[zoneData[idx]]++; g_cine->_zoneQuery[g_cine->_zoneData[idx]]++;
} }
} }
if (zoneData[idx] == zoneIdx) { if (g_cine->_zoneData[idx] == zoneIdx) {
result = 1; result = 1;
// Future Wars breaks out early on the first match, but // Future Wars breaks out early on the first match, but
// Operation Stealth doesn't because it needs to update // Operation Stealth doesn't because it needs to update
@ -1969,10 +1968,10 @@ uint16 compareVars(int16 a, int16 b) {
} }
void executeObjectScripts() { void executeObjectScripts() {
ScriptList::iterator it = objectScripts.begin(); ScriptList::iterator it = g_cine->_objectScripts.begin();
for (; it != objectScripts.end();) { for (; it != g_cine->_objectScripts.end();) {
if ((*it)->_index < 0 || (*it)->execute() < 0) { if ((*it)->_index < 0 || (*it)->execute() < 0) {
it = objectScripts.erase(it); it = g_cine->_objectScripts.erase(it);
} else { } else {
++it; ++it;
} }
@ -1980,10 +1979,10 @@ void executeObjectScripts() {
} }
void executeGlobalScripts() { void executeGlobalScripts() {
ScriptList::iterator it = globalScripts.begin(); ScriptList::iterator it = g_cine->_globalScripts.begin();
for (; it != globalScripts.end();) { for (; it != g_cine->_globalScripts.end();) {
if ((*it)->_index < 0 || (*it)->execute() < 0) { if ((*it)->_index < 0 || (*it)->execute() < 0) {
it = globalScripts.erase(it); it = g_cine->_globalScripts.erase(it);
} else { } else {
++it; ++it;
} }

View file

@ -420,16 +420,16 @@ int FWScript::o2_playSampleAlt() {
uint16 size = getNextWord(); uint16 size = getNextWord();
if (size == 0xFFFF) { 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 (g_cine->getPlatform() == Common::kPlatformPC) {
// if speaker output is available, play sound on it // if speaker output is available, play sound on it
// if it's another device, don't play anything // if it's another device, don't play anything
// TODO: implement this, it's used in the introduction for example // TODO: implement this, it's used in the introduction for example
// on each letter displayed // on each letter displayed
} else { } 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; return 0;
@ -611,9 +611,9 @@ int FWScript::o2_stopObjectScript() {
byte param = getNextByte(); byte param = getNextByte();
debugC(5, kCineDebugScript, "Line: %d: stopObjectScript(%d)", _line, param); 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) { if ((*it)->_index == param) {
(*it)->_index = -1; (*it)->_index = -1;
} }
@ -699,7 +699,7 @@ int FWScript::o2_loadBg() {
int FWScript::o2_wasZoneChecked() { int FWScript::o2_wasZoneChecked() {
byte param = getNextByte(); 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); debugC(5, kCineDebugScript, "Line: %d: o2_wasZoneChecked(%d)", _line, param);
return 0; return 0;
} }

View file

@ -81,7 +81,6 @@ uint16 _messageLen;
int16 playerCommand; int16 playerCommand;
Common::String commandBuffer;
char currentPrcName[20]; char currentPrcName[20];
char currentRelName[20]; char currentRelName[20];
char currentObjectName[20]; char currentObjectName[20];
@ -137,9 +136,6 @@ static const int16 canUseOnItemTable[] = { 1, 0, 0, 1, 1, 0, 0 };
CommandeType objectListCommand[20]; CommandeType objectListCommand[20];
int16 objListTab[20]; int16 objListTab[20];
Common::Array<uint16> zoneData;
Common::Array<uint16> zoneQuery; ///< Only exists in Operation Stealth
/** /**
* Move the player character using the keyboard * Move the player character using the keyboard
* @param x Negative values move left, positive right, zero not at all * @param x Negative values move left, positive right, zero not at all
@ -174,9 +170,9 @@ void stopMusicAfterFadeOut() {
} }
void runObjectScript(int16 entryIdx) { void runObjectScript(int16 entryIdx) {
ScriptPtr tmp(scriptInfo->create(*relTable[entryIdx], entryIdx)); ScriptPtr tmp(scriptInfo->create(*g_cine->_relTable[entryIdx], entryIdx));
assert(tmp); assert(tmp);
objectScripts.push_back(tmp); g_cine->_objectScripts.push_back(tmp);
} }
/** /**
@ -190,19 +186,19 @@ void addPlayerCommandMessage(int16 cmd) {
tmp.objIdx = cmd; tmp.objIdx = cmd;
tmp.type = 3; tmp.type = 3;
overlayList.push_back(tmp); g_cine->_overlayList.push_back(tmp);
} }
int16 getRelEntryForObject(uint16 param1, uint16 param2, SelectedObjStruct *pSelectedObject) { int16 getRelEntryForObject(uint16 param1, uint16 param2, SelectedObjStruct *pSelectedObject) {
int16 i; int16 i;
int16 found = -1; int16 found = -1;
for (i = 0; i < (int16)relTable.size(); i++) { for (i = 0; i < (int16)g_cine->_relTable.size(); i++) {
if (relTable[i]->_param1 == param1 && relTable[i]->_param2 == pSelectedObject->idx) { if (g_cine->_relTable[i]->_param1 == param1 && g_cine->_relTable[i]->_param2 == pSelectedObject->idx) {
if (param2 == 1) { if (param2 == 1) {
found = i; found = i;
} else if (param2 == 2) { } else if (param2 == 2) {
if (relTable[i]->_param3 == pSelectedObject->param) { if (g_cine->_relTable[i]->_param3 == pSelectedObject->param) {
found = i; found = i;
} }
} }
@ -228,19 +224,19 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) {
int width; int width;
// reverse_iterator would be nice // reverse_iterator would be nice
for (it = overlayList.reverse_begin(); it != overlayList.end(); --it) { for (it = g_cine->_overlayList.reverse_begin(); it != g_cine->_overlayList.end(); --it) {
if (it->type >= 2 || !objectTable[it->objIdx].name[0]) { if (it->type >= 2 || !g_cine->_objectTable[it->objIdx].name[0]) {
continue; continue;
} }
objX = objectTable[it->objIdx].x; objX = g_cine->_objectTable[it->objIdx].x;
objY = objectTable[it->objIdx].y; objY = g_cine->_objectTable[it->objIdx].y;
frame = ABS((int16)(objectTable[it->objIdx].frame)); frame = ABS((int16)(g_cine->_objectTable[it->objIdx].frame));
part = objectTable[it->objIdx].part; part = g_cine->_objectTable[it->objIdx].part;
// Additional case for negative frame values in Operation Stealth // 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)) { if ((it->type == 1) && (x >= objX) && (objX + frame >= x) && (y >= objY) && (objY + part >= y)) {
return it->objIdx; return it->objIdx;
} else { } else {
@ -249,18 +245,18 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) {
} }
if (it->type == 0) { if (it->type == 0) {
threshold = animDataTable[frame]._var1; threshold = g_cine->_animDataTable[frame]._var1;
} else { } else {
threshold = animDataTable[frame]._width / 2; threshold = g_cine->_animDataTable[frame]._width / 2;
} }
height = animDataTable[frame]._height; height = g_cine->_animDataTable[frame]._height;
width = animDataTable[frame]._realWidth; width = g_cine->_animDataTable[frame]._realWidth;
xdif = x - objX; xdif = x - objX;
ydif = y - objY; 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; continue;
} }
@ -272,17 +268,17 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) {
continue; 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; 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; return it->objIdx;
} }
} else if (it->type == 0) { // use generated mask } 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; return it->objIdx;
} }
} else if (it->type == 1) { // is mask } 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; return it->objIdx;
} }
} }
@ -294,18 +290,18 @@ int16 getObjectUnderCursor(uint16 x, uint16 y) {
void CineEngine::resetEngine() { void CineEngine::resetEngine() {
g_sound->stopMusic(); g_sound->stopMusic();
freeAnimDataTable(); freeAnimDataTable();
overlayList.clear(); g_cine->_overlayList.clear();
bgIncrustList.clear(); g_cine->_bgIncrustList.clear();
closePart(); closePart();
objectScripts.clear(); g_cine->_objectScripts.clear();
globalScripts.clear(); g_cine->_globalScripts.clear();
relTable.clear(); g_cine->_relTable.clear();
scriptTable.clear(); g_cine->_scriptTable.clear();
messageTable.clear(); g_cine->_messageTable.clear();
resetObjectTable(); resetObjectTable();
globalVars.reset(); g_cine->_globalVars.reset();
var2 = var3 = var4 = var5 = 0; var2 = var3 = var4 = var5 = 0;
@ -320,10 +316,10 @@ void CineEngine::resetEngine() {
playerCommand = -1; playerCommand = -1;
isDrawCommandEnabled = 0; isDrawCommandEnabled = 0;
commandBuffer = ""; g_cine->_commandBuffer = "";
globalVars[VAR_MOUSE_X_POS] = 0; g_cine->_globalVars[VAR_MOUSE_X_POS] = 0;
globalVars[VAR_MOUSE_Y_POS] = 0; g_cine->_globalVars[VAR_MOUSE_Y_POS] = 0;
fadeRequired = false; fadeRequired = false;
@ -332,7 +328,7 @@ void CineEngine::resetEngine() {
checkForPendingDataLoadSwitch = 0; checkForPendingDataLoadSwitch = 0;
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
seqList.clear(); g_cine->_seqList.clear();
currentAdditionalBgIdx = 0; currentAdditionalBgIdx = 0;
currentAdditionalBgIdx2 = 0; currentAdditionalBgIdx2 = 0;
// TODO: Add resetting of the following variables // TODO: Add resetting of the following variables
@ -539,8 +535,8 @@ int16 buildObjectListCommand(int16 param) {
} }
for (i = 0; i < 255; i++) { for (i = 0; i < 255; i++) {
if (objectTable[i].name[0] && objectTable[i].costume == param) { if (g_cine->_objectTable[i].name[0] && g_cine->_objectTable[i].costume == param) {
strcpy(objectListCommand[j], objectTable[i].name); strcpy(objectListCommand[j], g_cine->_objectTable[i].name);
objListTab[j] = i; objListTab[j] = i;
j++; j++;
} }
@ -581,9 +577,9 @@ void makeCommandLine() {
commandVar2 = -10; commandVar2 = -10;
if (playerCommand != -1) { if (playerCommand != -1) {
commandBuffer = defaultActionCommand[playerCommand]; g_cine->_commandBuffer = defaultActionCommand[playerCommand];
} else { } else {
commandBuffer = ""; g_cine->_commandBuffer = "";
} }
if ((playerCommand != -1) && (choiceResultTable[playerCommand] == 2)) { // need object selection ? if ((playerCommand != -1) && (choiceResultTable[playerCommand] == 2)) { // need object selection ?
@ -602,7 +598,7 @@ void makeCommandLine() {
canUseOnObject = 0; canUseOnObject = 0;
} else { // Future Wars } else { // Future Wars
playerCommand = -1; playerCommand = -1;
commandBuffer = ""; g_cine->_commandBuffer = "";
} }
} else { } else {
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
@ -616,13 +612,13 @@ void makeCommandLine() {
commandVar3[0] = si; commandVar3[0] = si;
commandVar1 = 1; commandVar1 = 1;
commandBuffer += " "; g_cine->_commandBuffer += " ";
commandBuffer += objectTable[commandVar3[0]].name; g_cine->_commandBuffer += g_cine->_objectTable[commandVar3[0]].name;
commandBuffer += " "; g_cine->_commandBuffer += " ";
if (g_cine->getGameType() == Cine::GType_OS) { if (g_cine->getGameType() == Cine::GType_OS) {
commandBuffer += commandPrepositionTable[playerCommand]; g_cine->_commandBuffer += commandPrepositionTable[playerCommand];
} else { // Future Wars } else { // Future Wars
commandBuffer += defaultCommandPreposition; g_cine->_commandBuffer += defaultCommandPreposition;
} }
} }
} }
@ -634,7 +630,7 @@ void makeCommandLine() {
processInventory(x, y + 8); processInventory(x, y + 8);
playerCommand = -1; playerCommand = -1;
commandVar1 = 0; commandVar1 = 0;
commandBuffer = ""; g_cine->_commandBuffer = "";
CursorMan.showMouse(true); CursorMan.showMouse(true);
} }
} }
@ -654,8 +650,8 @@ void makeCommandLine() {
commandVar3[commandVar1] = si; commandVar3[commandVar1] = si;
commandVar1++; commandVar1++;
commandBuffer += " "; g_cine->_commandBuffer += " ";
commandBuffer += objectTable[si].name; g_cine->_commandBuffer += g_cine->_objectTable[si].name;
} }
} }
@ -673,13 +669,13 @@ void makeCommandLine() {
playerCommand = -1; playerCommand = -1;
commandVar1 = 0; commandVar1 = 0;
commandBuffer = ""; g_cine->_commandBuffer = "";
} }
} }
if (g_cine->getGameType() == Cine::GType_OS || !disableSystemMenu) { if (g_cine->getGameType() == Cine::GType_OS || !disableSystemMenu) {
isDrawCommandEnabled = 1; isDrawCommandEnabled = 1;
renderer->setCommand(commandBuffer); renderer->setCommand(g_cine->_commandBuffer);
} }
} }
@ -858,7 +854,7 @@ uint16 executePlayerInput() {
if (allowPlayerInput) { // Player input is allowed if (allowPlayerInput) { // Player input is allowed
if (isDrawCommandEnabled) { if (isDrawCommandEnabled) {
renderer->setCommand(commandBuffer); renderer->setCommand(g_cine->_commandBuffer);
} }
isDrawCommandEnabled = 0; isDrawCommandEnabled = 0;
limitMouseCheckCount = true; limitMouseCheckCount = true;
@ -906,8 +902,8 @@ uint16 executePlayerInput() {
commandVar3[commandVar1] = si; commandVar3[commandVar1] = si;
commandVar1++; commandVar1++;
commandBuffer += " "; g_cine->_commandBuffer += " ";
commandBuffer += objectTable[si].name; g_cine->_commandBuffer += g_cine->_objectTable[si].name;
isDrawCommandEnabled = 1; isDrawCommandEnabled = 1;
@ -929,27 +925,27 @@ uint16 executePlayerInput() {
playerCommand = -1; playerCommand = -1;
commandVar1 = 0; commandVar1 = 0;
commandBuffer = ""; g_cine->_commandBuffer = "";
} else if (g_cine->getGameType() == Cine::GType_OS) { } else if (g_cine->getGameType() == Cine::GType_OS) {
isDrawCommandEnabled = 1; isDrawCommandEnabled = 1;
commandBuffer += commandPrepositionTable[playerCommand]; g_cine->_commandBuffer += commandPrepositionTable[playerCommand];
} }
renderer->setCommand(commandBuffer); renderer->setCommand(g_cine->_commandBuffer);
} else { } else {
globalVars[VAR_MOUSE_X_POS] = mouseX; g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX;
if (!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 (g_cine->getGameType() == Cine::GType_OS) {
if (!mouseY) { 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]; g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = g_cine->_globalVars[VAR_MOUSE_X_POS];
globalVars[VAR_MOUSE_Y_POS_2ND] = globalVars[VAR_MOUSE_Y_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 (g_cine->getGameType() == Cine::GType_OS || commandVar2 != objIdx) {
if (objIdx != -1) { if (objIdx != -1) {
renderer->setCommand(commandBuffer + " " + objectTable[objIdx].name); renderer->setCommand(g_cine->_commandBuffer + " " + g_cine->_objectTable[objIdx].name);
} else { } else {
isDrawCommandEnabled = 1; isDrawCommandEnabled = 1;
} }
@ -976,19 +972,19 @@ uint16 executePlayerInput() {
int16 objIdx; int16 objIdx;
int16 relEntry; int16 relEntry;
globalVars[VAR_MOUSE_X_POS] = mouseX; g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX;
if (!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 (g_cine->getGameType() == Cine::GType_OS) {
if (!mouseY) { 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]; g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = g_cine->_globalVars[VAR_MOUSE_X_POS];
globalVars[VAR_MOUSE_Y_POS_2ND] = globalVars[VAR_MOUSE_Y_POS]; g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = g_cine->_globalVars[VAR_MOUSE_Y_POS];
} }
objIdx = getObjectUnderCursor(mouseX, mouseY); objIdx = getObjectUnderCursor(mouseX, mouseY);
@ -1020,97 +1016,97 @@ uint16 executePlayerInput() {
// Handle possible horizontal movement by keyboard // Handle possible horizontal movement by keyboard
if (xMoveKeyb != kKeybMoveCenterX && allowPlayerInput) { if (xMoveKeyb != kKeybMoveCenterX && allowPlayerInput) {
if (xMoveKeyb == kKeybMoveRight) { // moving right if (xMoveKeyb == kKeybMoveRight) { // moving right
const int16 playerFrame = objectTable[1].frame; const int16 playerFrame = g_cine->_objectTable[1].frame;
const int16 playerX = objectTable[1].x; const int16 playerX = g_cine->_objectTable[1].x;
// TODO: Check if multiplying _width by two here is correct or not // TODO: Check if multiplying _width by two here is correct or not
const int16 newX = animDataTable[playerFrame]._width * 2 + playerX + 8; const int16 newX = g_cine->_animDataTable[playerFrame]._width * 2 + 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;
} else { // moving left } else { // moving left
const int16 playerX = objectTable[1].x; const int16 playerX = g_cine->_objectTable[1].x;
const int16 newX = playerX - 8; 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 // Restrain horizontal position to range 0-319
if (globalVars[VAR_MOUSE_X_POS] < 0) { if (g_cine->_globalVars[VAR_MOUSE_X_POS] < 0) {
globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = 0; g_cine->_globalVars[VAR_MOUSE_X_POS] = g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = 0;
} else if (globalVars[VAR_MOUSE_X_POS] > 319) { } else if (g_cine->_globalVars[VAR_MOUSE_X_POS] > 319) {
globalVars[VAR_MOUSE_X_POS] = globalVars[VAR_MOUSE_X_POS_2ND] = 319; g_cine->_globalVars[VAR_MOUSE_X_POS] = g_cine->_globalVars[VAR_MOUSE_X_POS_2ND] = 319;
} }
} }
// Handle possible vertical movement by keyboard // Handle possible vertical movement by keyboard
if (yMoveKeyb != kKeybMoveCenterY && allowPlayerInput) { if (yMoveKeyb != kKeybMoveCenterY && allowPlayerInput) {
if (yMoveKeyb == kKeybMoveDown) { // moving down if (yMoveKeyb == kKeybMoveDown) { // moving down
const int16 playerFrame = objectTable[1].frame; const int16 playerFrame = g_cine->_objectTable[1].frame;
const int16 playerY = objectTable[1].y; const int16 playerY = g_cine->_objectTable[1].y;
// TODO: Check if multiplying _height by two here is correct or not // TODO: Check if multiplying _height by two here is correct or not
const int16 newY = animDataTable[playerFrame]._height * 2 + playerY - 1; const int16 newY = g_cine->_animDataTable[playerFrame]._height * 2 + playerY - 1;
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;
} else { // moving up } else { // moving up
const int16 playerY = objectTable[1].y; const int16 playerY = g_cine->_objectTable[1].y;
const int16 newY = playerY - 8; 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 // Restrain vertical position to range 0-199
if (globalVars[VAR_MOUSE_Y_POS] < 0) { if (g_cine->_globalVars[VAR_MOUSE_Y_POS] < 0) {
globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = 0; g_cine->_globalVars[VAR_MOUSE_Y_POS] = g_cine->_globalVars[VAR_MOUSE_Y_POS_2ND] = 0;
} else if (globalVars[VAR_MOUSE_Y_POS] > 199) { } else if (g_cine->_globalVars[VAR_MOUSE_Y_POS] > 199) {
globalVars[VAR_MOUSE_Y_POS] = globalVars[VAR_MOUSE_Y_POS_2ND] = 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 } else if (egoMovedWithKeyboard && allowPlayerInput) { // FW: Move using keyboard
egoMovedWithKeyboard = false; egoMovedWithKeyboard = false;
switch (globalVars[VAR_MOUSE_X_MODE]) { switch (g_cine->_globalVars[VAR_MOUSE_X_MODE]) {
case 1: case 1:
mouseX = objectTable[1].x + 12; mouseX = g_cine->_objectTable[1].x + 12;
break; break;
case 2: case 2:
mouseX = objectTable[1].x + 7; mouseX = g_cine->_objectTable[1].x + 7;
break; break;
default: default:
mouseX = globalVars[VAR_MOUSE_X_POS]; mouseX = g_cine->_globalVars[VAR_MOUSE_X_POS];
break; break;
} }
switch (globalVars[VAR_MOUSE_Y_MODE]) { switch (g_cine->_globalVars[VAR_MOUSE_Y_MODE]) {
case 1: case 1:
mouseY = objectTable[1].y + 34; mouseY = g_cine->_objectTable[1].y + 34;
break; break;
case 2: case 2:
mouseY = objectTable[1].y + 28; mouseY = g_cine->_objectTable[1].y + 28;
break; break;
default: default:
mouseY = globalVars[VAR_MOUSE_Y_POS]; mouseY = g_cine->_globalVars[VAR_MOUSE_Y_POS];
break; break;
} }
if (var_5E == bgVar0) { if (var_5E == bgVar0) {
var_5E = 0; var_5E = 0;
globalVars[VAR_MOUSE_X_POS] = mouseX; g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX;
globalVars[VAR_MOUSE_Y_POS] = mouseY; g_cine->_globalVars[VAR_MOUSE_Y_POS] = mouseY;
} else { } else {
if (xMoveKeyb) { if (xMoveKeyb) {
if (xMoveKeyb == kKeybMoveLeft) { if (xMoveKeyb == kKeybMoveLeft) {
globalVars[VAR_MOUSE_X_POS] = 1; g_cine->_globalVars[VAR_MOUSE_X_POS] = 1;
} else { } else {
globalVars[VAR_MOUSE_X_POS] = 320; g_cine->_globalVars[VAR_MOUSE_X_POS] = 320;
} }
} else { } else {
globalVars[VAR_MOUSE_X_POS] = mouseX; g_cine->_globalVars[VAR_MOUSE_X_POS] = mouseX;
} }
if (yMoveKeyb) { if (yMoveKeyb) {
if (yMoveKeyb == kKeybMoveUp) { if (yMoveKeyb == kKeybMoveUp) {
globalVars[VAR_MOUSE_Y_POS] = 1; g_cine->_globalVars[VAR_MOUSE_Y_POS] = 1;
} else { } else {
globalVars[VAR_MOUSE_Y_POS] = 200; g_cine->_globalVars[VAR_MOUSE_Y_POS] = 200;
} }
} else { } 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); msk = (byte *)malloc(width * height);
if (g_cine->getGameType() == Cine::GType_OS) { 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 { } else {
memcpy(msk, maskPtr, width * height); memcpy(msk, maskPtr, width * height);
} }
for (++it; it != overlayList.end(); ++it) { for (++it; it != g_cine->_overlayList.end(); ++it) {
if (it->type != 5) { if (it->type != 5) {
continue; continue;
} }
maskX = objectTable[it->objIdx].x; maskX = g_cine->_objectTable[it->objIdx].x;
maskY = objectTable[it->objIdx].y; 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; maskWidth = g_cine->_animDataTable[maskSpriteIdx]._realWidth;
maskHeight = animDataTable[maskSpriteIdx]._height; maskHeight = g_cine->_animDataTable[maskSpriteIdx]._height;
gfxUpdateSpriteMask(msk, x, y, width, height, animDataTable[maskSpriteIdx].data(), maskX, maskY, maskWidth, maskHeight); gfxUpdateSpriteMask(msk, x, y, width, height, g_cine->_animDataTable[maskSpriteIdx].data(), maskX, maskY, maskWidth, maskHeight);
#ifdef DEBUG_SPRITE_MASK #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 #endif
} }
@ -1199,7 +1195,7 @@ void removeMessages() {
Common::List<overlay>::iterator it; Common::List<overlay>::iterator it;
bool remove; 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) { if (g_cine->getGameType() == Cine::GType_OS) {
// NOTE: These are really removeOverlay calls that have been deferred. // NOTE: These are really removeOverlay calls that have been deferred.
// In Operation Stealth's disassembly elements are removed from the // In Operation Stealth's disassembly elements are removed from the
@ -1213,7 +1209,7 @@ void removeMessages() {
} }
if (remove) { if (remove) {
it = overlayList.erase(it); it = g_cine->_overlayList.erase(it);
} else { } else {
++it; ++it;
} }
@ -1255,7 +1251,7 @@ void checkForPendingDataLoad() {
} }
if (newObjectName[0] != 0) { if (newObjectName[0] != 0) {
overlayList.clear(); g_cine->_overlayList.clear();
loadObject(newObjectName); loadObject(newObjectName);
@ -1294,15 +1290,13 @@ void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 par
tmp.width = param4; tmp.width = param4;
tmp.color = param5; 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) { void removeSeq(uint16 param1, uint16 param2, uint16 param3) {
Common::List<SeqListElement>::iterator it; 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) { if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) {
it->var4 = -1; it->var4 = -1;
break; break;
@ -1313,7 +1307,7 @@ void removeSeq(uint16 param1, uint16 param2, uint16 param3) {
bool isSeqRunning(uint16 param1, uint16 param2, uint16 param3) { bool isSeqRunning(uint16 param1, uint16 param2, uint16 param3) {
Common::List<SeqListElement>::iterator it; 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) { if (it->objIdx == param1 && it->var4 == param2 && it->varE == param3) {
// Just to be on the safe side there's a restriction of the // Just to be on the safe side there's a restriction of the
// addition's result to 16-bit arithmetic here like in 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; Common::List<SeqListElement>::iterator it;
SeqListElement tmp; 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.objIdx = objIdx;
tmp.var4 = param1; tmp.var4 = param1;
@ -1346,12 +1340,12 @@ void addSeqListElement(uint16 objIdx, int16 param1, int16 param2, int16 frame, i
tmp.var1C = 0; tmp.var1C = 0;
tmp.var1E = 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) { void modifySeqListElement(uint16 objIdx, int16 var4Test, int16 param1, int16 param2, int16 param3, int16 param4) {
// Find a suitable list element and modify it // 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) { if (it->objIdx == objIdx && it->var4 == var4Test) {
it->varC = param1; it->varC = param1;
it->var18 = param2; 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 // In the original an error string is set and 0 is returned if the following doesn't hold
assert(*ptrData); assert(*ptrData);
di = (objectTable[objIdx].costume + 1) % (*ptrData); di = (g_cine->_objectTable[objIdx].costume + 1) % (*ptrData);
++ptrData; // Jump over the just read byte ++ptrData; // Jump over the just read byte
// Here ptr2 seems to be indexing a table of structs (8 bytes per struct): // Here ptr2 seems to be indexing a table of structs (8 bytes per struct):
// struct { // struct {
@ -1446,18 +1440,18 @@ uint16 addAni(uint16 param1, uint16 objIdx, const int8 *ptr, SeqListElement &ele
return 0; return 0;
} }
objectTable[objIdx].x += ptr2[4]; g_cine->_objectTable[objIdx].x += ptr2[4];
objectTable[objIdx].y += ptr2[5]; g_cine->_objectTable[objIdx].y += ptr2[5];
objectTable[objIdx].mask += ptr2[6]; g_cine->_objectTable[objIdx].mask += ptr2[6];
if (ptr2[6]) { if (ptr2[6]) {
resetGfxEntityEntry(objIdx); resetGfxEntityEntry(objIdx);
} }
objectTable[objIdx].frame = ptr2[7] + element.var8; g_cine->_objectTable[objIdx].frame = ptr2[7] + element.var8;
if (param3 || !element.var14) { if (param3 || !element.var14) {
objectTable[objIdx].costume = di; g_cine->_objectTable[objIdx].costume = di;
} else { } else {
assert(param4); assert(param4);
*param4 = di; *param4 = di;
@ -1476,7 +1470,7 @@ void resetGfxEntityEntry(uint16 objIdx) {
bool foundCutPoint = false; bool foundCutPoint = false;
// Go through the overlay list and partition the whole list into two categories (Type A and type B objects) // 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 if (it->objIdx == objIdx && it->type != 2 && it->type != 3) { // Type A object
aReverseObjs.push_front(*it); aReverseObjs.push_front(*it);
} else { // Type B object } else { // Type B object
@ -1485,10 +1479,10 @@ void resetGfxEntityEntry(uint16 objIdx) {
if (it->type == 2 || it->type == 3) { if (it->type == 2 || it->type == 3) {
objectMask = 10000; objectMask = 10000;
} else { } 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(); bObjsCutPoint = bObjs.reverse_begin();
foundCutPoint = true; foundCutPoint = true;
} }
@ -1496,26 +1490,26 @@ void resetGfxEntityEntry(uint16 objIdx) {
} }
// Recreate the overlay list in a different order. // Recreate the overlay list in a different order.
overlayList.clear(); g_cine->_overlayList.clear();
if (foundCutPoint) { if (foundCutPoint) {
// If a cut point was found the order is: // 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. // 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 ++bObjsCutPoint; // Include the cut point in the first list insertion
overlayList.insert(overlayList.end(), bObjs.begin(), bObjsCutPoint); g_cine->_overlayList.insert(g_cine->_overlayList.end(), bObjs.begin(), bObjsCutPoint);
overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end()); g_cine->_overlayList.insert(g_cine->_overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
overlayList.insert(overlayList.end(), bObjsCutPoint, bObjs.end()); g_cine->_overlayList.insert(g_cine->_overlayList.end(), bObjsCutPoint, bObjs.end());
} else { } else {
// If no cut point was found the order is: // If no cut point was found the order is:
// A objects in reverse order, B objects. // A objects in reverse order, B objects.
overlayList.insert(overlayList.end(), aReverseObjs.begin(), aReverseObjs.end()); g_cine->_overlayList.insert(g_cine->_overlayList.end(), aReverseObjs.begin(), aReverseObjs.end());
overlayList.insert(overlayList.end(), bObjs.begin(), bObjs.end()); g_cine->_overlayList.insert(g_cine->_overlayList.end(), bObjs.begin(), bObjs.end());
} }
} }
void processSeqListElement(SeqListElement &element) { void processSeqListElement(SeqListElement &element) {
int16 x = objectTable[element.objIdx].x; int16 x = g_cine->_objectTable[element.objIdx].x;
int16 y = objectTable[element.objIdx].y; int16 y = g_cine->_objectTable[element.objIdx].y;
const int8 *ptr1 = (const int8 *) animDataTable[element.frame].data(); const int8 *ptr1 = (const int8 *) g_cine->_animDataTable[element.frame].data();
int16 var_10; int16 var_10;
int16 var_4; int16 var_4;
int16 var_2; int16 var_2;
@ -1548,8 +1542,8 @@ void processSeqListElement(SeqListElement &element) {
int16 x2 = element.var18; int16 x2 = element.var18;
int16 y2 = element.var1A; int16 y2 = element.var1A;
if (element.varC) { if (element.varC) {
x2 += objectTable[element.varC].x; x2 += g_cine->_objectTable[element.varC].x;
y2 += objectTable[element.varC].y; y2 += g_cine->_objectTable[element.varC].y;
} }
computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, x2, y2); computeMove1(element, ptr1[4] + x, ptr1[5] + y, param1, param2, x2, y2);
} else { } else {
@ -1558,7 +1552,7 @@ void processSeqListElement(SeqListElement &element) {
if (xMoveKeyb != kKeybMoveRight) { if (xMoveKeyb != kKeybMoveRight) {
adder = -adder; 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) { if (yMoveKeyb && allowPlayerInput) {
@ -1566,11 +1560,11 @@ void processSeqListElement(SeqListElement &element) {
if (yMoveKeyb != kKeybMoveDown) { if (yMoveKeyb != kKeybMoveDown) {
adder = -adder; 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]) { 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, globalVars[VAR_MOUSE_X_POS], 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 { } else {
element.var16 = 0; element.var16 = 0;
element.var14 = 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, && !addAni(3, element.objIdx, ptr1, element, 0, &var_4)) || (element.var16 == 2 && !addAni(2, element.objIdx, ptr1, element, 0,
&var_4))) { &var_4))) {
if (element.varC == 255) { if (element.varC == 255) {
globalVars[VAR_MOUSE_Y_POS] = 0; g_cine->_globalVars[VAR_MOUSE_Y_POS] = 0;
} }
} }
if ((element.var14 == 1 if ((element.var14 == 1
&& !addAni(0, element.objIdx, ptr1, element, 1, &var_2))) { && !addAni(0, element.objIdx, ptr1, element, 1, &var_2))) {
if (element.varC == 255) { if (element.varC == 255) {
globalVars[VAR_MOUSE_X_POS] = 0; g_cine->_globalVars[VAR_MOUSE_X_POS] = 0;
if (var_4 != -1) { 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.var14 == 2 && !addAni(1, element.objIdx, ptr1, element, 1, &var_2))) {
if (element.varC == 255) { if (element.varC == 255) {
globalVars[VAR_MOUSE_X_POS] = 0; g_cine->_globalVars[VAR_MOUSE_X_POS] = 0;
if (var_4 != -1) { 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.var16 + element.var14 == 0) {
if (element.var1C) { if (element.var1C) {
if (element.var1E) { if (element.var1E) {
objectTable[element.objIdx].costume = 0; g_cine->_objectTable[element.objIdx].costume = 0;
element.var1E = 0; element.var1E = 0;
} }
@ -1633,7 +1627,7 @@ void processSeqListElement(SeqListElement &element) {
void processSeqList() { void processSeqList() {
Common::List<SeqListElement>::iterator it; 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) { if (it->var4 == -1) {
continue; continue;
} }

View file

@ -66,8 +66,6 @@ struct SeqListElement {
int16 var1E; int16 var1E;
}; };
extern Common::List<SeqListElement> seqList;
extern uint16 var2; extern uint16 var2;
extern uint16 var3; extern uint16 var3;
extern uint16 var4; extern uint16 var4;
@ -95,8 +93,6 @@ extern uint16 _messageLen;
extern int16 playerCommand; extern int16 playerCommand;
extern Common::String commandBuffer;
extern char currentPrcName[20]; extern char currentPrcName[20];
extern char currentRelName[20]; extern char currentRelName[20];
extern char currentObjectName[20]; extern char currentObjectName[20];
@ -137,8 +133,6 @@ struct SelectedObjStruct {
}; };
#define NUM_MAX_ZONE 16 #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); void addMessage(byte param1, int16 param2, int16 param3, int16 param4, int16 param5);