diff options
author | Filippos Karapetis | 2010-06-03 21:57:49 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-06-03 21:57:49 +0000 |
commit | 1973bd5a71fc2847b123e0f1d769220210eceba4 (patch) | |
tree | 7e3ee0f6005e48bc7ff4ff5c4b76d75ab3e46af6 /engines/sci | |
parent | 576306c323d092b590e184ececb70745633aae4e (diff) | |
download | scummvm-rg350-1973bd5a71fc2847b123e0f1d769220210eceba4.tar.gz scummvm-rg350-1973bd5a71fc2847b123e0f1d769220210eceba4.tar.bz2 scummvm-rg350-1973bd5a71fc2847b123e0f1d769220210eceba4.zip |
Added channel remapping to MidiParser_SCI (currently unused)
svn-id: r49414
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/sound/midiparser_sci.cpp | 16 | ||||
-rw-r--r-- | engines/sci/sound/midiparser_sci.h | 11 |
2 files changed, 25 insertions, 2 deletions
diff --git a/engines/sci/sound/midiparser_sci.cpp b/engines/sci/sound/midiparser_sci.cpp index 2068ea9a33..83a67509cf 100644 --- a/engines/sci/sound/midiparser_sci.cpp +++ b/engines/sci/sound/midiparser_sci.cpp @@ -60,6 +60,9 @@ MidiParser_SCI::MidiParser_SCI(SciVersion soundVersion) : _dataincToAdd = 0; _resetOnPause = false; _channelsUsed = 0; + + for (int i = 0; i < 16; i++) + _channelRemap[i] = i; } MidiParser_SCI::~MidiParser_SCI() { @@ -120,17 +123,26 @@ void MidiParser_SCI::unloadMusic() { // Center the pitch wheels and hold pedal in preparation for the next piece of music if (_driver) { for (int i = 0; i < 16; ++i) { - if (_channelsUsed & (1 << i)) { + if (isChannelUsed(i)) { _driver->send(0xE0 | i, 0, 0x40); // Reset pitch wheel _driver->send(0xB0 | i, 0x40, 0); // Reset hold pedal } } } + + for (int i = 0; i < 16; i++) + _channelRemap[i] = i; } void MidiParser_SCI::parseNextEvent(EventInfo &info) { + byte remappedChannel = _channelRemap[info.channel()]; + + // Remap channel. Keep the upper 4 bits (command code) and change + // the lower 4 bits (channel) + info.event = (info.event & 0xF0) | (remappedChannel & 0xF); + // Monitor which channels are used by this song - _channelsUsed |= (1 << info.channel()); + setChannelUsed(info.channel()); // Set signal AFTER waiting for delta, otherwise we would set signal too soon resulting in all sorts of bugs if (_dataincAdd) { diff --git a/engines/sci/sound/midiparser_sci.h b/engines/sci/sound/midiparser_sci.h index f95c71ce2f..d9ae583aff 100644 --- a/engines/sci/sound/midiparser_sci.h +++ b/engines/sci/sound/midiparser_sci.h @@ -71,7 +71,16 @@ public: jumpToTick(0); } + void remapChannel(byte channel, byte newChannel) { + assert(channel < 0xF); // don't touch special SCI channel 15 + assert(newChannel < 0xF); // don't touch special SCI channel 15 + _channelRemap[channel] = newChannel; + } + protected: + bool isChannelUsed(byte channel) { return _channelsUsed & (1 << channel); } + void setChannelUsed(byte channel) { _channelsUsed |= (1 << channel); } + void parseNextEvent(EventInfo &info); byte *midiMixChannels(); byte *midiFilterChannels(int channelMask); @@ -93,6 +102,8 @@ protected: // A 16-bit mask, containing the channels used // by the currently parsed song uint16 _channelsUsed; + + byte _channelRemap[16]; }; } // End of namespace Sci |