aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sound/soundcmd.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2011-08-25 02:52:58 +0300
committerFilippos Karapetis2011-08-25 02:52:58 +0300
commit996deff15b347f05f95b2a6b9d0e382d25d0db3e (patch)
tree52471b99071de706443e9c12e8934ceeb4d233c9 /engines/sci/sound/soundcmd.cpp
parent3774c38db59dd8528126112011d5345afee111bd (diff)
downloadscummvm-rg350-996deff15b347f05f95b2a6b9d0e382d25d0db3e.tar.gz
scummvm-rg350-996deff15b347f05f95b2a6b9d0e382d25d0db3e.tar.bz2
scummvm-rg350-996deff15b347f05f95b2a6b9d0e382d25d0db3e.zip
SCI: Fixed bug #3392767 - "SCI: SQ4 (English/CD/Win): Engine Abort In Timepod Hangar"
This bug only manifested in the Windows version of SQ4CD. Some Windows MIDI music tracks are missing from room 530, which messed up the animations in that scene, and led to a crash. Moved the code that obtains the song number from an object into a separate function. Also, fixed a bug in kDoSoundSetPriority().
Diffstat (limited to 'engines/sci/sound/soundcmd.cpp')
-rw-r--r--engines/sci/sound/soundcmd.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp
index 4ea290ff9e..d4cff7614c 100644
--- a/engines/sci/sound/soundcmd.cpp
+++ b/engines/sci/sound/soundcmd.cpp
@@ -49,11 +49,22 @@ reg_t SoundCommandParser::kDoSoundInit(int argc, reg_t *argv, reg_t acc) {
return acc;
}
-void SoundCommandParser::processInitSound(reg_t obj) {
- int resourceId = readSelectorValue(_segMan, obj, SELECTOR(number));
+int SoundCommandParser::getSoundResourceId(reg_t obj) {
+ int resourceId = obj.segment ? readSelectorValue(_segMan, obj, SELECTOR(number)) : -1;
// Modify the resourceId for the Windows versions that have an alternate MIDI soundtrack, like SSCI did.
- if (g_sci && g_sci->_features->useAltWinGMSound())
- resourceId += 1000;
+ if (g_sci && g_sci->_features->useAltWinGMSound()) {
+ // Check if the alternate MIDI song actually exists...
+ // There are cases where it just doesn't exist (e.g. SQ4, room 530 -
+ // bug #3392767). In these cases, use the DOS tracks instead.
+ if (resourceId && _resMan->testResource(ResourceId(kResourceTypeSound, resourceId + 1000)))
+ resourceId += 1000;
+ }
+
+ return resourceId;
+}
+
+void SoundCommandParser::processInitSound(reg_t obj) {
+ int resourceId = getSoundResourceId(obj);
// Check if a track with the same sound object is already playing
MusicEntry *oldSound = _music->getSlot(obj);
@@ -123,10 +134,7 @@ void SoundCommandParser::processPlaySound(reg_t obj) {
return;
}
- int resourceId = obj.segment ? readSelectorValue(_segMan, obj, SELECTOR(number)) : -1;
- // Modify the resourceId for the Windows versions that have an alternate MIDI soundtrack, like SSCI did.
- if (g_sci && g_sci->_features->useAltWinGMSound())
- resourceId += 1000;
+ int resourceId = getSoundResourceId(obj);
if (musicSlot->resourceId != resourceId) { // another sound loaded into struct
processDisposeSound(obj);
@@ -618,13 +626,10 @@ reg_t SoundCommandParser::kDoSoundSetPriority(int argc, reg_t *argv, reg_t acc)
}
if (value == -1) {
- uint16 resourceNr = musicSlot->resourceId;
- // Modify the resourceId for the Windows versions that have an alternate MIDI soundtrack, like SSCI did.
- if (g_sci && g_sci->_features->useAltWinGMSound())
- resourceNr += 1000;
+ uint16 resourceId = musicSlot->resourceId;
// Set priority from the song data
- Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, resourceNr), 0);
+ Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, resourceId), 0);
if (song->data[0] == 0xf0)
_music->soundSetPriority(musicSlot, song->data[1]);
else