aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/features.cpp36
-rw-r--r--engines/sci/engine/features.h8
-rw-r--r--engines/sci/engine/kernel.cpp10
-rw-r--r--engines/sci/engine/kernel.h2
-rw-r--r--engines/sci/engine/kstring.cpp15
5 files changed, 52 insertions, 19 deletions
diff --git a/engines/sci/engine/features.cpp b/engines/sci/engine/features.cpp
index 71f99dbbf5..315c86c56c 100644
--- a/engines/sci/engine/features.cpp
+++ b/engines/sci/engine/features.cpp
@@ -38,6 +38,7 @@ GameFeatures::GameFeatures(SegManager *segMan, Kernel *kernel) : _segMan(segMan)
_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 @@ SciVersion GameFeatures::detectGfxFunctionsType() {
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
diff --git a/engines/sci/engine/features.h b/engines/sci/engine/features.h
index 5b383746d8..167c207437 100644
--- a/engines/sci/engine/features.h
+++ b/engines/sci/engine/features.h
@@ -66,6 +66,12 @@ public:
* @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 @@ private:
bool autoDetectSci21KernelType();
#endif
- SciVersion _doSoundType, _setCursorType, _lofsType, _gfxFunctionsType;
+ SciVersion _doSoundType, _setCursorType, _lofsType, _gfxFunctionsType, _messageFunctionType;
#ifdef ENABLE_SCI32
SciVersion _sci21KernelType;
#endif
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index 21331335f7..58ac35462e 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -670,7 +670,7 @@ bool Kernel::debugSetFunctionLogging(const char *kernelName, bool logging) {
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 @@ void Kernel::setDefaultKernelNames() {
}
_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 @@ void Kernel::loadKernelNames(GameFeatures *features) {
setKernelNamesSci2();
else
#endif
- setDefaultKernelNames();
+ setDefaultKernelNames(features);
mapFunctions();
}
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index f7b46b81dd..227eb19c01 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -225,7 +225,7 @@ private:
/**
* Sets the default kernel function names, based on the SCI version used.
*/
- void setDefaultKernelNames();
+ void setDefaultKernelNames(GameFeatures *features);
#ifdef ENABLE_SCI32
/**
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 76541f78e0..3a7bb30c80 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -456,8 +456,7 @@ enum kMessageFunc {
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 @@ reg_t kMessage(EngineState *s, int argc, reg_t *argv) {
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);
}