[Scummvm-git-logs] scummvm master -> 0c7e60ba39d7337dcad7a242ce0ff184c57dc614

neuromancer noreply at scummvm.org
Tue Jun 23 21:36:43 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
0c7e60ba39 FREESCAPE: improved fidelity of sound playback in some corner cases


Commit: 0c7e60ba39d7337dcad7a242ce0ff184c57dc614
    https://github.com/scummvm/scummvm/commit/0c7e60ba39d7337dcad7a242ce0ff184c57dc614
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2026-06-23T23:15:32+02:00

Commit Message:
FREESCAPE: improved fidelity of sound playback in some corner cases

Changed paths:
    engines/freescape/language/instruction.cpp
    engines/freescape/sound.h
    engines/freescape/sound/dos.cpp


diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 0e65eba54e1..8d6c924d57a 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -389,10 +389,19 @@ void FreescapeEngine::executeExecute(FCLInstruction &instruction) {
 }
 
 void FreescapeEngine::executeSound(FCLInstruction &instruction) {
-	stopAllSounds(Sound::kTypeMovement);
-	_firstSound = false;
 	uint16 index = instruction._source;
 	bool sync = instruction._additional;
+	// An undefined sound index is a no-op in the original engines (e.g.
+	// start_speaker_sound returns early when the DOS table index is 0xFF) and
+	// must NOT disturb the sound that is already playing. Otherwise the
+	// stopAllSounds() below cuts the previous sound and then plays nothing
+	// (e.g. SOUND 15; SOUND 16 where sound 16 is undefined in the data).
+	if (_sound && !_sound->isSoundAvailable(index)) {
+		debugC(1, kFreescapeDebugCode, "Sound %d not available, keeping current sound", index);
+		return;
+	}
+	stopAllSounds(Sound::kTypeMovement);
+	_firstSound = false;
 	debugC(1, kFreescapeDebugCode, "Playing sound %d", index);
 	playSound(index, sync);
 }
diff --git a/engines/freescape/sound.h b/engines/freescape/sound.h
index 239b37588f3..2f291465d67 100644
--- a/engines/freescape/sound.h
+++ b/engines/freescape/sound.h
@@ -44,6 +44,11 @@ public:
 	virtual void playSound(int index, Type type) = 0;
 	virtual void stopSound(Type type) = 0;
 	virtual bool isPlayingSound(Type type) const = 0;
+
+	// Whether the given sound index actually exists. Used to skip undefined
+	// sounds without disturbing the sound currently playing, matching the
+	// original engines where an unknown index leaves the active sound untouched.
+	virtual bool isSoundAvailable(int index) const { return true; }
 };
 
 } // End of namespace Freescape
diff --git a/engines/freescape/sound/dos.cpp b/engines/freescape/sound/dos.cpp
index cb9dbdf83e0..696164f87d6 100644
--- a/engines/freescape/sound/dos.cpp
+++ b/engines/freescape/sound/dos.cpp
@@ -64,6 +64,10 @@ public:
 		return !_speaker->endOfStream();
 	}
 
+	bool isSoundAvailable(int index) const override {
+		return _soundsSpeakerFx.getValOrDefault(index) != nullptr;
+	}
+
 private:
 	Common::HashMap<uint16, soundSpeakerFx *> _soundsSpeakerFx;
 




More information about the Scummvm-git-logs mailing list