From e90f846df9f1d0e31b933d1cd0a8c28c0fbb7d1f Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 6 Jan 2004 16:53:35 +0000 Subject: - enabled debugger in QueenEngine::errorString - initialise Cutaway::_personCount* when the Cutaway starts - minor tweaks in BankManager svn-id: r12185 --- queen/journal.cpp | 4 +- queen/logic.cpp | 392 ++++++++++++++++++++++-------------------------------- queen/logic.h | 48 ++++--- queen/queen.cpp | 70 +++++++++- queen/queen.h | 6 + 5 files changed, 266 insertions(+), 254 deletions(-) (limited to 'queen') diff --git a/queen/journal.cpp b/queen/journal.cpp index d3b024cf07..650d41b114 100644 --- a/queen/journal.cpp +++ b/queen/journal.cpp @@ -85,7 +85,7 @@ void Journal::use() { system->delay_msecs(20); } - _vm->logic()->writeOptionSettings(); + _vm->writeOptionSettings(); _vm->graphics()->textClear(0, GAME_SCREEN_HEIGHT - 1); _vm->graphics()->putCameraOnBob(0); @@ -451,7 +451,7 @@ void Journal::drawYesNoPanel(int titleNum) { void Journal::drawConfigPanel() { - _vm->logic()->checkOptionSettings(); + _vm->checkOptionSettings(); drawSlideBar(_vm->logic()->talkSpeed(), 130, 100, BOB_TALK_SPEED, 136 - 4, 164, FRAME_BLUE_PIN); // XXX music_volume diff --git a/queen/logic.cpp b/queen/logic.cpp index fdde034878..d04296d1d2 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -50,16 +50,6 @@ Logic::Logic(QueenEngine *vm) memset(_talkSelected, 0, sizeof(_talkSelected)); _puzzleAttemptCount = 0; initialise(); - if (_vm->resource()->isDemo()) { - _preChangeRoom = &Logic::preChangeRoom_Demo; - _executeSpecialMove = &Logic::executeSpecialMove_Demo; - } else if (_vm->resource()->isInterview()) { - _preChangeRoom = &Logic::preChangeRoom_Interview; - _executeSpecialMove = &Logic::executeSpecialMove_Interview; - } else { - _preChangeRoom = &Logic::preChangeRoom_Game; - _executeSpecialMove = &Logic::executeSpecialMove_Game; - } } Logic::~Logic() { @@ -2169,7 +2159,7 @@ void Logic::sceneStop() { void Logic::changeRoom() { - if (!(this->*_preChangeRoom)()) + if (!preChangeRoom()) roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 1, false); _vm->display()->showMouseCursor(true); } @@ -2188,227 +2178,9 @@ void Logic::useJournal() { } -void Logic::registerDefaultSettings() { - ConfMan.registerDefault("master_volume", 255); - ConfMan.registerDefault("music_mute", false); - ConfMan.registerDefault("sfx_mute", false); - ConfMan.registerDefault("talkspeed", DEFAULT_TALK_SPEED); - ConfMan.registerDefault("speech_mute", _vm->resource()->isFloppy()); - ConfMan.registerDefault("subtitles", true); -} - - -void Logic::checkOptionSettings() { - // check talkspeed value - if (_talkSpeed < 4) { - _talkSpeed = 4; - } else if (_talkSpeed > 95) { - _talkSpeed = 100; - } - - // XXX check master_volume value - - // only CD-ROM version has speech - if (_vm->resource()->isFloppy() && _vm->sound()->speechOn()) { - _vm->sound()->speechToggle(false); - } - - // ensure text is always on when voice is off - if (!_vm->sound()->speechOn()) { - _subtitles = true; - } -} - - -void Logic::readOptionSettings() { - // XXX master_volume - _vm->sound()->musicToggle(!ConfMan.getBool("music_mute")); - _vm->sound()->sfxToggle(!ConfMan.getBool("sfx_mute")); - _talkSpeed = ConfMan.getInt("talkspeed"); - _vm->sound()->speechToggle(!ConfMan.getBool("speech_mute")); - _subtitles = ConfMan.getBool("subtitles"); - - checkOptionSettings(); -} - - -void Logic::writeOptionSettings() { - // XXX master_volume - ConfMan.set("music_mute", !_vm->sound()->musicOn()); - ConfMan.set("sfx_mute", !_vm->sound()->sfxOn()); - ConfMan.set("talkspeed", _talkSpeed); - ConfMan.set("speech_mute", !_vm->sound()->speechOn()); - ConfMan.set("subtitles", _subtitles); - - ConfMan.flushToDisk(); -} - - -bool Logic::preChangeRoom_Demo() { - if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) { - currentRoom(79); - roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); - playCutaway("clogo.cut"); - sceneReset(); - currentRoom(ROOM_HOTEL_LOBBY); - entryObj(584); - roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 2, true); - playCutaway("c70d.cut"); - gameState(VAR_INTRO_PLAYED, 1); - inventorySetup(); - inventoryRefresh(); - return true; - } - return false; -} - - -bool Logic::preChangeRoom_Interview() { - if (currentRoom() == 2 && gameState(2) == 0) { - currentRoom(6); - roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); - playCutaway("start.cut"); - gameState(2, 1); - inventorySetup(); - inventoryRefresh(); - return true; - } - return false; -} - - -bool Logic::preChangeRoom_Game() { - if (currentRoom() == ROOM_JUNGLE_PINNACLE) { - handlePinnacleRoom(); - return true; - } else if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) { - roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); - playCutaway("copy.cut"); - playCutaway("clogo.cut"); - - // XXX enable talking for talkie version - - if (ConfMan.getBool("alt_intro")) { - _vm->graphics()->loadPanel(); - playCutaway("cintr.cut"); - } else { - playCutaway("cdint.cut"); - _vm->graphics()->loadPanel(); - } - - playCutaway("cred.cut"); - sceneReset(); - currentRoom(ROOM_HOTEL_LOBBY); - entryObj(584); - roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 2, true); - playCutaway("c70d.cut"); - gameState(VAR_INTRO_PLAYED, 1); - inventorySetup(); - inventoryRefresh(); - return true; - } - return false; -} - - -bool Logic::executeSpecialMove_Demo(uint16 sm) { - switch (sm) { - case 4: - asmMakeJoeUseUnderwear(); - break; - case 5: - asmSwitchToDressPalette(); - break; - case 14: - asmEndDemo(); - break; - default: - return false; - } - return true; -} - - -bool Logic::executeSpecialMove_Interview(uint16 sm) { - switch (sm) { - case 1: - asmInterviewIntro(); - break; - case 2: - asmEndInterview(); - break; - default: - return false; - } - return true; -} - - -bool Logic::executeSpecialMove_Game(uint16 sm) { - typedef void (Logic::*SpecialMoveProc)(); - static const SpecialMoveProc asmTable[] = { - /* 00 */ - NULL, - NULL, - &Logic::asmMakeJoeUseDress, - &Logic::asmMakeJoeUseNormalClothes, - /* 04 */ - &Logic::asmMakeJoeUseUnderwear, - &Logic::asmSwitchToDressPalette, - &Logic::asmSwitchToNormalPalette, - &Logic::asmStartCarAnimation, // room 74 - /* 08 */ - &Logic::asmStopCarAnimation, // room 74 - &Logic::asmStartFightAnimation, // room 69 - &Logic::asmWaitForFrankPosition, // c69e.cut - &Logic::asmMakeFrankGrowing, // c69z.cut - /* 12 */ - &Logic::asmMakeRobotGrowing, // c69z.cut - &Logic::asmShrinkRobot, - &Logic::asmEndGame, - &Logic::asmPutCameraOnDino, - /* 16 */ - &Logic::asmPutCameraOnJoe, - &Logic::asmAltIntroPanRight, // cintr.cut - &Logic::asmAltIntroPanLeft, // cintr.cut - &Logic::asmSetAzuraInLove, - /* 20 */ - &Logic::asmPanRightFromJoe, - &Logic::asmSetLightsOff, - &Logic::asmSetLightsOn, - &Logic::asmSetManequinAreaOn, - /* 24 */ - &Logic::asmPanToJoe, - &Logic::asmTurnGuardOn, - &Logic::asmPanLeft320To144, - &Logic::asmSmooch, - /* 28 */ - &Logic::asmMakeLightningHitPlane, - &Logic::asmScaleBlimp, - &Logic::asmScaleEnding, - &Logic::asmWaitForCarPosition, - /* 32 */ - &Logic::asmShakeScreen, - &Logic::asmAttemptPuzzle, - &Logic::asmScaleTitle, - NULL, - /* 36 */ - &Logic::asmPanRightToHugh, - &Logic::asmMakeWhiteFlash, - &Logic::asmPanRightToJoeAndRita, - &Logic::asmPanLeftToBomb // cdint.cut - }; - if (sm >= ARRAYSIZE(asmTable) || asmTable[sm] == NULL) - return false; - (this->*asmTable[sm])(); - return true; -} - - void Logic::executeSpecialMove(uint16 sm) { - debug(6, "Special move: %d", sm); - if (!(this->*_executeSpecialMove)(sm)) + if (!handleSpecialMove(sm)) warning("unhandled / invalid special move : %d", sm); } @@ -3053,6 +2825,166 @@ void Logic::stopCredits() { } +bool LogicDemo::preChangeRoom() { + if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) { + currentRoom(79); + roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); + playCutaway("clogo.cut"); + sceneReset(); + currentRoom(ROOM_HOTEL_LOBBY); + entryObj(584); + roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 2, true); + playCutaway("c70d.cut"); + gameState(VAR_INTRO_PLAYED, 1); + inventorySetup(); + inventoryRefresh(); + return true; + } + return false; +} + + +bool LogicInterview::preChangeRoom() { + if (currentRoom() == 2 && gameState(2) == 0) { + currentRoom(6); + roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); + playCutaway("start.cut"); + gameState(2, 1); + inventorySetup(); + inventoryRefresh(); + return true; + } + return false; +} + + +bool LogicGame::preChangeRoom() { + if (currentRoom() == ROOM_JUNGLE_PINNACLE) { + handlePinnacleRoom(); + return true; + } else if (currentRoom() == FOTAQ_LOGO && gameState(VAR_INTRO_PLAYED) == 0) { + roomDisplay(currentRoom(), RDM_FADE_NOJOE, 100, 2, true); + playCutaway("copy.cut"); + playCutaway("clogo.cut"); + + // XXX enable talking for talkie version + + if (ConfMan.getBool("alt_intro")) { + _vm->graphics()->loadPanel(); + playCutaway("cintr.cut"); + } else { + playCutaway("cdint.cut"); + _vm->graphics()->loadPanel(); + } + + playCutaway("cred.cut"); + sceneReset(); + currentRoom(ROOM_HOTEL_LOBBY); + entryObj(584); + roomDisplay(currentRoom(), RDM_FADE_JOE, 100, 2, true); + playCutaway("c70d.cut"); + gameState(VAR_INTRO_PLAYED, 1); + inventorySetup(); + inventoryRefresh(); + return true; + } + return false; +} + + +bool LogicDemo::handleSpecialMove(uint16 sm) { + switch (sm) { + case 4: + asmMakeJoeUseUnderwear(); + break; + case 5: + asmSwitchToDressPalette(); + break; + case 14: + asmEndDemo(); + break; + default: + return false; + } + return true; +} + + +bool LogicInterview::handleSpecialMove(uint16 sm) { + switch (sm) { + case 1: + asmInterviewIntro(); + break; + case 2: + asmEndInterview(); + break; + default: + return false; + } + return true; +} + + +bool LogicGame::handleSpecialMove(uint16 sm) { + typedef void (Logic::*SpecialMoveProc)(); + static const SpecialMoveProc asmTable[] = { + /* 00 */ + 0, + 0, + &Logic::asmMakeJoeUseDress, + &Logic::asmMakeJoeUseNormalClothes, + /* 04 */ + &Logic::asmMakeJoeUseUnderwear, + &Logic::asmSwitchToDressPalette, + &Logic::asmSwitchToNormalPalette, + &Logic::asmStartCarAnimation, // room 74 + /* 08 */ + &Logic::asmStopCarAnimation, // room 74 + &Logic::asmStartFightAnimation, // room 69 + &Logic::asmWaitForFrankPosition, // c69e.cut + &Logic::asmMakeFrankGrowing, // c69z.cut + /* 12 */ + &Logic::asmMakeRobotGrowing, // c69z.cut + &Logic::asmShrinkRobot, + &Logic::asmEndGame, + &Logic::asmPutCameraOnDino, + /* 16 */ + &Logic::asmPutCameraOnJoe, + &Logic::asmAltIntroPanRight, // cintr.cut + &Logic::asmAltIntroPanLeft, // cintr.cut + &Logic::asmSetAzuraInLove, + /* 20 */ + &Logic::asmPanRightFromJoe, + &Logic::asmSetLightsOff, + &Logic::asmSetLightsOn, + &Logic::asmSetManequinAreaOn, + /* 24 */ + &Logic::asmPanToJoe, + &Logic::asmTurnGuardOn, + &Logic::asmPanLeft320To144, + &Logic::asmSmooch, + /* 28 */ + &Logic::asmMakeLightningHitPlane, + &Logic::asmScaleBlimp, + &Logic::asmScaleEnding, + &Logic::asmWaitForCarPosition, + /* 32 */ + &Logic::asmShakeScreen, + &Logic::asmAttemptPuzzle, + &Logic::asmScaleTitle, + 0, + /* 36 */ + &Logic::asmPanRightToHugh, + &Logic::asmMakeWhiteFlash, + &Logic::asmPanRightToJoeAndRita, + &Logic::asmPanLeftToBomb // cdint.cut + }; + if (sm >= ARRAYSIZE(asmTable) || asmTable[sm] == 0) + return false; + (this->*asmTable[sm])(); + return true; +} + } // End of namespace Queen diff --git a/queen/logic.h b/queen/logic.h index 8608b9ce38..b95a334cd0 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -60,7 +60,7 @@ class Logic { public: Logic(QueenEngine *vm); - ~Logic(); + virtual ~Logic(); uint16 currentRoom() const { return _currentRoom; } void currentRoom(uint16 room) { @@ -241,18 +241,6 @@ public: bool subtitles() const { return _subtitles; } void subtitles(bool enable) { _subtitles = enable; } - void registerDefaultSettings(); - void checkOptionSettings(); - void readOptionSettings(); - void writeOptionSettings(); - - bool preChangeRoom_Demo(); - bool preChangeRoom_Interview(); - bool preChangeRoom_Game(); - - bool executeSpecialMove_Demo(uint16 sm); - bool executeSpecialMove_Interview(uint16 sm); - bool executeSpecialMove_Game(uint16 sm); void executeSpecialMove(uint16 sm); void asmMakeJoeUseDress(); @@ -299,9 +287,6 @@ public: void startCredits(const char *filename); void stopCredits(); - typedef bool (Logic::*ExecuteSpecialMoveProc)(uint16); - typedef bool (Logic::*PreChangeRoomProc)(); - enum { MAX_ZONES_NUMBER = 32, MAX_AREAS_NUMBER = 11, @@ -315,6 +300,10 @@ protected: void initialise(); + virtual bool preChangeRoom() = 0; + virtual bool handleSpecialMove(uint16 sm) = 0; + + LineReader *_queen2jas; uint16 _currentRoom; @@ -438,13 +427,34 @@ protected: bool _subtitles; - ExecuteSpecialMoveProc _executeSpecialMove; - PreChangeRoomProc _preChangeRoom; - QueenEngine *_vm; Credits *_credits; }; +class LogicDemo : public Logic { +public: + LogicDemo(QueenEngine *vm) : Logic(vm) {} +protected: + bool preChangeRoom(); + bool handleSpecialMove(uint16 sm); +}; + +class LogicInterview : public Logic { +public: + LogicInterview(QueenEngine *vm) : Logic(vm) {} +protected: + bool preChangeRoom(); + bool handleSpecialMove(uint16 sm); +}; + +class LogicGame : public Logic { +public: + LogicGame(QueenEngine *vm) : Logic(vm) {} +protected: + bool preChangeRoom(); + bool handleSpecialMove(uint16 sm); +}; + } // End of namespace Queen diff --git a/queen/queen.cpp b/queen/queen.cpp index 7ec2d4c4a9..e0c04ffc9f 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -98,6 +98,7 @@ QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst) _system->init_size(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT); } + QueenEngine::~QueenEngine() { _timer->removeTimerProc(&timerHandler); delete _bam; @@ -114,6 +115,61 @@ QueenEngine::~QueenEngine() { delete _walk; } + +void QueenEngine::registerDefaultSettings() { + ConfMan.registerDefault("master_volume", 255); + ConfMan.registerDefault("music_mute", false); + ConfMan.registerDefault("sfx_mute", false); + ConfMan.registerDefault("talkspeed", Logic::DEFAULT_TALK_SPEED); + ConfMan.registerDefault("speech_mute", _resource->isFloppy()); + ConfMan.registerDefault("subtitles", true); +} + + +void QueenEngine::checkOptionSettings() { + // check talkspeed value + if (_logic->talkSpeed() < 4) { + _logic->talkSpeed(4); + } else if (_logic->talkSpeed() > 95) { + _logic->talkSpeed(100); + } + + // XXX check master_volume value + + // only CD-ROM version has speech + if (_resource->isFloppy() && _sound->speechOn()) { + _sound->speechToggle(false); + } + + // ensure text is always on when voice is off + if (!_sound->speechOn()) { + _logic->subtitles(true); + } +} + + +void QueenEngine::readOptionSettings() { + // XXX master_volume + _sound->musicToggle(!ConfMan.getBool("music_mute")); + _sound->sfxToggle(!ConfMan.getBool("sfx_mute")); + _logic->talkSpeed(ConfMan.getInt("talkspeed")); + _sound->speechToggle(!ConfMan.getBool("speech_mute")); + _logic->subtitles(ConfMan.getBool("subtitles")); + checkOptionSettings(); +} + + +void QueenEngine::writeOptionSettings() { + // XXX master_volume + ConfMan.set("music_mute", !_sound->musicOn()); + ConfMan.set("sfx_mute", !_sound->sfxOn()); + ConfMan.set("talkspeed", _logic->talkSpeed()); + ConfMan.set("speech_mute", !_sound->speechOn()); + ConfMan.set("subtitles", _logic->subtitles()); + ConfMan.flushToDisk(); +} + + void QueenEngine::errorString(const char *buf1, char *buf2) { strcpy(buf2, buf1); if (_debugger && !_debugger->isAttached()) { @@ -126,8 +182,8 @@ void QueenEngine::errorString(const char *buf1, char *buf2) { void QueenEngine::go() { initialise(); - _logic->registerDefaultSettings(); - _logic->readOptionSettings(); + registerDefaultSettings(); + readOptionSettings(); _logic->oldRoom(0); _logic->newRoom(_logic->currentRoom()); @@ -159,6 +215,7 @@ void QueenEngine::go() { } } + void QueenEngine::initialise(void) { _bam = new BamScene(this); _resource = new Resource(_gameDataPath, _system->get_savefile_manager(), getSavePath()); @@ -168,7 +225,14 @@ void QueenEngine::initialise(void) { _display = new Display(this, _system); _graphics = new Graphics(this); _input = new Input(_resource->getLanguage(), _system); - _logic = new Logic(this); + + if (_resource->isDemo()) { + _logic = new LogicDemo(this); + } else if (_resource->isInterview()) { + _logic = new LogicInterview(this); + } else { + _logic = new LogicGame(this); + } MidiDriver *driver = GameDetector::createMidi(GameDetector::detectMusicDriver(MDT_NATIVE | MDT_ADLIB | MDT_PREFER_NATIVE)); if (!driver) diff --git a/queen/queen.h b/queen/queen.h index b58b26453e..f305e296b1 100644 --- a/queen/queen.h +++ b/queen/queen.h @@ -62,6 +62,11 @@ public: Common::RandomSource randomizer; + void registerDefaultSettings(); + void checkOptionSettings(); + void readOptionSettings(); + void writeOptionSettings(); + protected: void errorString(const char *buf_input, char *buf_output); @@ -70,6 +75,7 @@ protected: void initialise(); + static void timerHandler(void *ptr); void gotTimerTick(); -- cgit v1.2.3