diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/simon/items.cpp | 13 | ||||
-rw-r--r-- | engines/simon/simon.cpp | 6 | ||||
-rw-r--r-- | engines/simon/sound.cpp | 188 | ||||
-rw-r--r-- | engines/simon/sound.h | 4 | ||||
-rw-r--r-- | engines/simon/vga.cpp | 4 |
5 files changed, 132 insertions, 83 deletions
diff --git a/engines/simon/items.cpp b/engines/simon/items.cpp index 691222ad89..f7c9cbe262 100644 --- a/engines/simon/items.cpp +++ b/engines/simon/items.cpp @@ -1837,7 +1837,18 @@ void SimonEngine::o3_listSaveGames() { void SimonEngine::o3_checkCD() { // 135: switch CD - debug(0, "Switch to CD number %d", readVariable(97)); + uint disc = readVariable(97); + + if (!strcmp(_gameDescription->extra, "4CD")) { + _sound->switchVoiceFile(disc); + } else if (!strcmp(_gameDescription->extra, "2CD")) { + if (disc == 1 || disc == 2) + _sound->switchVoiceFile(1); + else if (disc == 3 || disc == 4) + _sound->switchVoiceFile(2); + } + + debug(0, "Switch to CD number %d", disc); } void SimonEngine::o3_screenTextBox() { diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp index 7e9979ff1a..4e14832a8b 100644 --- a/engines/simon/simon.cpp +++ b/engines/simon/simon.cpp @@ -3268,10 +3268,12 @@ void SimonEngine::playSpeech(uint speech_id, uint vgaSpriteId) { } _skipVgaWait = true; } else { - if (_subtitles && _language != Common::HB_ISR) { + if (getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) { loadVoice(speech_id); return; - } else if (_subtitles && _scriptVar2) { + } + + if (_subtitles && _scriptVar2) { loadSprite(4, 2, 5, 0, 0, 0); waitForSync(205); kill_sprite_simon2(2,5); diff --git a/engines/simon/sound.cpp b/engines/simon/sound.cpp index 73c0f36589..4dd7df3b04 100644 --- a/engines/simon/sound.cpp +++ b/engines/simon/sound.cpp @@ -256,8 +256,18 @@ Sound::Sound(SimonEngine *vm, const GameSpecificSettings *gss, Audio::Mixer *mix _hasVoiceFile = false; _ambientPlaying = 0; - // SIMON1CD32 uses separate speech files - if (!(_vm->getFeatures() & GF_TALKIE) || (_vm->getGameId() == GID_SIMON1CD32)) + if (_vm->getFeatures() & GF_TALKIE) { + loadVoiceFile(gss); + + if (_vm->getGameType() == GType_SIMON1) + loadSfxFile(gss); + } + +} + +void Sound::loadVoiceFile(const GameSpecificSettings *gss) { + // Game versions which use separate voice files + if (_vm->getGameType() == GType_FF || _vm->getGameId() == GID_SIMON1CD32) return; File *file = new File(); @@ -320,42 +330,43 @@ Sound::Sound(SimonEngine *vm, const GameSpecificSettings *gss, Audio::Mixer *mix _voice = new VocSound(_mixer, file); } } +} + +void Sound::loadSfxFile(const GameSpecificSettings *gss) { + File *file = new File(); - if ((_vm->getGameType() == GType_SIMON1) && (_vm->getFeatures() & GF_TALKIE)) { - file = new File(); #ifdef USE_MAD - if (!_hasEffectsFile && gss->mp3_effects_filename && gss->mp3_effects_filename[0]) { - file->open(gss->mp3_effects_filename); - if (file->isOpen()) { - _hasEffectsFile = true; - _effects = new MP3Sound(_mixer, file); - } + if (!_hasEffectsFile && gss->mp3_effects_filename && gss->mp3_effects_filename[0]) { + file->open(gss->mp3_effects_filename); + if (file->isOpen()) { + _hasEffectsFile = true; + _effects = new MP3Sound(_mixer, file); } + } #endif #ifdef USE_VORBIS - if (!_hasEffectsFile && gss->vorbis_effects_filename && gss->vorbis_effects_filename[0]) { - file->open(gss->vorbis_effects_filename); - if (file->isOpen()) { - _hasEffectsFile = true; - _effects = new VorbisSound(_mixer, file); - } + if (!_hasEffectsFile && gss->vorbis_effects_filename && gss->vorbis_effects_filename[0]) { + file->open(gss->vorbis_effects_filename); + if (file->isOpen()) { + _hasEffectsFile = true; + _effects = new VorbisSound(_mixer, file); } + } #endif #ifdef USE_FLAC - if (!_hasEffectsFile && gss->flac_effects_filename && gss->flac_effects_filename[0]) { - file->open(gss->flac_effects_filename); - if (file->isOpen()) { - _hasEffectsFile = true; - _effects = new FlacSound(_mixer, file); - } + if (!_hasEffectsFile && gss->flac_effects_filename && gss->flac_effects_filename[0]) { + file->open(gss->flac_effects_filename); + if (file->isOpen()) { + _hasEffectsFile = true; + _effects = new FlacSound(_mixer, file); } + } #endif - if (!_hasEffectsFile && gss->voc_effects_filename && gss->voc_effects_filename[0]) { - file->open(gss->voc_effects_filename); - if (file->isOpen()) { - _hasEffectsFile = true; - _effects = new VocSound(_mixer, file); - } + if (!_hasEffectsFile && gss->voc_effects_filename && gss->voc_effects_filename[0]) { + file->open(gss->voc_effects_filename); + if (file->isOpen()) { + _hasEffectsFile = true; + _effects = new VocSound(_mixer, file); } } } @@ -460,57 +471,6 @@ void Sound::playVoice(uint sound) { } } -void Sound::playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient) { - byte flags; - int rate; - - if (ambient == true) { - if (sound == _ambientPlaying) - return; - - _ambientPlaying = sound; - - if (_ambientPaused) - return; - } else { - if (_effectsPaused) - return; - } - - int size = READ_LE_UINT32(soundData + 4); - Common::MemoryReadStream stream(soundData, size); - if (!loadWAVFromStream(stream, size, rate, flags)) { - error("playSoundData: Not a valid WAV data"); - } - - byte *buffer = (byte *)malloc(size); - memcpy(buffer, soundData + stream.pos(), size); - - if (ambient == true) { - _mixer->stopHandle(_ambientHandle); - _mixer->playRaw(&_ambientHandle, buffer, size, rate, Audio::Mixer::FLAG_LOOP|flags); - } else { - _mixer->playRaw(&_effectsHandle, buffer, size, rate, flags); - } -} - -void Sound::playVoiceData(byte *soundData, uint sound) { - byte flags; - int rate; - - int size = READ_LE_UINT32(soundData + 4); - Common::MemoryReadStream stream(soundData, size); - if (!loadWAVFromStream(stream, size, rate, flags)) { - error("playSoundData: Not a valid WAV data"); - } - - byte *buffer = (byte *)malloc(size); - memcpy(buffer, soundData + stream.pos(), size); - - _mixer->stopHandle(_voiceHandle); - _mixer->playRaw(&_voiceHandle, buffer, size, rate, flags); -} - void Sound::playEffects(uint sound) { if (!_effects) return; @@ -570,4 +530,74 @@ void Sound::ambientPause(bool b) { } } +// Feeble Files specific +void Sound::playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient) { + byte flags; + int rate; + + if (ambient == true) { + if (sound == _ambientPlaying) + return; + + _ambientPlaying = sound; + + if (_ambientPaused) + return; + } else { + if (_effectsPaused) + return; + } + + int size = READ_LE_UINT32(soundData + 4); + Common::MemoryReadStream stream(soundData, size); + if (!loadWAVFromStream(stream, size, rate, flags)) { + error("playSoundData: Not a valid WAV data"); + } + + byte *buffer = (byte *)malloc(size); + memcpy(buffer, soundData + stream.pos(), size); + + if (ambient == true) { + _mixer->stopHandle(_ambientHandle); + _mixer->playRaw(&_ambientHandle, buffer, size, rate, Audio::Mixer::FLAG_LOOP|flags); + } else { + _mixer->playRaw(&_effectsHandle, buffer, size, rate, flags); + } +} + +void Sound::playVoiceData(byte *soundData, uint sound) { + byte flags; + int rate; + + int size = READ_LE_UINT32(soundData + 4); + Common::MemoryReadStream stream(soundData, size); + if (!loadWAVFromStream(stream, size, rate, flags)) { + error("playSoundData: Not a valid WAV data"); + } + + byte *buffer = (byte *)malloc(size); + memcpy(buffer, soundData + stream.pos(), size); + + _mixer->stopHandle(_voiceHandle); + _mixer->playRaw(&_voiceHandle, buffer, size, rate, flags); +} + +void Sound::switchVoiceFile(uint disc) { + if (_lastVoiceFile != disc) { + stopAll(); + + char filename[16]; + _lastVoiceFile = disc; + sprintf(filename, "voices%d.wav",disc); + File *file = new File(); + file->open(filename); + if (file->isOpen() == false) { + warning("playVoice: Can't load voice file %s", filename); + return; + } + delete _voice; + _voice = new WavSound(_mixer, file); + } +} + } // End of namespace Simon diff --git a/engines/simon/sound.h b/engines/simon/sound.h index f2da1a61e2..778a38c1f4 100644 --- a/engines/simon/sound.h +++ b/engines/simon/sound.h @@ -58,6 +58,9 @@ public: Sound(SimonEngine *vm, const GameSpecificSettings *gss, Audio::Mixer *mixer); ~Sound(); + void loadVoiceFile(const GameSpecificSettings *gss); + void loadSfxFile(const GameSpecificSettings *gss); + void readSfxFile(const char *filename); void loadSfxTable(Common::File *gameFile, uint32 base); void readVoiceFile(const char *filename); @@ -69,6 +72,7 @@ public: // Feeble Files specific void playSoundData(byte *soundData, uint sound, uint pan, uint vol, bool ambient); void playVoiceData(byte *soundData, uint sound); + void switchVoiceFile(uint disc); bool hasVoice() const; bool isVoiceActive() const; diff --git a/engines/simon/vga.cpp b/engines/simon/vga.cpp index 570021b160..edf531da8f 100644 --- a/engines/simon/vga.cpp +++ b/engines/simon/vga.cpp @@ -2217,8 +2217,10 @@ void SimonEngine::vc63_fastFadeIn() { } void SimonEngine::vc64_skipIfSpeechEnded() { - if (!_sound->isVoiceActive() || (_subtitles && _language != Common::HB_ISR)) + if ((getGameType() == GType_SIMON2 && _subtitles && _language != Common::HB_ISR) || + !_sound->isVoiceActive()) { vcSkipNextInstruction(); + } } void SimonEngine::vc65_slowFadeIn() { |