diff options
author | Martin Kiewitz | 2016-01-02 22:43:27 +0100 |
---|---|---|
committer | Martin Kiewitz | 2016-01-02 22:43:27 +0100 |
commit | 4892bd806693693f0d82c4855c57a9745516cab5 (patch) | |
tree | 4bc18854790384710988b14a7372ec5bf5f90a36 /engines | |
parent | 9d5ee9cba0d1881296a14eb4385029afb3258c1f (diff) | |
download | scummvm-rg350-4892bd806693693f0d82c4855c57a9745516cab5.tar.gz scummvm-rg350-4892bd806693693f0d82c4855c57a9745516cab5.tar.bz2 scummvm-rg350-4892bd806693693f0d82c4855c57a9745516cab5.zip |
SCI: fix sciAudio not doing loops correctly
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/sound/audio.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp index 8c029cf502..7b9a8e0b67 100644 --- a/engines/sci/sound/audio.cpp +++ b/engines/sci/sound/audio.cpp @@ -83,11 +83,20 @@ void AudioPlayer::handleFanmadeSciAudio(reg_t sciAudioObject, SegManager *segMan reg_t fileNameReg = readSelector(segMan, sciAudioObject, kernel->findSelector("fileName")); Common::String fileName = segMan->getString(fileNameReg); - int16 loopCount = (int16)readSelectorValue(segMan, sciAudioObject, kernel->findSelector("loopCount")); - // When loopCount is -1, we treat it as infinite looping, else no looping is done. - // This is observed by game scripts, which can set loopCount to all sorts of random values. + reg_t loopCountReg = readSelector(segMan, sciAudioObject, kernel->findSelector("loopCount")); + Common::String loopCountStr = segMan->getString(loopCountReg); + int16 loopCount = atoi(loopCountStr.c_str()); + // Adjust loopCount for ScummVM's LoopingAudioStream semantics - loopCount = (loopCount == -1) ? 0 : 1; + if (loopCount == -1) { + loopCount = 0; // loop endlessly + } else if (loopCount >= 0) { + // sciAudio loopCount == 0 -> play 1 time -> ScummVM's loopCount should be 1 + // sciAudio loopCount == 1 -> play 2 times -> ScummVM's loopCount should be 2 + loopCount++; + } else { + loopCount = 1; // play once in case the value makes no sense + } // Determine sound type Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType; |