diff options
-rw-r--r-- | engines/pink/objects/sequences/sequence.cpp | 18 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequence.h | 5 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequence_item.cpp | 8 | ||||
-rw-r--r-- | engines/pink/objects/sequences/sequence_item.h | 4 | ||||
-rw-r--r-- | engines/pink/sound.cpp | 4 | ||||
-rw-r--r-- | engines/pink/sound.h | 1 |
6 files changed, 31 insertions, 9 deletions
diff --git a/engines/pink/objects/sequences/sequence.cpp b/engines/pink/objects/sequences/sequence.cpp index f9aafa49de..2071683681 100644 --- a/engines/pink/objects/sequences/sequence.cpp +++ b/engines/pink/objects/sequences/sequence.cpp @@ -147,6 +147,15 @@ void SequenceAudio::toConsole() { } } +void SequenceAudio::start(int unk) { + Sequence::start(unk); + int index = _context->getNextItemIndex(); + if (index < _items.size()) { + auto leaderAudio = (SequenceItemLeaderAudio*) _items[index]; + _sample = leaderAudio->getSample(); + } +} + void SequenceAudio::end() { delete _sound; _sound = nullptr; @@ -154,12 +163,15 @@ void SequenceAudio::end() { } void SequenceAudio::update() { - // Not Working. In original there is check for current buffer size of wav file - Sequence::update(); + if (!_sound->isPlaying()) + end(); + else if (_sample <= _sound->getCurrentSample()){ + start(0); + } } void SequenceAudio::init(int unk) { - _unk2 = 0; + _sample = 0; _sound = _sequencer->_page->loadSound(_soundName); _sound->play(Audio::Mixer::SoundType::kMusicSoundType, 100, 0); Sequence::init(unk); diff --git a/engines/pink/objects/sequences/sequence.h b/engines/pink/objects/sequences/sequence.h index 8a9264aecd..e4695f2088 100644 --- a/engines/pink/objects/sequences/sequence.h +++ b/engines/pink/objects/sequences/sequence.h @@ -44,7 +44,7 @@ public: void setContext(SequenceContext *context); virtual void init(int unk); - void start(int unk); + virtual void start(int unk); virtual void end(); virtual void update(); @@ -67,6 +67,7 @@ public: virtual void toConsole(); virtual void init(int unk); + virtual void start(int unk); virtual void end(); virtual void update(); virtual void restart(); @@ -74,7 +75,7 @@ public: private: Common::String _soundName; Sound *_sound; - int _unk2; + int _sample; }; } // End of namespace Pink diff --git a/engines/pink/objects/sequences/sequence_item.cpp b/engines/pink/objects/sequences/sequence_item.cpp index f7870d3f3b..5ea7b7468d 100644 --- a/engines/pink/objects/sequences/sequence_item.cpp +++ b/engines/pink/objects/sequences/sequence_item.cpp @@ -85,11 +85,15 @@ void SequenceItemLeader::toConsole() { void SequenceItemLeaderAudio::deserialize(Archive &archive) { SequenceItem::deserialize(archive); - archive.readDWORD(); + _sample = archive.readDWORD(); } void SequenceItemLeaderAudio::toConsole() { - debug("\t\t\t\tSequenceItemLeaderAudio: _actor=%s, _action=%s", _actor.c_str(), _action.c_str()); + debug("\t\t\t\tSequenceItemLeaderAudio: _actor=%s, _action=%s _sample=%d", _actor.c_str(), _action.c_str(), _sample); +} + +uint32 SequenceItemLeaderAudio::getSample() { + return _sample; } bool SequenceItemDefaultAction::execute(int index, Sequence *sequence, bool unk2) { diff --git a/engines/pink/objects/sequences/sequence_item.h b/engines/pink/objects/sequences/sequence_item.h index f217eafd74..0563310fea 100644 --- a/engines/pink/objects/sequences/sequence_item.h +++ b/engines/pink/objects/sequences/sequence_item.h @@ -53,14 +53,14 @@ public: virtual bool isLeader(); }; -// behaviour is identical to SequenceItemLeader class SequenceItemLeaderAudio : public SequenceItemLeader { public: virtual void deserialize(Archive &archive); virtual void toConsole(); + uint32 getSample(); private: - //uint32 _sample; // zero in data files and not used; + uint32 _sample; }; class SequenceItemDefaultAction : public SequenceItem { diff --git a/engines/pink/sound.cpp b/engines/pink/sound.cpp index cf62f03c93..5312c965c9 100644 --- a/engines/pink/sound.cpp +++ b/engines/pink/sound.cpp @@ -84,4 +84,8 @@ void Sound::setBalance(int8 balance) { _mixer->setChannelBalance(_handle, balance); } +uint32 Sound::getCurrentSample() { + return _mixer->getSoundElapsedTime(_handle) * 22050 / 1000; +} + } // End of namespace Pink
\ No newline at end of file diff --git a/engines/pink/sound.h b/engines/pink/sound.h index fdd5e23ce2..9e9dbdff62 100644 --- a/engines/pink/sound.h +++ b/engines/pink/sound.h @@ -49,6 +49,7 @@ public: void resume(); void stop(); + uint32 getCurrentSample(); void setBalance(int8 balance); private: |