From e77928440307f0d8a765e32100e031989ad25ff5 Mon Sep 17 00:00:00 2001 From: Robert Špalek Date: Mon, 12 Oct 2009 22:27:23 +0000 Subject: Sound effects are now correctly played. Dubbing is not yet played. svn-id: r45000 --- engines/draci/animation.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'engines/draci/animation.cpp') diff --git a/engines/draci/animation.cpp b/engines/draci/animation.cpp index c3ae4a8f12..37ef609ea4 100644 --- a/engines/draci/animation.cpp +++ b/engines/draci/animation.cpp @@ -39,6 +39,7 @@ Animation::Animation(DraciEngine *vm, int index) : _vm(vm) { _paused = false; _tick = _vm->_system->getMillis(); _currentFrame = 0; + _hasChangedFrame = true; _callback = &Animation::doNothing; } @@ -97,6 +98,8 @@ void Animation::nextFrame(bool force) { // Fetch new frame and mark it dirty markDirtyRect(surface); + + _hasChangedFrame = true; } } @@ -129,6 +132,15 @@ void Animation::drawFrame(Surface *surface) { // Draw frame frame->drawReScaled(surface, false, _displacement); } + + const SoundSample *sample = _samples[_currentFrame]; + if (_hasChangedFrame && sample) { + debugC(3, kDraciSoundDebugLevel, + "Playing sample on animation %d, frame %d: %d+%d at %dHz", + _id, _currentFrame, sample->_offset, sample->_length, sample->_frequency); + _vm->_sound->playSound(sample, Audio::Mixer::kMaxChannelVolume, false); + } + _hasChangedFrame = false; } void Animation::setID(int id) { @@ -162,6 +174,9 @@ bool Animation::isPlaying() const { void Animation::setPlaying(bool playing) { _tick = _vm->_system->getMillis(); _playing = playing; + + // When restarting an animation, allow playing sounds. + _hasChangedFrame |= playing; } bool Animation::isPaused() const { -- cgit v1.2.3