diff options
Diffstat (limited to 'engines/saga')
-rw-r--r-- | engines/saga/detection.cpp | 40 | ||||
-rw-r--r-- | engines/saga/input.cpp | 3 | ||||
-rw-r--r-- | engines/saga/interface.cpp | 12 | ||||
-rw-r--r-- | engines/saga/introproc_ihnm.cpp | 10 | ||||
-rw-r--r-- | engines/saga/music.cpp | 14 | ||||
-rw-r--r-- | engines/saga/music.h | 3 | ||||
-rw-r--r-- | engines/saga/saga.cpp | 39 | ||||
-rw-r--r-- | engines/saga/saga.h | 6 | ||||
-rw-r--r-- | engines/saga/scene.cpp | 2 | ||||
-rw-r--r-- | engines/saga/sfuncs.cpp | 4 | ||||
-rw-r--r-- | engines/saga/sound.cpp | 47 | ||||
-rw-r--r-- | engines/saga/sound.h | 7 |
12 files changed, 127 insertions, 60 deletions
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 9c897d8ebc..cc9ba34cdc 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -147,9 +147,19 @@ public: return "Inherit the Earth (C) Wyrmkeep Entertainment"; } + virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const; + virtual SaveStateList listSaves(const char *target) const; }; +bool SagaMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsListSaves) || + (f == kSupportsDirectLoad) || + (f == kSupportsDeleteSave); +} + bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { const Saga::SAGAGameDescription *gd = (const Saga::SAGAGameDescription *)desc; if (gd) { @@ -158,6 +168,36 @@ bool SagaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return gd != 0; } +SaveStateList SagaMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringList filenames; + char saveDesc[SAVE_TITLE_SIZE]; + Common::String pattern = target; + pattern += ".s??"; + + filenames = saveFileMan->listSavefiles(pattern.c_str()); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + for (Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + // Obtain the last 2 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 2); + + if (slotNum >= 0 && slotNum <= 99) { + Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); + if (in) { + for (int i = 0; i < 3; i++) + in->readUint32BE(); + in->read(saveDesc, SAVE_TITLE_SIZE); + saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file)); + delete in; + } + } + } + + return saveList; +} + #if PLUGIN_ENABLED_DYNAMIC(SAGA) REGISTER_PLUGIN_DYNAMIC(SAGA, PLUGIN_TYPE_ENGINE, SagaMetaEngine); #else diff --git a/engines/saga/input.cpp b/engines/saga/input.cpp index ac80d87dd0..61b729b701 100644 --- a/engines/saga/input.cpp +++ b/engines/saga/input.cpp @@ -141,9 +141,6 @@ int SagaEngine::processInput() { break; case Common::EVENT_MOUSEMOVE: break; - case Common::EVENT_QUIT: - shutDown(); - break; default: break; } diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 256e231f57..2112f5ee98 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -688,7 +688,7 @@ bool Interface::processAscii(Common::KeyState keystate) { setMode(kPanelMain); _vm->_script->setNoPendingVerb(); } else if (ascii == 'q' || ascii == 'Q') { - _vm->shutDown(); + _vm->quitGame(); } break; case kPanelBoss: @@ -1084,7 +1084,7 @@ void Interface::setQuit(PanelButton *panelButton) { if (_vm->getGameId() == GID_IHNM_DEMO) _vm->_scene->creditsScene(); // display sales info for IHNM demo else - _vm->shutDown(); + _vm->quitGame(); break; } } @@ -1153,6 +1153,7 @@ void Interface::setLoad(PanelButton *panelButton) { debug(1, "Loading save game %d", _vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber); setMode(kPanelMain); _vm->load(_vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber)); + _vm->syncSoundSettings(); } } } @@ -1616,6 +1617,7 @@ void Interface::setOption(PanelButton *panelButton) { debug(1, "Loading save game %d", _vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber); setMode(kPanelMain); _vm->load(_vm->calcSaveFileName(_vm->getSaveFile(_optionSaveFileTitleNumber)->slotNumber)); + _vm->syncSoundSettings(); } } } else { @@ -1650,8 +1652,8 @@ void Interface::setOption(PanelButton *panelButton) { break; case kTextSound: _vm->_soundVolume = (_vm->_soundVolume + 1) % 11; - _vm->_sound->setVolume(_vm->_soundVolume == 10 ? 255 : _vm->_soundVolume * 25); ConfMan.setInt("sfx_volume", _vm->_soundVolume * 25); + _vm->_sound->setVolume(); break; case kTextVoices: if (_vm->_voiceFilesExist) { @@ -1669,6 +1671,10 @@ void Interface::setOption(PanelButton *panelButton) { _vm->_subtitlesEnabled = true; // Set it to "Text" _vm->_voicesEnabled = false; } + + _vm->_speechVolume = (_vm->_speechVolume + 1) % 11; + ConfMan.setInt("speech_volume", _vm->_speechVolume * 25); + _vm->_sound->setVolume(); ConfMan.setBool("subtitles", _vm->_subtitlesEnabled); ConfMan.setBool("voices", _vm->_voicesEnabled); diff --git a/engines/saga/introproc_ihnm.cpp b/engines/saga/introproc_ihnm.cpp index 6614f4098f..aaa428ca53 100644 --- a/engines/saga/introproc_ihnm.cpp +++ b/engines/saga/introproc_ihnm.cpp @@ -59,8 +59,12 @@ int Scene::IHNMStartProc() { // Play Cyberdreams logo for 168 frames if (!playTitle(0, logoLength, true)) { + if (_vm->quit()) + return !SUCCESS; // Play Dreamers Guild logo for 10 seconds if (!playLoopingTitle(1, 10)) { + if (_vm->quit()) + return !SUCCESS; // Play the title music _vm->_music->play(1, MUSIC_NORMAL); // Play title screen @@ -70,6 +74,8 @@ int Scene::IHNMStartProc() { } else { _vm->_music->play(1, MUSIC_NORMAL); playTitle(0, 10); + if (_vm->quit()) + return !SUCCESS; playTitle(2, 12); } @@ -142,9 +148,9 @@ bool Scene::checkKey() { while (_vm->_eventMan->pollEvent(event)) { switch (event.type) { + case Common::EVENT_RTL: case Common::EVENT_QUIT: res = true; - _vm->shutDown(); break; case Common::EVENT_KEYDOWN: // Don't react to modifier keys alone. The original did @@ -187,7 +193,7 @@ bool Scene::playTitle(int title, int time, int mode) { _vm->_gfx->getCurrentPal(pal_cut); - while (!done) { + while (!done && !_vm->quit()) { curTime = _vm->_system->getMillis(); switch (phase) { diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp index 75008efb7d..9b0efad0d5 100644 --- a/engines/saga/music.cpp +++ b/engines/saga/music.cpp @@ -348,7 +348,7 @@ void MusicPlayer::stopMusic() { } } -Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enabled) : _vm(vm), _mixer(mixer), _enabled(enabled), _adlib(false) { +Music::Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver) : _vm(vm), _mixer(mixer), _adlib(false) { _player = new MusicPlayer(driver); _currentVolume = 0; @@ -434,11 +434,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) { uint32 loopStart; debug(2, "Music::play %d, %d", resourceId, flags); - - if (!_enabled) { - return; - } - + if (isPlaying() && _trackNumber == resourceId) { return; } @@ -446,11 +442,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) { _trackNumber = resourceId; _player->stopMusic(); _mixer->stopHandle(_musicHandle); - - if (!_vm->_musicVolume) { - return; - } - + int realTrackNumber; if (_vm->getGameType() == GType_ITE) { diff --git a/engines/saga/music.h b/engines/saga/music.h index 1953dc6f91..57ff9e0671 100644 --- a/engines/saga/music.h +++ b/engines/saga/music.h @@ -105,7 +105,7 @@ protected: class Music { public: - Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver, int enabled); + Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver); ~Music(void); void setNativeMT32(bool b) { _player->setNativeMT32(b); } bool hasNativeMT32() { return _player->hasNativeMT32(); } @@ -133,7 +133,6 @@ private: Audio::SoundHandle _musicHandle; uint32 _trackNumber; - int _enabled; bool _adlib; int _targetVolume; diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index 34cd70e47e..aa3624acea 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -64,7 +64,6 @@ SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc) _leftMouseButtonPressed = _rightMouseButtonPressed = false; _console = NULL; - _quit = false; _resource = NULL; _sndRes = NULL; @@ -142,8 +141,7 @@ SagaEngine::~SagaEngine() { } int SagaEngine::init() { - _soundVolume = ConfMan.getInt("sfx_volume") / 25; - _musicVolume = ConfMan.getInt("music_volume") / 25; + _musicVolume = ConfMan.getInt("music_volume"); _subtitlesEnabled = ConfMan.getBool("subtitles"); _readingSpeed = getTalkspeed(); _copyProtection = ConfMan.getBool("copy_protection"); @@ -194,29 +192,21 @@ int SagaEngine::init() { if (native_mt32) _driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); - _music = new Music(this, _mixer, _driver, _musicVolume); + _music = new Music(this, _mixer, _driver); _music->setNativeMT32(native_mt32); _music->setAdlib(adlib); - - if (!_musicVolume) { - debug(1, "Music disabled."); - } - _render = new Render(this, _system); if (!_render->initialized()) { return FAILURE; } // Initialize system specific sound - _sound = new Sound(this, _mixer, _soundVolume); - if (!_soundVolume) { - debug(1, "Sound disabled."); - } - + _sound = new Sound(this, _mixer); + _interface->converseInit(); _script->setVerb(_script->getVerbType(kVerbWalkTo)); - _music->setVolume(-1, 1); + _music->setVolume(_musicVolume, 1); _gfx->initPalette(); @@ -233,6 +223,8 @@ int SagaEngine::init() { } } + syncSoundSettings(); + // FIXME: This is the ugly way of reducing redraw overhead. It works // well for 320x200 but it's unclear how well it will work for // 640x480. @@ -270,6 +262,7 @@ int SagaEngine::go() { char *fileName = calcSaveFileName(ConfMan.getInt("save_slot")); load(fileName); + syncSoundSettings(); } else { _framesEsc = 0; _scene->startScene(); @@ -277,7 +270,7 @@ int SagaEngine::go() { uint32 currentTicks; - while (!_quit) { + while (!quit()) { if (_console->isAttached()) _console->onFrame(); @@ -317,7 +310,7 @@ int SagaEngine::go() { _system->delayMillis(10); } - return 0; + return _eventMan->shouldRTL(); } void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) { @@ -527,4 +520,16 @@ int SagaEngine::getTalkspeed() { return (ConfMan.getInt("talkspeed") * 3 + 255 / 2) / 255; } +void SagaEngine::syncSoundSettings() { + _subtitlesEnabled = ConfMan.getBool("subtitles"); + _readingSpeed = getTalkspeed(); + + if (_readingSpeed > 3) + _readingSpeed = 0; + + _musicVolume = ConfMan.getInt("music_volume"); + _music->setVolume(_musicVolume, 1); + _sound->setVolume(); +} + } // End of namespace Saga diff --git a/engines/saga/saga.h b/engines/saga/saga.h index eeb8f7a61b..0b6b3b1478 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -492,7 +492,6 @@ protected: public: SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc); virtual ~SagaEngine(); - void shutDown() { _quit = true; } void save(const char *fileName, const char *saveName); void load(const char *fileName); @@ -513,6 +512,8 @@ public: return isSaveListFull() ? _saveFilesCount : _saveFilesCount + 1; } + virtual void syncSoundSettings(); + int16 _framesEsc; uint32 _globalFlags; @@ -521,6 +522,7 @@ public: int _soundVolume; int _musicVolume; + int _speechVolume; bool _subtitlesEnabled; bool _voicesEnabled; bool _voiceFilesExist; @@ -611,8 +613,6 @@ public: bool _rightMouseButtonPressed; int _mouseClickCount; - bool _quit; - //current game description int _gameNumber; const SAGAGameDescription *_gameDescription; diff --git a/engines/saga/scene.cpp b/engines/saga/scene.cpp index c3c1587822..074b4c933a 100644 --- a/engines/saga/scene.cpp +++ b/engines/saga/scene.cpp @@ -315,7 +315,7 @@ void Scene::creditsScene() { break; } - _vm->shutDown(); + _vm->quitGame(); return; } diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index feee6612f4..e1e1074e1d 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -339,7 +339,7 @@ void Script::sfMainMode(SCRIPTFUNC_PARAMS) { // exit the game. Known non-interactive demos are GID_ITE_MACDEMO1 and // GID_ITE_WINDEMO1 if (_vm->getFeatures() & GF_NON_INTERACTIVE) - _vm->shutDown(); + _vm->quitGame(); } // Script function #6 (0x06) blocking @@ -555,7 +555,7 @@ void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) { } if (_vm->getGameType() == GType_ITE && sceneNumber < 0) { - _vm->shutDown(); + _vm->quitGame(); return; } diff --git a/engines/saga/sound.cpp b/engines/saga/sound.cpp index 1d3263d302..1d41d39cf2 100644 --- a/engines/saga/sound.cpp +++ b/engines/saga/sound.cpp @@ -22,8 +22,10 @@ * $Id$ * */ -#include "saga/saga.h" +#include "common/config-manager.h" + +#include "saga/saga.h" #include "saga/sound.h" #include "sound/audiostream.h" @@ -32,13 +34,13 @@ namespace Saga { -Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume) : +Sound::Sound(SagaEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer), _voxStream(0) { for (int i = 0; i < SOUND_HANDLES; i++) _handles[i].type = kFreeHandle; - setVolume(volume == 10 ? 255 : volume * 25); + setVolume(); } Sound::~Sound() { @@ -61,7 +63,8 @@ SndHandle *Sound::getHandle() { return NULL; } -void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop) { +void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, + sndHandleType handleType, bool loop) { byte flags; flags = Audio::Mixer::FLAG_AUTOFREE; @@ -81,7 +84,12 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int flags |= Audio::Mixer::FLAG_UNSIGNED; if (!(_vm->getFeatures() & GF_COMPRESSED_SOUNDS)) { - _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); + if (handleType == kVoiceHandle) + _mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); + else + _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); } else { Audio::AudioStream *stream = NULL; MemoryReadStream *tmp = NULL; @@ -116,12 +124,23 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int #endif default: // No compression, play it as raw sound - _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume); + if (handleType == kVoiceHandle) + _mixer->playRaw(Audio::Mixer::kSpeechSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); + else + _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, + buffer.size, buffer.frequency, flags, -1, volume); break; } - if (stream != NULL) - _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, stream, -1, volume, 0, true, false); + if (stream != NULL) { + if (handleType == kVoiceHandle) + _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, handle, stream, -1, + volume, 0, true, false); + else + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, stream, -1, + volume, 0, true, false); + } } } @@ -129,7 +148,7 @@ void Sound::playSound(SoundBuffer &buffer, int volume, bool loop) { SndHandle *handle = getHandle(); handle->type = kEffectHandle; - playSoundBuffer(&handle->handle, buffer, 2 * volume, loop); + playSoundBuffer(&handle->handle, buffer, 2 * volume, handle->type, loop); } void Sound::pauseSound() { @@ -156,7 +175,7 @@ void Sound::playVoice(SoundBuffer &buffer) { SndHandle *handle = getHandle(); handle->type = kVoiceHandle; - playSoundBuffer(&handle->handle, buffer, 255, false); + playSoundBuffer(&handle->handle, buffer, 255, handle->type, false); } void Sound::pauseVoice() { @@ -184,9 +203,11 @@ void Sound::stopAll() { stopSound(); } -void Sound::setVolume(int volume) { - _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume); - _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume); +void Sound::setVolume() { + _vm->_soundVolume = ConfMan.getInt("sound_volume"); + _vm->_speechVolume = ConfMan.getInt("speech_volume"); + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, _vm->_soundVolume); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, _vm->_speechVolume); } } // End of namespace Saga diff --git a/engines/saga/sound.h b/engines/saga/sound.h index ce479c64d1..6d9e42a49d 100644 --- a/engines/saga/sound.h +++ b/engines/saga/sound.h @@ -71,7 +71,7 @@ struct SndHandle { class Sound { public: - Sound(SagaEngine *vm, Audio::Mixer *mixer, int volume); + Sound(SagaEngine *vm, Audio::Mixer *mixer); ~Sound(); void playSound(SoundBuffer &buffer, int volume, bool loop); @@ -86,11 +86,12 @@ public: void stopAll(); - void setVolume(int volume); + void setVolume(); private: - void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, bool loop); + void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume, + sndHandleType handleType, bool loop); SndHandle *getHandle(); |