From bf82f16982cc6e0f5ea6069f8ec4f9fbbc38739d Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Thu, 2 Dec 2010 21:16:39 +0000 Subject: MOHAWK: Implement Myst opcodes 141 to 143, circuit breakers svn-id: r54741 --- engines/mohawk/myst_stacks/myst.cpp | 79 +++++++++++++++++++++++++++++++++++++ engines/mohawk/myst_stacks/myst.h | 3 ++ 2 files changed, 82 insertions(+) (limited to 'engines') diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index c07047e6df..0b94b7432a 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -23,9 +23,11 @@ * */ +#include "mohawk/cursors.h" #include "mohawk/myst.h" #include "mohawk/graphics.h" #include "mohawk/myst_areas.h" +#include "mohawk/myst_saveload.h" #include "mohawk/sound.h" #include "mohawk/video.h" #include "mohawk/myst_stacks/myst.h" @@ -78,6 +80,9 @@ void MystScriptParser_Myst::setupOpcodes() { OPCODE(135, opcode_135); OPCODE(136, opcode_136); OPCODE(137, opcode_137); + OPCODE(141, o_circuitBreakerStartMove); + OPCODE(142, o_circuitBreakerMove); + OPCODE(143, o_circuitBreakerEndMove); OPCODE(146, opcode_146); OPCODE(147, opcode_147); OPCODE(149, opcode_149); @@ -612,6 +617,80 @@ void MystScriptParser_Myst::opcode_137(uint16 op, uint16 var, uint16 argc, uint1 // TODO: Time slider movement } +void MystScriptParser_Myst::o_circuitBreakerStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Circuit breaker start move", op); + + MystResourceType12 *breaker = static_cast(_invokingResource); + breaker->drawFrame(0); + _vm->_cursor->setCursor(700); + _tempVar = 0; +} + +void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Circuit breaker move", op); + + uint16 *mystVars = _vm->_saveLoad->_v->myst_vars; + MystResourceType12 *breaker = static_cast(_invokingResource); + + int16 maxStep = breaker->getStepsV() - 1; + int16 step = ((_vm->_mouse.y - 80) * breaker->getStepsV()) / 65; + + if (step > maxStep) + step = maxStep; + else if (step < 0) + step = 0; + + breaker->drawFrame(step); + + if (_tempVar != step) { + _tempVar = step; + + // Breaker switched + if (step == maxStep) { + + // Choose breaker + if (breaker->getType8Var() == 93) { + + // Voltage is still too high or not broken + if (mystVars[17] > 59 || mystVars[15] != 1) { + uint16 soundId = breaker->getList2(1); + if (soundId) + _vm->_sound->playSound(soundId); + } else { + uint16 soundId = breaker->getList2(0); + if (soundId) + _vm->_sound->playSound(soundId); + + // Reset breaker state + mystVars[15] = 0; + } + } else { + // Voltage is still too high or not broken + if (mystVars[17] > 59 || mystVars[15] != 2) { + uint16 soundId = breaker->getList2(1); + if (soundId) + _vm->_sound->playSound(soundId); + } else { + uint16 soundId = breaker->getList2(0); + if (soundId) + _vm->_sound->playSound(soundId); + + // Reset breaker state + mystVars[15] = 0; + } + } + } + } +} + +void MystScriptParser_Myst::o_circuitBreakerEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + debugC(kDebugScript, "Opcode %d: Circuit breaker end move", op); + + MystResourceType12 *breaker = static_cast(_invokingResource); + _vm->redrawArea(breaker->getType8Var()); + _vm->checkCursorHints(); +} + void MystScriptParser_Myst::opcode_146(uint16 op, uint16 var, uint16 argc, uint16 *argv) { // Used on Card 4098 // TODO: Boiler wheel clockwise mouse down diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h index e3096fdd24..a64c7176dd 100644 --- a/engines/mohawk/myst_stacks/myst.h +++ b/engines/mohawk/myst_stacks/myst.h @@ -93,6 +93,9 @@ private: DECLARE_OPCODE(opcode_135); DECLARE_OPCODE(opcode_136); DECLARE_OPCODE(opcode_137); + DECLARE_OPCODE(o_circuitBreakerStartMove); + DECLARE_OPCODE(o_circuitBreakerMove); + DECLARE_OPCODE(o_circuitBreakerEndMove); DECLARE_OPCODE(opcode_146); DECLARE_OPCODE(opcode_147); DECLARE_OPCODE(opcode_149); -- cgit v1.2.3