aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound/drivers/midi.cpp
diff options
context:
space:
mode:
authormd52011-02-26 05:16:35 +0200
committermd52011-02-26 05:22:10 +0200
commit318c51a2027b554a5c0bc8b045103026657b7073 (patch)
tree50d645a868fa4ac16f53a07ad9a309b0edceb40b /engines/sci/sound/drivers/midi.cpp
parent67aee1ebd85963b3034103a8681efabb33ea7b85 (diff)
downloadscummvm-rg350-318c51a2027b554a5c0bc8b045103026657b7073.tar.gz
scummvm-rg350-318c51a2027b554a5c0bc8b045103026657b7073.tar.bz2
scummvm-rg350-318c51a2027b554a5c0bc8b045103026657b7073.zip
SCI: Added support for reading data off the MT32.DRV driver found in LSL2 early (bug #3192627)
Diffstat (limited to 'engines/sci/sound/drivers/midi.cpp')
-rw-r--r--engines/sci/sound/drivers/midi.cpp66
1 files changed, 51 insertions, 15 deletions
diff --git a/engines/sci/sound/drivers/midi.cpp b/engines/sci/sound/drivers/midi.cpp
index 08e93d3213..73420eff6e 100644
--- a/engines/sci/sound/drivers/midi.cpp
+++ b/engines/sci/sound/drivers/midi.cpp
@@ -604,10 +604,13 @@ void MidiPlayer_Midi::readMt32DrvData() {
if (f.open("MT32.DRV")) {
int size = f.size();
- assert(size >= 166);
-
- // Send before-SysEx text
- f.seek(0x59);
+ // Skip before-SysEx text
+ if (size == 1773 || size == 1759) // XMAS88 / KQ4 early
+ f.seek(0x59);
+ else if (size == 2771) // LSL2 early
+ f.seek(0x29);
+ else
+ error("Unknown MT32.DRV size (%d)", size);
// Skip 2 extra 0 bytes in some drivers
if (f.readUint16LE() != 0)
@@ -620,25 +623,58 @@ void MidiPlayer_Midi::readMt32DrvData() {
// Save goodbye message
f.read(_goodbyeMsg, 20);
+ _goodbyeMsg[19] = 0; // make sure that the message is nul-terminated
// Set volume
byte volume = CLIP<uint16>(f.readUint16LE(), 0, 100);
setMt32Volume(volume);
- byte reverbSysEx[13];
- // This old driver should have a full reverb SysEx
- if ((f.read(reverbSysEx, 13) != 13) || (reverbSysEx[0] != 0xf0) || (reverbSysEx[12] != 0xf7))
- error("Error reading MT32.DRV");
+ if (size == 2771) {
+ // MT32.DRV in LSL2 early contains more data, like a normal patch
+ byte reverb = f.readByte();
+
+ _hasReverb = true;
+
+ // Skip reverb SysEx message
+ f.skip(11);
+
+ // Read reverb data (stored vertically - patch #3117434)
+ for (int j = 0; j < 3; ++j) {
+ for (int i = 0; i < kReverbConfigNr; i++) {
+ _reverbConfig[i][j] = f.readByte();
+ }
+ }
+
+ f.skip(2235); // skip driver code
+
+ // Patches 1-48
+ sendMt32SysEx(0x50000, static_cast<Common::SeekableReadStream *>(&f), 256);
+ sendMt32SysEx(0x50200, static_cast<Common::SeekableReadStream *>(&f), 128);
- // Send reverb SysEx
- sysEx(reverbSysEx + 1, 11);
- _hasReverb = false;
+ setReverb(reverb);
- f.seek(0x29);
+ // Send after-SysEx text
+ f.seek(0);
+ sendMt32SysEx(0x200000, static_cast<Common::SeekableReadStream *>(&f), 20);
+
+ // Send the mystery SysEx
+ sendMt32SysEx(0x52000a, (const byte *)"\x16\x16\x16\x16\x16\x16", 6);
+ } else {
+ byte reverbSysEx[13];
+ // This old driver should have a full reverb SysEx
+ if ((f.read(reverbSysEx, 13) != 13) || (reverbSysEx[0] != 0xf0) || (reverbSysEx[12] != 0xf7))
+ error("Error reading MT32.DRV");
- // Read AdLib->MT-32 patch map
- for (int i = 0; i < 48; i++) {
- _patchMap[i] = f.readByte();
+ // Send reverb SysEx
+ sysEx(reverbSysEx + 1, 11);
+ _hasReverb = false;
+
+ f.seek(0x29);
+
+ // Read AdLib->MT-32 patch map
+ for (int i = 0; i < 48; i++) {
+ _patchMap[i] = f.readByte();
+ }
}
f.close();