aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound
diff options
context:
space:
mode:
authorMartin Kiewitz2010-06-19 20:00:32 +0000
committerMartin Kiewitz2010-06-19 20:00:32 +0000
commit089f5bba1491be81cebc495a7e5245fe045da323 (patch)
treea590bc48ee4c9eedc88b4d725fa3dd14e4361aed /engines/sci/sound
parent24459b5842e6cf8ef906e81c9b43c36c657f1119 (diff)
downloadscummvm-rg350-089f5bba1491be81cebc495a7e5245fe045da323.tar.gz
scummvm-rg350-089f5bba1491be81cebc495a7e5245fe045da323.tar.bz2
scummvm-rg350-089f5bba1491be81cebc495a7e5245fe045da323.zip
SCI: stopping scripts from sending to unused channels manually (fixes sq1vga)
svn-id: r50060
Diffstat (limited to 'engines/sci/sound')
-rw-r--r--engines/sci/sound/midiparser_sci.cpp20
-rw-r--r--engines/sci/sound/midiparser_sci.h1
-rw-r--r--engines/sci/sound/music.cpp2
3 files changed, 17 insertions, 6 deletions
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp
index 99468fe09c..1cfaadd36d 100644
--- a/engines/sci/sound/midiparser_sci.cpp
+++ b/engines/sci/sound/midiparser_sci.cpp
@@ -144,6 +144,20 @@ void MidiParser_SCI::unloadMusic() {
}
}
+// this is used for scripts sending direct midi commands to us. we verify in that case that the channel is actually
+// used
+void MidiParser_SCI::sendManuallyToDriver(uint32 b) {
+ byte midiChannel = b & 0xf;
+
+ if (!_channelUsed[midiChannel]) {
+ // scripts trying to send to unused channel
+ // this happens at least in sq1vga right at the start, it's a script issue
+ return;
+ }
+
+ sendToDriver(b);
+}
+
void MidiParser_SCI::sendToDriver(uint32 b) {
byte midiChannel = b & 0xf;
@@ -161,11 +175,7 @@ void MidiParser_SCI::sendToDriver(uint32 b) {
return;
// Channel remapping
int16 realChannel = _channelRemap[midiChannel];
- if (realChannel == -1) {
- // FIXME: Happens in SQ1VGA when the game starts
- warning("Attempt to send to uninitialized channel %d", midiChannel);
- return;
- }
+ assert(realChannel != -1);
b = (b & 0xFFFFFFF0) | realChannel;
_driver->send(b);
diff --git a/engines/sci/sound/midiparser_sci.h b/engines/sci/sound/midiparser_sci.h
index abedafdde0..31a3b923fb 100644
--- a/engines/sci/sound/midiparser_sci.h
+++ b/engines/sci/sound/midiparser_sci.h
@@ -80,6 +80,7 @@ public:
void sendToDriver(byte status, byte firstOp, byte secondOp) {
sendToDriver(status | ((uint32)firstOp << 8) | ((uint32)secondOp << 16));
}
+ void sendManuallyToDriver(uint32 b);
protected:
void parseNextEvent(EventInfo &info);
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index 6e12ac7409..8499b6da59 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -463,7 +463,7 @@ void SciMusic::sendMidiCommand(uint32 cmd) {
void SciMusic::sendMidiCommand(MusicEntry *pSnd, uint32 cmd) {
if (pSnd->pMidiParser)
- pSnd->pMidiParser->sendToDriver(cmd);
+ pSnd->pMidiParser->sendManuallyToDriver(cmd);
else
error("tried to cmdSendMidi on non midi slot (%04x:%04x)", PRINT_REG(pSnd->soundObj));
}