aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/script.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2010-11-17 09:10:43 +0000
committerFilippos Karapetis2010-11-17 09:10:43 +0000
commite4c967a3014eebff5e2c4fd02a3268749eed4122 (patch)
tree098903de78f41dbc847fd38569b6d71cc02c2951 /engines/sci/engine/script.cpp
parentf44b084deba5a192ac1fe90377179733b694d243 (diff)
downloadscummvm-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/script.cpp')
-rw-r--r--engines/sci/engine/script.cpp28
1 files changed, 27 insertions, 1 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 {