diff options
author | Filippos Karapetis | 2010-05-30 18:45:07 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-30 18:45:07 +0000 |
commit | 016862ac3a4928529d9eaedf6edf3e916c89155c (patch) | |
tree | 99d7cca38a0dfa5eebc3bcf465d86ff7922348de /engines/sci | |
parent | 29c2f30558e9c40d5c1a76ab600611b21ee72851 (diff) | |
download | scummvm-rg350-016862ac3a4928529d9eaedf6edf3e916c89155c.tar.gz scummvm-rg350-016862ac3a4928529d9eaedf6edf3e916c89155c.tar.bz2 scummvm-rg350-016862ac3a4928529d9eaedf6edf3e916c89155c.zip |
Moved setScriptSize() inside Script::init(), and removed a FIXME - the SCI1.1 word-align is done inside Script::init()
svn-id: r49330
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/script.cpp | 7 | ||||
-rw-r--r-- | engines/sci/engine/segment.cpp | 60 | ||||
-rw-r--r-- | engines/sci/engine/segment.h | 5 | ||||
-rw-r--r-- | engines/sci/resource.cpp | 1 |
4 files changed, 23 insertions, 50 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index d52cdd693b..99a567d1e7 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -437,13 +437,6 @@ int script_instantiate_sci11(ResourceManager *resMan, SegManager *segMan, int sc scr->setExportTableOffset(6); int heapStart = scr->getScriptSize(); - - // FIXME: This code was used to ensure that the heap address is word-aligned - // Make sure that this is used in all places where the heap is referenced, - // not just here... - //if (heapStart & 2) - // heapStart++; - segMan->scriptInitialiseLocals(make_reg(seg_id, heapStart + 4)); segMan->scriptInitialiseObjectsSci11(seg_id); scr->heapRelocate(make_reg(seg_id, READ_SCI11ENDIAN_UINT16(scr->_heapStart))); diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index 8a9b953289..a8c4eb73f6 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -117,8 +117,8 @@ void Script::freeScript() { _codeBlocks.clear(); } -bool Script::init(int script_nr, ResourceManager *resMan) { - setScriptSize(script_nr, resMan); +void Script::init(int script_nr, ResourceManager *resMan) { + Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); _localsOffset = 0; _localsBlock = NULL; @@ -132,7 +132,25 @@ bool Script::init(int script_nr, ResourceManager *resMan) { _buf = 0; _heapStart = 0; - return true; + _scriptSize = script->size; + _bufSize = script->size; + _heapSize = 0; + + if (getSciVersion() == SCI_VERSION_0_EARLY) { + _bufSize += READ_LE_UINT16(script->data) * 2; + } else if (getSciVersion() >= SCI_VERSION_1_1) { + Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0); + _bufSize += heap->size; + _heapSize = heap->size; + + // Ensure that the start of the heap resource can be word-aligned. + if (script->size & 2) { + _bufSize++; + _scriptSize++; + } + + assert(_bufSize <= 65535); + } } void Script::load(ResourceManager *resMan) { @@ -156,42 +174,6 @@ void Script::load(ResourceManager *resMan) { } } -void Script::setScriptSize(int script_nr, ResourceManager *resMan) { - Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0); - Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0); - bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY); - - _scriptSize = script->size; - _heapSize = 0; // Set later - - if (!script || (getSciVersion() >= SCI_VERSION_1_1 && !heap)) { - error("SegManager::setScriptSize: failed to load %s", !script ? "script" : "heap"); - } - if (oldScriptHeader) { - _bufSize = script->size + READ_LE_UINT16(script->data) * 2; - //locals_size = READ_LE_UINT16(script->data) * 2; - } else if (getSciVersion() < SCI_VERSION_1_1) { - _bufSize = script->size; - } else { - _bufSize = script->size + heap->size; - _heapSize = heap->size; - - // Ensure that the start of the heap resource can be word-aligned. - if (script->size & 2) { - _bufSize++; - _scriptSize++; - } - - if (_bufSize > 65535) { - error("Script and heap sizes combined exceed 64K." - "This means a fundamental design bug was made in SCI\n" - "regarding SCI1.1 games.\nPlease report this so it can be" - "fixed in the next major version"); - return; - } - } -} - Object *Script::allocateObject(uint16 offset) { return &_objects[offset]; } diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index 3a4e929abe..127ab28b7e 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -363,7 +363,7 @@ public: ~Script(); void freeScript(); - bool init(int script_nr, ResourceManager *resMan); + void init(int script_nr, ResourceManager *resMan); void load(ResourceManager *resMan); virtual bool isValidOffset(uint16 offset) const; @@ -512,9 +512,6 @@ public: * Finds the pointer where a block of a specific type starts from */ byte *findBlock(int type); - -private: - void setScriptSize(int script_nr, ResourceManager *resMan); }; /** Data stack */ diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index ba5689dcf0..c36feb57c6 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -1926,6 +1926,7 @@ reg_t ResourceManager::findGameObject(bool addSci11ScriptOffset) { if (getSciVersion() >= SCI_VERSION_1_1 && addSci11ScriptOffset) { offset += script->size; + // Ensure that the start of the heap is word-aligned - same as in Script::init() if (script->size & 2) offset++; } |