diff options
author | Filippos Karapetis | 2010-01-15 07:40:07 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-01-15 07:40:07 +0000 |
commit | 177cfe4c92085991867fe82ad750e51620f55f6e (patch) | |
tree | 5a728dbe92fdfa367b0afb98314d9ff980d79ba9 | |
parent | 69c1de90e4ee2ad9650ce40a6bd06a296494d160 (diff) | |
download | scummvm-rg350-177cfe4c92085991867fe82ad750e51620f55f6e.tar.gz scummvm-rg350-177cfe4c92085991867fe82ad750e51620f55f6e.tar.bz2 scummvm-rg350-177cfe4c92085991867fe82ad750e51620f55f6e.zip |
When unloading a song, only reset the channels that it actually used, not all channels
svn-id: r47304
-rw-r--r-- | engines/sci/sound/midiparser_sci.cpp | 15 | ||||
-rw-r--r-- | engines/sci/sound/midiparser_sci.h | 4 |
2 files changed, 14 insertions, 5 deletions
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index 00b954c43f..0bf3a09101 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -80,6 +80,8 @@ bool MidiParser_SCI::loadMusic(SoundResource::Track *track, MusicEntry *psnd, in _tracks[0] = _mixedData; setTrack(0); _loopTick = 0; + _channelsUsed = 0; + return true; } @@ -95,17 +97,20 @@ void MidiParser_SCI::unloadMusic() { } // Center the pitch wheels and hold pedal in preparation for the next piece of music - // TODO: We should monitor what channels are used by each song, and only - // reset these channels, not all of them! if (_driver) { for (int i = 0; i < 16; ++i) { - _driver->send(0xE0 | i, 0, 0x40); // Reset pitch wheel - _driver->send(0xB0 | i, 0x40, 0); // Reset hold pedal + if (_channelsUsed & (1 << i)) { + _driver->send(0xE0 | i, 0, 0x40); // Reset pitch wheel + _driver->send(0xB0 | i, 0x40, 0); // Reset hold pedal + } } } } void MidiParser_SCI::parseNextEvent(EventInfo &info) { + // Monitor which channels are used by this song + _channelsUsed |= (1 << info.channel()); + // Set signal AFTER waiting for delta, otherwise we would set signal too soon resulting in all sorts of bugs if (_signalSet) { _signalSet = false; @@ -186,7 +191,7 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) { case 0x46: // LSL3 - binoculars case 0x61: // Iceman (Adlib?) case 0x73: // Hoyle - case 0xd1: // KQ4, when riding the unicorn + case 0xD1: // KQ4, when riding the unicorn // Obscure SCI commands - ignored break; // Standard MIDI commands diff --git a/engines/sci/sound/midiparser_sci.h b/engines/sci/sound/midiparser_sci.h index 5e62e2d7c3..cc97466e37 100644 --- a/engines/sci/sound/midiparser_sci.h +++ b/engines/sci/sound/midiparser_sci.h @@ -84,6 +84,10 @@ protected: bool _signalSet; int16 _signalToSet; + + // A 16-bit mask, containing the channels used + // by the currently parsed song + uint16 _channelsUsed; }; } // End of namespace Sci |