aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kernel.cpp38
-rw-r--r--engines/sci/engine/kernel.h1
-rw-r--r--engines/sci/engine/ksound.cpp49
-rw-r--r--engines/sci/engine/savegame.cpp2
-rw-r--r--engines/sci/engine/vm.cpp28
5 files changed, 69 insertions, 49 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp
index c5f5e9e61a..501ad54dfa 100644
--- a/engines/sci/engine/kernel.cpp
+++ b/engines/sci/engine/kernel.cpp
@@ -254,19 +254,19 @@ struct SciKernelMapSubEntry {
#define MAP_CALL(_name_) #_name_, k##_name_
static const SciKernelMapSubEntry kDoSound_subops[] = {
- { SIG_SOUNDSCI0, 0, MAP_CALL(DoSoundInit), "(o)", NULL },
- { SIG_SOUNDSCI0, 1, MAP_CALL(DoSoundPlay), "(o)", NULL },
- { SIG_SOUNDSCI0, 2, MAP_CALL(DoSoundDummy), "(o)", NULL },
- { SIG_SOUNDSCI0, 3, MAP_CALL(DoSoundDispose), "(o)", NULL },
- { SIG_SOUNDSCI0, 4, MAP_CALL(DoSoundMute), "(o)", NULL },
- { SIG_SOUNDSCI0, 5, MAP_CALL(DoSoundStop), "(o)", NULL },
- { SIG_SOUNDSCI0, 6, MAP_CALL(DoSoundPause), "(o)", NULL },
- { SIG_SOUNDSCI0, 7, MAP_CALL(DoSoundResume), "(o)", NULL },
- { SIG_SOUNDSCI0, 8, MAP_CALL(DoSoundMasterVolume), "(o)", NULL },
- { SIG_SOUNDSCI0, 9, MAP_CALL(DoSoundUpdate), "(o)", NULL },
- { SIG_SOUNDSCI0, 10, MAP_CALL(DoSoundFade), "(o)", NULL },
- { SIG_SOUNDSCI0, 11, MAP_CALL(DoSoundGetPolyphony), "(o)", NULL },
- { SIG_SOUNDSCI0, 12, MAP_CALL(DoSoundStop), "(o)", NULL },
+ { SIG_SOUNDSCI0, 0, MAP_CALL(DoSoundInit), "o", NULL },
+ { SIG_SOUNDSCI0, 1, MAP_CALL(DoSoundPlay), "o", NULL },
+ { SIG_SOUNDSCI0, 2, MAP_CALL(DoSoundDummy), "o", NULL },
+ { SIG_SOUNDSCI0, 3, MAP_CALL(DoSoundDispose), "o", NULL },
+ { SIG_SOUNDSCI0, 4, MAP_CALL(DoSoundMute), "(i)", NULL },
+ { SIG_SOUNDSCI0, 5, MAP_CALL(DoSoundStop), "o", NULL },
+ { SIG_SOUNDSCI0, 6, MAP_CALL(DoSoundPause), "[o0]", NULL },
+ { SIG_SOUNDSCI0, 7, MAP_CALL(DoSoundResume), "o", NULL },
+ { SIG_SOUNDSCI0, 8, MAP_CALL(DoSoundMasterVolume), "(i)", NULL },
+ { SIG_SOUNDSCI0, 9, MAP_CALL(DoSoundUpdate), "o", NULL },
+ { SIG_SOUNDSCI0, 10, MAP_CALL(DoSoundFade), "o", NULL },
+ { SIG_SOUNDSCI0, 11, MAP_CALL(DoSoundGetPolyphony), "", NULL },
+ { SIG_SOUNDSCI0, 12, MAP_CALL(DoSoundStopAll), "", NULL },
{ SIG_SOUNDSCI1EARLY, 0, MAP_CALL(DoSoundMasterVolume), NULL, NULL },
{ SIG_SOUNDSCI1EARLY, 1, MAP_CALL(DoSoundMute), NULL, NULL },
{ SIG_SOUNDSCI1EARLY, 2, MAP_CALL(DoSoundDummy), NULL, NULL },
@@ -274,19 +274,19 @@ static const SciKernelMapSubEntry kDoSound_subops[] = {
{ SIG_SOUNDSCI1EARLY, 4, MAP_CALL(DoSoundUpdate), NULL, NULL },
{ SIG_SOUNDSCI1EARLY, 5, MAP_CALL(DoSoundInit), NULL, NULL },
{ SIG_SOUNDSCI1EARLY, 6, MAP_CALL(DoSoundDispose), NULL, NULL },
- { SIG_SOUNDSCI1EARLY, 7, MAP_CALL(DoSoundPlay), NULL, NULL },
+ { SIG_SOUNDSCI1EARLY, 7, MAP_CALL(DoSoundPlay), "oi", NULL },
{ SIG_SOUNDSCI1EARLY, 8, MAP_CALL(DoSoundStop), NULL, NULL },
- { SIG_SOUNDSCI1EARLY, 9, MAP_CALL(DoSoundPause), NULL, NULL },
- { SIG_SOUNDSCI1EARLY, 10, MAP_CALL(DoSoundFade), NULL, NULL },
+ { SIG_SOUNDSCI1EARLY, 9, MAP_CALL(DoSoundPause), "[o0]i", NULL },
+ { SIG_SOUNDSCI1EARLY, 10, MAP_CALL(DoSoundFade), "oiiii", NULL },
{ SIG_SOUNDSCI1EARLY, 11, MAP_CALL(DoSoundUpdateCues), "o", NULL },
{ SIG_SOUNDSCI1EARLY, 12, MAP_CALL(DoSoundSendMidi), "oiiii", NULL },
- { SIG_SOUNDSCI1EARLY, 13, MAP_CALL(DoSoundReverb), "i", NULL },
+ { SIG_SOUNDSCI1EARLY, 13, MAP_CALL(DoSoundReverb), "oi", NULL },
{ SIG_SOUNDSCI1EARLY, 14, MAP_CALL(DoSoundSetHold), "oi", NULL },
{ SIG_SOUNDSCI1EARLY, 15, MAP_CALL(DoSoundDummy), "", NULL },
// ^^ Longbow demo
{ SIG_SOUNDSCI1LATE, 0, MAP_CALL(DoSoundMasterVolume), NULL, NULL },
{ SIG_SOUNDSCI1LATE, 1, MAP_CALL(DoSoundMute), NULL, NULL },
- { SIG_SOUNDSCI1LATE, 2, MAP_CALL(DoSoundDummy), NULL, NULL },
+ { SIG_SOUNDSCI1LATE, 2, MAP_CALL(DoSoundDummy), "", NULL },
{ SIG_SOUNDSCI1LATE, 3, MAP_CALL(DoSoundGetPolyphony), NULL, NULL },
{ SIG_SOUNDSCI1LATE, 4, MAP_CALL(DoSoundGetAudioCapability), "", NULL },
{ SIG_SOUNDSCI1LATE, 5, MAP_CALL(DoSoundSuspend), "", NULL },
@@ -295,7 +295,7 @@ static const SciKernelMapSubEntry kDoSound_subops[] = {
{ SIG_SOUNDSCI1LATE, 8, MAP_CALL(DoSoundPlay), NULL, NULL },
{ SIG_SOUNDSCI1LATE, 9, MAP_CALL(DoSoundStop), NULL, NULL },
{ SIG_SOUNDSCI1LATE, 10, MAP_CALL(DoSoundPause), NULL, NULL },
- { SIG_SOUNDSCI1LATE, 11, MAP_CALL(DoSoundFade), NULL, NULL },
+ { SIG_SOUNDSCI1LATE, 11, MAP_CALL(DoSoundFade), "oiiii(i)", NULL },
{ SIG_SOUNDSCI1LATE, 12, MAP_CALL(DoSoundSetHold), NULL, NULL },
{ SIG_SOUNDSCI1LATE, 13, MAP_CALL(DoSoundDummy), NULL, NULL },
{ SIG_SOUNDSCI1LATE, 14, MAP_CALL(DoSoundSetVolume), "oi", NULL },
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 7fa3916b31..a5ea379ba6 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -473,6 +473,7 @@ reg_t kDoSoundDummy(EngineState *s, int argc, reg_t *argv);
reg_t kDoSoundDispose(EngineState *s, int argc, reg_t *argv);
reg_t kDoSoundMute(EngineState *s, int argc, reg_t *argv);
reg_t kDoSoundStop(EngineState *s, int argc, reg_t *argv);
+reg_t kDoSoundStopAll(EngineState *s, int argc, reg_t *argv);
reg_t kDoSoundPause(EngineState *s, int argc, reg_t *argv);
reg_t kDoSoundResume(EngineState *s, int argc, reg_t *argv);
reg_t kDoSoundMasterVolume(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 4ecbc523d5..69ae68674b 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -41,32 +41,33 @@ namespace Sci {
reg_t kDoSound(EngineState *s, int argc, reg_t *argv) {
if (!s)
return make_reg(0, g_sci->_features->detectDoSoundType());
- return g_sci->_soundCmd->parseCommand(argc, argv, s->r_acc);
+ error("not supposed to call this");
}
-#define CREATE_FORWARD(_name_, _forward_) reg_t k##_name_(EngineState *s, int argc, reg_t *argv) { return g_sci->_##_forward_(argc, argv, s->r_acc); }
-
-CREATE_FORWARD(DoSoundInit, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundPlay, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundDummy, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundDispose, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundMute, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundStop, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundPause, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundResume, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundMasterVolume, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundUpdate, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundFade, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundGetPolyphony, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundUpdateCues, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundSendMidi, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundReverb, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundSetHold, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundGetAudioCapability, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundSuspend, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundSetVolume, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundSetPriority, soundCmd->parseCommand)
-CREATE_FORWARD(DoSoundSetLoop, soundCmd->parseCommand)
+#define CREATE_DOSOUND_FORWARD(_name_) reg_t k##_name_(EngineState *s, int argc, reg_t *argv) { return g_sci->_soundCmd->k##_name_(argc, argv, s->r_acc); }
+
+CREATE_DOSOUND_FORWARD(DoSoundInit)
+CREATE_DOSOUND_FORWARD(DoSoundPlay)
+CREATE_DOSOUND_FORWARD(DoSoundDummy)
+CREATE_DOSOUND_FORWARD(DoSoundDispose)
+CREATE_DOSOUND_FORWARD(DoSoundMute)
+CREATE_DOSOUND_FORWARD(DoSoundStop)
+CREATE_DOSOUND_FORWARD(DoSoundStopAll)
+CREATE_DOSOUND_FORWARD(DoSoundPause)
+CREATE_DOSOUND_FORWARD(DoSoundResume)
+CREATE_DOSOUND_FORWARD(DoSoundMasterVolume)
+CREATE_DOSOUND_FORWARD(DoSoundUpdate)
+CREATE_DOSOUND_FORWARD(DoSoundFade)
+CREATE_DOSOUND_FORWARD(DoSoundGetPolyphony)
+CREATE_DOSOUND_FORWARD(DoSoundUpdateCues)
+CREATE_DOSOUND_FORWARD(DoSoundSendMidi)
+CREATE_DOSOUND_FORWARD(DoSoundReverb)
+CREATE_DOSOUND_FORWARD(DoSoundSetHold)
+CREATE_DOSOUND_FORWARD(DoSoundGetAudioCapability)
+CREATE_DOSOUND_FORWARD(DoSoundSuspend)
+CREATE_DOSOUND_FORWARD(DoSoundSetVolume)
+CREATE_DOSOUND_FORWARD(DoSoundSetPriority)
+CREATE_DOSOUND_FORWARD(DoSoundSetLoop)
reg_t kDoCdAudio(EngineState *s, int argc, reg_t *argv) {
switch (argv[0].toUint16()) {
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index d1159acbfb..0fe5f2088a 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -607,7 +607,7 @@ void SoundCommandParser::reconstructPlayList(int savegame_version) {
(*i)->volume = readSelectorValue(_segMan, (*i)->soundObj, SELECTOR(vol));
}
- cmdPlaySound((*i)->soundObj, 0);
+ processPlaySound((*i)->soundObj);
}
}
}
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 6973694ea9..a0f38c634c 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -787,16 +787,17 @@ static void callKernelFunc(EngineState *s, int kernelFuncNr, int argc) {
error("Invalid kernel function 0x%x requested", kernelFuncNr);
const KernelFunction &kernelCall = kernel->_kernelFuncs[kernelFuncNr];
+ reg_t *argv = s->xs->sp + 1;
if (kernelCall.signature
- && !kernel->signatureMatch(kernelCall.signature, argc, s->xs->sp + 1)) {
+ && !kernel->signatureMatch(kernelCall.signature, argc, argv)) {
// signature mismatch, check if a workaround is available
bool workaroundFound;
SciTrackOriginReply originReply;
reg_t workaround;
workaround = trackOriginAndFindWorkaround(0, kernelCall.workarounds, workaroundFound, &originReply);
if (!workaroundFound) {
- kernel->signatureDebug(kernelCall.signature, argc, s->xs->sp + 1);
+ kernel->signatureDebug(kernelCall.signature, argc, argv);
error("[VM] k%s (%x) signature mismatch via method %s::%s (script %d, localCall %x)", kernel->getKernelName(kernelFuncNr).c_str(), kernelFuncNr, originReply.objectName.c_str(), originReply.methodName.c_str(), originReply.scriptNr, originReply.localCallOffset);
}
// FIXME: implement some real workaround type logic - ignore call, still do call etc.
@@ -804,8 +805,6 @@ static void callKernelFunc(EngineState *s, int kernelFuncNr, int argc) {
return;
}
- reg_t *argv = s->xs->sp + 1;
-
if (!kernelCall.isDummy) {
// Add stack frame to indicate we're executing a callk.
// This is useful in debugger backtraces if this
@@ -817,7 +816,26 @@ static void callKernelFunc(EngineState *s, int kernelFuncNr, int argc) {
xstack->type = EXEC_STACK_TYPE_KERNEL;
// Call kernel function
- s->r_acc = kernelCall.function(s, argc, argv);
+ if (!kernelCall.subFunctionCount) {
+ s->r_acc = kernelCall.function(s, argc, argv);
+ } else {
+ // Sub-functions available, check signature and call that one directly
+ if (argc < 1)
+ error("[VM] k%s: no subfunction-id parameter given");
+ const uint16 subId = argv[0].toUint16();
+ // Skip over subfunction-id
+ argc--;
+ argv++;
+ if (subId >= kernelCall.subFunctionCount)
+ error("[VM] k%s: subfunction-id %d requested, but not available", kernelCall.origName, subId);
+ const KernelSubFunction &kernelSubCall = kernelCall.subFunctions[subId];
+ if (!kernel->signatureMatch(kernelSubCall.signature, argc, argv)) {
+ // Signature mismatch
+ kernel->signatureDebug(kernelSubCall.signature, argc, argv);
+ error("[VM] k%s: subfunction signature mismatch", kernelSubCall.name);
+ }
+ s->r_acc = kernelSubCall.function(s, argc, argv);
+ }
#if 0
// Used for debugging