From 191d85f174128c36890f7616689084ac343a5bfc Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 23 Jan 2011 07:02:49 +0000 Subject: MOHAWK: Implement Riven's stopSound() and fadeAmbientSounds() opcodes svn-id: r55460 --- engines/mohawk/riven_scripts.cpp | 18 +++++++++++++----- engines/mohawk/sound.cpp | 5 +++-- engines/mohawk/sound.h | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index 7decf4d2df..fcdae70ce5 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -394,14 +394,21 @@ void RivenScript::disableHotspot(uint16 op, uint16 argc, uint16 *argv) { // Command 12: stop sounds (flags) void RivenScript::stopSound(uint16 op, uint16 argc, uint16 *argv) { + // WORKAROUND: The Play Riven/Visit Riven/Start New Game buttons + // in the main menu call this function to stop ambient sounds + // after the change stack call to Temple Island. However, this + // would cause all ambient sounds not to play. An alternative + // fix would be to stop all scripts on a stack change, but this + // does fine for now. + if (_vm->getCurStack() == tspit && (_vm->getCurCardRMAP() == 0x6e9a || _vm->getCurCardRMAP() == 0xfeeb)) + return; + // The argument is a bitflag for the setting. // bit 0 is normal sound stopping (unused) // bit 1 is ambient sound stopping // Having no flags set means clear all - - // TODO: Enable this once empty SLST entries are properly handled - //if (argv[0] & 2 || argv[0] == 0) - // _vm->_sound->stopAllSLST(); + if (argv[0] & 2 || argv[0] == 0) + _vm->_sound->stopAllSLST(); if (argv[0] & 1) warning("Unhandled stopSound() flag"); @@ -521,7 +528,8 @@ void RivenScript::unk_36(uint16 op, uint16 argc, uint16 *argv) { // Command 37: fade ambient sounds void RivenScript::fadeAmbientSounds(uint16 op, uint16 argc, uint16 *argv) { - warning("STUB: fadeAmbientSounds()"); + // Similar to stopSound(), but does fading + _vm->_sound->stopAllSLST(true); } // Command 38: Play a movie with extra parameters (movie id, delay high, delay low, record type, record id) diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index a8d185602d..1583baf2b0 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -291,8 +291,9 @@ void Sound::playSLST(SLSTRecord slstRecord) { } } -void Sound::stopAllSLST() { +void Sound::stopAllSLST(bool fade) { for (uint16 i = 0; i < _currentSLSTSounds.size(); i++) { + // TODO: Fade out, if requested _vm->_mixer->stopHandle(*_currentSLSTSounds[i].handle); delete _currentSLSTSounds[i].handle; } @@ -326,7 +327,7 @@ void Sound::playSLSTSound(uint16 id, bool fade, bool loop, uint16 volume, int16 } void Sound::stopSLSTSound(uint16 index, bool fade) { - // TODO: Fade out, mixer needs to be extended to get volume on a handle + // TODO: Fade out, if requested _vm->_mixer->stopHandle(*_currentSLSTSounds[index].handle); delete _currentSLSTSounds[index].handle; _currentSLSTSounds.remove_at(index); diff --git a/engines/mohawk/sound.h b/engines/mohawk/sound.h index 73f7a728ab..33fd167d9f 100644 --- a/engines/mohawk/sound.h +++ b/engines/mohawk/sound.h @@ -148,7 +148,7 @@ public: void playSLST(SLSTRecord slstRecord); void pauseSLST(); void resumeSLST(); - void stopAllSLST(); + void stopAllSLST(bool fade = false); static byte convertRivenVolume(uint16 volume); private: -- cgit v1.2.3