aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound/drivers/midi.cpp
diff options
context:
space:
mode:
authorathrxx2019-03-27 18:18:08 +0100
committerFilippos Karapetis2019-04-02 20:45:35 +0300
commitbba5513a2d8a6bce05c8bb6289d1a8deff743e4b (patch)
tree23632f6a38e68d28d5b63810d8ddca69437fe54c /engines/sci/sound/drivers/midi.cpp
parent5d4e22ebc9f679cea041beead8269d626d7906f9 (diff)
downloadscummvm-rg350-bba5513a2d8a6bce05c8bb6289d1a8deff743e4b.tar.gz
scummvm-rg350-bba5513a2d8a6bce05c8bb6289d1a8deff743e4b.tar.bz2
scummvm-rg350-bba5513a2d8a6bce05c8bb6289d1a8deff743e4b.zip
SCI: - update MT32/GM driver initTrack method
This adds specific support for SCI0_EARLY targets. Based on and tested with Christmas Cards 1988. I've not added the volume reset (neither for SCI0_EARLY nor SCI0_LATE), since the ScummVM driver seems to handle volume differently on purpose (probably based on SCI1?).
Diffstat (limited to 'engines/sci/sound/drivers/midi.cpp')
-rw-r--r--engines/sci/sound/drivers/midi.cpp55
1 files changed, 39 insertions, 16 deletions
diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index 4f3f0da4b0..eaa3258e45 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -509,30 +509,53 @@ void MidiPlayer_Midi::initTrack(SciSpan<const byte> &header) {
// or MT32.DRV itself.
setReverb(_defaultReverb);
- /* TODO: I have no idea what SCI_VERSION_0_EARLY games do here.
- Therefore the extra code is restricted to SCI_VERSION_0_LATE for now.*/
- if (_version == SCI_VERSION_0_EARLY)
- return;
-
uint8 caps = header.getInt8At(0);
- if (caps != 0 && caps != 2)
+ if (caps != 0 && (_version == SCI_VERSION_0_EARLY || caps != 2))
return;
- uint8 readPos = 3;
- byte msg[9];
+ uint8 readPos = 1;
uint8 flags = 0;
+ byte msg[9];
+ memset(msg, 0x10, 9);
- for (int i = 1; i < 9; ++i) {
- readPos++;
- flags = header.getInt8At(readPos++);
- msg[i - 1] = (flags & 1) ? i : 0x10;
- }
+ if (_version == SCI_VERSION_0_EARLY) {
+ uint8 writePos = 0;
+ for (int i = 0; i < 16; ++i) {
+ flags = header.getInt8At(readPos++);
+ if (flags & 8) {
+ // If both flags 1 and 8 are set this will make the driver assign that channel to MT32 part 9.
+ // This suggests that any one channel could be the rhythm channel. I don't know whether this has any practical relevance.
+ // A channel not flagged with 8 can also be assigned to MT-32 part 9 if it just happens to be the last channel. This is how
+ // it is done in the tracks that I have seen so far. Flag 8 without flag 1 is the control channel (not handled in the driver).
+ if (flags & 1) {
+ if (i < 11) {
+ msg[8] = i;
+ writePos++;
+ }
+ } else {
+ debugC(9, kDebugLevelSound, "MidiPlayer_Midi::initTrack(): Control channel found: 0x%.02x", i);
+ }
+ } else if (i < 11 && (flags & 1)) {
+ assert(writePos < 9);
+ msg[writePos++] = i;
+ }
+ }
- flags = header.getInt8At(readPos);
- msg[8] = (flags & 0x80) ? 9 : 0x10;
+ } else {
+ readPos = 3;
+ for (int i = 1; i < 9; ++i) {
+ readPos++;
+ flags = header.getInt8At(readPos++);
+ msg[i - 1] = (flags & 1) ? i : 0x10;
+ }
+
+ flags = header.getInt8At(readPos);
+ msg[8] = (flags & 0x80) ? 9 : 0x10;
+ }
// assign channels
- Sci::SciSpan<const byte> s(msg, 9);
+ debugC(5, kDebugLevelSound, "MidiPlayer_Midi::initTrack(): Channels assigned to MT-32 parts: 0x%.02x 0x%.02x 0x%.02x 0x%.02x 0x%.02x 0x%.02x 0x%.02x 0x%.02x 0x%.02x", msg[0], msg[1], msg[2], msg[3], msg[4], msg[5], msg[6], msg[7], msg[8]);
+ Sci::SciSpan<const byte> s(msg, 9);
sendMt32SysEx(0x10000D, s, false);
}