aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scumm/sound.cpp58
-rw-r--r--scumm/sound.h1
-rw-r--r--scumm/string.cpp12
3 files changed, 26 insertions, 45 deletions
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);
diff --git a/scumm/sound.h b/scumm/sound.h
index 89c4335c6d..b4602cd834 100644
--- a/scumm/sound.h
+++ b/scumm/sound.h
@@ -107,6 +107,7 @@ public:
void processSoundQues();
void setOverrideFreq(int freq);
void playSound(int soundID, int heOffset, int heChannel, int heFlags);
+ void startHETalkSound(uint32 offset);
void startTalkSound(uint32 offset, uint32 b, int mode, SoundHandle *handle = NULL);
void stopTalkSound();
bool isMouthSyncOff(uint pos);
diff --git a/scumm/string.cpp b/scumm/string.cpp
index f41a9bb1fb..e847219ed4 100644
--- a/scumm/string.cpp
+++ b/scumm/string.cpp
@@ -274,7 +274,7 @@ void ScummEngine::CHARSET_1() {
value[i] = 0;
talk_sound_b = atoi(value);
- _sound->talkSound(talk_sound_a, talk_sound_b, 2);
+ _sound->startHETalkSound(talk_sound_a);
break;
case 104:
_haveMsg = 0;
@@ -295,7 +295,7 @@ void ScummEngine::CHARSET_1() {
talk_sound_a = atoi(value);
talk_sound_b = 0;
- _sound->talkSound(talk_sound_a, talk_sound_b, 2);
+ _sound->startHETalkSound(talk_sound_a);
break;
case 119:
if (_haveMsg != 0xFE)
@@ -335,7 +335,11 @@ void ScummEngine::CHARSET_1() {
talk_sound_b = buffer[8] | (buffer[9] << 8) | (buffer[12] << 16) | (buffer[13] << 24);
buffer += 14;
- _sound->talkSound(talk_sound_a, talk_sound_b, 2);
+ if (_heversion >= 60) {
+ _sound->startHETalkSound(talk_sound_a);
+ } else {
+ _sound->talkSound(talk_sound_a, talk_sound_b, 2);
+ }
// Set flag that speech variant exist of this msg.
// This is actually a hack added by ScummVM; the original did
@@ -393,6 +397,8 @@ loc_avoid_ks_fe:
} else {
if ((_imuseDigital && _sound->isSoundRunning(kTalkSoundID)) && (!ConfMan.getBool("subtitles") || VAR(VAR_VOICE_MODE) == 0)) {
// Special case for games using imuse digital.for sound
+ } else if (_heversion >= 60 && !ConfMan.getBool("subtitles") && _sound->isSoundRunning(1)) {
+ // Special case for HE games
} else if ((_gameId == GID_LOOM256) && !ConfMan.getBool("subtitles") && (_sound->pollCD())) {
// Special case for loomcd, since it only uses CD audio.for sound
} else if (!ConfMan.getBool("subtitles") && (_haveMsg == 0xFE || _mixer->isSoundHandleActive(_sound->_talkChannelHandle))) {