diff options
author | Max Horn | 2003-12-24 17:47:51 +0000 |
---|---|---|
committer | Max Horn | 2003-12-24 17:47:51 +0000 |
commit | 3fe9778b04c7c65db30300d598ee0e90df8e524e (patch) | |
tree | 5cd12d105d96fbfb2d5cdc487748d2dd4ec4b484 /scumm/sound.cpp | |
parent | 8c4b9bd8d683e862ae8e35d0c53d99b261961ad0 (diff) | |
download | scummvm-rg350-3fe9778b04c7c65db30300d598ee0e90df8e524e.tar.gz scummvm-rg350-3fe9778b04c7c65db30300d598ee0e90df8e524e.tar.bz2 scummvm-rg350-3fe9778b04c7c65db30300d598ee0e90df8e524e.zip |
cleanup
svn-id: r11895
Diffstat (limited to 'scumm/sound.cpp')
-rw-r--r-- | scumm/sound.cpp | 137 |
1 files changed, 68 insertions, 69 deletions
diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 3184674765..bdb6bdc2d0 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -461,7 +461,7 @@ static int compareMP3OffsetTable(const void *a, const void *b) { void Sound::startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle *handle) { int num = 0, i; - int size; + int size = 0; byte *sound; int id = -1; @@ -502,80 +502,79 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, PlayingSoundHandle return; } - startSfxSound(_sfxFile, 0, handle); - return; - } - - if (_sfxFile->isOpen() == false) { - warning("startTalkSound: SFX file is not open"); - return; - } - - // FIXME hack until more is known - // the size of the data after the sample isn't known - // 64 is just a guess - if (_scumm->_features & GF_HUMONGOUS) { - // SKIP TLKB (8) TALK (8) HSHD (24) and SDAT (8) - _sfxFile->seek(offset + 48, SEEK_SET); - sound = (byte *)malloc(b - 64); - _sfxFile->read(sound, b - 64); - _scumm->_mixer->playRaw(handle, sound, b - 64, 11025, 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. - // - // Do any other games than these need this hack? - // - // HACK: Checking for script 99 in Sam & Max is to keep Conroy's song - // from being interrupted. - - if (mode == 1 && (_scumm->_gameId == GID_TENTACLE - || (_scumm->_gameId == GID_SAMNMAX && !_scumm->isScriptRunning(99)))) { - id = 777777; - _scumm->_mixer->stopID(id); - } - - if (b > 8) { - num = (b - 8) >> 1; - } - - if (offset_table != NULL) { - MP3OffsetTable *result = NULL, key; - - key.org_offset = offset; - result = (MP3OffsetTable *)bsearch(&key, offset_table, num_sound_effects, - sizeof(MP3OffsetTable), compareMP3OffsetTable); + } else { - if (result == NULL) { - warning("startTalkSound: did not find sound at offset %d !", offset); + if (!_sfxFile->isOpen()) { + warning("startTalkSound: SFX file is not open"); return; } - if (2 * num != result->num_tags) { - warning("startTalkSound: number of tags do not match (%d - %d) !", b, - result->num_tags); - num = result->num_tags; + + // FIXME hack until more is known + // the size of the data after the sample isn't known + // 64 is just a guess + if (_scumm->_features & GF_HUMONGOUS) { + // SKIP TLKB (8) TALK (8) HSHD (24) and SDAT (8) + _sfxFile->seek(offset + 48, SEEK_SET); + sound = (byte *)malloc(b - 64); + _sfxFile->read(sound, b - 64); + _scumm->_mixer->playRaw(handle, sound, b - 64, 11025, SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE); + return; } - offset = result->new_offset; - size = result->compressed_size; - } else { - offset += 8; - size = -1; + + // 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. + // + // Do any other games than these need this hack? + // + // HACK: Checking for script 99 in Sam & Max is to keep Conroy's song + // from being interrupted. + + if (mode == 1 && (_scumm->_gameId == GID_TENTACLE + || (_scumm->_gameId == GID_SAMNMAX && !_scumm->isScriptRunning(99)))) { + id = 777777; + _scumm->_mixer->stopID(id); + } + + if (b > 8) { + num = (b - 8) >> 1; + } + + if (offset_table != NULL) { + MP3OffsetTable *result = NULL, key; + + key.org_offset = offset; + result = (MP3OffsetTable *)bsearch(&key, offset_table, num_sound_effects, + sizeof(MP3OffsetTable), compareMP3OffsetTable); + + if (result == NULL) { + warning("startTalkSound: did not find sound at offset %d !", offset); + return; + } + if (2 * num != result->num_tags) { + warning("startTalkSound: number of tags do not match (%d - %d) !", b, + result->num_tags); + num = result->num_tags; + } + offset = result->new_offset; + size = result->compressed_size; + } else { + offset += 8; + size = -1; + } + + _sfxFile->seek(offset, SEEK_SET); + + assert(num+1 < (int)ARRAYSIZE(_mouthSyncTimes)); + for (i = 0; i < num; i++) + _mouthSyncTimes[i] = _sfxFile->readUint16BE(); + + _mouthSyncTimes[i] = 0xFFFF; + _sfxMode |= mode; + _curSoundPos = 0; + _mouthSyncMode = true; } - _sfxFile->seek(offset, SEEK_SET); - - assert(num+1 < (int)ARRAYSIZE(_mouthSyncTimes)); - for (i = 0; i < num; i++) - _mouthSyncTimes[i] = _sfxFile->readUint16BE(); - - _mouthSyncTimes[i] = 0xFFFF; - _sfxMode |= mode; - _curSoundPos = 0; - _mouthSyncMode = true; - startSfxSound(_sfxFile, size, handle, id); } |