From fd146d77d086315f89983743d2cd2e53a0b81433 Mon Sep 17 00:00:00 2001 From: sluicebox <22204938+sluicebox@users.noreply.github.com> Date: Thu, 26 May 2022 20:09:19 -0400 Subject: [PATCH] SCI32: Initialize Sound:handle for non-preload samples Fixes bug #13500 where LSL6HIRES doesn't play the audio for the death message after the security guard launches a missile. Thanks to @RayKoopa for reporting this and other discrepancies --- engines/sci/sound/soundcmd.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index 057c594cce43..12cc153d9c9c 100644 --- a/engines/sci/sound/soundcmd.cpp +++ b/engines/sci/sound/soundcmd.cpp @@ -35,6 +35,11 @@ namespace Sci { +enum SoundFlags { + kSoundFlagFixedPriority = 2, + kSoundFlagPreload = 4 +}; + SoundCommandParser::SoundCommandParser(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, AudioPlayer *audio, SciVersion soundVersion) : _resMan(resMan), _segMan(segMan), _kernel(kernel), _audio(audio), _soundVersion(soundVersion) { @@ -253,6 +258,16 @@ void SoundCommandParser::processPlaySound(reg_t obj, bool playBed, bool restorin _audio->incrementPlayCounter(); } + if (_soundVersion >= SCI_VERSION_2_1_EARLY && musicSlot->isSample) { + // When playing a sample without the preload flag, set the + // handle to -1 instead of the object. LSL6HIRES depends on + // this to play certain death messages. Fixes bug #13500 + uint16 flags = readSelectorValue(_segMan, obj, SELECTOR(flags)); + if (!(flags & kSoundFlagPreload)) { + writeSelectorValue(_segMan, obj, SELECTOR(handle), -1); + } + } + // Reset any left-over signals musicSlot->signal = 0; musicSlot->fadeStep = 0; @@ -805,12 +820,12 @@ reg_t SoundCommandParser::kDoSoundSetPriority(EngineState *s, int argc, reg_t *a // NB: It seems SSCI doesn't actually reset the priority here. - writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) & 0xFD); + writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) & ~kSoundFlagFixedPriority); } else { // Scripted priority musicSlot->overridePriority = true; - writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | 2); + writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | kSoundFlagFixedPriority); _music->soundSetPriority(musicSlot, value); }