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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Nov 20 11:29:42 CET 2009


Revision: 46002
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46002&view=rev
Author:   thebluegr
Date:     2009-11-20 10:29:42 +0000 (Fri, 20 Nov 2009)

Log Message:
-----------
Some corrections for the lofs autodetection - SQ4 floppy works again

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

Modified: scummvm/trunk/engines/sci/engine/script.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/script.cpp	2009-11-20 08:55:35 UTC (rev 46001)
+++ scummvm/trunk/engines/sci/engine/script.cpp	2009-11-20 10:29:42 UTC (rev 46002)
@@ -240,6 +240,7 @@
 	FIND_SELECTOR(subtitleLang);
 	FIND_SELECTOR(parseLang);
 	FIND_SELECTOR(overlay);
+	FIND_SELECTOR(newRoom);
 	FIND_SELECTOR(setCursor);
 	FIND_SELECTOR(topString);
 	FIND_SELECTOR(scaleX);

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-11-20 08:55:35 UTC (rev 46001)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-11-20 10:29:42 UTC (rev 46002)
@@ -259,6 +259,10 @@
 		objName = "Game";
 		slc = _kernel->_selectorCache.play;
 		break;
+	case kDetectLofsTypeFallback:
+		objName = "Game";
+		slc = _kernel->_selectorCache.newRoom;
+		break;
 	default:
 		break;
 	}
@@ -285,32 +289,34 @@
 		int i = 0;
 		byte argc;
 
-		if (featureDetection == kDetectLofsType && (opcode == op_lofsa || opcode == op_lofss)) {
-			uint16 lofs;
+		if (featureDetection == kDetectLofsType || featureDetection == kDetectLofsTypeFallback) {
+			if (opcode == op_lofsa || opcode == op_lofss) {
+				uint16 lofs;
 
-			// Load lofs operand
-			if (opsize & 1) {
-				if (offset >= script->_bufSize)
-					break;
-				lofs = script->_buf[offset++];
-			} else {
-				if ((uint32)offset + 1 >= (uint32)script->_bufSize)
-					break;
-				lofs = READ_LE_UINT16(script->_buf + offset);
-				offset += 2;
-			}
+				// Load lofs operand
+				if (opsize & 1) {
+					if (offset >= script->_bufSize)
+						break;
+					lofs = script->_buf[offset++];
+				} else {
+					if ((uint32)offset + 1 >= (uint32)script->_bufSize)
+						break;
+					lofs = READ_LE_UINT16(script->_buf + offset);
+					offset += 2;
+				}
 
-			// Check for going out of bounds when interpreting as abs/rel
-			if (lofs >= script->_bufSize)
-				_lofsType = SCI_VERSION_0_EARLY;
+				// Check for going out of bounds when interpreting as abs/rel
+				if (lofs >= script->_bufSize)
+					_lofsType = SCI_VERSION_0_EARLY;
 
-			if ((signed)offset + (int16)lofs < 0)
-				_lofsType = SCI_VERSION_1_MIDDLE;
+				if ((signed)offset + (int16)lofs < 0)
+					_lofsType = SCI_VERSION_1_MIDDLE;
 
-			if ((signed)offset + (int16)lofs >= (signed)script->_bufSize)
-				_lofsType = SCI_VERSION_1_MIDDLE;
+				if ((signed)offset + (int16)lofs >= (signed)script->_bufSize)
+					_lofsType = SCI_VERSION_1_MIDDLE;
 
-			return true;
+				return true;
+			}
 		}
 
 		while (g_opcode_formats[opcode][i]) {
@@ -477,7 +483,9 @@
 			return _lofsType;
 		}
 
-		if (!autoDetectFeature(kDetectLofsType)) {
+		// Either the init or the newRoom selectors of the Game
+		// object make calls to lofsa/lofss
+		if (!autoDetectFeature(kDetectLofsType) && !autoDetectFeature(kDetectLofsTypeFallback)) {
 			warning("Lofs detection failed, taking an educated guess");
 
 			if (getSciVersion() >= SCI_VERSION_1_MIDDLE)

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-11-20 08:55:35 UTC (rev 46001)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-11-20 10:29:42 UTC (rev 46002)
@@ -107,7 +107,8 @@
 	kDetectMoveCountType = 1,
 	kDetectSoundType = 2,
 	kDetectSetCursorType = 3,
-	kDetectLofsType = 4
+	kDetectLofsType = 4,
+	kDetectLofsTypeFallback = 5
 };
 
 class FileHandle {

Modified: scummvm/trunk/engines/sci/engine/static_selectors.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/static_selectors.cpp	2009-11-20 08:55:35 UTC (rev 46001)
+++ scummvm/trunk/engines/sci/engine/static_selectors.cpp	2009-11-20 10:29:42 UTC (rev 46002)
@@ -74,9 +74,10 @@
 	{      "nodePtr",  44 }, {   "cantBeHere",  57 }, {    "topString", 101 },
 	{        "flags", 102 }, {         "init", 104 }, {      "dispose", 105 },
 	{       "caller", 134 }, {          "cue", 136 }, {        "owner", 150 },
-	{       "setVol", 156 }, {    "setCursor", 183 }, {    "completed", 210 },
-	{       "cycler", 215 }, {     "distance", 224 }, {    "canBeHere", 232 },
-	{     "syncTime", 247 }, {      "syncCue", 248 }, {              0,   0 }
+	{       "setVol", 156 }, {      "newRoom", 173 }, {    "setCursor", 183 },
+	{    "completed", 210 }, {       "cycler", 215 }, {     "distance", 224 },
+	{    "canBeHere", 232 }, {     "syncTime", 247 }, {      "syncCue", 248 },
+	{              0,   0 }
 };
 
 // Taken from KQ6 floppy (Full Game)

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-11-20 08:55:35 UTC (rev 46001)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-11-20 10:29:42 UTC (rev 46002)
@@ -191,6 +191,8 @@
 	Selector subtitleLang;
 	Selector parseLang;
 
+	Selector newRoom;	/** For SCI1 lofs parameter type autodetection fallback */
+
 	Selector setCursor; /** For autodetection */
 };
 


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