aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/he/sound_he.cpp39
-rw-r--r--engines/scumm/he/sound_he.h1
2 files changed, 34 insertions, 6 deletions
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 9a039b0008..1a2dd25e86 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -154,6 +154,7 @@ void SoundHE::stopSound(int sound) {
if (_heChannel[i].sound == sound) {
_heChannel[i].sound = 0;
_heChannel[i].priority = 0;
+ _heChannel[i].timer = 0;
_heChannel[i].sbngBlock = 0;
_heChannel[i].codeOffs = 0;
memset(_heChannel[i].soundVars, 0, sizeof(_heChannel[i].soundVars));
@@ -191,6 +192,7 @@ void SoundHE::stopSoundChannel(int chan) {
_heChannel[chan].sound = 0;
_heChannel[chan].priority = 0;
+ _heChannel[chan].timer = 0;
_heChannel[chan].sbngBlock = 0;
_heChannel[chan].codeOffs = 0;
memset(_heChannel[chan].soundVars, 0, sizeof(_heChannel[chan].soundVars));
@@ -386,6 +388,27 @@ void SoundHE::processSoundCode() {
_heChannel[chan].codeOffs += size;
}
}
+
+ for (chan = 0; chan < ARRAYSIZE(_heChannel); chan++) {
+ if (_heChannel[chan].sound == 0)
+ continue;
+
+ if (_heChannel[chan].timer == 0)
+ continue;
+
+ if (_vm->getHETimer(chan + 4) > _heChannel[chan].timer) {
+ if (_heChannel[chan].sound == 1) {
+ _vm->stopTalk();
+ }
+
+ _heChannel[chan].sound = 0;
+ _heChannel[chan].priority = 0;
+ _heChannel[chan].timer = 0;
+ _heChannel[chan].sbngBlock = 0;
+ _heChannel[chan].codeOffs = 0;
+ _heChannel[chan].soundVars[0] = 0;
+ }
+ }
}
void SoundHE::processSoundOpcodes(int sound, byte *codePtr, int *soundVars) {
@@ -602,20 +625,24 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
_overrideFreq = 0;
}
+ _vm->setHETimer(heChannel + 4);
+ _heChannel[heChannel].sound = soundID;
+ _heChannel[heChannel].priority = priority;
+ _heChannel[heChannel].sbngBlock = (codeOffs != -1) ? 1 : 0;
+ _heChannel[heChannel].codeOffs = codeOffs;
+ memset(_heChannel[heChannel].soundVars, 0, sizeof(_heChannel[heChannel].soundVars));
+
// TODO: Extra sound flags
if (heFlags & 1) {
flags |= Audio::Mixer::FLAG_LOOP;
+ _heChannel[heChannel].timer = 0;
+ } else {
+ _heChannel[heChannel].timer = size * 1000 / rate;
}
_vm->_mixer->stopHandle(_heSoundChannels[heChannel]);
_vm->_mixer->playRaw(&_heSoundChannels[heChannel], ptr + heOffset + 8, size, rate, flags, soundID, 255, 0, 0,0, type);
- _vm->setHETimer(heChannel + 4);
- _heChannel[heChannel].sound = soundID;
- _heChannel[heChannel].priority = priority;
- _heChannel[heChannel].sbngBlock = (codeOffs != -1) ? 1 : 0;
- _heChannel[heChannel].codeOffs = codeOffs;
- memset(_heChannel[heChannel].soundVars, 0, sizeof(_heChannel[heChannel].soundVars));
}
// Support for PCM music in 3DO versions of Humongous Entertainment games
else if (READ_BE_UINT32(ptr) == MKID_BE('MRAW')) {
diff --git a/engines/scumm/he/sound_he.h b/engines/scumm/he/sound_he.h
index 4e3511b2ab..50f349863d 100644
--- a/engines/scumm/he/sound_he.h
+++ b/engines/scumm/he/sound_he.h
@@ -48,6 +48,7 @@ public: // Used by createSound()
int sound;
int codeOffs;
int priority;
+ int timer;
int sbngBlock;
int soundVars[27];
} _heChannel[8];