diff options
author | Travis Howell | 2005-01-30 11:03:49 +0000 |
---|---|---|
committer | Travis Howell | 2005-01-30 11:03:49 +0000 |
commit | bebad400d6cbbf38f8664bc1f2a5afea5716e93b (patch) | |
tree | 6ea72d3b7dd33de9c0b25f2c880beea9a3fc8830 /scumm | |
parent | 0199bf70fe9e5d94666b876eaa5dbab3bf5008d8 (diff) | |
download | scummvm-rg350-bebad400d6cbbf38f8664bc1f2a5afea5716e93b.tar.gz scummvm-rg350-bebad400d6cbbf38f8664bc1f2a5afea5716e93b.tar.bz2 scummvm-rg350-bebad400d6cbbf38f8664bc1f2a5afea5716e93b.zip |
Check sound queue for music in HE games.
Avoid extra sound channel.
svn-id: r16706
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/akos.cpp | 3 | ||||
-rw-r--r-- | scumm/intern.h | 2 | ||||
-rw-r--r-- | scumm/script_v100he.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v72he.cpp | 11 | ||||
-rw-r--r-- | scumm/script_v80he.cpp | 2 | ||||
-rw-r--r-- | scumm/script_v90he.cpp | 2 | ||||
-rw-r--r-- | scumm/sound.cpp | 40 | ||||
-rw-r--r-- | scumm/sound.h | 1 |
8 files changed, 23 insertions, 40 deletions
diff --git a/scumm/akos.cpp b/scumm/akos.cpp index b1af3d9727..7dbdc2359b 100644 --- a/scumm/akos.cpp +++ b/scumm/akos.cpp @@ -211,7 +211,6 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { while (size--) { if (READ_LE_UINT32(akst) == 0) { a->cost.seq3[i] = READ_LE_UINT32(akst + 4); - akst += 8; found = true; break; } @@ -243,7 +242,6 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { if (READ_LE_UINT16(aksf) == start) { a->cost.seq1[i] = READ_LE_UINT16(aksf + 2); a->cost.seq2[i] = READ_LE_UINT16(aksf + 4); - aksf += 6; found = true; break; } @@ -268,7 +266,6 @@ void ScummEngine::akos_decodeData(Actor *a, int frame, uint usemask) { while (size--) { if (READ_LE_UINT32(akst) == start) { a->cost.seq3[i] = READ_LE_UINT32(akst + 4); - akst += 8; found = true; break; } diff --git a/scumm/intern.h b/scumm/intern.h index 10c9671820..97e6441ce8 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -759,7 +759,7 @@ protected: void o72_captureWizImage(); void o72_getTimer(); void o72_setTimer(); - void o72_unknown5A(); + void o72_getSoundElapsedTimeOfSound(); void o72_startScript(); void o72_startObject(); void o72_drawObject(); diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp index 28851fb69c..ec3702819e 100644 --- a/scumm/script_v100he.cpp +++ b/scumm/script_v100he.cpp @@ -311,7 +311,7 @@ void ScummEngine_v100he::setupOpcodes() { OPCODE(o6_isScriptRunning), OPCODE(o90_sin), /* D8 */ - OPCODE(o72_unknown5A), + OPCODE(o72_getSoundElapsedTimeOfSound), OPCODE(o6_isSoundRunning), OPCODE(o80_getSoundVar), OPCODE(o100_unknown25), diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 44686e5bdd..051c4342ca 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -155,7 +155,7 @@ void ScummEngine_v72he::setupOpcodes() { /* 58 */ OPCODE(o72_getTimer), OPCODE(o72_setTimer), - OPCODE(o72_unknown5A), + OPCODE(o72_getSoundElapsedTimeOfSound), OPCODE(o6_wordArrayDec), /* 5C */ OPCODE(o6_if), @@ -714,13 +714,10 @@ void ScummEngine_v72he::o72_setTimer() { } } -void ScummEngine_v72he::o72_unknown5A() { - // Seems to get length of sound already played +void ScummEngine_v72he::o72_getSoundElapsedTimeOfSound() { int snd = pop(); - int r = _mixer->getSoundElapsedTime(_sound->_musicChannelHandle); - - push(r * 10); - debug(1,"o72_unknown5A stub (%d)", snd); + push(_mixer->getSoundElapsedTimeOfSoundID(snd) * 10); + debug(1,"o72_getSoundElapsedTimeOfSound (%d)", snd); } void ScummEngine_v72he::o72_startScript() { diff --git a/scumm/script_v80he.cpp b/scumm/script_v80he.cpp index 01377a5d43..898d9b14d0 100644 --- a/scumm/script_v80he.cpp +++ b/scumm/script_v80he.cpp @@ -153,7 +153,7 @@ void ScummEngine_v80he::setupOpcodes() { /* 58 */ OPCODE(o72_getTimer), OPCODE(o72_setTimer), - OPCODE(o72_unknown5A), + OPCODE(o72_getSoundElapsedTimeOfSound), OPCODE(o6_wordArrayDec), /* 5C */ OPCODE(o6_if), diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp index fcffa3dd51..d747838682 100644 --- a/scumm/script_v90he.cpp +++ b/scumm/script_v90he.cpp @@ -153,7 +153,7 @@ void ScummEngine_v90he::setupOpcodes() { /* 58 */ OPCODE(o72_getTimer), OPCODE(o72_setTimer), - OPCODE(o72_unknown5A), + OPCODE(o72_getSoundElapsedTimeOfSound), OPCODE(o6_wordArrayDec), /* 5C */ OPCODE(o6_if), diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 43cbcb5b65..73a586d471 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -164,7 +164,6 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) { int size = -1; int rate; byte flags = SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE; - bool music = false; if (_vm->_heversion >= 70 && soundID > _vm->_numSounds) { debug(0, "playSound #%d", soundID); @@ -199,16 +198,15 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) { if (skip > tracks - 1) skip = 0; - musicFile.seek(+28, SEEK_CUR); - if (musicFile.readUint32LE() == TO_LE_32(MKID('SGEN'))) { + if (_vm->_heversion >= 80) { + // Skip to offsets + musicFile.seek(+40, SEEK_CUR); + // Skip to correct music header skip *= 21; - - // Skip to offsets - musicFile.seek(+8, SEEK_CUR); } else { - // Rewind - musicFile.seek(-28, SEEK_CUR); + // Skip to offsets + musicFile.seek(+4, SEEK_CUR); // Skip to correct music header skip *= 25; @@ -229,12 +227,10 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) { musicFile.read(ptr, size); musicFile.close(); + _vm->_mixer->stopID(_currentMusic); _currentMusic = soundID; - music = true; if (_vm->_heversion == 70) { - // Allocate a sound buffer, copy the data into it, and play - _vm->_mixer->stopHandle(_musicChannelHandle); - _vm->_mixer->playRaw(&_musicChannelHandle, ptr, size, 11025, flags, soundID); + _vm->_mixer->playRaw(NULL, ptr, size, 11025, flags, soundID); return; } } else { @@ -299,18 +295,12 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) { } // TODO: Set sound channel based on heChannel - if (heFlags & 1) - flags |= SoundMixer::FLAG_LOOP; + // Set sound looping based on heFlags // Allocate a sound buffer, copy the data into it, and play sound = (char *)malloc(size); memcpy(sound, ptr + heOffset + 8, size); - - if (music == true) { - _vm->_mixer->stopHandle(_musicChannelHandle); - _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID); - } else - _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); + _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); } else if (READ_UINT32(ptr) == MKID('MRAW')) { // pcm music in 3DO humongous games @@ -325,9 +315,9 @@ void Sound::playSound(int soundID, int heOffset, int heChannel, int heFlags) { // Allocate a sound buffer, copy the data into it, and play sound = (char *)malloc(size); memcpy(sound, ptr + 8, size); + _vm->_mixer->stopID(_currentMusic); _currentMusic = soundID; - _vm->_mixer->stopHandle(_musicChannelHandle); - _vm->_mixer->playRaw(&_musicChannelHandle, sound, size, rate, flags, soundID); + _vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); } // Support for sampled sound effects in Monkey Island 1 and 2 else if (READ_UINT32(ptr) == MKID('SBL ')) { @@ -673,7 +663,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle _sfxFile->seek(offset + 32, SEEK_SET); if (_sfxFile->readUint32LE() == TO_LE_32(MKID('SBNG'))) { - warning("startTalkSound: Skipped SBNG block"); + debug(2, "startTalkSound: Skipped SBNG block"); // Skip the SBNG, so we end up at the SDAT chunk extra = _sfxFile->readUint32BE(); _sfxFile->seek(extra - 4, SEEK_CUR); @@ -821,8 +811,8 @@ int Sound::isSoundRunning(int sound) const { // getSoundStatus(), with a -1, will return the // ID number of the first active music it finds. if (_vm->_heversion >= 70 || _currentMusic) - return (_musicChannelHandle.isActive()); - else if (_vm->_imuse) + sound = _currentMusic; + if (_vm->_imuse) return (_vm->_imuse->getSoundStatus(sound)); } } diff --git a/scumm/sound.h b/scumm/sound.h index c2b6f0db70..6b3830d323 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -85,7 +85,6 @@ protected: int16 _currentMusic; public: PlayingSoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on - PlayingSoundHandle _musicChannelHandle; // Handle of mixer channel music is on bool _soundsPaused; byte _sfxMode; |