diff options
Diffstat (limited to 'engines/mohawk')
-rw-r--r-- | engines/mohawk/myst_stacks/stoneship.cpp | 102 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/stoneship.h | 18 |
2 files changed, 96 insertions, 24 deletions
diff --git a/engines/mohawk/myst_stacks/stoneship.cpp b/engines/mohawk/myst_stacks/stoneship.cpp index 7c8fecf6fa..8b19618ec1 100644 --- a/engines/mohawk/myst_stacks/stoneship.cpp +++ b/engines/mohawk/myst_stacks/stoneship.cpp @@ -70,6 +70,9 @@ void MystScriptParser_Stoneship::setupOpcodes() { OPCODE(102, o_cabinBookMovie); OPCODE(103, o_drawerOpenSirius); OPCODE(104, o_drawerClose); + OPCODE(105, o_telescopeStart); + OPCODE(106, o_telescopeMove); + OPCODE(107, o_telescopeStop); OPCODE(108, o_generatorStart); OPCODE(109, NOP); OPCODE(110, o_generatorStop); @@ -96,23 +99,27 @@ void MystScriptParser_Stoneship::setupOpcodes() { OPCODE(205, opcode_205); OPCODE(206, opcode_206); OPCODE(207, o_chest_init); - OPCODE(208, opcode_208); + OPCODE(208, o_telescope_init); OPCODE(209, o_achenarDrawers_init); OPCODE(210, o_cloudOrb_init); // "Exit" Opcodes - OPCODE(300, opcode_300); + OPCODE(300, NOP); } #undef OPCODE void MystScriptParser_Stoneship::disablePersistentScripts() { _batteryCharging = false; + _telescopeRunning = false; } void MystScriptParser_Stoneship::runPersistentScripts() { if (_batteryCharging) chargeBattery_run(); + + if (_telescopeRunning) + telescope_run(); } uint16 MystScriptParser_Stoneship::getVar(uint16 var) { @@ -432,6 +439,35 @@ void MystScriptParser_Stoneship::o_drawerClose(uint16 op, uint16 var, uint16 arg drawerClose(argv[0]); } +void MystScriptParser_Stoneship::o_telescopeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos(); + _telescopeOldMouse = mouse.x; + _vm->_cursor->setCursor(700); +} + +void MystScriptParser_Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Telescope move", op); + + MystResourceType11 *display = static_cast<MystResourceType11 *>(_invokingResource); + const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos(); + + // Compute telescope position + _telescopePosition = (_telescopePosition - (mouse.x - _telescopeOldMouse) / 2 + 3240) % 3240; + _telescopeOldMouse = mouse.x; + + // Copy image to screen + Common::Rect src = Common::Rect(_telescopePosition, 0, _telescopePosition + 112, 112); + _vm->_gfx->copyImageSectionToScreen(_telescopePanorama, src, display->getRect()); + + // Draw lighthouse + telescopeLighthouseDraw(); + _vm->_system->updateScreen(); +} + +void MystScriptParser_Stoneship::o_telescopeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + _vm->checkCursorHints(); +} + void MystScriptParser_Stoneship::o_generatorStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { debugC(kDebugScript, "Opcode %d: Generator start", op); @@ -840,23 +876,53 @@ void MystScriptParser_Stoneship::o_chest_init(uint16 op, uint16 var, uint16 argc _state.chestOpenState = 0; } -void MystScriptParser_Stoneship::opcode_208(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - varUnusedCheck(op, var); +void MystScriptParser_Stoneship::o_telescope_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Telescope init", op); // Used in Card 2218 (Telescope view) - if (argc == 3) { - debugC(kDebugScript, "Opcode %d: Telescope View", op); - uint16 imagePanorama = argv[0]; - uint16 imageLighthouseOff = argv[1]; - uint16 imageLighthouseOn = argv[2]; + _telescopePanorama = argv[0]; + _telescopeLighthouseOff = argv[1]; + _telescopeLighthouseOn = argv[2]; + _telescopePosition = 0; - debugC(kDebugScript, "Image (Panorama): %d", imagePanorama); - debugC(kDebugScript, "Image (Lighthouse Off): %d", imageLighthouseOff); - debugC(kDebugScript, "Image (Lighthouse On): %d", imageLighthouseOn); + _telescopeRunning = true; + _telescopeLighthouseState = false; + _telescopeNexTime = _vm->_system->getMillis() + 1000; +} - // TODO: Fill in Logic. - } else - unknown(op, var, argc, argv); +void MystScriptParser_Stoneship::telescope_run() { + uint32 time = _vm->_system->getMillis(); + + if (time > _telescopeNexTime) { + + _telescopeNexTime = time + 1000; + _telescopeLighthouseState = !_telescopeLighthouseState; + + telescopeLighthouseDraw(); + _vm->_system->updateScreen(); + } +} + +void MystScriptParser_Stoneship::telescopeLighthouseDraw() { + if (_telescopePosition > 1137 && _telescopePosition < 1294) { + uint16 imageId = _telescopeLighthouseOff; + + if (_state.generatorPowerAvailable == 1 && _telescopeLighthouseState) + imageId = _telescopeLighthouseOn; + + Common::Rect src(1205, 0, 1205 + 131, 112); + src.clip(Common::Rect(_telescopePosition, 0, _telescopePosition + 112, 112)); + src.translate(-1205, 0); + src.clip(131, 112); + + Common::Rect dest(_telescopePosition, 0, _telescopePosition + 112, 112); + dest.clip(Common::Rect(1205, 0, 1205 + 131, 112)); + dest.translate(-_telescopePosition, 0); + dest.clip(112, 112); + dest.translate(222, 112); + + _vm->_gfx->copyImageSectionToScreen(imageId, src, dest); + } } void MystScriptParser_Stoneship::o_achenarDrawers_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { @@ -885,10 +951,4 @@ void MystScriptParser_Stoneship::o_cloudOrb_init(uint16 op, uint16 var, uint16 a _cloudOrbStopSound = argv[1]; } -void MystScriptParser_Stoneship::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - // Used in Card 2218 (Telescope view) - varUnusedCheck(op, var); - // TODO: Fill in Logic. Clearing Variable for View? -} - } // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/stoneship.h b/engines/mohawk/myst_stacks/stoneship.h index af77aeda03..7fa8e7a486 100644 --- a/engines/mohawk/myst_stacks/stoneship.h +++ b/engines/mohawk/myst_stacks/stoneship.h @@ -56,6 +56,9 @@ private: DECLARE_OPCODE(o_cabinBookMovie); DECLARE_OPCODE(o_drawerOpenSirius); DECLARE_OPCODE(o_drawerClose); + DECLARE_OPCODE(o_telescopeStart); + DECLARE_OPCODE(o_telescopeMove); + DECLARE_OPCODE(o_telescopeStop); DECLARE_OPCODE(o_generatorStart); DECLARE_OPCODE(o_generatorStop); DECLARE_OPCODE(o_drawerOpenAchenar); @@ -80,12 +83,10 @@ private: DECLARE_OPCODE(opcode_205); DECLARE_OPCODE(opcode_206); DECLARE_OPCODE(o_chest_init); - DECLARE_OPCODE(opcode_208); + DECLARE_OPCODE(o_telescope_init); DECLARE_OPCODE(o_achenarDrawers_init); DECLARE_OPCODE(o_cloudOrb_init); - DECLARE_OPCODE(opcode_300); - void chargeBattery_run(); MystGameState::Stoneship &_state; @@ -109,6 +110,17 @@ private: MystResourceType6 *_hologramSelection; // 88 uint16 _hologramDisplayPos; + uint16 _telescopePosition; // 112 + uint16 _telescopePanorama; + uint16 _telescopeOldMouse; + uint16 _telescopeLighthouseOff; // 130 + uint16 _telescopeLighthouseOn; // 128 + bool _telescopeLighthouseState; // 124 + bool _telescopeRunning; + uint32 _telescopeNexTime; + void telescope_run(); + void telescopeLighthouseDraw(); + MystResourceType6 *_cloudOrbMovie; // 136 uint16 _cloudOrbSound; // 140 uint16 _cloudOrbStopSound; // 142 |