diff options
-rw-r--r-- | engines/sci/sound/midiparser_sci.cpp | 20 | ||||
-rw-r--r-- | engines/sci/sound/midiparser_sci.h | 1 | ||||
-rw-r--r-- | engines/sci/sound/music.cpp | 2 |
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)); } |