diff options
author | Filippos Karapetis | 2010-11-17 09:10:43 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-11-17 09:10:43 +0000 |
commit | e4c967a3014eebff5e2c4fd02a3268749eed4122 (patch) | |
tree | 098903de78f41dbc847fd38569b6d71cc02c2951 /engines/sci/engine | |
parent | f44b084deba5a192ac1fe90377179733b694d243 (diff) | |
download | scummvm-rg350-e4c967a3014eebff5e2c4fd02a3268749eed4122.tar.gz scummvm-rg350-e4c967a3014eebff5e2c4fd02a3268749eed4122.tar.bz2 scummvm-rg350-e4c967a3014eebff5e2c4fd02a3268749eed4122.zip |
SCI: Added the SCI3 equivalent of initialiseObjects(), from a patch by lskovlun
svn-id: r54281
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/script.cpp | 28 | ||||
-rw-r--r-- | engines/sci/engine/script.h | 9 |
2 files changed, 35 insertions, 2 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index c4ff0cc699..088cd9cb89 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -566,13 +566,39 @@ void Script::initialiseObjectsSci11(SegManager *segMan, SegmentId segmentId) { relocate(make_reg(segmentId, READ_SCI11ENDIAN_UINT16(_heapStart))); } +void Script::initialiseObjectsSci3(SegManager *segMan, SegmentId segmentId) { + const byte *seeker = _buf; + + // SCI3 local variables always start dword-aligned + if (_numExports % 2) + seeker = _buf + 22 + _numExports * 2; + else + seeker = _buf + 24 + _numExports * 2; + + // SCI3 object structures always start dword-aligned + if (_localsCount % 2) + seeker = seeker + 2 + _localsCount * 2; + else + seeker = seeker + _localsCount * 2; + + while (READ_SCI11ENDIAN_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) { + reg_t reg = make_reg(segmentId, seeker - _buf); + Object *obj = scriptObjInit(reg); + + obj->setSuperClassSelector(segMan->getClassAddress(obj->getSuperClassSelector().offset, SCRIPT_GET_LOCK, NULL_REG)); + seeker += READ_SCI11ENDIAN_UINT16(seeker + 2); + } + + relocate(make_reg(segmentId, 0)); +} + void Script::initialiseObjects(SegManager *segMan, SegmentId segmentId) { if (getSciVersion() <= SCI_VERSION_1_LATE) initialiseObjectsSci0(segMan, segmentId); else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) initialiseObjectsSci11(segMan, segmentId); else if (getSciVersion() == SCI_VERSION_3) - warning("TODO: initialiseObjects(): SCI3 equivalent"); + initialiseObjectsSci3(segMan, segmentId); } reg_t Script::findCanonicAddress(SegManager *segMan, reg_t addr) const { diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h index bc263edc8c..211427942d 100644 --- a/engines/sci/engine/script.h +++ b/engines/sci/engine/script.h @@ -268,11 +268,18 @@ private: void initialiseObjectsSci0(SegManager *segMan, SegmentId segmentId); /** - * Initializes the script's objects (SCI1.1+) + * Initializes the script's objects (SCI1.1 - SCI2.1) * @param segMan A reference to the segment manager * @param segmentId The script's segment id */ void initialiseObjectsSci11(SegManager *segMan, SegmentId segmentId); + + /** + * Initializes the script's objects (SCI3) + * @param segMan A reference to the segment manager + * @param segmentId The script's segment id + */ + void initialiseObjectsSci3(SegManager *segMan, SegmentId segmentId); }; } // End of namespace Sci |