[Scummvm-cvs-logs] SF.net SVN: scummvm:[54282] scummvm/trunk/engines/sci/engine
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Wed Nov 17 10:28:04 CET 2010
Revision: 54282
http://scummvm.svn.sourceforge.net/scummvm/?rev=54282&view=rev
Author: thebluegr
Date: 2010-11-17 09:28:04 +0000 (Wed, 17 Nov 2010)
Log Message:
-----------
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
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/script.cpp
scummvm/trunk/engines/sci/engine/script.h
Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp 2010-11-17 09:10:43 UTC (rev 54281)
+++ scummvm/trunk/engines/sci/engine/script.cpp 2010-11-17 09:28:04 UTC (rev 54282)
@@ -168,7 +168,13 @@
_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 @@
}
}
+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 @@
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,20 +592,8 @@
}
void Script::initialiseObjectsSci3(SegManager *segMan, SegmentId segmentId) {
- const byte *seeker = _buf;
+ const byte *seeker = getSci3ObjectsPointer();
- // 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);
Modified: scummvm/trunk/engines/sci/engine/script.h
===================================================================
--- scummvm/trunk/engines/sci/engine/script.h 2010-11-17 09:10:43 UTC (rev 54281)
+++ scummvm/trunk/engines/sci/engine/script.h 2010-11-17 09:28:04 UTC (rev 54282)
@@ -261,6 +261,11 @@
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
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