diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agos/agos.cpp | 21 | ||||
-rw-r--r-- | engines/agos/agos.h | 3 | ||||
-rw-r--r-- | engines/agos/animation.cpp | 6 | ||||
-rw-r--r-- | engines/agos/detection.cpp | 41 | ||||
-rw-r--r-- | engines/agos/event.cpp | 6 | ||||
-rw-r--r-- | engines/agos/gfx.cpp | 2 | ||||
-rw-r--r-- | engines/agos/input.cpp | 18 | ||||
-rw-r--r-- | engines/agos/midi.cpp | 56 | ||||
-rw-r--r-- | engines/agos/midi.h | 7 | ||||
-rw-r--r-- | engines/agos/oracle.cpp | 2 | ||||
-rw-r--r-- | engines/agos/saveload.cpp | 16 | ||||
-rw-r--r-- | engines/agos/script.cpp | 10 | ||||
-rw-r--r-- | engines/agos/script_e1.cpp | 13 | ||||
-rw-r--r-- | engines/agos/script_e2.cpp | 4 | ||||
-rw-r--r-- | engines/agos/script_s1.cpp | 5 | ||||
-rw-r--r-- | engines/agos/script_ww.cpp | 4 | ||||
-rw-r--r-- | engines/agos/sound.cpp | 13 | ||||
-rw-r--r-- | engines/agos/subroutine.cpp | 2 | ||||
-rw-r--r-- | engines/agos/verb.cpp | 2 | ||||
-rw-r--r-- | engines/agos/window.cpp | 4 |
20 files changed, 154 insertions, 81 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index a9fd204d73..7d03156bb6 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -97,8 +97,6 @@ AGOSEngine::AGOSEngine(OSystem *syst) _vc_get_out_of_code = 0; _gameOffsetsPtr = 0; - _quit = false; - _debugger = 0; _gameFile = 0; @@ -550,6 +548,7 @@ int AGOSEngine::init() { // Setup mixer _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); if ((getGameType() == GType_SIMON2 && getPlatform() == Common::kPlatformWindows) || (getGameType() == GType_SIMON1 && getPlatform() == Common::kPlatformWindows) || @@ -574,7 +573,7 @@ int AGOSEngine::init() { if (ret) warning("MIDI Player init failed: \"%s\"", _midi.getErrorName (ret)); - _midi.setVolume(ConfMan.getInt("music_volume")); + _midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); _midiEnabled = true; @@ -952,7 +951,7 @@ void AGOSEngine::pauseEngineIntern(bool pauseIt) { void AGOSEngine::pause() { pauseEngine(true); - while (_pause && !_quit) { + while (_pause && !quit()) { delay(1); if (_keyPressed.keycode == Common::KEYCODE_p) pauseEngine(false); @@ -989,7 +988,7 @@ int AGOSEngine::go() { (getFeatures() & GF_DEMO)) { int i; - while (!_quit) { + while (!quit()) { for (i = 0; i < 4; i++) { setWindowImage(3, 9902 + i); debug(0, "Displaying image %d", 9902 + i); @@ -1018,13 +1017,13 @@ int AGOSEngine::go() { runSubroutine101(); permitInput(); - while (!_quit) { + while (!quit()) { waitForInput(); handleVerbClicked(_verbHitArea); delay(100); } - return 0; + return _eventMan->shouldRTL(); } @@ -1084,4 +1083,12 @@ uint32 AGOSEngine::getTime() const { return (uint32)time(NULL); } + +void AGOSEngine::syncSoundSettings() { + _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume")); + _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, ConfMan.getInt("speech_volume")); + _midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); +} + } // End of namespace AGOS diff --git a/engines/agos/agos.h b/engines/agos/agos.h index 8ad5487b35..49b4478ec7 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -269,7 +269,6 @@ protected: uint16 _marks; - bool _quit; bool _scriptVar2; bool _runScriptReturn1; bool _runScriptCondition[40]; @@ -589,6 +588,8 @@ protected: void loadSoundFile(const char *filename); + virtual void syncSoundSettings(); + int getUserFlag(Item *item, int a); int getUserFlag1(Item *item, int a); int getUserItem(Item *item, int n); diff --git a/engines/agos/animation.cpp b/engines/agos/animation.cpp index 3e1b9b0611..f4abf19645 100644 --- a/engines/agos/animation.cpp +++ b/engines/agos/animation.cpp @@ -26,7 +26,6 @@ #include "common/endian.h" -#include "common/events.h" #include "common/system.h" #include "graphics/cursorman.h" @@ -151,7 +150,7 @@ void MoviePlayer::play() { startSound(); - while (_frameNum < _framesCount && !_vm->_quit) + while (_frameNum < _framesCount && !_vm->quit()) handleNextFrame(); closeFile(); @@ -279,9 +278,6 @@ void MoviePlayer::handleNextFrame() { case Common::EVENT_RBUTTONUP: _rightButtonDown = false; break; - case Common::EVENT_QUIT: - _vm->_quit = true; - break; default: break; } diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp index 26d8916ab7..12f281d0dc 100644 --- a/engines/agos/detection.cpp +++ b/engines/agos/detection.cpp @@ -27,6 +27,7 @@ #include "common/advancedDetector.h" #include "common/config-manager.h" +#include "common/savefile.h" #include "agos/agos.h" @@ -100,7 +101,7 @@ static const Common::ADParams detectionParams = { class AgosMetaEngine : public Common::AdvancedMetaEngine { public: AgosMetaEngine() : Common::AdvancedMetaEngine(detectionParams) {} - + virtual const char *getName() const { return "AGOS"; } @@ -108,10 +109,18 @@ public: virtual const char *getCopyright() const { return "AGOS (C) Adventure Soft"; } - + + 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 AgosMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsListSaves); +} + bool AgosMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { const AGOS::AGOSGameDescription *gd = (const AGOS::AGOSGameDescription *)desc; bool res = true; @@ -149,6 +158,34 @@ bool AgosMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return res; } +SaveStateList AgosMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringList filenames; + Common::String saveDesc; + Common::String pattern = target; + pattern += ".???"; + + 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 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + if (slotNum >= 0 && slotNum <= 999) { + Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); + if (in) { + saveDesc = file->c_str(); + saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file)); + delete in; + } + } + } + + return saveList; +} + #if PLUGIN_ENABLED_DYNAMIC(AGOS) REGISTER_PLUGIN_DYNAMIC(AGOS, PLUGIN_TYPE_ENGINE, AgosMetaEngine); #else diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp index 010b331cf8..4db3545594 100644 --- a/engines/agos/event.cpp +++ b/engines/agos/event.cpp @@ -142,7 +142,7 @@ bool AGOSEngine::kickoffTimeEvents() { cur_time = getTime() - _gameStoppedClock; - while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !_quit) { + while ((te = _firstTimeStruct) != NULL && te->time <= cur_time && !quit()) { result = true; _pendingDeleteTimeEvent = te; invokeTimeEvent(te); @@ -520,8 +520,8 @@ void AGOSEngine::delay(uint amount) { setBitFlag(92, false); _rightButtonDown++; break; + case Common::EVENT_RTL: case Common::EVENT_QUIT: - _quit = true; return; default: break; @@ -544,7 +544,7 @@ void AGOSEngine::delay(uint amount) { _system->delayMillis(this_delay); cur = _system->getMillis(); - } while (cur < start + amount && !_quit); + } while (cur < start + amount && !quit()); } void AGOSEngine::timer_callback() { diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 9a3962ea21..25a4b919f4 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -1286,7 +1286,7 @@ void AGOSEngine::setWindowImageEx(uint16 mode, uint16 vga_res) { if (getGameType() == GType_WW && (mode == 6 || mode == 8 || mode == 9)) { setWindowImage(mode, vga_res); } else { - while (_copyScnFlag && !_quit) + while (_copyScnFlag && !quit()) delay(1); setWindowImage(mode, vga_res); diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index 6f4cd09947..4327c2878d 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -123,7 +123,7 @@ void AGOSEngine::setup_cond_c_helper() { clearName(); _lastNameOn = last; - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = 0; _leftButtonDown = 0; @@ -145,7 +145,7 @@ void AGOSEngine::setup_cond_c_helper() { } delay(100); - } while ((_lastHitArea3 == (HitArea *) -1 || _lastHitArea3 == 0) && !_quit); + } while ((_lastHitArea3 == (HitArea *) -1 || _lastHitArea3 == 0) && !quit()); if (_lastHitArea == NULL) { } else if (_lastHitArea->id == 0x7FFB) { @@ -189,12 +189,12 @@ void AGOSEngine::waitForInput() { resetVerbs(); } - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; _dragAccept = 1; - while (!_quit) { + while (!quit()) { if ((getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) && _keyPressed.keycode == Common::KEYCODE_F10) displayBoxStars(); @@ -563,16 +563,18 @@ bool AGOSEngine::processSpecialKeys() { case Common::KEYCODE_PLUS: case Common::KEYCODE_KP_PLUS: if (_midiEnabled) { - _midi.setVolume(_midi.getVolume() + 16); + _midi.setVolume(_midi.getMusicVolume() + 16, _midi.getSFXVolume() + 16); } - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16); + ConfMan.setInt("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) + 16); + syncSoundSettings(); break; case Common::KEYCODE_MINUS: case Common::KEYCODE_KP_MINUS: if (_midiEnabled) { - _midi.setVolume(_midi.getVolume() - 16); + _midi.setVolume(_midi.getMusicVolume() - 16, _midi.getSFXVolume() - 16); } - _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16); + ConfMan.setInt("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType) - 16); + syncSoundSettings(); break; case Common::KEYCODE_m: _musicPaused ^= 1; diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index 891e9bde95..fd0e4eaa9d 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -49,7 +49,9 @@ MidiPlayer::MidiPlayer() { _enable_sfx = true; _current = 0; - _masterVolume = 255; + _musicVolume = 255; + _sfxVolume = 255; + resetVolumeTable(); _paused = false; @@ -104,10 +106,13 @@ void MidiPlayer::send(uint32 b) { byte channel = (byte)(b & 0x0F); if ((b & 0xFFF0) == 0x07B0) { - // Adjust volume changes by master volume. + // Adjust volume changes by master music and master sfx volume. byte volume = (byte)((b >> 16) & 0x7F); _current->volume[channel] = volume; - volume = volume * _masterVolume / 255; + if (_current == &_sfx) + volume = volume * _sfxVolume / 255; + else if (_current == &_music) + volume = volume * _musicVolume / 255; b = (b & 0xFF00FFFF) | (volume << 16); } else if ((b & 0xF0) == 0xC0 && _map_mt32_to_gm) { b = (b & 0xFFFF00FF) | (MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8); @@ -133,8 +138,12 @@ void MidiPlayer::send(uint32 b) { if (!_current->channel[channel]) _current->channel[channel] = (channel == 9) ? _driver->getPercussionChannel() : _driver->allocateChannel(); if (_current->channel[channel]) { - if (channel == 9) - _current->channel[9]->volume(_current->volume[9] * _masterVolume / 255); + if (channel == 9) { + if (_current == &_sfx) + _current->channel[9]->volume(_current->volume[9] * _sfxVolume / 255); + else if (_current == &_music) + _current->channel[9]->volume(_current->volume[9] * _musicVolume / 255); + } _current->channel[channel]->send(b); if ((b & 0xFFF0) == 0x79B0) { // We have received a "Reset All Controllers" message @@ -143,7 +152,10 @@ void MidiPlayer::send(uint32 b) { // consistent behaviour, explicitly set the volume to // what we think it should be. - _current->channel[channel]->volume(_current->volume[channel] * _masterVolume / 255); + if (_current == &_sfx) + _current->channel[channel]->volume(_current->volume[channel] * _sfxVolume / 255); + else if (_current == &_music) + _current->channel[channel]->volume(_current->volume[channel] * _musicVolume / 255); } } } @@ -255,30 +267,36 @@ void MidiPlayer::pause(bool b) { Common::StackLock lock(_mutex); for (int i = 0; i < 16; ++i) { if (_music.channel[i]) - _music.channel[i]->volume(_paused ? 0 : (_music.volume[i] * _masterVolume / 255)); + _music.channel[i]->volume(_paused ? 0 : (_music.volume[i] * _musicVolume / 255)); if (_sfx.channel[i]) - _sfx.channel[i]->volume(_paused ? 0 : (_sfx.volume[i] * _masterVolume / 255)); + _sfx.channel[i]->volume(_paused ? 0 : (_sfx.volume[i] * _sfxVolume / 255)); } } -void MidiPlayer::setVolume(int volume) { - if (volume < 0) - volume = 0; - else if (volume > 255) - volume = 255; - - if (_masterVolume == volume) +void MidiPlayer::setVolume(int musicVol, int sfxVol) { + if (musicVol < 0) + musicVol = 0; + else if (musicVol > 255) + musicVol = 255; + if (sfxVol < 0) + sfxVol = 0; + else if (sfxVol > 255) + sfxVol = 255; + + if (_musicVolume == musicVol && _sfxVolume == sfxVol) return; - _masterVolume = volume; + + _musicVolume = musicVol; + _sfxVolume = sfxVol; // Now tell all the channels this. Common::StackLock lock(_mutex); if (_driver && !_paused) { for (int i = 0; i < 16; ++i) { if (_music.channel[i]) - _music.channel[i]->volume(_music.volume[i] * _masterVolume / 255); + _music.channel[i]->volume(_music.volume[i] * _musicVolume / 255); if (_sfx.channel[i]) - _sfx.channel[i]->volume(_sfx.volume[i] * _masterVolume / 255); + _sfx.channel[i]->volume(_sfx.volume[i] * _sfxVolume / 255); } } } @@ -354,7 +372,7 @@ void MidiPlayer::resetVolumeTable() { for (i = 0; i < 16; ++i) { _music.volume[i] = _sfx.volume[i] = 127; if (_driver) - _driver->send(((_masterVolume >> 1) << 16) | 0x7B0 | i); + _driver->send(((_musicVolume >> 1) << 16) | 0x7B0 | i); } } diff --git a/engines/agos/midi.h b/engines/agos/midi.h index 2994c49bb6..c004230e5b 100644 --- a/engines/agos/midi.h +++ b/engines/agos/midi.h @@ -68,6 +68,8 @@ protected: // These are maintained for both music and SFX byte _masterVolume; // 0-255 + byte _musicVolume; + byte _sfxVolume; bool _paused; // These are only used for music. @@ -103,8 +105,9 @@ public: void stop(); void pause(bool b); - int getVolume() { return _masterVolume; } - void setVolume(int volume); + int getMusicVolume() { return _musicVolume; } + int getSFXVolume() { return _sfxVolume; } + void setVolume(int musicVol, int sfxVol); void setDriver(MidiDriver *md); public: diff --git a/engines/agos/oracle.cpp b/engines/agos/oracle.cpp index 2d2feb7b9e..c174362e7c 100644 --- a/engines/agos/oracle.cpp +++ b/engines/agos/oracle.cpp @@ -459,7 +459,7 @@ void AGOSEngine_Feeble::saveUserGame(int slot) { } windowPutChar(window, 0x7f); - while (!_quit) { + while (!quit()) { _keyPressed.reset(); delay(1); diff --git a/engines/agos/saveload.cpp b/engines/agos/saveload.cpp index 9779630d47..90a48b88a2 100644 --- a/engines/agos/saveload.cpp +++ b/engines/agos/saveload.cpp @@ -279,11 +279,11 @@ restart: name = buf; _saveGameNameLen = 0; - while (!_quit) { + while (!quit()) { windowPutChar(window, 128); _keyPressed.reset(); - while (!_quit) { + while (!quit()) { delay(10); if (_keyPressed.ascii && _keyPressed.ascii < 128) { i = _keyPressed.ascii; @@ -443,7 +443,7 @@ void AGOSEngine_Elvira2::userGame(bool load) { name = buf + 192; - while (!_quit) { + while (!quit()) { windowPutChar(window, 128); _saveLoadEdit = true; @@ -516,7 +516,7 @@ int AGOSEngine_Elvira2::userGameGetKey(bool *b, char *buf, uint maxChar) { _keyPressed.reset(); - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; @@ -526,7 +526,7 @@ int AGOSEngine_Elvira2::userGameGetKey(bool *b, char *buf, uint maxChar) { return _keyPressed.ascii; } delay(10); - } while (_lastHitArea3 == 0 && !_quit); + } while (_lastHitArea3 == 0 && !quit()); ha = _lastHitArea; if (ha == NULL || ha->id < 200) { @@ -708,7 +708,7 @@ restart:; _saveGameNameLen++; } - while (!_quit) { + while (!quit()) { windowPutChar(window, 127); _saveLoadEdit = true; @@ -787,7 +787,7 @@ int AGOSEngine_Simon1::userGameGetKey(bool *b, char *buf, uint maxChar) { _keyPressed.reset(); - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; @@ -797,7 +797,7 @@ int AGOSEngine_Simon1::userGameGetKey(bool *b, char *buf, uint maxChar) { return _keyPressed.ascii; } delay(10); - } while (_lastHitArea3 == 0 && !_quit); + } while (_lastHitArea3 == 0 && !quit()); ha = _lastHitArea; if (ha == NULL || ha->id < 205) { diff --git a/engines/agos/script.cpp b/engines/agos/script.cpp index fa132ec26f..39c172be62 100644 --- a/engines/agos/script.cpp +++ b/engines/agos/script.cpp @@ -410,7 +410,7 @@ void AGOSEngine::o_msg() { void AGOSEngine::o_end() { // 68: exit interpreter - _quit = true; + quitGame(); } void AGOSEngine::o_done() { @@ -965,7 +965,7 @@ void AGOSEngine::writeVariable(uint16 variable, uint16 contents) { int AGOSEngine::runScript() { bool flag; - if (_quit) + if (quit()) return 1; do { @@ -1010,9 +1010,9 @@ int AGOSEngine::runScript() { error("Invalid opcode '%d' encountered", _opcode); executeOpcode(_opcode); - } while (getScriptCondition() != flag && !getScriptReturn() && !_quit); + } while (getScriptCondition() != flag && !getScriptReturn() && !quit()); - return (_quit) ? 1 : getScriptReturn(); + return (quit()) ? 1 : getScriptReturn(); } Child *nextSub(Child *sub, int16 key) { @@ -1066,7 +1066,7 @@ void AGOSEngine::waitForSync(uint a) { _exitCutscene = false; _rightButtonDown = false; - while (_vgaWaitFor != 0 && !_quit) { + while (_vgaWaitFor != 0 && !quit()) { if (_rightButtonDown) { if (_vgaWaitFor == 200 && (getGameType() == GType_FF || !getBitFlag(14))) { skipSpeech(); diff --git a/engines/agos/script_e1.cpp b/engines/agos/script_e1.cpp index 9b572e347b..8705755df6 100644 --- a/engines/agos/script_e1.cpp +++ b/engines/agos/script_e1.cpp @@ -24,7 +24,6 @@ */ - #include "agos/agos.h" #include "agos/vga.h" @@ -565,7 +564,7 @@ void AGOSEngine_Elvira1::oe1_look() { lobjFunc(l, "You can see "); /* Show objects */ } if (r && (r->flags & 4) && levelOf(i) < 10000) { - _quit = true; + quitGame(); } } @@ -944,7 +943,7 @@ restart: windowPutChar(window, *message2); if (confirmYesOrNo(120, 62) == 0x7FFF) { - _quit = true; + quitGame(); } else { goto restart; } @@ -1053,11 +1052,11 @@ uint AGOSEngine::confirmYesOrNo(uint16 x, uint16 y) { ha->priority = 999; ha->window = 0; - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!_quit) { + while (!quit()) { if (_lastHitArea3 != 0) break; delay(1); @@ -1102,11 +1101,11 @@ uint AGOSEngine::continueOrQuit() { ha->priority = 999; ha->window = 0; - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!_quit) { + while (!quit()) { if (_lastHitArea3 != 0) break; delay(1); diff --git a/engines/agos/script_e2.cpp b/engines/agos/script_e2.cpp index 6f6db8efb4..05e457579d 100644 --- a/engines/agos/script_e2.cpp +++ b/engines/agos/script_e2.cpp @@ -370,11 +370,11 @@ void AGOSEngine_Elvira2::oe2_pauseGame() { uint32 pauseTime = getTime(); haltAnimation(); - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!_quit) { + while (!quit()) { if (processSpecialKeys() != 0 || _lastHitArea3 != 0) break; delay(1); diff --git a/engines/agos/script_s1.cpp b/engines/agos/script_s1.cpp index 6183a3fb20..d07f682937 100644 --- a/engines/agos/script_s1.cpp +++ b/engines/agos/script_s1.cpp @@ -24,7 +24,6 @@ */ - #include "common/system.h" #include "agos/agos.h" @@ -339,10 +338,10 @@ void AGOSEngine_Simon1::os1_pauseGame() { break; } - while (!_quit) { + while (!quit()) { delay(1); if (_keyPressed.keycode == keyYes) - _quit = true; + quitGame(); else if (_keyPressed.keycode == keyNo) break; } diff --git a/engines/agos/script_ww.cpp b/engines/agos/script_ww.cpp index 8dc915f6e8..f0da324fbd 100644 --- a/engines/agos/script_ww.cpp +++ b/engines/agos/script_ww.cpp @@ -368,11 +368,11 @@ void AGOSEngine_Waxworks::oww_pauseGame() { uint32 pauseTime = getTime(); haltAnimation(); - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - while (!_quit) { + while (!quit()) { if (_lastHitArea3 != 0) break; delay(1); diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp index c456c92e60..4d60bbdbed 100644 --- a/engines/agos/sound.cpp +++ b/engines/agos/sound.cpp @@ -56,10 +56,12 @@ protected: public: BaseSound(Audio::Mixer *mixer, File *file, uint32 base = 0, bool bigEndian = false); BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigEndian = false); + virtual ~BaseSound(); + void close(); + void playSound(uint sound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol = 0) { playSound(sound, sound, type, handle, flags, vol); } - virtual ~BaseSound(); virtual void playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, byte flags, int vol = 0) = 0; virtual Audio::AudioStream *makeAudioStream(uint sound) { return NULL; } }; @@ -184,6 +186,12 @@ BaseSound::BaseSound(Audio::Mixer *mixer, File *file, uint32 *offsets, bool bigE _freeOffsets = false; } +void BaseSound::close() { + if (_freeOffsets) { + free(_offsets); + } +} + BaseSound::~BaseSound() { if (_freeOffsets) free(_offsets); @@ -555,6 +563,9 @@ void Sound::readSfxFile(const char *filename) { void Sound::loadSfxTable(File *gameFile, uint32 base) { stopAll(); + + if (_effects) + _effects->close(); if (_vm->getPlatform() == Common::kPlatformWindows) _effects = new WavSound(_mixer, gameFile, base); diff --git a/engines/agos/subroutine.cpp b/engines/agos/subroutine.cpp index cb71ed7efa..488ebf4edf 100644 --- a/engines/agos/subroutine.cpp +++ b/engines/agos/subroutine.cpp @@ -555,7 +555,7 @@ int AGOSEngine::startSubroutine(Subroutine *sub) { _currentTable = sub; restart: - if (_quit) + if (quit()) return result; while ((byte *)sl != (byte *)sub) { diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp index c8f6d40f1f..9fd128d764 100644 --- a/engines/agos/verb.cpp +++ b/engines/agos/verb.cpp @@ -343,7 +343,7 @@ void AGOSEngine::handleVerbClicked(uint verb) { Subroutine *sub; int result; - if (_quit) + if (quit()) return; _objectItem = _hitAreaObjectItem; diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp index e1f986b92e..87db49e46b 100644 --- a/engines/agos/window.cpp +++ b/engines/agos/window.cpp @@ -298,11 +298,11 @@ void AGOSEngine::waitWindow(WindowBlock *window) { ha->id = 0x7FFF; ha->priority = 999; - while (!_quit) { + while (!quit()) { _lastHitArea = NULL; _lastHitArea3 = NULL; - for (;;) { + while (!quit()) { if (_lastHitArea3 != 0) break; delay(1); |