From fcc45186a535e5387caa5cdb8a594ae7fff04f65 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Mon, 25 May 2009 12:38:20 +0000 Subject: SCI: Adlib: fix crash in SQ4. svn-id: r40886 --- engines/sci/sfx/softseq/adlib.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/sci/sfx/softseq/adlib.cpp b/engines/sci/sfx/softseq/adlib.cpp index d788ea38d8..1b3180d9ea 100644 --- a/engines/sci/sfx/softseq/adlib.cpp +++ b/engines/sci/sfx/softseq/adlib.cpp @@ -443,17 +443,15 @@ void MidiDriver_Adlib::voiceOn(int voice, int note, int velocity) { _voices[voice].age = 0; - if (channel == 9) { + if ((channel == 9) && _rhythmKeyMap) { patch = CLIP(note, 27, 88) + 101; } else { patch = _channels[channel].patch; } // Set patch if different from current patch - if ((patch != _voices[voice].patch) && _playSwitch) { - _voices[voice].patch = patch; + if ((patch != _voices[voice].patch) && _playSwitch) setPatch(voice, patch); - } _voices[voice].velocity = velocity; setNote(voice, note, true); @@ -567,9 +565,10 @@ void MidiDriver_Adlib::setVelocityReg(int regOffset, int velocity, int kbScaleLe void MidiDriver_Adlib::setPatch(int voice, int patch) { if ((patch < 0) || ((uint)patch >= _patches.size())) { warning("ADLIB: Invalid patch %i requested", patch); - return; + patch = 0; } + _voices[voice].patch = patch; AdlibModulator &mod = _patches[patch].mod; // Set the common settings for both operators -- cgit v1.2.3