diff options
author | Bastien Bouclet | 2011-05-14 10:47:42 +0200 |
---|---|---|
committer | Bastien Bouclet | 2011-05-14 10:51:55 +0200 |
commit | 3537456eb51ed65b67c888ef01a0638719410fdb (patch) | |
tree | b87fe5b487a0cbab3ec5a50f7a5383a7552c17f9 /engines | |
parent | 0bbb41224939568e4ee0ac5db2837ff4297b2ae8 (diff) | |
download | scummvm-rg350-3537456eb51ed65b67c888ef01a0638719410fdb.tar.gz scummvm-rg350-3537456eb51ed65b67c888ef01a0638719410fdb.tar.bz2 scummvm-rg350-3537456eb51ed65b67c888ef01a0638719410fdb.zip |
MOHAWK: Implement Mechanical opcodes 109, 110, 111, 112, 113 and 114. Fortress rotation controls.
QuickTime Custom framerate and backwards playback is required for the actual rotation to be implemented (opcode 205).
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/myst_stacks/mechanical.cpp | 125 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/mechanical.h | 16 |
2 files changed, 114 insertions, 27 deletions
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp index b8a6b3110e..dbb1aeae69 100644 --- a/engines/mohawk/myst_stacks/mechanical.cpp +++ b/engines/mohawk/myst_stacks/mechanical.cpp @@ -59,6 +59,12 @@ void Mechanical::setupOpcodes() { OPCODE(106, o_elevatorRotationStart); OPCODE(107, o_elevatorRotationMove); OPCODE(108, o_elevatorRotationStop); + OPCODE(109, o_fortressRotationSpeedStart); + OPCODE(110, o_fortressRotationSpeedMove); + OPCODE(111, o_fortressRotationSpeedStop); + OPCODE(112, o_fortressRotationBrakeStart); + OPCODE(113, o_fortressRotationBrakeMove); + OPCODE(114, o_fortressRotationBrakeStop); OPCODE(121, o_elevatorWindowMovie); OPCODE(122, o_elevatorGoMiddle); OPCODE(123, o_elevatorTopMovie); @@ -78,7 +84,7 @@ void Mechanical::setupOpcodes() { OPCODE(202, o_bird_init); OPCODE(203, o_snakeBox_init); OPCODE(204, o_elevatorRotation_init); - OPCODE(205, opcode_205); + OPCODE(205, o_fortressRotation_init); OPCODE(206, opcode_206); OPCODE(209, opcode_209); @@ -89,11 +95,11 @@ void Mechanical::setupOpcodes() { #undef OPCODE void Mechanical::disablePersistentScripts() { - opcode_205_disable(); opcode_206_disable(); opcode_209_disable(); _elevatorGoingMiddle = false; _birdSinging = false; + _fortressRotationRunning = false; } void Mechanical::runPersistentScripts() { @@ -106,7 +112,9 @@ void Mechanical::runPersistentScripts() { if (_elevatorGoingMiddle) elevatorGoMiddle_run(); - opcode_205_run(); + if (_fortressRotationRunning) + fortressRotation_run(); + opcode_206_run(); opcode_209_run(); } @@ -379,6 +387,85 @@ void Mechanical::o_elevatorRotationStop(uint16 op, uint16 var, uint16 argc, uint _vm->checkCursorHints(); } +void Mechanical::o_fortressRotationSpeedStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d Fortress rotation speed lever start", op); + + _vm->_cursor->setCursor(700); + + MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); + lever->drawFrame(0); +} + +void Mechanical::o_fortressRotationSpeedMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d Fortress rotation speed lever move", op); + + const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos(); + MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); + + // Make the handle follow the mouse + int16 maxStep = lever->getNumFrames() - 1; + Common::Rect rect = lever->getRect(); + int16 step = ((rect.top + 65 - mouse.y) * lever->getNumFrames()) / 65; + step = CLIP<int16>(step, 0, maxStep); + + _fortressRotationSpeed = step; + + // Draw current frame + lever->drawFrame(step); +} + +void Mechanical::o_fortressRotationSpeedStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d Fortress rotation speed lever stop", op); + + MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); + + // Release lever + for (int i = _fortressRotationSpeed; i >= 0; i--) { + lever->drawFrame(i); + _vm->_system->delayMillis(10); + } + + _fortressRotationSpeed = 0; + + _vm->checkCursorHints(); +} + +void Mechanical::o_fortressRotationBrakeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d Fortress rotation brake lever start", op); + + _vm->_cursor->setCursor(700); + + MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); + lever->drawFrame(_fortressRotationBrake); +} + +void Mechanical::o_fortressRotationBrakeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d Fortress rotation brake lever move", op); + + const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos(); + MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); + + // Make the handle follow the mouse + int16 maxStep = lever->getNumFrames() - 1; + Common::Rect rect = lever->getRect(); + int16 step = ((rect.top + 65 - mouse.y) * lever->getNumFrames()) / 65; + step = CLIP<int16>(step, 0, maxStep); + + _fortressRotationBrake = step; + + // Draw current frame + lever->drawFrame(step); +} + +void Mechanical::o_fortressRotationBrakeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d Fortress rotation brake lever stop", op); + + MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource); + lever->drawFrame(_fortressRotationBrake); + + _vm->checkCursorHints(); +} + void Mechanical::o_elevatorWindowMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) { uint16 startTime = argv[0]; uint16 endTime = argv[1]; @@ -596,36 +683,24 @@ void Mechanical::o_elevatorRotation_init(uint16 op, uint16 var, uint16 argc, uin _elevatorRotationLeverMoving = false; } -static struct { - uint16 soundIdPosition[4]; - - bool enabled; -} g_opcode205Parameters; - -void Mechanical::opcode_205_run() { +void Mechanical::fortressRotation_run() { // Used for Card 6156 (Fortress Rotation Controls) // TODO: Fill in function... - // g_opcode205Parameters.soundIdPosition[4] } -void Mechanical::opcode_205_disable() { - g_opcode205Parameters.enabled = false; -} +void Mechanical::o_fortressRotation_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Fortress rotation init", op); -void Mechanical::opcode_205(uint16 op, uint16 var, uint16 argc, uint16 *argv) { - varUnusedCheck(op, var); + _fortressRotationGears = static_cast<MystResourceType6 *>(_invokingResource); - // Used for Card 6156 (Fortress Rotation Controls) + _fortressRotationSounds[0] = argv[0]; + _fortressRotationSounds[1] = argv[1]; + _fortressRotationSounds[2] = argv[2]; + _fortressRotationSounds[3] = argv[3]; - if (argc == 4) { - g_opcode205Parameters.soundIdPosition[0] = argv[0]; - g_opcode205Parameters.soundIdPosition[1] = argv[1]; - g_opcode205Parameters.soundIdPosition[2] = argv[2]; - g_opcode205Parameters.soundIdPosition[3] = argv[3]; + _fortressRotationBrake = 0; - g_opcode205Parameters.enabled = true; - } else - unknown(op, var, argc, argv); + _fortressRotationRunning = true; } static struct { diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h index 320fbb77cd..9b383fe435 100644 --- a/engines/mohawk/myst_stacks/mechanical.h +++ b/engines/mohawk/myst_stacks/mechanical.h @@ -52,7 +52,7 @@ private: void birdSing_run(); void elevatorRotation_run(); void elevatorGoMiddle_run(); - void opcode_205_run(); + void fortressRotation_run(); void opcode_205_disable(); void opcode_206_run(); void opcode_206_disable(); @@ -67,6 +67,12 @@ private: DECLARE_OPCODE(o_elevatorRotationStart); DECLARE_OPCODE(o_elevatorRotationMove); DECLARE_OPCODE(o_elevatorRotationStop); + DECLARE_OPCODE(o_fortressRotationSpeedStart); + DECLARE_OPCODE(o_fortressRotationSpeedMove); + DECLARE_OPCODE(o_fortressRotationSpeedStop); + DECLARE_OPCODE(o_fortressRotationBrakeStart); + DECLARE_OPCODE(o_fortressRotationBrakeMove); + DECLARE_OPCODE(o_fortressRotationBrakeStop); DECLARE_OPCODE(o_elevatorWindowMovie); DECLARE_OPCODE(o_elevatorGoMiddle); DECLARE_OPCODE(o_elevatorTopMovie); @@ -85,7 +91,7 @@ private: DECLARE_OPCODE(o_bird_init); DECLARE_OPCODE(o_snakeBox_init); DECLARE_OPCODE(o_elevatorRotation_init); - DECLARE_OPCODE(opcode_205); + DECLARE_OPCODE(o_fortressRotation_init); DECLARE_OPCODE(opcode_206); DECLARE_OPCODE(opcode_209); @@ -93,7 +99,13 @@ private: bool _mystStaircaseState; // 76 + bool _fortressRotationRunning; + uint16 _fortressRotationSpeed; // 78 + uint16 _fortressRotationBrake; // 80 uint16 _fortressPosition; // 82 + uint16 _fortressRotationSounds[4]; // 86 to 92 + MystResourceType6 *_fortressRotationGears; // 172 + uint16 _elevatorGoingDown; // 112 |