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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Sun Feb 7 03:53:07 CET 2010


Revision: 47948
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47948&view=rev
Author:   mthreepwood
Date:     2010-02-07 02:53:07 +0000 (Sun, 07 Feb 2010)

Log Message:
-----------
Rewrite detectSetCursorType() so that it works for KQ5 Mac in addition to KQ5 DOS CD.

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

Modified: scummvm/trunk/engines/sci/engine/features.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/features.cpp	2010-02-06 23:06:20 UTC (rev 47947)
+++ scummvm/trunk/engines/sci/engine/features.cpp	2010-02-07 02:53:07 UTC (rev 47948)
@@ -71,17 +71,6 @@
 		objAddr = _segMan->findObjectByName(objName);
 		slc = _kernel->_selectorCache.play;
 		break;
-	case kDetectSetCursorType:
-		objName = "Game";
-		objAddr = _segMan->findObjectByName(objName);
-		// KQ5CD overrides the default setCursor selector of the Game object,
-		// so we need to handle this separately
-		// KQ5 PC floppy is early SCI1, Amiga middle SCI1, and CD late SCI1
-		assert(!_gameId.empty());
-		if (_gameId == "kq5" && getSciVersion() == SCI_VERSION_1_LATE)
-			objAddr = _gameObj;
-		slc = _kernel->_selectorCache.setCursor;
-		break;
 	case kDetectLofsType:
 		objName = "Game";
 		objAddr = _segMan->findObjectByName(objName);
@@ -260,15 +249,6 @@
 								return true;
 						}
 						break;
-					case kDetectSetCursorType:
-						// Games with colored mouse cursors call kIsObject before kSetCursor
-						if (kFuncNum == 6) {	// kIsObject (SCI0-SCI11)
-							foundTarget = true;
-						} else if (kFuncNum == 40) {	// kSetCursor (SCI0-SCI11)
-							_setCursorType = foundTarget ? SCI_VERSION_1_1 : SCI_VERSION_0_EARLY;
-							return true;
-						}
-						break;
 #ifdef ENABLE_SCI32
 					case kDetectSci21KernelTable:
 							if (kFuncNum == 0x40) {
@@ -302,15 +282,6 @@
 		}
 	} while (offset > 0);
 
-	// Some games, like KQ5CD, never actually call SetCursor inside Game::setCursor
-	// but call isObject. Cover this case here, if we're actually reading the selector
-	// itself, and not iterating through the Game object (i.e. when the selector
-	// dictionary is missing)
-	if (featureDetection == kDetectSetCursorType && methodNum == -1 && foundTarget) {
-		_setCursorType = SCI_VERSION_1_1;
-		return true;
-	}
-
 	return false;	// not found
 }
 
@@ -347,40 +318,39 @@
 
 SciVersion GameFeatures::detectSetCursorType() {
 	if (_setCursorType == SCI_VERSION_NONE) {
-		if (getSciVersion() <= SCI_VERSION_01) {
-			// SCI0/SCI01 games never use cursor views
+		if (getSciVersion() <= SCI_VERSION_1_MIDDLE) {
+			// SCI1 middle and older games never use cursor views
 			_setCursorType = SCI_VERSION_0_EARLY;
-		} else if (getSciVersion() >= SCI_VERSION_1_EARLY && getSciVersion() <= SCI_VERSION_1_MIDDLE) {
-			// SCI1 early/SCI1 middle games never use cursor views
-			_setCursorType = SCI_VERSION_0_EARLY;
 		} else if (getSciVersion() >= SCI_VERSION_1_1) {
 			// SCI1.1 games always use cursor views
 			_setCursorType = SCI_VERSION_1_1;
 		} else {	// SCI1 late game, detect cursor semantics
-			bool found = false;
+			// If the Cursor object exists, we're using the SCI0 early kSetCursor semantics.
+			if (_segMan->findObjectByName("Cursor") == NULL_REG) {
+				_setCursorType = SCI_VERSION_0_EARLY;
+				debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", getSciVersionDesc(_setCursorType).c_str());
+				return _setCursorType;
+			}
 
-			if (_kernel->_selectorCache.setCursor == -1) {
-				// Find which function of the Game object calls setCursor
+			// Check for the existence of the handCursor object (first found). This is based on KQ5.
+			reg_t objAddr = _segMan->findObjectByName("handCursor", 0);
 
-				Object *obj = _segMan->getObject(_gameObj);
-				for (uint m = 0; m < obj->getMethodCount(); m++) {
-					found = autoDetectFeature(kDetectSetCursorType, m);
-					if (found)
-						break;
-				}
-			} else {
-				found = autoDetectFeature(kDetectSetCursorType);
+			// If that doesn't exist, we assume it uses SCI1.1 kSetCursor semantics
+			if (objAddr == NULL_REG) {
+				_setCursorType = SCI_VERSION_1_1;
+				debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", getSciVersionDesc(_setCursorType).c_str());
+				return _setCursorType;
 			}
 
-			if (!found) {
-				// Quite normal in several demos which don't have a cursor
-				warning("SetCursor detection failed, taking an educated guess");
+			// Now we check what the number variable holds in the handCursor object.
+			uint16 number = GET_SEL32V(_segMan, objAddr, SELECTOR(number));
 
-				if (getSciVersion() >= SCI_VERSION_1_1)
-					_setCursorType = SCI_VERSION_1_1;
-				else
-					_setCursorType = SCI_VERSION_0_EARLY;
-			}
+			// If the number is 0, it uses views and therefore the SCI1.1 kSetCursor semantics,
+			// otherwise it uses the SCI0 early kSetCursor semantics.
+			if (number == 0)
+				_setCursorType = SCI_VERSION_1_1;
+			else
+				_setCursorType = SCI_VERSION_0_EARLY;
 		}
 
 		debugC(1, kDebugLevelGraphics, "Detected SetCursor type: %s", getSciVersionDesc(_setCursorType).c_str());

Modified: scummvm/trunk/engines/sci/engine/features.h
===================================================================
--- scummvm/trunk/engines/sci/engine/features.h	2010-02-06 23:06:20 UTC (rev 47947)
+++ scummvm/trunk/engines/sci/engine/features.h	2010-02-07 02:53:07 UTC (rev 47948)
@@ -35,9 +35,8 @@
 	kDetectGfxFunctions = 0,
 	kDetectMoveCountType = 1,
 	kDetectSoundType = 2,
-	kDetectSetCursorType = 3,
-	kDetectLofsType = 4,
-	kDetectSci21KernelTable = 5
+	kDetectLofsType = 3,
+	kDetectSci21KernelTable = 4
 };
 
 class GameFeatures {


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