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

lskovlun at users.sourceforge.net lskovlun at users.sourceforge.net
Thu Nov 18 18:04:00 CET 2010


Revision: 54327
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54327&view=rev
Author:   lskovlun
Date:     2010-11-18 17:04:00 +0000 (Thu, 18 Nov 2010)

Log Message:
-----------
SCI3: Add proper support for the calle instruction

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kscripts.cpp
    scummvm/trunk/engines/sci/engine/script.cpp
    scummvm/trunk/engines/sci/engine/script.h
    scummvm/trunk/engines/sci/engine/vm.cpp

Modified: scummvm/trunk/engines/sci/engine/kscripts.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-11-18 17:02:51 UTC (rev 54326)
+++ scummvm/trunk/engines/sci/engine/kscripts.cpp	2010-11-18 17:04:00 UTC (rev 54327)
@@ -262,7 +262,7 @@
 		return NULL_REG;
 	}
 
-	uint16 address = scr->validateExportFunc(index);
+	uint16 address = scr->validateExportFunc(index, true);
 
 	// Point to the heap for SCI1.1 - SCI2.1 games
 	if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1)

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2010-11-18 17:02:51 UTC (rev 54326)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2010-11-18 17:04:00 UTC (rev 54327)
@@ -398,7 +398,7 @@
 	_lockers = lockers;
 }
 
-uint16 Script::validateExportFunc(int pubfunct) {
+uint16 Script::validateExportFunc(int pubfunct, bool relocate) {
 	bool exportsAreWide = (g_sci->_features->detectLofsType() == SCI_VERSION_1_MIDDLE);
 
 	if (_numExports <= pubfunct) {
@@ -408,8 +408,15 @@
 
 	if (exportsAreWide)
 		pubfunct *= 2;
-	uint16 offset = getSciVersion() != SCI_VERSION_3 ? READ_SCI11ENDIAN_UINT16(_exportTable + pubfunct) :
-		relocateOffsetSci3(pubfunct * 2 + 22);
+
+	uint16 offset;
+
+	if (getSciVersion() != SCI_VERSION_3 || !relocate) {
+		offset = READ_SCI11ENDIAN_UINT16(_exportTable + pubfunct);
+	} else {
+		offset = relocateOffsetSci3(pubfunct * 2 + 22);
+	}
+
 	VERIFY(offset < _bufSize, "invalid export function pointer");
 
 	// Check if the offset found points to a second export table (e.g. script 912

Modified: scummvm/trunk/engines/sci/engine/script.h
===================================================================
--- scummvm/trunk/engines/sci/engine/script.h	2010-11-18 17:02:51 UTC (rev 54326)
+++ scummvm/trunk/engines/sci/engine/script.h	2010-11-18 17:04:00 UTC (rev 54327)
@@ -206,10 +206,11 @@
 	 * Validate whether the specified public function is exported by
 	 * the script in the specified segment.
 	 * @param pubfunct		Index of the function to validate
+	 * @param relocate              Decide whether to relocate this public function or not
 	 * @return				NULL if the public function is invalid, its
 	 * 						offset into the script's segment otherwise
 	 */
-	uint16 validateExportFunc(int pubfunct);
+	uint16 validateExportFunc(int pubfunct, bool relocate);
 
 	/**
 	 * Marks the script as deleted.
@@ -254,6 +255,11 @@
 	 */
 	int relocateOffsetSci3(uint32 offset);
 
+	/**
+	 * Gets an offset to the beginning of the code block in a SCI3 script
+	 */
+	int getCodeBlockOffset() { return READ_SCI11ENDIAN_UINT32(_buf); }
+
 private:
 	/**
 	 * Processes a relocation block within a SCI0-SCI2.1 script

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-11-18 17:02:51 UTC (rev 54326)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-11-18 17:04:00 UTC (rev 54327)
@@ -328,7 +328,11 @@
 		scr = s->_segMan->getScript(seg);
 	}
 
-	const int temp = scr->validateExportFunc(pubfunct);
+	int temp = scr->validateExportFunc(pubfunct, false);
+
+	if (getSciVersion() == SCI_VERSION_3)
+		temp += scr->getCodeBlockOffset();
+
 	if (!temp) {
 #ifdef ENABLE_SCI32
 		// HACK: Temporarily switch to a warning in SCI32 games until we can figure out why Torin has


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