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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Tue Jul 27 21:07:39 CEST 2010


Revision: 51384
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51384&view=rev
Author:   mthreepwood
Date:     2010-07-27 19:07:39 +0000 (Tue, 27 Jul 2010)

Log Message:
-----------
SCI: Better fix for bug #3035058 - ECOQUEST demo: Missing subtitles

The demo really uses kGetMessage and not kMessage. We now detect which version of the message function is used. Thanks to Walter for pointing this out.

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

Modified: scummvm/trunk/engines/sci/engine/features.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/features.cpp	2010-07-27 18:45:32 UTC (rev 51383)
+++ scummvm/trunk/engines/sci/engine/features.cpp	2010-07-27 19:07:39 UTC (rev 51384)
@@ -38,6 +38,7 @@
 	_doSoundType = SCI_VERSION_NONE;
 	_lofsType = SCI_VERSION_NONE;
 	_gfxFunctionsType = SCI_VERSION_NONE;
+	_messageFunctionType = SCI_VERSION_NONE;
 	_moveCountType = kMoveCountUninitialized;
 
 #ifdef ENABLE_SCI32
@@ -407,6 +408,41 @@
 	return _gfxFunctionsType;
 }
 
+SciVersion GameFeatures::detectMessageFunctionType() {
+	if (_messageFunctionType != SCI_VERSION_NONE)
+		return _messageFunctionType;
+
+	if (getSciVersion() > SCI_VERSION_1_1) {
+		_messageFunctionType = SCI_VERSION_1_1;
+		return _messageFunctionType;
+	} else if (getSciVersion() < SCI_VERSION_1_1) {
+		_messageFunctionType = SCI_VERSION_1_LATE;
+		return _messageFunctionType;
+	}
+
+	Common::List<ResourceId> *resources = g_sci->getResMan()->listResources(kResourceTypeMessage, -1);
+
+	if (resources->empty()) {
+		// No messages found, so this doesn't really matter anyway...
+		_messageFunctionType = SCI_VERSION_1_1;
+		return _messageFunctionType;
+	}
+
+	Resource *res = g_sci->getResMan()->findResource(*resources->begin(), false);
+	assert(res);
+
+	// Only v2 Message resources use the kGetMessage kernel function.
+	// v3-v5 use the kMessage kernel function.
+
+	if (READ_SCI11ENDIAN_UINT32(res->data) / 1000 == 2)
+		_messageFunctionType = SCI_VERSION_1_LATE;
+	else
+		_messageFunctionType = SCI_VERSION_1_1;
+
+	debugC(1, kDebugLevelVM, "Detected message function type: %s", getSciVersionDesc(_messageFunctionType));
+	return _messageFunctionType;
+}
+
 #ifdef ENABLE_SCI32
 bool GameFeatures::autoDetectSci21KernelType() {
 	// First, check if the Sound object is loaded

Modified: scummvm/trunk/engines/sci/engine/features.h
===================================================================
--- scummvm/trunk/engines/sci/engine/features.h	2010-07-27 18:45:32 UTC (rev 51383)
+++ scummvm/trunk/engines/sci/engine/features.h	2010-07-27 19:07:39 UTC (rev 51384)
@@ -66,6 +66,12 @@
 	 * @return Graphics functions type, SCI_VERSION_0_EARLY / SCI_VERSION_0_LATE
 	 */
 	SciVersion detectGfxFunctionsType();
+
+	/**
+	 * Autodetects the message function used
+	 * @return Message function type, SCI_VERSION_1_LATE / SCI_VERSION_1_1
+	 */
+	SciVersion detectMessageFunctionType();
 	
 #ifdef ENABLE_SCI32
 	/**
@@ -105,7 +111,7 @@
 	bool autoDetectSci21KernelType();
 #endif
 
-	SciVersion _doSoundType, _setCursorType, _lofsType, _gfxFunctionsType;
+	SciVersion _doSoundType, _setCursorType, _lofsType, _gfxFunctionsType, _messageFunctionType;
 #ifdef ENABLE_SCI32
 	SciVersion _sci21KernelType;
 #endif

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2010-07-27 18:45:32 UTC (rev 51383)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2010-07-27 19:07:39 UTC (rev 51384)
@@ -670,7 +670,7 @@
 	return true;
 }
 
-void Kernel::setDefaultKernelNames() {
+void Kernel::setDefaultKernelNames(GameFeatures *features) {
 	_kernelNames = Common::StringArray(s_defaultKernelNames, ARRAYSIZE(s_defaultKernelNames));
 
 	// Some (later) SCI versions replaced CanBeHere by CantBeHere
@@ -722,7 +722,11 @@
 		}
 
 		_kernelNames[0x71] = "PalVary";
-		_kernelNames[0x7c] = "Message";
+
+		// At least EcoQuest 1 demo uses kGetMessage instead of kMessage.
+		// Detect which function to use.
+		if (features->detectMessageFunctionType() == SCI_VERSION_1_1)
+			_kernelNames[0x7c] = "Message";
 		break;
 
 	default:
@@ -774,7 +778,7 @@
 		setKernelNamesSci2();
 	else
 #endif
-		setDefaultKernelNames();
+		setDefaultKernelNames(features);
 
 	mapFunctions();
 }

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2010-07-27 18:45:32 UTC (rev 51383)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2010-07-27 19:07:39 UTC (rev 51384)
@@ -225,7 +225,7 @@
 	/**
 	 * Sets the default kernel function names, based on the SCI version used.
 	 */
-	void setDefaultKernelNames();
+	void setDefaultKernelNames(GameFeatures *features);
 
 #ifdef ENABLE_SCI32
 	/**

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2010-07-27 18:45:32 UTC (rev 51383)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2010-07-27 19:07:39 UTC (rev 51384)
@@ -456,8 +456,7 @@
 	K_MESSAGE_REFNOUN,
 	K_MESSAGE_PUSH,
 	K_MESSAGE_POP,
-	K_MESSAGE_LASTMESSAGE,
-	K_MESSAGE_ECOQUEST1_DEMO = 99
+	K_MESSAGE_LASTMESSAGE
 };
 
 reg_t kGetMessage(EngineState *s, int argc, reg_t *argv) {
@@ -559,18 +558,6 @@
 
 		return NULL_REG;
 	}
-	case K_MESSAGE_ECOQUEST1_DEMO:
-		// The EcoQuest 1 demo uses a special version of kMessage. It's one of the
-		// earliest SCI 1.1 games. The noun is always 99 in this case, so we can
-		// treat it as a subop. If any other games require this syntax, we can change
-		// this to work with those games too.
-
-		if (g_sci->getGameId() != GID_ECOQUEST || !g_sci->isDemo())
-			error("kMessage called with EcoQuest 1 demo syntax in a different game");
-
-		tuple.noun = argv[0].toUint16();
-		tuple.verb = argv[2].toUint16();
-		return make_reg(0, s->_msgState->getMessage(argv[1].toUint16(), tuple, argv[3]));
 	default:
 		warning("Message: subfunction %i invoked (not implemented)", func);
 	}


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