diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/myst_stacks/myst.cpp | 121 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/myst.h | 16 | ||||
-rw-r--r-- | engines/mohawk/myst_state.cpp | 13 | ||||
-rw-r--r-- | engines/mohawk/myst_state.h | 8 |
4 files changed, 129 insertions, 29 deletions
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index defbde9a77..8f591bdbd5 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -169,7 +169,7 @@ void MystScriptParser_Myst::setupOpcodes() { OPCODE(211, o_fireplace_init); OPCODE(212, opcode_212); OPCODE(213, opcode_213); - OPCODE(214, opcode_214); + OPCODE(214, o_observatory_init); OPCODE(215, opcode_215); OPCODE(216, o_treeCard_init); OPCODE(217, o_treeEntry_init); @@ -207,6 +207,7 @@ void MystScriptParser_Myst::disablePersistentScripts() { _basementPressureDecreasing = false; _imagerValidationRunning = false; _imagerRunning = false; + _observatoryRunning = false; opcode_212_disable(); } @@ -252,6 +253,9 @@ void MystScriptParser_Myst::runPersistentScripts() { if (_imagerRunning) imager_run(); + + if (_observatoryRunning) + observatory_run(); } uint16 MystScriptParser_Myst::getVar(uint16 var) { @@ -2728,27 +2732,104 @@ void MystScriptParser_Myst::opcode_213(uint16 op, uint16 var, uint16 argc, uint1 unknown(op, var, argc, argv); } -void MystScriptParser_Myst::opcode_214(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - varUnusedCheck(op, var); +void MystScriptParser_Myst::o_observatory_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Stellar observatory init", op); - // Used for Card 4500 (Stellar Observatory) - if (argc == 5) { - debugC(kDebugScript, "Opcode %d: Unknown...", op); + _tempVar = 0; + _observatoryNotInitialized = true; + _observatoryVisualizer = static_cast<MystResourceType8 *>(_invokingResource); + _observatoryGoButton = static_cast<MystResourceType8 *>(_vm->_resources[argv[0]]); + _observatoryDaySlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[1]]); + _observatoryMonthSlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[2]]); + _observatoryYearSlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[3]]); + _observatoryTimeSlider = static_cast<MystResourceType10 *>(_vm->_resources[argv[4]]); - uint16 u0 = argv[0]; - uint16 u1 = argv[1]; - uint16 u2 = argv[2]; - uint16 u3 = argv[3]; - uint16 u4 = argv[4]; - - debugC(kDebugScript, "\tu0: %d", u0); - debugC(kDebugScript, "\tu1: %d", u1); - debugC(kDebugScript, "\tu2: %d", u2); - debugC(kDebugScript, "\tu3: %d", u3); - debugC(kDebugScript, "\tu4: %d", u4); - // TODO: Complete Implementation... - } else - unknown(op, var, argc, argv); + // Set date selection sliders position + _observatoryDaySlider->setPosition(_state.observatoryDaySlider); + _observatoryMonthSlider->setPosition(_state.observatoryMonthSlider); + _observatoryYearSlider->setPosition(_state.observatoryYearSlider); + _observatoryTimeSlider->setPosition(_state.observatoryTimeSlider); + + _observatoryLastTime = _vm->_system->getMillis(); + + observatorySetTargetToSetting(); + + _observatoryRunning = true; +} + +void MystScriptParser_Myst::observatoryUpdateVisualizer(uint16 x, uint16 y) { + Common::Rect &visu0 = _observatoryVisualizer->_subImages[0].rect; + Common::Rect &visu1 = _observatoryVisualizer->_subImages[1].rect; + + visu0.left = x; + visu0.right = visu0.left + 105; + visu0.bottom = 512 - y; + visu0.top = visu0.bottom - 106; + + visu1.left = visu0.left; + visu1.top = visu0.top; + visu1.right = visu0.right; + visu1.bottom = visu0.bottom; +} + +void MystScriptParser_Myst::observatorySetTargetToSetting() { + uint16 visuX = _state.observatoryYearSetting * 0.28; + uint16 visuY = 250 * _state.observatoryTimeSetting + + 65 * (_state.observatoryMonthSetting + 1) + + 20 * _state.observatoryDaySetting; + + observatoryUpdateVisualizer(visuX % 407, visuY % 407); + + _state.observatoryDayTarget = _state.observatoryDaySetting; + _state.observatoryMonthTarget = _state.observatoryMonthSetting; + _state.observatoryYearTarget = _state.observatoryYearSetting; + _state.observatoryTimeTarget = _state.observatoryTimeSetting; +} + +void MystScriptParser_Myst::observatory_run() { + if (_observatoryNotInitialized) { + _observatoryNotInitialized = false; + + _vm->_cursor->hideCursor(); + + // Make sliders "initialize" + _vm->_sound->replaceSound(8500); + _observatoryDaySlider->drawConditionalDataToScreen(2); + _vm->_system->delayMillis(200); + _vm->redrawResource(_observatoryDaySlider); + + _vm->_sound->replaceSound(8500); + _observatoryMonthSlider->drawConditionalDataToScreen(2); + _vm->_system->delayMillis(200); + _vm->redrawResource(_observatoryMonthSlider); + + _vm->_sound->replaceSound(8500); + _observatoryYearSlider->drawConditionalDataToScreen(2); + _vm->_system->delayMillis(200); + _vm->redrawResource(_observatoryYearSlider); + + _vm->_sound->replaceSound(8500); + _observatoryTimeSlider->drawConditionalDataToScreen(2); + _vm->_system->delayMillis(200); + _vm->redrawResource(_observatoryTimeSlider); + + _vm->_cursor->showCursor(); + } + + // Setting not at target + if (_state.observatoryDayTarget != _state.observatoryDaySetting + || _state.observatoryMonthTarget != _state.observatoryMonthSetting + || _state.observatoryYearTarget != _state.observatoryYearSetting + || _state.observatoryTimeTarget != _state.observatoryTimeSetting) { + + // Blink go button + uint32 time = _vm->_system->getMillis(); + if (time > _observatoryLastTime + 250) { + _tempVar = (_tempVar + 1) % 2; + _observatoryGoButton->drawConditionalDataToScreen(_tempVar); + _observatoryLastTime = time; + } + } } void MystScriptParser_Myst::opcode_215(uint16 op, uint16 var, uint16 argc, uint16 *argv) { diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h index fa87009dc0..386d2b0f5d 100644 --- a/engines/mohawk/myst_stacks/myst.h +++ b/engines/mohawk/myst_stacks/myst.h @@ -66,6 +66,7 @@ private: void tree_run(); void imagerValidation_run(); void imager_run(); + void observatory_run(); DECLARE_OPCODE(o_libraryBookPageTurnLeft); DECLARE_OPCODE(o_libraryBookPageTurnRight); @@ -158,7 +159,7 @@ private: DECLARE_OPCODE(o_fireplace_init); DECLARE_OPCODE(opcode_212); DECLARE_OPCODE(opcode_213); - DECLARE_OPCODE(opcode_214); + DECLARE_OPCODE(o_observatory_init); DECLARE_OPCODE(opcode_215); DECLARE_OPCODE(o_treeCard_init); DECLARE_OPCODE(o_treeEntry_init); @@ -250,6 +251,16 @@ private: uint16 _treeMinAccessiblePosition; // 230 uint16 _treeMaxAccessiblePosition; // 232 + bool _observatoryRunning; + MystResourceType8 *_observatoryVisualizer; // 184 + MystResourceType8 *_observatoryGoButton; // 188 + MystResourceType10 *_observatoryDaySlider; // 192 + MystResourceType10 *_observatoryMonthSlider; // 196 + MystResourceType10 *_observatoryYearSlider; // 200 + MystResourceType10 *_observatoryTimeSlider; // 204 + uint32 _observatoryLastTime; // 208 + bool _observatoryNotInitialized; // 212 + void generatorRedrawRocket(); void generatorButtonValue(MystResource *button, uint16 &offset, uint16 &value); @@ -273,6 +284,9 @@ private: void treeSetAlcoveAccessible(); uint32 treeNextMoveDelay(uint16 pressure); + + void observatorySetTargetToSetting(); + void observatoryUpdateVisualizer(uint16 x, uint16 y); }; } // End of namespace Mohawk diff --git a/engines/mohawk/myst_state.cpp b/engines/mohawk/myst_state.cpp index 8131e35559..0eefe58637 100644 --- a/engines/mohawk/myst_state.cpp +++ b/engines/mohawk/myst_state.cpp @@ -56,6 +56,11 @@ MystGameState::MystGameState(MohawkEngine_Myst *vm, Common::SaveFileManager *sav _myst.imagerActive = 1; // Stellar Observatory Lights - Default to On _myst.observatoryLights = 1; + // Stellar Observatory sliders + _myst.observatoryDaySlider = 90; + _myst.observatoryMonthSlider = 90; + _myst.observatoryYearSlider = 90; + _myst.observatoryTimeSlider = 90; // Lighthouse Trapdoor State - Default to Locked _stoneship.trapdoorState = 2; @@ -197,10 +202,10 @@ void MystGameState::syncGameState(Common::Serializer &s, bool isME) { for (int i = 0; i < 5; i++) s.syncAsUint16LE(_myst.rocketSliderPosition[i]); - s.syncAsUint16LE(_myst.u6); - s.syncAsUint16LE(_myst.u7); - s.syncAsUint16LE(_myst.u8); - s.syncAsUint16LE(_myst.u9); + s.syncAsUint16LE(_myst.observatoryDaySlider); + s.syncAsUint16LE(_myst.observatoryMonthSlider); + s.syncAsUint16LE(_myst.observatoryYearSlider); + s.syncAsUint16LE(_myst.observatoryTimeSlider); // Channelwood if (isME) { diff --git a/engines/mohawk/myst_state.h b/engines/mohawk/myst_state.h index a8c7cf3dea..2787efac4f 100644 --- a/engines/mohawk/myst_state.h +++ b/engines/mohawk/myst_state.h @@ -163,10 +163,10 @@ public: uint16 treePosition; uint32 treeLastMoveTime; uint16 rocketSliderPosition[5]; - uint16 u6; - uint16 u7; - uint16 u8; - uint16 u9; + uint16 observatoryDaySlider; + uint16 observatoryMonthSlider; + uint16 observatoryYearSlider; + uint16 observatoryTimeSlider; } _myst; /* 7 Channelwood Specific Variables : |