[Scummvm-cvs-logs] SF.net SVN: scummvm:[54280] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Nov 17 09:53:03 CET 2010


Revision: 54280
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54280&view=rev
Author:   thebluegr
Date:     2010-11-17 08:53:02 +0000 (Wed, 17 Nov 2010)

Log Message:
-----------
SCI: Some restructuring. Added some SCI3 placeholders/stubs

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/script.cpp
    scummvm/trunk/engines/sci/engine/segment.cpp
    scummvm/trunk/engines/sci/resource.cpp

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-11-17 08:30:08 UTC (rev 54279)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-11-17 08:53:02 UTC (rev 54280)
@@ -248,8 +248,8 @@
 
 	uint16 address = scr->validateExportFunc(index);
 
-	// Point to the heap for SCI1.1+ games
-	if (getSciVersion() >= SCI_VERSION_1_1)
+	// Point to the heap for SCI1.1 - SCI2.1 games
+	if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1)
 		address += scr->getScriptSize();
 
 	return make_reg(scriptSeg, address);

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2010-11-17 08:30:08 UTC (rev 54279)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2010-11-17 08:53:02 UTC (rev 54280)
@@ -144,14 +144,7 @@
 	_synonyms = 0;
 	_numSynonyms = 0;
 	
-	if (getSciVersion() >= SCI_VERSION_1_1) {
-		if (READ_LE_UINT16(_buf + 1 + 5) > 0) {	// does the script have an export table?
-			_exportTable = (const uint16 *)(_buf + 1 + 5 + 2);
-			_numExports = READ_SCI11ENDIAN_UINT16(_exportTable - 1);
-		}
-		_localsOffset = _scriptSize + 4;
-		_localsCount = READ_SCI11ENDIAN_UINT16(_buf + _localsOffset - 2);
-	} else {
+	if (getSciVersion() <= SCI_VERSION_1_LATE) {
 		_exportTable = (const uint16 *)findBlockSCI0(SCI_OBJ_EXPORTS);
 		if (_exportTable) {
 			_numExports = READ_SCI11ENDIAN_UINT16(_exportTable + 1);
@@ -167,9 +160,26 @@
 			_localsOffset = localsBlock - _buf + 4;
 			_localsCount = (READ_LE_UINT16(_buf + _localsOffset - 2) - 4) >> 1;	// half block size
 		}
+	} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
+		if (READ_LE_UINT16(_buf + 1 + 5) > 0) {	// does the script have an export table?
+			_exportTable = (const uint16 *)(_buf + 1 + 5 + 2);
+			_numExports = READ_SCI11ENDIAN_UINT16(_exportTable - 1);
+		}
+		_localsOffset = _scriptSize + 4;
+		_localsCount = READ_SCI11ENDIAN_UINT16(_buf + _localsOffset - 2);
+	} else if (getSciVersion() == SCI_VERSION_3) {
+		warning("TODO: Script::load(): SCI3 equivalent");
 	}
 
-	if (getSciVersion() > SCI_VERSION_0_EARLY) {
+	if (getSciVersion() == SCI_VERSION_0_EARLY) {
+		// SCI0 early
+		// Old script block. There won't be a localvar block in this case.
+		// Instead, the script starts with a 16 bit int specifying the
+		// number of locals we need; these are then allocated and zeroed.
+		_localsCount = READ_LE_UINT16(_buf);
+		_localsOffset = -_localsCount * 2; // Make sure it's invalid
+	} else {
+		// SCI0 late and newer
 		// Does the script actually have locals? If not, set the locals offset to 0
 		if (!_localsCount)
 			_localsOffset = 0;
@@ -178,12 +188,6 @@
 			error("Locals extend beyond end of script: offset %04x, count %d vs size %d", _localsOffset, _localsCount, _bufSize);
 			_localsCount = (_bufSize - _localsOffset) >> 1;
 		}
-	} else {
-		// Old script block. There won't be a localvar block in this case.
-		// Instead, the script starts with a 16 bit int specifying the
-		// number of locals we need; these are then allocated and zeroed.
-		_localsCount = READ_LE_UINT16(_buf);
-		_localsOffset = -_localsCount * 2; // Make sure it's invalid
 	}
 }
 
@@ -242,7 +246,7 @@
 		return false;
 	}
 	block[idx].segment = segment; // Perform relocation
-	if (getSciVersion() >= SCI_VERSION_1_1)
+	if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1)
 		block[idx].offset += scriptSize;
 
 	return true;
@@ -260,7 +264,7 @@
 	uint16 heapSize = (uint16)_bufSize;
 	uint16 heapOffset = 0;
 
-	if (getSciVersion() >= SCI_VERSION_1_1) {
+	if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
 		heap = _heapStart;
 		heapSize = (uint16)_heapSize;
 		heapOffset = _scriptSize;
@@ -423,13 +427,15 @@
 void Script::initialiseClasses(SegManager *segMan) {
 	const byte *seeker = 0;
 	uint16 mult = 0;
-	
-	if (getSciVersion() >= SCI_VERSION_1_1) {
+
+	if (getSciVersion() <= SCI_VERSION_1_LATE) {
+		seeker = findBlockSCI0(SCI_OBJ_CLASS);
+		mult = 1;
+	} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
 		seeker = _heapStart + 4 + READ_SCI11ENDIAN_UINT16(_heapStart + 2) * 2;
 		mult = 2;
-	} else {
-		seeker = findBlockSCI0(SCI_OBJ_CLASS);
-		mult = 1;
+	} else if (getSciVersion() == SCI_VERSION_3) {
+		warning("TODO: initialiseClasses(): SCI3 equivalent");
 	}
 
 	if (!seeker)
@@ -448,14 +454,16 @@
 		if (!marker)
 			break;
 
-		if (getSciVersion() >= SCI_VERSION_1_1) {
-			isClass = (READ_SCI11ENDIAN_UINT16(seeker + 14) & kInfoFlagClass);	// -info- selector
-			species = READ_SCI11ENDIAN_UINT16(seeker + 10);
-		} else {
+		if (getSciVersion() <= SCI_VERSION_1_LATE) {
 			isClass = (marker == SCI_OBJ_CLASS);
 			if (isClass)
 				species = READ_SCI11ENDIAN_UINT16(seeker + 12);
 			classpos += 12;
+		} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
+			isClass = (READ_SCI11ENDIAN_UINT16(seeker + 14) & kInfoFlagClass);	// -info- selector
+			species = READ_SCI11ENDIAN_UINT16(seeker + 10);
+		} else if (getSciVersion() == SCI_VERSION_3) {
+			// TODO: SCI3 equivalent
 		}
 
 		if (isClass) {
@@ -559,10 +567,12 @@
 }
 
 void Script::initialiseObjects(SegManager *segMan, SegmentId segmentId) {
-	if (getSciVersion() >= SCI_VERSION_1_1)
+	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
-		initialiseObjectsSci0(segMan, segmentId);
+	else if (getSciVersion() == SCI_VERSION_3)
+		warning("TODO: initialiseObjects(): SCI3 equivalent");
 }
 
 reg_t Script::findCanonicAddress(SegManager *segMan, reg_t addr) const {

Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp	2010-11-17 08:30:08 UTC (rev 54279)
+++ scummvm/trunk/engines/sci/engine/segment.cpp	2010-11-17 08:53:02 UTC (rev 54280)
@@ -148,7 +148,7 @@
 		return false;
 	}
 	block[idx].segment = segment; // Perform relocation
-	if (getSciVersion() >= SCI_VERSION_1_1)
+	if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1)
 		block[idx].offset += scriptSize;
 
 	return true;

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2010-11-17 08:30:08 UTC (rev 54279)
+++ scummvm/trunk/engines/sci/resource.cpp	2010-11-17 08:53:02 UTC (rev 54280)
@@ -2411,9 +2411,9 @@
 	
 	int16 offset = !isSci11Mac() ? READ_LE_UINT16(offsetPtr) : READ_BE_UINT16(offsetPtr);
 
-	// In SCI1.1 and newer, the heap is appended at the end of the script,
+	// In SCI1.1 - SCI2.1, the heap is appended at the end of the script,
 	// so adjust the offset accordingly
-	if (getSciVersion() >= SCI_VERSION_1_1 && addSci11ScriptOffset) {
+	if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1 && addSci11ScriptOffset) {
 		offset += script->size;
 
 		// Ensure that the start of the heap is word-aligned - same as in Script::init()
@@ -2425,7 +2425,8 @@
 }
 
 Common::String ResourceManager::findSierraGameId() {
-	// In SCI0-SCI1, the heap is embedded in the script. In SCI1.1+, it's separated
+	// In SCI0-SCI1, the heap is embedded in the script. In SCI1.1 - SCI2.1,
+	// it's in a separate heap resource
 	Resource *heap = 0;
 	int nameSelector = 3;
 


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