diff options
author | Max Horn | 2008-09-01 20:18:17 +0000 |
---|---|---|
committer | Max Horn | 2008-09-01 20:18:17 +0000 |
commit | 10a8cdee390698cdc38b1ca28077e39b29ef53f2 (patch) | |
tree | 00b2a4516e37ae5ed33939b6e99fe0d04b712c94 | |
parent | c26c9ec3a7045c3a13d8389a91a46701f6833f97 (diff) | |
parent | 852bc9dbb750b9995d31e70f4158c97d3758c46f (diff) | |
download | scummvm-rg350-10a8cdee390698cdc38b1ca28077e39b29ef53f2.tar.gz scummvm-rg350-10a8cdee390698cdc38b1ca28077e39b29ef53f2.tar.bz2 scummvm-rg350-10a8cdee390698cdc38b1ca28077e39b29ef53f2.zip |
Merging more of the GSoC 2008 RTL branch: LURE
svn-id: r34251
-rw-r--r-- | engines/lure/animseq.cpp | 14 | ||||
-rw-r--r-- | engines/lure/detection.cpp | 39 | ||||
-rw-r--r-- | engines/lure/events.cpp | 16 | ||||
-rw-r--r-- | engines/lure/events.h | 2 | ||||
-rw-r--r-- | engines/lure/fights.cpp | 8 | ||||
-rw-r--r-- | engines/lure/game.cpp | 29 | ||||
-rw-r--r-- | engines/lure/game.h | 5 | ||||
-rw-r--r-- | engines/lure/intro.cpp | 7 | ||||
-rw-r--r-- | engines/lure/lure.cpp | 73 | ||||
-rw-r--r-- | engines/lure/lure.h | 6 | ||||
-rw-r--r-- | engines/lure/menu.cpp | 6 | ||||
-rw-r--r-- | engines/lure/scripts.cpp | 6 | ||||
-rw-r--r-- | engines/lure/sound.cpp | 32 | ||||
-rw-r--r-- | engines/lure/sound.h | 4 | ||||
-rw-r--r-- | engines/lure/surface.cpp | 14 |
15 files changed, 190 insertions, 71 deletions
diff --git a/engines/lure/animseq.cpp b/engines/lure/animseq.cpp index 2af02b0374..f9f53b2806 100644 --- a/engines/lure/animseq.cpp +++ b/engines/lure/animseq.cpp @@ -44,12 +44,18 @@ AnimAbortType AnimationSequence::delay(uint32 milliseconds) { while (g_system->getMillis() < delayCtr) { while (events.pollEvent()) { if ((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) { - if (events.event().kbd.keycode == Common::KEYCODE_ESCAPE) return ABORT_END_INTRO; - else return ABORT_NEXT_SCENE; - } else if (events.type() == Common::EVENT_LBUTTONDOWN) + if (events.event().kbd.keycode == Common::KEYCODE_ESCAPE) + return ABORT_END_INTRO; + else + return ABORT_NEXT_SCENE; + } else if (events.type() == Common::EVENT_LBUTTONDOWN) { return ABORT_NEXT_SCENE; - else if (events.type() == Common::EVENT_QUIT) + } else if ((events.type() == Common::EVENT_QUIT) || (events.type() == Common::EVENT_RTL)) { return ABORT_END_INTRO; + } else if (events.type() == Common::EVENT_MAINMENU) { + return ABORT_NONE; + } + } uint32 delayAmount = delayCtr - g_system->getMillis(); diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp index 7dd1c77348..ccfa26fadc 100644 --- a/engines/lure/detection.cpp +++ b/engines/lure/detection.cpp @@ -26,6 +26,7 @@ #include "base/plugins.h" #include "common/advancedDetector.h" +#include "common/savefile.h" #include "lure/lure.h" @@ -184,9 +185,19 @@ public: return "Lure of the Temptress (C) Revolution"; } + 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 LureMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsListSaves) || + (f == kSupportsDirectLoad) || + (f == kSupportsDeleteSave); +} + bool LureMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const { const Lure::LureGameDescription *gd = (const Lure::LureGameDescription *)desc; if (gd) { @@ -195,6 +206,34 @@ bool LureMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common return gd != 0; } +SaveStateList LureMetaEngine::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 = Lure::getSaveName(in); + saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file)); + delete in; + } + } + } + + return saveList; +} + #if PLUGIN_ENABLED_DYNAMIC(LURE) REGISTER_PLUGIN_DYNAMIC(LURE, PLUGIN_TYPE_ENGINE, LureMetaEngine); #else diff --git a/engines/lure/events.cpp b/engines/lure/events.cpp index 30e0e571b7..e244f69097 100644 --- a/engines/lure/events.cpp +++ b/engines/lure/events.cpp @@ -29,6 +29,7 @@ #include "graphics/cursorman.h" #include "lure/events.h" +#include "lure/lure.h" #include "lure/res.h" namespace Lure { @@ -137,11 +138,12 @@ void Mouse::setPosition(int newX, int newY) { void Mouse::waitForRelease() { Events &e = Events::getReference(); + LureEngine &engine = LureEngine::getReference(); do { - while (e.pollEvent() && !e.quitFlag) ; + while (e.pollEvent() && !engine.quit()) ; g_system->delayMillis(20); - } while (!e.quitFlag && (lButton() || rButton() || mButton())); + } while (!engine.quit() && (lButton() || rButton() || mButton())); } /*--------------------------------------------------------------------------*/ @@ -150,7 +152,6 @@ static Events *int_events = NULL; Events::Events() { int_events = this; - quitFlag = false; } Events &Events::getReference() { @@ -163,10 +164,6 @@ bool Events::pollEvent() { // Handle keypress switch (_event.type) { - case Common::EVENT_QUIT: - quitFlag = true; - break; - case Common::EVENT_LBUTTONDOWN: case Common::EVENT_LBUTTONUP: case Common::EVENT_RBUTTONDOWN: @@ -190,7 +187,7 @@ void Events::waitForPress() { bool keyButton = false; while (!keyButton) { while (pollEvent()) { - if (_event.type == Common::EVENT_QUIT) return; + if ((_event.type == Common::EVENT_QUIT) || (_event.type == Common::EVENT_RTL)) return; else if ((_event.type == Common::EVENT_KEYDOWN) && (_event.kbd.ascii != 0)) keyButton = true; else if ((_event.type == Common::EVENT_LBUTTONDOWN) || @@ -210,10 +207,11 @@ void Events::waitForPress() { bool Events::interruptableDelay(uint32 milliseconds) { Events &events = Events::getReference(); + LureEngine &engine = LureEngine::getReference(); uint32 delayCtr = g_system->getMillis() + milliseconds; while (g_system->getMillis() < delayCtr) { - if (events.quitFlag) return true; + if (engine.quit()) return true; if (events.pollEvent()) { if (((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) || diff --git a/engines/lure/events.h b/engines/lure/events.h index d1246f95d8..f04072aa0f 100644 --- a/engines/lure/events.h +++ b/engines/lure/events.h @@ -66,8 +66,6 @@ class Events { private: Common::Event _event; public: - bool quitFlag; - Events(); static Events &getReference(); diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp index dcf09ba50d..51fce850e6 100644 --- a/engines/lure/fights.cpp +++ b/engines/lure/fights.cpp @@ -22,6 +22,7 @@ #include "lure/fights.h" #include "lure/luredefs.h" #include "lure/game.h" +#include "lure/lure.h" #include "lure/res.h" #include "lure/room.h" #include "lure/sound.h" @@ -108,15 +109,15 @@ bool FightsManager::isFighting() { } void FightsManager::fightLoop() { + LureEngine &engine = LureEngine::getReference(); Resources &res = Resources::getReference(); Game &game = Game::getReference(); Room &room = Room::getReference(); - Events &events = Events::getReference(); FighterRecord &playerFight = getDetails(PLAYER_ID); uint32 timerVal = g_system->getMillis(); // Loop for the duration of the battle - while (!events.quitFlag && (playerFight.fwhits != GENERAL_MAGIC_ID)) { + while (!engine.quit() && (playerFight.fwhits != GENERAL_MAGIC_ID)) { checkEvents(); if (g_system->getMillis() > timerVal + GAME_FRAME_DELAY) { @@ -184,6 +185,7 @@ const KeyMapping keyList[] = { {Common::KEYCODE_INVALID, 0}}; void FightsManager::checkEvents() { + LureEngine &engine = LureEngine::getReference(); Game &game = Game::getReference(); Events &events = Events::getReference(); Mouse &mouse = Mouse::getReference(); @@ -196,7 +198,7 @@ void FightsManager::checkEvents() { if (events.type() == Common::EVENT_KEYDOWN) { switch (events.event().kbd.keycode) { case Common::KEYCODE_ESCAPE: - events.quitFlag = true; + engine.quitGame(); return; case Common::KEYCODE_d: diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp index f9b31c21c5..479877f229 100644 --- a/engines/lure/game.cpp +++ b/engines/lure/game.cpp @@ -23,10 +23,10 @@ * */ -#include "lure/lure.h" #include "lure/game.h" #include "lure/animseq.h" #include "lure/fights.h" +#include "lure/lure.h" #include "lure/res_struct.h" #include "lure/room.h" #include "lure/scripts.h" @@ -125,6 +125,7 @@ void Game::nextFrame() { void Game::execute() { OSystem &system = *g_system; + LureEngine &engine = LureEngine::getReference(); Room &room = Room::getReference(); Resources &res = Resources::getReference(); Events &events = Events::getReference(); @@ -137,12 +138,20 @@ void Game::execute() { screen.empty(); screen.setPaletteEmpty(); + + bool _loadSavegame = false; + + if (engine.gameToLoad() != -1) + _loadSavegame = engine.loadGame(engine.gameToLoad()); + + if (!_loadSavegame) { + // Flag for starting game + setState(GS_RESTART); + } - // Flag for starting game - setState(GS_RESTART); bool initialRestart = true; - while (!events.quitFlag) { + while (!engine.quit()) { if ((_state & GS_RESTART) != 0) { res.reset(); @@ -162,7 +171,7 @@ void Game::execute() { mouse.cursorOn(); // Main game loop - while (!events.quitFlag && ((_state & GS_RESTART) == 0)) { + while (!engine.quit() && ((_state & GS_RESTART) == 0)) { // If time for next frame, allow everything to update if (system.getMillis() > timerVal + GAME_FRAME_DELAY) { timerVal = system.getMillis(); @@ -291,10 +300,7 @@ void Game::execute() { if (restartFlag) setState(GS_RESTART); - - } else if ((_state & GS_RESTART) == 0) - // Exiting game - events.quitFlag = true; + } } } @@ -892,7 +898,7 @@ void Game::doShowCredits() { void Game::doQuit() { Sound.pause(); if (getYN()) - Events::getReference().quitFlag = true; + LureEngine::getReference().quitGame(); Sound.resume(); } @@ -977,6 +983,7 @@ bool Game::getYN() { Events &events = Events::getReference(); Screen &screen = Screen::getReference(); Resources &res = Resources::getReference(); + LureEngine &engine = LureEngine::getReference(); Common::Language l = LureEngine::getReference().getLanguage(); Common::KeyCode y = Common::KEYCODE_y; @@ -1018,7 +1025,7 @@ bool Game::getYN() { } g_system->delayMillis(10); - } while (!events.quitFlag && !breakFlag); + } while (!engine.quit() && !breakFlag); screen.update(); if (!vKbdFlag) diff --git a/engines/lure/game.h b/engines/lure/game.h index 5054074fb2..06dcee750f 100644 --- a/engines/lure/game.h +++ b/engines/lure/game.h @@ -27,6 +27,7 @@ #define LURE_GAME_H +#include "common/config-manager.h" #include "engines/engine.h" #include "lure/luredefs.h" #include "lure/menu.h" @@ -85,8 +86,8 @@ public: bool &debugFlag() { return _debugFlag; } bool fastTextFlag() { return _fastTextFlag; } bool soundFlag() { return _soundFlag; } - uint8 sfxVolume() { return _sfxVolume; } - uint8 musicVolume() { return _musicVolume; } + uint8 sfxVolume() { return ConfMan.getInt("sfx_volume"); } + uint8 musicVolume() { return ConfMan.getInt("music_volume"); } Debugger &debugger() { return *_debugger; } // Menu item support methods diff --git a/engines/lure/intro.cpp b/engines/lure/intro.cpp index 4d3e172dc5..b4cbf4a833 100644 --- a/engines/lure/intro.cpp +++ b/engines/lure/intro.cpp @@ -55,17 +55,18 @@ static const AnimRecord anim_screens[] = { bool Introduction::showScreen(uint16 screenId, uint16 paletteId, uint16 delaySize) { Screen &screen = Screen::getReference(); - Events &events = Events::getReference(); bool isEGA = LureEngine::getReference().isEGA(); screen.screen().loadScreen(screenId); screen.update(); Palette p(paletteId); + if (LureEngine::getReference().quit()) return true; + if (isEGA) screen.setPalette(&p); else screen.paletteFadeIn(&p); bool result = interruptableDelay(delaySize); - if (events.quitFlag) return true; + if (LureEngine::getReference().quit()) return true; if (!isEGA) screen.paletteFadeOut(); @@ -83,6 +84,8 @@ bool Introduction::interruptableDelay(uint32 milliseconds) { if (events.interruptableDelay(milliseconds)) { if (events.type() == Common::EVENT_KEYDOWN) return events.event().kbd.keycode == 27; + else if (LureEngine::getReference().quit()) + return true; else if (events.type() == Common::EVENT_LBUTTONDOWN) return false; } diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp index ea760ddb4f..335f3384a1 100644 --- a/engines/lure/lure.cpp +++ b/engines/lure/lure.cpp @@ -92,6 +92,7 @@ int LureEngine::init() { _room = new Room(); _fights = new FightsManager(); + _gameToLoad = -1; _initialised = true; return 0; } @@ -121,38 +122,45 @@ LureEngine &LureEngine::getReference() { } int LureEngine::go() { - - if (ConfMan.getBool("copy_protection")) { - CopyProtectionDialog *dialog = new CopyProtectionDialog(); - bool result = dialog->show(); - delete dialog; - if (_events->quitFlag) - return 0; - - if (!result) - error("Sorry - copy protection failed"); - } - Game *gameInstance = new Game(); + + // If requested, load a savegame instead of showing the intro + if (ConfMan.hasKey("save_slot")) { + _gameToLoad = ConfMan.getInt("save_slot"); + if (_gameToLoad < 0 || _gameToLoad > 999) + _gameToLoad = -1; + } + + if (_gameToLoad == -1) { + if (ConfMan.getBool("copy_protection")) { + CopyProtectionDialog *dialog = new CopyProtectionDialog(); + bool result = dialog->show(); + delete dialog; + if (quit()) + return _eventMan->shouldRTL(); + + if (!result) + error("Sorry - copy protection failed"); + } - if (ConfMan.getInt("boot_param") == 0) { - // Show the introduction - Sound.loadSection(Sound.isRoland() ? ROLAND_INTRO_SOUND_RESOURCE_ID : ADLIB_INTRO_SOUND_RESOURCE_ID); - - Introduction *intro = new Introduction(); - intro->show(); - delete intro; + if (ConfMan.getInt("boot_param") == 0) { + // Show the introduction + Sound.loadSection(Sound.isRoland() ? ROLAND_INTRO_SOUND_RESOURCE_ID : ADLIB_INTRO_SOUND_RESOURCE_ID); + Introduction *intro = new Introduction(); + intro->show(); + delete intro; + } } // Play the game - if (!_events->quitFlag) { + if (!quit()) { // Play the game Sound.loadSection(Sound.isRoland() ? ROLAND_MAIN_SOUND_RESOURCE_ID : ADLIB_MAIN_SOUND_RESOURCE_ID); gameInstance->execute(); } delete gameInstance; - return 0; + return _eventMan->shouldRTL(); } void LureEngine::pauseEngineIntern(bool pause) { @@ -246,6 +254,10 @@ void LureEngine::GUIError(const char *msg, ...) { Engine::GUIErrorMessage(buffer); } +void LureEngine::syncSoundSettings() { + Sound.syncSounds(); +} + Common::String *LureEngine::detectSave(int slotNumber) { Common::ReadStream *f = this->_saveFileMan->openForLoading( generateSaveName(slotNumber)); @@ -274,4 +286,23 @@ Common::String *LureEngine::detectSave(int slotNumber) { return result; } +Common::String getSaveName(Common::InSaveFile *in) { + // Check for header + char saveName[MAX_DESC_SIZE]; + char buffer[5]; + in->read(&buffer[0], 5); + if (memcmp(&buffer[0], "lure", 5) == 0) { + // Check language version + in->readByte(); + in->readByte(); + char *p = saveName; + int decCtr = MAX_DESC_SIZE - 1; + while ((decCtr > 0) && ((*p++ = in->readByte()) != 0)) --decCtr; + *p = '\0'; + + } + + return Common::String(saveName); +} + } // End of namespace Lure diff --git a/engines/lure/lure.h b/engines/lure/lure.h index 1c5b40e54b..2c1a70329e 100644 --- a/engines/lure/lure.h +++ b/engines/lure/lure.h @@ -30,6 +30,7 @@ #include "common/rect.h" #include "sound/mixer.h" #include "common/file.h" +#include "common/savefile.h" #include "lure/disk.h" #include "lure/res.h" @@ -47,6 +48,7 @@ struct LureGameDescription; class LureEngine : public Engine { private: bool _initialised; + int _gameToLoad; uint8 _saveVersion; Disk *_disk; Resources *_resources; @@ -70,9 +72,11 @@ public: virtual int init(); virtual int go(); virtual void pauseEngineIntern(bool pause); + virtual void syncSoundSettings(); Disk &disk() { return *_disk; } + int gameToLoad() { return _gameToLoad; } bool loadGame(uint8 slotNumber); bool saveGame(uint8 slotNumber, Common::String &caption); Common::String *detectSave(int slotNumber); @@ -84,7 +88,7 @@ public: Common::Platform getPlatform() const; bool isEGA() const { return (getFeatures() & GF_EGA) != 0; } }; - + Common::String getSaveName(Common::InSaveFile *in); } // End of namespace Lure #endif diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp index 0b4ef06081..562f54da20 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -116,6 +116,7 @@ Menu &Menu::getReference() { uint8 Menu::execute() { OSystem &system = *g_system; + LureEngine &engine = LureEngine::getReference(); Mouse &mouse = Mouse::getReference(); Events &events = Events::getReference(); Screen &screen = Screen::getReference(); @@ -130,7 +131,7 @@ uint8 Menu::execute() { while (mouse.lButton() || mouse.rButton()) { while (events.pollEvent()) { - if (events.quitFlag) return MENUITEM_NONE; + if (engine.quit()) return MENUITEM_NONE; if (mouse.y() < MENUBAR_Y_SIZE) { MenuRecord *p = getMenuAt(mouse.x()); @@ -467,6 +468,7 @@ Action PopupMenu::Show(int numEntries, Action *actions) { uint16 PopupMenu::Show(int numEntries, const char *actions[]) { if (numEntries == 0) return 0xffff; + LureEngine &engine = LureEngine::getReference(); Events &e = Events::getReference(); Mouse &mouse = Mouse::getReference(); OSystem &system = *g_system; @@ -545,7 +547,7 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { } while (e.pollEvent()) { - if (e.quitFlag) { + if (engine.quit()) { selectedIndex = 0xffff; goto bail_out; diff --git a/engines/lure/scripts.cpp b/engines/lure/scripts.cpp index 7490f05b24..495f8046bb 100644 --- a/engines/lure/scripts.cpp +++ b/engines/lure/scripts.cpp @@ -26,6 +26,7 @@ #include "lure/animseq.h" #include "lure/fights.h" #include "lure/game.h" +#include "lure/lure.h" #include "lure/res.h" #include "lure/room.h" #include "lure/screen.h" @@ -190,6 +191,7 @@ void Script::addSound(uint16 soundIndex, uint16 v2, uint16 v3) { } void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) { + LureEngine &engine = LureEngine::getReference(); Screen &screen = Screen::getReference(); Mouse &mouse = Mouse::getReference(); Events &events = Events::getReference(); @@ -219,7 +221,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) { anim->show(); if (!events.interruptableDelay(30000)) { // No key yet pressed, so keep waiting - while (Sound.musicInterface_CheckPlaying(6) && !events.quitFlag) { + while (Sound.musicInterface_CheckPlaying(6) && !engine.quit()) { if (events.interruptableDelay(20)) break; } @@ -227,7 +229,7 @@ void Script::endgameSequence(uint16 v1, uint16 v2, uint16 v3) { delete anim; screen.paletteFadeOut(); - events.quitFlag = true; + engine.quitGame(); } // Setup the pig fight in the cave diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index 285f66e4e2..569058b282 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -220,10 +220,12 @@ void SoundManager::addSound(uint8 soundIndex, bool tidyFlag) { newEntry->channel = channelCtr; newEntry->numChannels = numChannels; newEntry->flags = rec.flags; + if (_isRoland) newEntry->volume = rec.volume; else /* resource volumes do not seem to work well with our adlib emu */ newEntry->volume = 240; /* 255 causes clipping with adlib */ + _activeSounds.push_back(SoundList::value_type(newEntry)); musicInterface_Play(rec.soundNumber, channelCtr, numChannels); @@ -280,6 +282,23 @@ uint8 SoundManager::descIndexOf(uint8 soundNumber) { return 0xff; // Couldn't find entry } +// Used to sync the volume for all channels with the Config Manager +// +void SoundManager::syncSounds() { + Game &game = Game::getReference(); + musicInterface_TidySounds(); + + g_system->lockMutex(_soundMutex); + MusicListIterator i; + for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) { + if ((*i)->isMusic()) + (*i)->setVolume(game.musicVolume()); + else + (*i)->setVolume(game.sfxVolume()); + } + g_system->unlockMutex(_soundMutex); +} + SoundDescResource *SoundManager::findSound(uint8 soundNumber) { debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::findSound soundNumber=%d", soundNumber); SoundListIterator i; @@ -402,9 +421,8 @@ void SoundManager::musicInterface_Play(uint8 soundNumber, uint8 channelNumber, u return; bool isMusic = (soundNumber & 0x80) != 0; - uint8 volume = isMusic ? game.musicVolume() : game.sfxVolume(); - if (!game.soundFlag() || (volume == 0)) + if (!game.soundFlag()) // Don't play sounds if sound is turned off return; @@ -563,12 +581,12 @@ void SoundManager::doTimer() { /*------------------------------------------------------------------------*/ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS], - uint8 channelNum, uint8 soundNum, bool isMusic, uint8 numChannels, void *soundData, uint32 size) { + uint8 channelNum, uint8 soundNum, bool isMus, uint8 numChannels, void *soundData, uint32 size) { _driver = driver; _channels = channels; _soundNumber = soundNum; _channelNumber = channelNum; - _isMusic = isMusic; + _isMusic = isMus; _numChannels = numChannels; _volume = 0; @@ -576,7 +594,11 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS], /* 90 is power on default for midi compliant devices */ _channels[_channelNumber + i].volume = 90; } - setVolume(240); /* 255 causes clipping with mastervol 192 and adlib */ + + if (_isMusic) + setVolume(ConfMan.getInt("music_volume")); + else + setVolume(ConfMan.getInt("sfx_volume")); _passThrough = false; diff --git a/engines/lure/sound.h b/engines/lure/sound.h index c5a31a6c28..cf5dca7e96 100644 --- a/engines/lure/sound.h +++ b/engines/lure/sound.h @@ -66,7 +66,7 @@ private: public: MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS], - uint8 channelNum, uint8 soundNum, bool isMusic, uint8 numChannels, void *soundData, uint32 size); + uint8 channelNum, uint8 soundNum, bool isMus, uint8 numChannels, void *soundData, uint32 size); ~MidiMusic(); void setVolume(int volume); int getVolume() { return _volume; } @@ -98,6 +98,7 @@ public: uint8 channelNumber() { return _channelNumber; } uint8 soundNumber() { return _soundNumber; } bool isPlaying() { return _isPlaying; } + bool isMusic() {return _isMusic; } }; class SoundManager: public Common::Singleton<SoundManager> { @@ -142,6 +143,7 @@ public: void stopSound(uint8 soundIndex); void killSound(uint8 soundNumber); void setVolume(uint8 soundNumber, uint8 volume); + void syncSounds(); void tidySounds(); uint8 descIndexOf(uint8 soundNumber); SoundDescResource *findSound(uint8 soundNumber); diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp index 64394545d1..23cc9043cf 100644 --- a/engines/lure/surface.cpp +++ b/engines/lure/surface.cpp @@ -506,6 +506,7 @@ Surface *Surface::getScreen(uint16 resourceId) { bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool varLength, int16 x, int16 y) { OSystem &system = *g_system; + LureEngine &engine = LureEngine::getReference(); Mouse &mouse = Mouse::getReference(); Events &events = Events::getReference(); Screen &screen = Screen::getReference(); @@ -533,7 +534,7 @@ bool Surface::getString(Common::String &line, int maxSize, bool isNumeric, bool // Loop until the input string changes refreshFlag = false; while (!refreshFlag && !abortFlag) { - abortFlag = events.quitFlag; + abortFlag = engine.quit(); if (abortFlag) break; while (events.pollEvent()) { @@ -975,7 +976,7 @@ bool SaveRestoreDialog::show(bool saveDialog) { // Provide highlighting of lines to select a save slot while (!abortFlag && !(mouse.lButton() && (selectedLine != -1)) && !mouse.rButton() && !mouse.mButton()) { - abortFlag = events.quitFlag; + abortFlag = engine.quit(); if (abortFlag) break; while (events.pollEvent()) { @@ -1178,7 +1179,7 @@ bool RestartRestoreDialog::show() { // Event loop for making selection bool buttonPressed = false; - while (!events.quitFlag) { + while (!engine.quit()) { // Handle events while (events.pollEvent()) { if ((events.type() == Common::EVENT_LBUTTONDOWN) && (highlightedButton != -1)) { @@ -1230,7 +1231,7 @@ bool RestartRestoreDialog::show() { Sound.killSounds(); - if (!restartFlag && !events.quitFlag) { + if (!restartFlag && !engine.quit()) { // Need to show Restore game dialog if (!SaveRestoreDialog::show(false)) // User cancelled, so fall back on Restart @@ -1299,6 +1300,7 @@ bool CopyProtectionDialog::show() { Screen &screen = Screen::getReference(); Events &events = Events::getReference(); Common::RandomSource rnd; + LureEngine &engine = LureEngine::getReference(); screen.setPaletteEmpty(); Palette p(COPY_PROTECTION_RESOURCE_ID - 1); @@ -1349,7 +1351,7 @@ bool CopyProtectionDialog::show() { // Clear any prior try _charIndex = 0; - while (!events.quitFlag) { + while (!engine.quit()) { while (events.pollEvent() && (_charIndex < 4)) { if (events.type() == Common::EVENT_KEYDOWN) { if ((events.event().kbd.keycode == Common::KEYCODE_BACKSPACE) && (_charIndex > 0)) { @@ -1383,7 +1385,7 @@ bool CopyProtectionDialog::show() { break; } - if (events.quitFlag) + if (engine.quit()) return false; // At this point, two page numbers have been entered - validate them |