diff options
author | athrxx | 2011-11-01 14:48:35 +0100 |
---|---|---|
committer | athrxx | 2011-11-01 20:31:59 +0100 |
commit | 9b838239ebed10e75b3806fd7c3a97922d2c0aa5 (patch) | |
tree | d097b2df2c30b706ab0ce3192c9d55c5be9052f9 | |
parent | 6a91508475aad570e266c84b33c7f56835e7cf6f (diff) | |
download | scummvm-rg350-9b838239ebed10e75b3806fd7c3a97922d2c0aa5.tar.gz scummvm-rg350-9b838239ebed10e75b3806fd7c3a97922d2c0aa5.tar.bz2 scummvm-rg350-9b838239ebed10e75b3806fd7c3a97922d2c0aa5.zip |
SCI: (KQ5 FM-Towns) - fix voice mapping
(Driver channels would get reserved via the 0x4b control, but they would never get released)
-rw-r--r-- | engines/sci/sound/music.cpp | 24 | ||||
-rw-r--r-- | engines/sci/sound/music.h | 1 |
2 files changed, 23 insertions, 2 deletions
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index 6461c93988..e39cbba980 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -44,8 +44,10 @@ SciMusic::SciMusic(SciVersion soundVersion) // operations _playList.reserve(10); - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { _usedChannel[i] = 0; + _channelRemap[i] = -1; + } _queuedCommands.reserve(1000); } @@ -355,6 +357,7 @@ int16 SciMusic::tryToOwnChannel(MusicEntry *caller, int16 bestChannel) { if (!_usedChannel[bestChannel]) { // currently unused, so give it to caller directly _usedChannel[bestChannel] = caller; + _channelRemap[bestChannel] = bestChannel; return bestChannel; } // otherwise look for unused channel @@ -363,6 +366,7 @@ int16 SciMusic::tryToOwnChannel(MusicEntry *caller, int16 bestChannel) { continue; if (!_usedChannel[channelNr]) { _usedChannel[channelNr] = caller; + _channelRemap[bestChannel] = channelNr; return channelNr; } } @@ -375,8 +379,24 @@ int16 SciMusic::tryToOwnChannel(MusicEntry *caller, int16 bestChannel) { void SciMusic::freeChannels(MusicEntry *caller) { // Remove used channels for (int i = 0; i < 15; i++) { - if (_usedChannel[i] == caller) + if (_usedChannel[i] == caller) { + if (_channelRemap[i] != -1) { + // athrxx: The original handles this differently. It seems to be checking for (and effecting) necessary + // remaps / resets etc. more or less all the time. There are several more tables to keep track of everything. + // I don't know whether all of that is needed and to which SCI versions it applies, though. + // At least it is necessary to release the allocated channels inside the driver. Otherwise these channels + // won't be available any more (e.g. after half of the KQ5 FM-Towns intro there will be no more music + // since the driver can't pick up any more channels). The channels also have to be reset to + // default values, since the original does the same (although in a different manny) and the music will be wrong + // otherwise (at least KQ5 FM-Towns). + + sendMidiCommand(0x4000e0 | _channelRemap[i]); // Reset pitch wheel + sendMidiCommand(0x0040b0 | _channelRemap[i]); // Release pedal + sendMidiCommand(0x004bb0 | _channelRemap[i]); // Release assigned driver channels + } _usedChannel[i] = 0; + _channelRemap[i] = -1; + } } // Also tell midiparser, that he lost ownership caller->pMidiParser->lostChannels(); diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 8577ed7313..fa6f538a7e 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -219,6 +219,7 @@ private: bool _soundOn; byte _masterVolume; MusicEntry *_usedChannel[16]; + int8 _channelRemap[16]; int8 _globalReverb; MidiCommandQueue _queuedCommands; |