diff options
Diffstat (limited to 'engines/hopkins/sound.cpp')
-rw-r--r-- | engines/hopkins/sound.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index e23c7e525f..9cbfa39f71 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -331,6 +331,11 @@ void SoundManager::DEL_MUSIC() { Music._currentIndex = -1; } +void SoundManager::checkSounds() { + checkMusic(); + checkVoices(); +} + void SoundManager::checkMusic() { if (Music._active && Music._isPlaying) { int mwavIndex = Music._mwavIndexes[Music._currentIndex]; @@ -363,6 +368,20 @@ void SoundManager::checkMusic() { } } +void SoundManager::checkVoices() { + // Check the status of each voice. + bool hasActiveVoice = false; + for (int i = 0; i < VOICE_COUNT; ++i) { + VOICE_STAT(i); + hasActiveVoice |= Voice[i]._status != 0; + } + + if (!hasActiveVoice && SOUND_FLAG) { + SOUND_FLAG = false; + SOUND_NUM = 0; + } +} + void SoundManager::LOAD_MSAMPLE(int mwavIndex, const Common::String &file) { if (!Mwav[mwavIndex]._active) { Common::File f; @@ -578,7 +597,8 @@ void SoundManager::PLAY_WAV(int wavIndex) { int SoundManager::VOICE_STAT(int voiceIndex) { if (Voice[voiceIndex]._status) { - if (Voice[voiceIndex]._audioStream->endOfStream()) + int wavIndex = Voice[voiceIndex]._wavIndex; + if (Swav[wavIndex]._audioStream->endOfStream()) STOP_VOICE(voiceIndex); } @@ -599,7 +619,6 @@ void SoundManager::STOP_VOICE(int voiceIndex) { Voice[voiceIndex].fieldC = 0; Voice[voiceIndex]._status = 0; Voice[voiceIndex].field14 = 0; - Voice[voiceIndex]._audioStream = NULL; } void SoundManager::SDL_LVOICE(size_t filePosition, size_t entryLength) { @@ -691,9 +710,9 @@ void SoundManager::PLAY_SAMPLE_SDL(int voiceIndex, int wavIndex) { DEL_SAMPLE_SDL(wavIndex); Voice[voiceIndex].fieldC = 0; - Voice[voiceIndex]._audioStream = Swav[wavIndex]._audioStream; Voice[voiceIndex]._status = 1; Voice[voiceIndex].field14 = 4; + Voice[voiceIndex]._wavIndex = wavIndex; int volume = (voiceIndex == 2) ? VOICEVOL * 255 / 16 : SOUNDVOL * 255 / 16; |