From 01b2f3867093cae9626126ce35bd2731a7072c6a Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Sun, 8 May 2005 14:31:27 +0000 Subject: HE games queue speech as sound resource 1. svn-id: r17965 --- scumm/sound.cpp | 58 ++++++++++++++++----------------------------------------- 1 file changed, 16 insertions(+), 42 deletions(-) (limited to 'scumm/sound.cpp') diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 4932ed41d1..68e3c3d066 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -648,10 +648,24 @@ static int compareMP3OffsetTable(const void *a, const void *b) { return ((const MP3OffsetTable *)a)->org_offset - ((const MP3OffsetTable *)b)->org_offset; } +void Sound::startHETalkSound(uint32 offset) { + byte *ptr; + int32 size; + + _vm->res.nukeResource(rtSound, 1); + _sfxFile->seek(offset + 4, SEEK_SET); + size = _sfxFile->readUint32BE() - 8; + _vm->res.createResource(rtSound, 1, size); + ptr = _vm->getResourceAddress(rtSound, 1); + _sfxFile->read(ptr, size); + + int channel = (_vm->VAR_SOUND_CHANNEL != 0xFF) ? _vm->VAR(_vm->VAR_SOUND_CHANNEL) : 0; + addSoundToQueue2(1, 0, channel, 0); +} + void Sound::startTalkSound(uint32 offset, uint32 b, int mode, SoundHandle *handle) { int num = 0, i; int size = 0; - byte *sound; int id = -1; if (_vm->_gameId == GID_CMI) { @@ -704,46 +718,6 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, SoundHandle *handl return; } - if (_vm->_heversion >= 60) { - _sfxMode |= mode; - - _sfxFile->seek(offset, SEEK_SET); - if (_sfxFile->readUint32LE() == TO_LE_32(MKID('WSOU'))) { - // Skip the WSOU chunk - _sfxFile->seek(offset + 8, SEEK_SET); - - // Try to load the WAVE data into an audio stream - AudioStream *stream = makeWAVStream(*_sfxFile); - if (!stream) { - warning("startTalkSound: IMA ADPCM compression not supported"); - return; - } - - int channel = _vm->VAR(_vm->VAR_SOUND_CHANNEL); - _vm->_mixer->playInputStream(SoundMixer::kSFXSoundType, &_heSoundChannels[channel], stream, 1); - } else { - // Skip the TALK (8) and HSHD (24) chunks - _sfxFile->seek(28, SEEK_CUR); - - if (_sfxFile->readUint32LE() == TO_LE_32(MKID('SBNG'))) { - // Skip the SBNG, so we end up at the SDAT chunk - size = _sfxFile->readUint32BE() - 4; - _sfxFile->seek(size, SEEK_CUR); - } - size = _sfxFile->readUint32BE() - 8; - sound = (byte *)malloc(size); - _sfxFile->read(sound, size); - - if (_vm->_heversion >= 70) { - int channel = _vm->VAR(_vm->VAR_SOUND_CHANNEL); - _vm->_mixer->playRaw(&_heSoundChannels[channel], sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE, 1); - } else { - _vm->_mixer->playRaw(handle, sound, size, 11000, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE); - } - } - return; - } - // Some games frequently assume that starting one sound effect will // automatically stop any other that may be playing at that time. So // that is what we do here, but we make an exception for speech. @@ -836,7 +810,7 @@ void Sound::stopTalkSound() { if (_sfxMode & 2) { if (_vm->_imuseDigital) { _vm->_imuseDigital->stopSound(kTalkSoundID); - } else if (_vm->_heversion >= 70) { + } else if (_vm->_heversion >= 60) { _vm->_mixer->stopID(1); } else { _vm->_mixer->stopHandle(_talkChannelHandle); -- cgit v1.2.3