aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2010-06-14 20:45:00 +0000
committerFilippos Karapetis2010-06-14 20:45:00 +0000
commit1fde7f1abceb5f7c52982e9b2bf18188037b63d5 (patch)
tree0ce987d7607048099598eee49c89e01c2cceabb1 /engines
parent86878450ee26cbf2b4f79e5e54787fe5cce2a10e (diff)
downloadscummvm-rg350-1fde7f1abceb5f7c52982e9b2bf18188037b63d5.tar.gz
scummvm-rg350-1fde7f1abceb5f7c52982e9b2bf18188037b63d5.tar.bz2
scummvm-rg350-1fde7f1abceb5f7c52982e9b2bf18188037b63d5.zip
Removed the code used for tracking script code block relocations in SCI0-SCI1 games, as we don't actually relocate these blocks, and it was used solely for verification of the exports table. The issue that this warning was created for should no longer occur
svn-id: r49669
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/script.cpp9
-rw-r--r--engines/sci/engine/segment.cpp57
-rw-r--r--engines/sci/engine/segment.h13
3 files changed, 16 insertions, 63 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index c1810df679..cb112a90f9 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -179,7 +179,10 @@ void SegManager::scriptInitialiseLocals(SegmentId segmentId) {
void SegManager::scriptInitialiseObjectsSci11(SegmentId seg) {
Script *scr = getScript(seg);
- const byte *seeker = scr->_heapStart + 4 + READ_SCI11ENDIAN_UINT16(scr->_heapStart + 2) * 2;
+ const byte *seeker = scr->_heapStart;;
+ uint16 entrySize = READ_SCI11ENDIAN_UINT16(seeker + 2) * 2;
+ seeker += entrySize; // skip first entry
+ seeker += 4; // skip header
while (READ_SCI11ENDIAN_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
if (READ_SCI11ENDIAN_UINT16(seeker + 14) & kInfoFlagClass) { // -info- selector
@@ -251,10 +254,6 @@ void script_instantiate_sci0(Script *scr, int segmentId, SegManager *segMan) {
addr = make_reg(segmentId, curOffset);;
switch (objType) {
- case SCI_OBJ_CODE:
- if (pass == 0)
- scr->scriptAddCodeBlock(addr);
- break;
case SCI_OBJ_OBJECT:
case SCI_OBJ_CLASS:
if (pass == 0 && objType == SCI_OBJ_CLASS) {
diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp
index 492e928e31..879cbc22ee 100644
--- a/engines/sci/engine/segment.cpp
+++ b/engines/sci/engine/segment.cpp
@@ -115,7 +115,6 @@ void Script::freeScript() {
_bufSize = 0;
_objects.clear();
- _codeBlocks.clear();
}
void Script::init(int script_nr, ResourceManager *resMan) {
@@ -125,8 +124,6 @@ void Script::init(int script_nr, ResourceManager *resMan) {
_localsBlock = NULL;
_localsCount = 0;
- _codeBlocks.clear();
-
_markedAsDeleted = false;
_nr = script_nr;
@@ -188,8 +185,6 @@ void Script::load(ResourceManager *resMan) {
memcpy(_heapStart, heap->data, heap->size);
}
- _codeBlocks.clear();
-
_exportTable = 0;
_numExports = 0;
_synonyms = 0;
@@ -310,13 +305,6 @@ bool Script::relocateLocal(SegmentId segment, int location) {
return false;
}
-void Script::scriptAddCodeBlock(reg_t location) {
- CodeBlock cb;
- cb.pos = location;
- cb.size = READ_SCI11ENDIAN_UINT16(_buf + location.offset - 2);
- _codeBlocks.push_back(cb);
-}
-
void Script::relocate(reg_t block) {
byte *heap = _buf;
uint16 heapSize = (uint16)_bufSize;
@@ -333,13 +321,14 @@ void Script::relocate(reg_t block) {
int count = READ_SCI11ENDIAN_UINT16(heap + block.offset);
int exportIndex = 0;
+ int pos = 0;
for (int i = 0; i < count; i++) {
- int pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset;
- // This occurs in SCI01/SCI1 games where every usually one export
- // value is zero. It seems that in this situation, we should skip
- // the export and move to the next one, though the total count
- // of valid exports remains the same
+ pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset;
+ // This occurs in SCI01/SCI1 games where usually one export value
+ // is zero. It seems that in this situation, we should skip the
+ // export and move to the next one, though the total count of valid
+ // exports remains the same
if (!pos) {
exportIndex++;
pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset;
@@ -347,37 +336,15 @@ void Script::relocate(reg_t block) {
error("Script::relocate(): Consecutive zero exports found");
}
+ // In SCI0-SCI1, script local variables, objects and code are relocated. We only relocate
+ // locals and objects here, and ignore relocation of code blocks. In SCI1.1 and newer
+ // versions, only locals and objects are relocated.
if (!relocateLocal(block.segment, pos)) {
- bool done = false;
- uint k;
-
- ObjMap::iterator it;
+ // Not a local? It's probably an object or code block. If it's an object, relocate it.
const ObjMap::iterator end = _objects.end();
- for (it = _objects.begin(); !done && it != end; ++it) {
+ for (ObjMap::iterator it = _objects.begin(); it != end; ++it)
if (it->_value.relocate(block.segment, pos, _scriptSize))
- done = true;
- }
-
- // Sanity check for SCI0-SCI1
- if (getSciVersion() < SCI_VERSION_1_1) {
- for (k = 0; !done && k < _codeBlocks.size(); k++) {
- if (pos >= _codeBlocks[k].pos.offset &&
- pos < _codeBlocks[k].pos.offset + _codeBlocks[k].size)
- done = true;
- }
- }
-
- if (!done) {
- debug("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
- debug("Relocation failed for index %04x (%d/%d)\n", pos, exportIndex + 1, count);
- if (_localsBlock)
- debug("- locals: %d at %04x\n", _localsBlock->_locals.size(), _localsOffset);
- else
- debug("- No locals\n");
- for (it = _objects.begin(), k = 0; it != end; ++it, ++k)
- debug("- obj#%d at %04x w/ %d vars\n", k, it->_value.getPos().offset, it->_value.getVarCount());
- debug("Trying to continue anyway...\n");
- }
+ break;
}
exportIndex++;
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index 045cb119a3..02d4809b70 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -331,11 +331,6 @@ private:
reg_t _pos; /**< Object offset within its script; for clones, this is their base */
};
-struct CodeBlock {
- reg_t pos;
- int size;
-};
-
typedef Common::HashMap<uint16, Object> ObjMap;
class Script : public SegmentObj {
@@ -362,8 +357,6 @@ private:
const byte *_synonyms; /**< Synonyms block or 0 if not present*/
uint16 _numSynonyms; /**< Number of entries in the synonyms block */
- Common::Array<CodeBlock> _codeBlocks;
-
int _localsOffset;
uint16 _localsCount;
@@ -403,12 +396,6 @@ public:
const Object *getObject(uint16 offset) const;
/**
- * Informs the segment manager that a code block must be relocated
- * @param location Start of block to relocate
- */
- void scriptAddCodeBlock(reg_t location);
-
- /**
* Initializes an object within the segment manager
* @param obj_pos Location (segment, offset) of the object. It must
* point to the beginning of the script/class block