From a24cb57c9d4d4292da582fafc52be70103a1e369 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 16 Jun 2012 02:58:53 +0200 Subject: GOB: Loop the Little Red title music --- engines/gob/inter.h | 1 + engines/gob/inter_littlered.cpp | 8 ++++++++ engines/gob/sound/sound.cpp | 4 ++++ engines/gob/sound/sound.h | 1 + engines/gob/sound/soundblaster.cpp | 24 +++++++++++++++++++++--- engines/gob/sound/soundblaster.h | 4 ++++ 6 files changed, 39 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/gob/inter.h b/engines/gob/inter.h index 0625646cdd..63bf3eb1c6 100644 --- a/engines/gob/inter.h +++ b/engines/gob/inter.h @@ -527,6 +527,7 @@ protected: virtual void setupOpcodesGob(); void oLittleRed_keyFunc(OpFuncParams ¶ms); + void oLittleRed_playComposition(OpFuncParams ¶ms); }; class Inter_v3 : public Inter_v2 { diff --git a/engines/gob/inter_littlered.cpp b/engines/gob/inter_littlered.cpp index 3a4494598e..729d9f5694 100644 --- a/engines/gob/inter_littlered.cpp +++ b/engines/gob/inter_littlered.cpp @@ -48,6 +48,8 @@ void Inter_LittleRed::setupOpcodesFunc() { Inter_v2::setupOpcodesFunc(); OPCODEFUNC(0x14, oLittleRed_keyFunc); + + OPCODEFUNC(0x3D, oLittleRed_playComposition); } void Inter_LittleRed::setupOpcodesGob() { @@ -107,4 +109,10 @@ void Inter_LittleRed::oLittleRed_keyFunc(OpFuncParams ¶ms) { } } +void Inter_LittleRed::oLittleRed_playComposition(OpFuncParams ¶ms) { + _vm->_sound->blasterRepeatComposition(-1); + + o1_playComposition(params); +} + } // End of namespace Gob diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp index 9f72d1a98f..170330f281 100644 --- a/engines/gob/sound/sound.cpp +++ b/engines/gob/sound/sound.cpp @@ -445,6 +445,10 @@ void Sound::blasterPlay(SoundDesc *sndDesc, int16 repCount, _blaster->playSample(*sndDesc, repCount, frequency, fadeLength); } +void Sound::blasterRepeatComposition(int32 repCount) { + _blaster->repeatComposition(repCount);; +} + void Sound::blasterStop(int16 fadeLength, SoundDesc *sndDesc) { if (!_blaster) return; diff --git a/engines/gob/sound/sound.h b/engines/gob/sound/sound.h index 064a249253..6ad0ec5483 100644 --- a/engines/gob/sound/sound.h +++ b/engines/gob/sound/sound.h @@ -63,6 +63,7 @@ public: void blasterPlayComposition(int16 *composition, int16 freqVal, SoundDesc *sndDescs = 0, int8 sndCount = kSoundsCount); void blasterStopComposition(); + void blasterRepeatComposition(int32 repCount); char blasterPlayingSound() const; diff --git a/engines/gob/sound/soundblaster.cpp b/engines/gob/sound/soundblaster.cpp index 4ff555b0e3..915d744494 100644 --- a/engines/gob/sound/soundblaster.cpp +++ b/engines/gob/sound/soundblaster.cpp @@ -31,6 +31,8 @@ SoundBlaster::SoundBlaster(Audio::Mixer &mixer) : SoundMixer(mixer, Audio::Mixer _compositionSamples = 0; _compositionSampleCount = 0; _compositionPos = -1; + + _compositionRepCount = 0; } SoundBlaster::~SoundBlaster() { @@ -79,6 +81,7 @@ void SoundBlaster::nextCompositionPos() { if (_compositionPos == 49) _compositionPos = -1; } + _compositionPos = -1; } @@ -98,6 +101,10 @@ void SoundBlaster::playComposition(int16 *composition, int16 freqVal, nextCompositionPos(); } +void SoundBlaster::repeatComposition(int32 repCount) { + _compositionRepCount = repCount; +} + void SoundBlaster::setSample(SoundDesc &sndDesc, int16 repCount, int16 frequency, int16 fadeLength) { @@ -106,10 +113,21 @@ void SoundBlaster::setSample(SoundDesc &sndDesc, int16 repCount, int16 frequency } void SoundBlaster::checkEndSample() { - if (_compositionPos != -1) + if (_compositionPos != -1) { + nextCompositionPos(); + return; + } + + if (_compositionRepCount != 0) { + if (_compositionRepCount > 0) + _compositionRepCount--; + nextCompositionPos(); - else - SoundMixer::checkEndSample(); + if (_compositionPos != -1) + return; + } + + SoundMixer::checkEndSample(); } void SoundBlaster::endFade() { diff --git a/engines/gob/sound/soundblaster.h b/engines/gob/sound/soundblaster.h index c2704c5482..c740ba2269 100644 --- a/engines/gob/sound/soundblaster.h +++ b/engines/gob/sound/soundblaster.h @@ -46,6 +46,8 @@ public: void stopComposition(); void endComposition(); + void repeatComposition(int32 repCount); + protected: Common::Mutex _mutex; @@ -54,6 +56,8 @@ protected: int16 _composition[50]; int8 _compositionPos; + int32 _compositionRepCount; + SoundDesc *_curSoundDesc; void setSample(SoundDesc &sndDesc, int16 repCount, -- cgit v1.2.3