diff options
-rw-r--r-- | engines/mohawk/myst.cpp | 12 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 4 | ||||
-rw-r--r-- | engines/mohawk/myst_scripts.cpp | 2 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/mechanical.cpp | 10 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/myst.cpp | 14 | ||||
-rw-r--r-- | engines/mohawk/sound.cpp | 25 | ||||
-rw-r--r-- | engines/mohawk/sound.h | 1 |
7 files changed, 27 insertions, 41 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index f965756fca..3237c949f3 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -268,6 +268,14 @@ void MohawkEngine_Myst::waitUntilMovieEnds(const VideoEntryPtr &video) { _video->removeEntry(video); } +void MohawkEngine_Myst::playSoundBlocking(uint16 id, byte volume) { + _sound->playSound(id, volume); + + while (_sound->isPlaying() && !shouldQuit()) { + doFrame(); + } +} + Common::Error MohawkEngine_Myst::run() { MohawkEngine::run(); @@ -478,7 +486,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS _sound->stopBackgroundMyst(); _video->stopVideos(); if (linkSrcSound) - _sound->playSoundBlocking(linkSrcSound); + playSoundBlocking(linkSrcSound); // Delete the previous stack and move the current stack to the previous one // There's probably a better way to do this, but the script classes shouldn't @@ -588,7 +596,7 @@ void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcS changeToCard(card, kTransitionCopy); if (linkDstSound) - _sound->playSoundBlocking(linkDstSound); + playSoundBlocking(linkDstSound); } uint16 MohawkEngine_Myst::getCardBackgroundId() { diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index e3fa5a91c6..edcc76fff4 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -29,6 +29,8 @@ #include "mohawk/myst_scripts.h" #include "mohawk/video.h" +#include "audio/mixer.h" + #include "common/events.h" #include "common/random.h" @@ -230,6 +232,8 @@ public: void playMovieBlockingCentered(const Common::String &filename); void waitUntilMovieEnds(const VideoEntryPtr &video); + void playSoundBlocking(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume); + GUI::Debugger *getDebugger() override { return _console; } bool canLoadGameStateCurrently() override; diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp index ed9237585f..59d736296e 100644 --- a/engines/mohawk/myst_scripts.cpp +++ b/engines/mohawk/myst_scripts.cpp @@ -650,7 +650,7 @@ void MystScriptParser::o_playSoundBlocking(uint16 op, uint16 var, uint16 argc, u debugC(kDebugScript, "\tsoundId: %d", soundId); _vm->_sound->stopSound(); - _vm->_sound->playSoundBlocking(soundId); + _vm->playSoundBlocking(soundId); } void MystScriptParser::o_copyBackBufferToScreen(uint16 op, uint16 var, uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp index 351379b01c..3bbf749c1f 100644 --- a/engines/mohawk/myst_stacks/mechanical.cpp +++ b/engines/mohawk/myst_stacks/mechanical.cpp @@ -611,7 +611,7 @@ void Mechanical::elevatorGoMiddle_run() { } // Blip - _vm->_sound->playSoundBlocking(14120); + _vm->playSoundBlocking(14120); // Restore button if (_elevatorInCabin) { @@ -626,11 +626,11 @@ void Mechanical::elevatorGoMiddle_run() { // Elevator going to middle animation _vm->_cursor->hideCursor(); - _vm->_sound->playSoundBlocking(11120); + _vm->playSoundBlocking(11120); _vm->_gfx->copyImageToBackBuffer(6118, Common::Rect(544, 333)); _vm->_sound->replaceSoundMyst(12120); _vm->_gfx->runTransition(kTransitionSlideToLeft, Common::Rect(177, 0, 370, 333), 25, 0); - _vm->_sound->playSoundBlocking(13120); + _vm->playSoundBlocking(13120); _vm->_sound->replaceSoundMyst(8120); _vm->_gfx->copyImageToBackBuffer(6327, Common::Rect(544, 333)); _vm->wait(500); @@ -866,7 +866,7 @@ void Mechanical::fortressRotation_run() { gears->seek(Audio::Timestamp(0, 1800 * (_fortressPosition % 2), 600)); } - _vm->_sound->playSoundBlocking(_fortressRotationSounds[_fortressPosition]); + _vm->playSoundBlocking(_fortressRotationSounds[_fortressPosition]); _gearsWereRunning = false; } @@ -1023,7 +1023,7 @@ void Mechanical::fortressSimulation_run() { // END HACK holo->seek(Audio::Timestamp(0, 1800 * simulationPosition, 600)); - _vm->_sound->playSoundBlocking( _fortressRotationSounds[simulationPosition]); + _vm->playSoundBlocking( _fortressRotationSounds[simulationPosition]); _gearsWereRunning = false; } diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index 6979ce5333..ff2415c6c5 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -902,12 +902,12 @@ void Myst::o_courtyardBoxesCheckSolution(uint16 op, uint16 var, uint16 argc, uin if (_state.courtyardImageBoxes == 50 && !_state.shipFloating) { _vm->_cursor->hideCursor(); _state.shipFloating = 1; - _vm->_sound->playSoundBlocking(soundId); + _vm->playSoundBlocking(soundId); _vm->_cursor->showCursor(); } else if (_state.courtyardImageBoxes != 50 && _state.shipFloating) { _vm->_cursor->hideCursor(); _state.shipFloating = 0; - _vm->_sound->playSoundBlocking(soundId); + _vm->playSoundBlocking(soundId); _vm->_cursor->showCursor(); } } @@ -1097,7 +1097,7 @@ void Myst::o_bookGivePage(uint16 op, uint16 var, uint16 argc, uint16 *argv) { } _vm->_cursor->hideCursor(); - _vm->_sound->playSoundBlocking(soundIdAddPage); + _vm->playSoundBlocking(soundIdAddPage); _vm->setMainCursor(kDefaultMystCursor); // Add page to book @@ -1269,11 +1269,11 @@ void Myst::o_imagerEraseButton(uint16 op, uint16 var, uint16 argc, uint16 *argv) return; } else if (_imagerValidationStep < 7) { // Too early - _vm->_sound->playSoundBlocking(_imagerSound[2]); + _vm->playSoundBlocking(_imagerSound[2]); _imagerValidationStep = 0; return; } else if (_imagerValidationStep < 11) { - _vm->_sound->playSoundBlocking(_imagerSound[3]); + _vm->playSoundBlocking(_imagerSound[3]); // Erase selected video from imager switch (_state.imagerSelection) { @@ -3375,12 +3375,12 @@ void Myst::libraryBookcaseTransform_run(void) { if (_state.libraryBookcaseDoor) { _vm->_gfx->copyImageSectionToBackBuffer(11179, Common::Rect(0, 0, 106, 81), Common::Rect(0, 72, 106, 153)); _vm->_gfx->runTransition(kTransitionBottomToTop, Common::Rect(0, 72, 106, 153), 5, 10); - _vm->_sound->playSoundBlocking(7348); + _vm->playSoundBlocking(7348); _vm->_sound->replaceBackgroundMyst(4348, 16384); } else { _vm->_gfx->copyImageSectionToBackBuffer(11178, Common::Rect(0, 0, 107, 67), Common::Rect(437, 84, 544, 151)); _vm->_gfx->copyBackBufferToScreen(Common::Rect(437, 84, 544, 151)); - _vm->_sound->playSoundBlocking(7348); + _vm->playSoundBlocking(7348); _vm->_sound->replaceBackgroundMyst(4334, 16384); } diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 2a54696b68..5907c5b002 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -293,31 +293,6 @@ Audio::SoundHandle *Sound::replaceSoundMyst(uint16 id, byte volume, bool loop) { return playSound(id, volume, loop); } -void Sound::playSoundBlocking(uint16 id, byte volume) { - Audio::SoundHandle *handle = playSound(id, volume); - - while (_vm->_mixer->isSoundHandleActive(*handle) && !_vm->shouldQuit()) { - Common::Event event; - while (_vm->_system->getEventManager()->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_KEYDOWN: - switch (event.kbd.keycode) { - case Common::KEYCODE_SPACE: - _vm->pauseGame(); - break; - default: - break; - } - default: - break; - } - } - - // Cut down on CPU usage - _vm->_system->delayMillis(10); - } -} - void Sound::playMidi(uint16 id) { uint32 idTag; if (!(_vm->getFeatures() & GF_HASMIDI)) { diff --git a/engines/mohawk/sound.h b/engines/mohawk/sound.h index 2b4b1ce091..7dcc125668 100644 --- a/engines/mohawk/sound.h +++ b/engines/mohawk/sound.h @@ -108,7 +108,6 @@ public: // Generic sound functions Audio::SoundHandle *playSound(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false, CueList *cueList = NULL); - void playSoundBlocking(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume); void playMidi(uint16 id); void stopMidi(); void stopSound(); |