diff options
author | Alyssa Milburn | 2011-04-01 14:43:22 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-04-01 14:44:41 +0200 |
commit | 1f543652b7cb6a092896f626aa334e56a55c47ec (patch) | |
tree | 97cd3a8ab1498ca864d396d103cf56e4e353243a | |
parent | c0d815413153b799f7a589d11f32a9a53f0d4de5 (diff) | |
download | scummvm-rg350-1f543652b7cb6a092896f626aa334e56a55c47ec.tar.gz scummvm-rg350-1f543652b7cb6a092896f626aa334e56a55c47ec.tar.bz2 scummvm-rg350-1f543652b7cb6a092896f626aa334e56a55c47ec.zip |
MOHAWK: Handle waiting for sound cues in LBAnimation.
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 39 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.h | 6 |
2 files changed, 35 insertions, 10 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 74dbfb3437..26bb09a645 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -1360,12 +1360,17 @@ NodeState LBAnimationNode::update(bool seeking) { break; } - assert(entry.size == 4); - uint16 strLen = READ_BE_UINT16(entry.data + 2); - - if (strLen) { - warning("Named wave file encountered (strlen %04x, id %d)", strLen, soundResourceId); + Common::String cue; + uint pos = 2; + while (pos < entry.size) { + char in = entry.data[pos]; + if (!in) + break; + pos++; + cue += in; } + if (pos == entry.size) + error("Cue in sound kLBAnimOp wasn't null-terminated"); switch (entry.opcode) { case kLBAnimOpPlaySound: @@ -1378,7 +1383,7 @@ NodeState LBAnimationNode::update(bool seeking) { if (seeking) break; debug(4, "b: WaitForSound(%0d)", soundResourceId); - if (!_parent->soundPlaying(soundResourceId)) + if (!_parent->soundPlaying(soundResourceId, cue)) break; _currentEntry--; return kLBNodeWaiting; @@ -1744,11 +1749,27 @@ void LBAnimation::stop() { void LBAnimation::playSound(uint16 resourceId) { _currentSound = resourceId; - _vm->_sound->playSound(_currentSound); + _vm->_sound->playSound(_currentSound, Audio::Mixer::kMaxChannelVolume, false, &_cueList); } -bool LBAnimation::soundPlaying(uint16 resourceId) { - return _currentSound == resourceId && _vm->_sound->isPlaying(_currentSound); +bool LBAnimation::soundPlaying(uint16 resourceId, const Common::String &cue) { + if (_currentSound != resourceId) + return false; + if (!_vm->_sound->isPlaying(_currentSound)) + return false; + + if (cue.empty()) + return true; + + uint samples = _vm->_sound->getNumSamplesPlayed(_currentSound); + for (uint i = 0; i < _cueList.pointCount; i++) { + if (_cueList.points[i].sampleFrame > samples) + break; + if (_cueList.points[i].name == cue) + return false; + } + + return true; } bool LBAnimation::transparentAt(int x, int y) { diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h index 7138078c00..e55f14bc2c 100644 --- a/engines/mohawk/livingbooks.h +++ b/engines/mohawk/livingbooks.h @@ -29,6 +29,7 @@ #include "mohawk/mohawk.h" #include "mohawk/console.h" #include "mohawk/graphics.h" +#include "mohawk/sound.h" #include "common/config-file.h" #include "common/substream.h" @@ -313,7 +314,7 @@ public: void stop(); void playSound(uint16 resourceId); - bool soundPlaying(uint16 resourceId); + bool soundPlaying(uint16 resourceId, const Common::String &cue); bool transparentAt(int x, int y); @@ -335,7 +336,10 @@ protected: Common::Array<LBAnimationNode *> _nodes; uint16 _tempo; + uint16 _currentSound; + CueList _cueList; + uint32 _lastTime, _currentFrame; bool _running; |