aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorathrxx2019-07-24 00:08:43 +0200
committerathrxx2019-07-24 15:47:06 +0200
commitfce453dc43bf1029c14923ee927cfaba1b23a34c (patch)
treec9c3f00c0dfe544d56479d0f923f27198419af42 /engines/sci
parent708f6ca4be3892bcde5cc9cc5487bba230c7c175 (diff)
downloadscummvm-rg350-fce453dc43bf1029c14923ee927cfaba1b23a34c.tar.gz
scummvm-rg350-fce453dc43bf1029c14923ee927cfaba1b23a34c.tar.bz2
scummvm-rg350-fce453dc43bf1029c14923ee927cfaba1b23a34c.zip
SCI: (CMS sound driver) - handle invalid program changes
(This triggered an assert in PQ2 at the airport. I've added a warning instead, since the original driver has no handling for that sort of thing. Invalid programs will simply point into invalid memory blocks)
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/sound/drivers/cms.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/engines/sci/sound/drivers/cms.cpp b/engines/sci/sound/drivers/cms.cpp
index 750de85229..0f79251ea7 100644
--- a/engines/sci/sound/drivers/cms.cpp
+++ b/engines/sci/sound/drivers/cms.cpp
@@ -334,8 +334,14 @@ void CMSVoice_V0::stop() {
}
void CMSVoice_V0::programChange(int program) {
- assert(program < 128);
- if (program == 127) {
+ if (program > 127) {
+ // I encountered this with PQ2 at the airport (program 204 sent on part 13). The original driver does not really handle that.
+ // In fact, it even interprets this value as signed so it will not point into the instrument data buffer, but into a random
+ // invalid memory location (in the case of 204 it will read a value of 8 from the device init data array). Since there seems
+ // to be no effect on the sound I don't emulate this (mis)behaviour.
+ warning("CMSVoice_V0::programChange:: Invalid program '%d' requested on midi channel '%d'", program, _assign);
+ program = 0;
+ } else if (program == 127) {
// This seems to replace the start of track offset with the current position so that 0xFC (kEndOfTrack)
// midi events would not reset the track to the start, but to the current position instead. This cannot
// be handled here. All versions of the SCI0 driver that I have seen so far do this. Still, I somehow