aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2010-11-17 09:28:04 +0000
committerFilippos Karapetis2010-11-17 09:28:04 +0000
commit59ad5085bc317488ebb006737cc130c9cb100a80 (patch)
treeb325870ce4a30901ce5d5b1498ec4f15e529f17f /engines/sci
parente4c967a3014eebff5e2c4fd02a3268749eed4122 (diff)
downloadscummvm-rg350-59ad5085bc317488ebb006737cc130c9cb100a80.tar.gz
scummvm-rg350-59ad5085bc317488ebb006737cc130c9cb100a80.tar.bz2
scummvm-rg350-59ad5085bc317488ebb006737cc130c9cb100a80.zip
SCI: Some more work on SCI3, based on a patch by lskovlun
- Added a SCI3 implementation of Script::load() - Added a SCI3 implementation of Script::initialiseClasses() - Removed some duplicate code svn-id: r54282
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/script.cpp43
-rw-r--r--engines/sci/engine/script.h5
2 files changed, 33 insertions, 15 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 088cd9cb89..7f5a4c75be 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -168,7 +168,13 @@ void Script::load(ResourceManager *resMan) {
_localsOffset = _scriptSize + 4;
_localsCount = READ_SCI11ENDIAN_UINT16(_buf + _localsOffset - 2);
} else if (getSciVersion() == SCI_VERSION_3) {
- warning("TODO: Script::load(): SCI3 equivalent");
+ _localsCount = READ_LE_UINT16(_buf + 12);
+ _numExports = READ_LE_UINT16(_buf + 20);
+ // SCI3 local variables always start dword-aligned
+ if (_numExports % 2)
+ _localsOffset = 22 + _numExports * 2;
+ else
+ _localsOffset = 24 + _numExports * 2;
}
if (getSciVersion() == SCI_VERSION_0_EARLY) {
@@ -191,6 +197,24 @@ void Script::load(ResourceManager *resMan) {
}
}
+const byte *Script::getSci3ObjectsPointer() {
+ const byte *ptr = 0;
+
+ // SCI3 local variables always start dword-aligned
+ if (_numExports % 2)
+ ptr = _buf + 22 + _numExports * 2;
+ else
+ ptr = _buf + 24 + _numExports * 2;
+
+ // SCI3 object structures always start dword-aligned
+ if (_localsCount % 2)
+ ptr += 2 + _localsCount * 2;
+ else
+ ptr += _localsCount * 2;
+
+ return ptr;
+}
+
Object *Script::getObject(uint16 offset) {
if (_objects.contains(offset))
return &_objects[offset];
@@ -435,7 +459,8 @@ void Script::initialiseClasses(SegManager *segMan) {
seeker = _heapStart + 4 + READ_SCI11ENDIAN_UINT16(_heapStart + 2) * 2;
mult = 2;
} else if (getSciVersion() == SCI_VERSION_3) {
- warning("TODO: initialiseClasses(): SCI3 equivalent");
+ seeker = getSci3ObjectsPointer();
+ mult = 1;
}
if (!seeker)
@@ -567,19 +592,7 @@ void Script::initialiseObjectsSci11(SegManager *segMan, SegmentId segmentId) {
}
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;
+ const byte *seeker = getSci3ObjectsPointer();
while (READ_SCI11ENDIAN_UINT16(seeker) == SCRIPT_OBJECT_MAGIC_NUMBER) {
reg_t reg = make_reg(segmentId, seeker - _buf);
diff --git a/engines/sci/engine/script.h b/engines/sci/engine/script.h
index 211427942d..2105d1e6de 100644
--- a/engines/sci/engine/script.h
+++ b/engines/sci/engine/script.h
@@ -261,6 +261,11 @@ private:
bool relocateLocal(SegmentId segment, int location);
/**
+ * Gets a pointer to the beginning of the objects in a SCI3 script
+ */
+ const byte *getSci3ObjectsPointer();
+
+ /**
* Initializes the script's objects (SCI0)
* @param segMan A reference to the segment manager
* @param segmentId The script's segment id