diff --git a/backends/midi/adlib.cpp b/backends/midi/adlib.cpp index dfa3d9aab1d..a1387cd406b 100644 --- a/backends/midi/adlib.cpp +++ b/backends/midi/adlib.cpp @@ -73,10 +73,11 @@ private: bool _allocated; byte _channel; - void init (MidiDriver_ADLIB *owner); + void init (MidiDriver_ADLIB *owner, byte channel); void allocate() { _allocated = true; } public: + byte getNumber() { return _channel; } void release() { _allocated = false; } // Regular messages @@ -572,8 +573,9 @@ private: // MidiChannel method implementations -void AdlibPart::init (MidiDriver_ADLIB *owner) { +void AdlibPart::init (MidiDriver_ADLIB *owner, byte channel) { _owner = owner; + _channel = channel; } @@ -715,7 +717,7 @@ MidiDriver_ADLIB::MidiDriver_ADLIB() { uint i; for (i = 0; i < ARRAYSIZE(_parts); ++i) { - _parts[i].init (this); + _parts[i].init (this, i); } _game_SmallHeader = false; _isOpen = false; diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 096b165bfef..a39834d96c4 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -44,19 +44,7 @@ #define MDPG_TAG "MDpg" #define MDHD_TAG "MDhd" -#ifdef FORCE_MT32_SOUNDS -static const byte mt32_to_gmidi[128] = { -// 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0x - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, // 1x - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, // 2x - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // 3x - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 4x - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 5x - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, // 6x - 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127 // 7x -}; -#else +#ifndef FORCE_MT32_SOUNDS // Roland to General Midi patch table. Still needs some work. static const byte mt32_to_gmidi[128] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -2302,6 +2290,8 @@ void Player::parse_sysex(byte *p, uint len) // Roland custom instrument definition. part = get_part (p[0] & 0x0F); if (part) { +#ifndef FORCE_MT32_SOUNDS + // Convert to a GM program change. memcpy (buf, p + 6, 10); buf[10] = '\0'; for (b = 0; b < ARRAYSIZE(roland_to_gm_map); ++b) { @@ -2318,6 +2308,11 @@ void Player::parse_sysex(byte *p, uint len) } } warning ("MT-32 instrument \"%s\" not supported yet", buf); +#else + // Send SysEx directly. + p[0] = part->_mc->getNumber(); + part->_mc->device()->sysEx (p - 1, len); +#endif } } else { warning ("Unknown SysEx manufacturer 0x%02X", (int) a); @@ -3661,8 +3656,10 @@ void IMuseGM::midiControl0(byte chan, byte value) void IMuseGM::midiProgram(MidiChannel *mc, byte program, bool mt32emulate) { +#ifndef FORCE_MT32_SOUNDS if (mt32emulate) program = mt32_to_gmidi[program]; +#endif mc->programChange (program); } diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index e5947acffbb..5ff7b47207b 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -236,7 +236,7 @@ void MidiDriver_SEQ::send(uint32 b) void MidiDriver_SEQ::sysEx (byte *msg, uint16 length) { - if (length > 256) { + if (length > 254) { warning ("Cannot send SysEx block - data too large"); return; } @@ -247,12 +247,20 @@ void MidiDriver_SEQ::sysEx (byte *msg, uint16 length) // Should be we using EV_SYSEX instead of SEQ_MIDIPUTC? // I'm not sure how to send EV_SYSEX. + buf[position++] = SEQ_MIDIPUTC; + buf[position++] = 0xFF; + buf[position++] = _device_num; + buf[position++] = 0; for (; length; --length) { buf[position++] = SEQ_MIDIPUTC; buf[position++] = (unsigned char) *chr; buf[position++] = _device_num; buf[position++] = 0; } + buf[position++] = SEQ_MIDIPUTC; + buf[position++] = 0xF7; + buf[position++] = _device_num; + buf[position++] = 0; write (device, buf, position); }