[Scummvm-cvs-logs] SF.net SVN: scummvm:[49669] scummvm/trunk/engines/sci/engine
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Mon Jun 14 22:45:01 CEST 2010
Revision: 49669
http://scummvm.svn.sourceforge.net/scummvm/?rev=49669&view=rev
Author: thebluegr
Date: 2010-06-14 20:45:00 +0000 (Mon, 14 Jun 2010)
Log Message:
-----------
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
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/script.cpp
scummvm/trunk/engines/sci/engine/segment.cpp
scummvm/trunk/engines/sci/engine/segment.h
Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp 2010-06-14 20:15:15 UTC (rev 49668)
+++ scummvm/trunk/engines/sci/engine/script.cpp 2010-06-14 20:45:00 UTC (rev 49669)
@@ -179,7 +179,10 @@
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 @@
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) {
Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp 2010-06-14 20:15:15 UTC (rev 49668)
+++ scummvm/trunk/engines/sci/engine/segment.cpp 2010-06-14 20:45:00 UTC (rev 49669)
@@ -115,7 +115,6 @@
_bufSize = 0;
_objects.clear();
- _codeBlocks.clear();
}
void Script::init(int script_nr, ResourceManager *resMan) {
@@ -125,8 +124,6 @@
_localsBlock = NULL;
_localsCount = 0;
- _codeBlocks.clear();
-
_markedAsDeleted = false;
_nr = script_nr;
@@ -188,8 +185,6 @@
memcpy(_heapStart, heap->data, heap->size);
}
- _codeBlocks.clear();
-
_exportTable = 0;
_numExports = 0;
_synonyms = 0;
@@ -310,13 +305,6 @@
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 @@
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 @@
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++;
Modified: scummvm/trunk/engines/sci/engine/segment.h
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.h 2010-06-14 20:15:15 UTC (rev 49668)
+++ scummvm/trunk/engines/sci/engine/segment.h 2010-06-14 20:45:00 UTC (rev 49669)
@@ -331,11 +331,6 @@
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 @@
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 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list