From f814dc971ca9f6526b4f6049642b79d6371dcfb8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 14 Jul 2011 00:48:30 +0200 Subject: SCUMM: Handle default instrument set up in iMuse like the original. --- engines/scumm/imuse/imuse.cpp | 16 +++++++++++++++- engines/scumm/imuse/sysex_scumm.cpp | 23 +++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/imuse/imuse.cpp b/engines/scumm/imuse/imuse.cpp index 451721cf70..5ad4798578 100644 --- a/engines/scumm/imuse/imuse.cpp +++ b/engines/scumm/imuse/imuse.cpp @@ -1682,7 +1682,21 @@ void IMuseInternal::setGlobalInstrument(byte slot, byte *data) { void IMuseInternal::copyGlobalInstrument(byte slot, Instrument *dest) { if (slot >= 32) return; - _global_instruments[slot].copy_to(dest); + + // Both the AdLib code and the PC Speaker code use an all zero instrument + // as default in the original, thus we do the same. + // PC Speaker instrument size is 23, while AdLib instrument size is 30. + // Thus we just use a 30 byte instrument data array as default. + const byte defaultInstr[30] = { 0 }; + + if (_global_instruments[slot].isValid()) { + // In case we have an valid instrument set up, copy it to the part. + _global_instruments[slot].copy_to(dest); + } else if (_pcSpeaker) { + dest->pcspk(defaultInstr); + } else { + dest->adlib(defaultInstr); + } } diff --git a/engines/scumm/imuse/sysex_scumm.cpp b/engines/scumm/imuse/sysex_scumm.cpp index 9f795133be..85ffc86f47 100644 --- a/engines/scumm/imuse/sysex_scumm.cpp +++ b/engines/scumm/imuse/sysex_scumm.cpp @@ -81,20 +81,19 @@ void sysexHandler_Scumm(Player *player, const byte *msg, uint16 len) { se->reallocateMidiChannels(player->_midi); } } else { - // Even in cases where a program does not seem to be specified, - // i.e. bytes 15 and 16 are 0, we send a program change because - // 0 is a valid program number. MI2 tests show that in such - // cases, a regular program change message always seems to follow - // anyway. if (player->_isMIDI) { + // Even in cases where a program does not seem to be specified, + // i.e. bytes 15 and 16 are 0, we send a program change because + // 0 is a valid program number. MI2 tests show that in such + // cases, a regular program change message always seems to follow + // anyway. part->_instrument.program(buf[8], player->_isMT32); - } else if (se->_pcSpeaker) { - // FIXME/HACK: This is only needed here, since when we use the following line: - // se->copyGlobalInstrument(buf[8], &part->_instrument); - // We would not get any instrument for PC Speaker. Because we don't default to an - // "empty" instrument in case the global instrument specified is not set up. - byte empty[23] = {0}; - part->_instrument.pcspk(empty); + } else { + // Like the original we set up the instrument data of the + // specified program here too. In case the global + // instrument data is not loaded already, this will take + // care of setting a default instrument too. + se->copyGlobalInstrument(buf[8], &part->_instrument); } part->sendAll(); } -- cgit v1.2.3