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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Nov 22 16:06:32 CET 2009


Revision: 46086
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46086&view=rev
Author:   thebluegr
Date:     2009-11-22 15:06:32 +0000 (Sun, 22 Nov 2009)

Log Message:
-----------
Check which DoSound method is actually invoked from Sound::play, to remove a hack for Jones CD. Added code to handle games which don't actually call SetCursor inside Game::setCursor (like KQ5CD)

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/state.cpp

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-11-22 13:38:18 UTC (rev 46085)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-11-22 15:06:32 UTC (rev 46086)
@@ -288,6 +288,7 @@
 
 	uint16 offset = addr.offset;
 	Script *script = _segMan->getScript(addr.segment);
+	uint16 intParam = 0xFFFF;
 
 	do {
 		uint16 kFuncNum;
@@ -324,9 +325,36 @@
 
 				if (_lofsType != SCI_VERSION_AUTODETECT)
 					return true;
+
+				// If we reach here, we haven't been able to deduce the lofs parameter
+				// type, but we have advanced the offset pointer already. So move on
+				// to the next opcode
+				continue;
 			}
 		}
 
+		if (featureDetection == kDetectSoundType) {
+			// The play method of the Sound object pushes the DoSound command
+			// that it'll use just before it calls DoSound. We intercept that here
+			// in order to check what sound semantics are used, cause the position
+			// of the sound commands has changed at some point during SCI1 middle
+			if (opcode == op_pushi) {
+				// Load the pushi parameter
+				if (opsize & 1) {
+					if (offset >= script->_bufSize)
+						break;
+					intParam = script->_buf[offset++];
+				} else {
+					if ((uint32)offset + 1 >= (uint32)script->_bufSize)
+						break;
+					intParam = READ_LE_UINT16(script->_buf + offset);
+					offset += 2;
+				}
+
+				continue;
+			}
+		}
+
 		while (g_opcode_formats[opcode][i]) {
 			switch (g_opcode_formats[opcode][i++]) {
 			case Script_Invalid:
@@ -381,8 +409,28 @@
 						if (kFuncNum == 6) {	// kIsObject (SCI0-SCI11)
 							foundTarget = true;
 						} else if (kFuncNum == 45) {	// kDoSound (SCI1)
-							_doSoundType = foundTarget ? SCI_VERSION_1_LATE : SCI_VERSION_1_EARLY;
-							return true;
+							// First, check which DoSound function is called by the play method of
+							// the Sound object
+							switch (intParam) {
+							case 1:
+								_doSoundType = SCI_VERSION_0_EARLY;
+								break;
+							case 7:
+								_doSoundType = SCI_VERSION_1_EARLY;
+								break;
+							case 8:
+								_doSoundType = SCI_VERSION_1_LATE;
+								break;
+							default:
+								// Unknown case... should never happen. We fall back to
+								// alternative detection here, which works in general, apart from
+								// some transitive games like Jones CD
+								_doSoundType = foundTarget ? SCI_VERSION_1_LATE : SCI_VERSION_1_EARLY;
+								break;
+							}
+
+							if (_doSoundType != SCI_VERSION_AUTODETECT)
+								return true;
 						}
 						break;
 					case kDetectSetCursorType:
@@ -393,6 +441,7 @@
 							_setCursorType = foundTarget ? SCI_VERSION_1_1 : SCI_VERSION_0_EARLY;
 							return true;
 						}
+						break;
 					default:
 						break;
 					}
@@ -415,6 +464,13 @@
 		}
 	} while (offset > 0);
 
+	// Some games, like KQ5CD, never actually call SetCursor inside Game::setCursor
+	// but call isObject
+	if (featureDetection == kDetectSetCursorType && foundTarget) {
+		_setCursorType = SCI_VERSION_1_1;
+		return true;
+	}
+
 	return false;	// not found
 }
 
@@ -440,21 +496,6 @@
 			}
 		}
 
-		// Jones CD and perhaps others were in the middle of the transition from SCI1 old to SCI1 new
-		// sound code, and had some temporary selector methods in the Sound object. Check for these here,
-		// and set the doSound type to SCI1 new if they're found
-		if (getSciVersion() == SCI_VERSION_1_MIDDLE) {
-			reg_t tmp;
-			Selector slc = _kernel->findSelector("cue");
-			if (slc != -1) {
-				if (lookup_selector(_segMan, _segMan->findObjectByName("Sound"), slc, NULL, &tmp) == kSelectorMethod) {
-					// The Sound object has a temporary cue selector, therefore the game is using late
-					// SCI1 sound functions
-					_doSoundType = SCI_VERSION_1_LATE;
-				}
-			}
-		}
-
 		debugC(1, kDebugLevelSound, "Detected DoSound type: %s", getSciVersionDesc(_doSoundType).c_str());
 	}
 


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