diff options
author | Bastien Bouclet | 2010-12-24 11:04:25 +0000 |
---|---|---|
committer | Bastien Bouclet | 2010-12-24 11:04:25 +0000 |
commit | 938b63323897e9e673191e12e0339b2ec032a624 (patch) | |
tree | cfee6b1b22dc2de42ed448a2e5b15b2951a48aa4 | |
parent | 04b516322857829758a4269794d39919ba9f1b80 (diff) | |
download | scummvm-rg350-938b63323897e9e673191e12e0339b2ec032a624.tar.gz scummvm-rg350-938b63323897e9e673191e12e0339b2ec032a624.tar.bz2 scummvm-rg350-938b63323897e9e673191e12e0339b2ec032a624.zip |
MOHAWK: Fix playing sound from aliases in Myst ME.
svn-id: r55031
-rw-r--r-- | engines/mohawk/sound.cpp | 25 | ||||
-rw-r--r-- | engines/mohawk/sound.h | 1 |
2 files changed, 22 insertions, 4 deletions
diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index aec01dcdd5..fd825b1575 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -130,13 +130,13 @@ Audio::SoundHandle *Sound::replaceSound(uint16 id, byte volume, bool loop) { //TODO: The original engine does fading - Common::String name = _vm->getResourceName(ID_MSND, id); + Common::String name = getName(id); // Check if sound is already playing for (uint32 i = 0; i < _handles.size(); i++) if (_handles[i].type == kUsedHandle && _vm->_mixer->isSoundHandleActive(_handles[i].handle) - && name.equals(_vm->getResourceName(ID_MSND, _handles[i].id))) + && name.equals(getName(_handles[i].id))) return &_handles[i].handle; stopSound(); @@ -562,13 +562,13 @@ Audio::SoundHandle *Sound::replaceBackground(uint16 id, uint16 volume) { //TODO: The original engine does fading - Common::String name = _vm->getResourceName(ID_MSND, id); + Common::String name = getName(id); // Check if sound is already playing for (uint32 i = 0; i < _handles.size(); i++) if (_handles[i].type == kBackgroundHandle && _vm->_mixer->isSoundHandleActive(_handles[i].handle) - && name.equals(_vm->getResourceName(ID_MSND, _handles[i].id))) + && name.equals(getName(_handles[i].id))) return &_handles[i].handle; // Stop old background sound @@ -619,4 +619,21 @@ void Sound::changeBackgroundVolume(uint16 vol) { _vm->_mixer->setChannelVolume(_handles[i].handle, vol >> 8); } +Common::String Sound::getName(uint16 id) { + if (_vm->getFeatures() & GF_ME) { + // Myst ME is a bit more efficient with sound storage than Myst + // Myst has lots of sounds repeated. To overcome this, Myst ME + // has MJMP resources which provide a link to the actual MSND + // resource we're looking for. This saves a lot of space from + // repeated data. + if (_vm->hasResource(ID_MJMP, id)) { + Common::SeekableReadStream *mjmpStream = _vm->getResource(ID_MJMP, id); + id = mjmpStream->readUint16LE(); + delete mjmpStream; + } + } + + return _vm->getResourceName(ID_MSND, id); +} + } // End of namespace Mohawk diff --git a/engines/mohawk/sound.h b/engines/mohawk/sound.h index daadd765eb..3c16939556 100644 --- a/engines/mohawk/sound.h +++ b/engines/mohawk/sound.h @@ -157,6 +157,7 @@ private: Common::Array<SndHandle> _handles; SndHandle *getHandle(); Audio::AudioStream *makeAudioStream(uint16 id); + Common::String getName(uint16 id); // Riven-specific void playSLSTSound(uint16 index, bool fade, bool loop, uint16 volume, int16 balance); |