From e70fcf1737812b3afa35f5350ba80e07d8359569 Mon Sep 17 00:00:00 2001 From: Jamieson Christian Date: Tue, 30 Sep 2003 08:25:57 +0000 Subject: [PATCH] Fix for Bug [812740] ALL: MT32: some notes cut off early logicdeluxe's patch to set MT-32 partial reserves equally for all channels, to ensure that entire notes don't get cut off. The patch as committed is slightly modified to reorder the MT-32 initialization sequence. The mods (1) ensure a brief delay between SysEx transmissions to give the MT-32 time to process each request, and (2) hopefully sequence the delays such that the ScummVM welcome message is actually readable and doesn't just flash for a split-second (as was the reported behavior in the past). svn-id: r10498 --- scumm/imuse.cpp | 27 ++++++++++++++++++++------- scumm/imuse_internal.h | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp index 9509151f19c..dc74f914134 100644 --- a/scumm/imuse.cpp +++ b/scumm/imuse.cpp @@ -44,6 +44,7 @@ IMuseInternal::IMuseInternal() : _old_adlib_instruments(false), _enable_multi_midi(false), +_native_mt32(false), _midi_adlib(0), _midi_native(0), _base_sounds(0), @@ -1084,6 +1085,7 @@ uint32 IMuseInternal::property(int prop, uint32 value) { break; case IMuse::PROP_NATIVE_MT32: + _native_mt32 = (value > 0); Instrument::nativeMT32(value > 0); break; @@ -1163,8 +1165,8 @@ void IMuseInternal::initMidiDriver(MidiDriver *midi) { if (result) error("IMuse initialization - %s", MidiDriver::getErrorName(result)); - // In case we have an MT-32 attached. - initMT32(midi); + if (_native_mt32) + initMT32(midi); // Connect to the driver's timer midi->setTimerCallback(midi, &IMuseInternal::midiTimerCallback); @@ -1175,16 +1177,17 @@ void IMuseInternal::initMT32(MidiDriver *midi) { char info[256] = "ScummVM "; int len; - // Compute version string(truncated to 20 chars max.) + // Reset the MT-32 + memcpy(&buffer[4], "\x7f\x00\x00\x01\x00", 5); + midi->sysEx(buffer, 9); + g_system->delay_msecs (100); + + // Compute version string (truncated to 20 chars max.) strcat(info, gScummVMVersion); len = strlen(info); if (len > 20) len = 20; - // Reset the MT-32 - memcpy(&buffer[4], "\x7f\x00\x00\x01\x00", 5); - midi->sysEx(buffer, 9); - // Display a welcome message on MT-32 displays. memcpy(&buffer[4], "\x20\x00\x00", 3); memcpy(&buffer[7], " ", 20); @@ -1194,6 +1197,16 @@ void IMuseInternal::initMT32(MidiDriver *midi) { checksum -= buffer[i]; buffer[27] = checksum; midi->sysEx(buffer, 28); + g_system->delay_msecs (500); + + // Set master volume to 100% + memcpy(&buffer[4], "\x10\x00\x16\x64\x76", 5); + midi->sysEx(buffer, 9); + g_system->delay_msecs (500); + + // Set partial reserve equally for all channels + memcpy(&buffer[4], "\x10\x00\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x48", 13); + midi->sysEx(buffer, 17); } void IMuseInternal::init_queue() { diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h index 03426a0538b..1194e779ebf 100644 --- a/scumm/imuse_internal.h +++ b/scumm/imuse_internal.h @@ -348,6 +348,7 @@ class IMuseInternal { protected: bool _old_adlib_instruments; bool _enable_multi_midi; + bool _native_mt32; MidiDriver *_midi_adlib; MidiDriver *_midi_native;