aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/myst_stacks/mechanical.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2011-05-14 11:37:36 +0200
committerBastien Bouclet2011-05-14 11:38:51 +0200
commit8db0bb927421622a5496c78351c1230584a17a97 (patch)
tree8db6126730f387a9156e6c9b6e51f51c49962fd5 /engines/mohawk/myst_stacks/mechanical.cpp
parentdcf9daf4cff0c74fd8533436d479d7c224bfb246 (diff)
downloadscummvm-rg350-8db0bb927421622a5496c78351c1230584a17a97.tar.gz
scummvm-rg350-8db0bb927421622a5496c78351c1230584a17a97.tar.bz2
scummvm-rg350-8db0bb927421622a5496c78351c1230584a17a97.zip
MOHAWK: Implement Mechanical opcodes 115, 116, 117, 118, 119 and 120. Fortress rotation simulator controls.
QuickTime Custom framerate and backwards playback is required for the actual simulation to be implemented (opcode 206).
Diffstat (limited to 'engines/mohawk/myst_stacks/mechanical.cpp')
-rw-r--r--engines/mohawk/myst_stacks/mechanical.cpp166
1 files changed, 107 insertions, 59 deletions
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index dbb1aeae69..d6dd1b5407 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -65,6 +65,12 @@ void Mechanical::setupOpcodes() {
OPCODE(112, o_fortressRotationBrakeStart);
OPCODE(113, o_fortressRotationBrakeMove);
OPCODE(114, o_fortressRotationBrakeStop);
+ OPCODE(115, o_fortressSimulationSpeedStart);
+ OPCODE(116, o_fortressSimulationSpeedMove);
+ OPCODE(117, o_fortressSimulationSpeedStop);
+ OPCODE(118, o_fortressSimulationBrakeStart);
+ OPCODE(119, o_fortressSimulationBrakeMove);
+ OPCODE(120, o_fortressSimulationBrakeStop);
OPCODE(121, o_elevatorWindowMovie);
OPCODE(122, o_elevatorGoMiddle);
OPCODE(123, o_elevatorTopMovie);
@@ -85,8 +91,8 @@ void Mechanical::setupOpcodes() {
OPCODE(203, o_snakeBox_init);
OPCODE(204, o_elevatorRotation_init);
OPCODE(205, o_fortressRotation_init);
- OPCODE(206, opcode_206);
- OPCODE(209, opcode_209);
+ OPCODE(206, o_fortressSimulation_init);
+ OPCODE(209, o_fortressSimulationStartup_init);
// "Exit" Opcodes
OPCODE(300, NOP);
@@ -95,8 +101,7 @@ void Mechanical::setupOpcodes() {
#undef OPCODE
void Mechanical::disablePersistentScripts() {
- opcode_206_disable();
- opcode_209_disable();
+ _fortressSimulationRunning = false;
_elevatorGoingMiddle = false;
_birdSinging = false;
_fortressRotationRunning = false;
@@ -115,8 +120,8 @@ void Mechanical::runPersistentScripts() {
if (_fortressRotationRunning)
fortressRotation_run();
- opcode_206_run();
- opcode_209_run();
+ if (_fortressSimulationRunning)
+ fortressSimulation_run();
}
uint16 Mechanical::getVar(uint16 var) {
@@ -466,6 +471,85 @@ void Mechanical::o_fortressRotationBrakeStop(uint16 op, uint16 var, uint16 argc,
_vm->checkCursorHints();
}
+void Mechanical::o_fortressSimulationSpeedStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d Fortress rotation simulator speed lever start", op);
+
+ _vm->_cursor->setCursor(700);
+
+ MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ lever->drawFrame(0);
+}
+
+void Mechanical::o_fortressSimulationSpeedMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d Fortress rotation simulator 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.bottom - mouse.y) * lever->getNumFrames()) / rect.height();
+ step = CLIP<int16>(step, 0, maxStep);
+
+ _fortressSimulationSpeed = step;
+
+ // Draw current frame
+ lever->drawFrame(step);
+}
+
+void Mechanical::o_fortressSimulationSpeedStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d Fortress rotation simulator speed lever stop", op);
+
+ MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+
+ // Release lever
+ for (int i = _fortressSimulationSpeed; i >= 0; i--) {
+ lever->drawFrame(i);
+ _vm->_system->delayMillis(10);
+ }
+
+ _fortressSimulationSpeed = 0;
+
+ _vm->checkCursorHints();
+}
+
+void Mechanical::o_fortressSimulationBrakeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d Fortress rotation simulator brake lever start", op);
+
+ _vm->_cursor->setCursor(700);
+
+ MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ lever->drawFrame(_fortressSimulationBrake);
+}
+
+void Mechanical::o_fortressSimulationBrakeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d Fortress rotation simulator 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.bottom - mouse.y) * lever->getNumFrames()) / rect.height();
+ step = CLIP<int16>(step, 0, maxStep);
+
+ _fortressSimulationBrake = step;
+
+ // Draw current frame
+ lever->drawFrame(step);
+}
+
+void Mechanical::o_fortressSimulationBrakeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d Fortress rotation simulator brake lever stop", op);
+
+ MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+ lever->drawFrame(_fortressSimulationBrake);
+
+ _vm->checkCursorHints();
+}
+
void Mechanical::o_elevatorWindowMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
uint16 startTime = argv[0];
uint16 endTime = argv[1];
@@ -703,69 +787,33 @@ void Mechanical::o_fortressRotation_init(uint16 op, uint16 var, uint16 argc, uin
_fortressRotationRunning = true;
}
-static struct {
- uint16 soundIdStart[2];
- uint16 soundIdPosition[4];
-
- bool enabled;
-} g_opcode206Parameters;
-
-void Mechanical::opcode_206_run() {
- if (g_opcode206Parameters.enabled) {
- // Used for Card 6044 (Fortress Rotation Simulator)
-
- // g_opcode206Parameters.soundIdStart[2]
- // g_opcode206Parameters.soundIdPosition[4]
-
- // TODO: Fill in function...
- }
-}
-
-void Mechanical::opcode_206_disable() {
- g_opcode206Parameters.enabled = false;
-}
-
-void Mechanical::opcode_206(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
-
+void Mechanical::fortressSimulation_run() {
// Used for Card 6044 (Fortress Rotation Simulator)
- if (argc == 6) {
- g_opcode206Parameters.soundIdStart[0] = argv[0];
- g_opcode206Parameters.soundIdStart[1] = argv[1];
- g_opcode206Parameters.soundIdPosition[0] = argv[2];
- g_opcode206Parameters.soundIdPosition[1] = argv[3];
- g_opcode206Parameters.soundIdPosition[2] = argv[4];
- g_opcode206Parameters.soundIdPosition[3] = argv[5];
-
- g_opcode206Parameters.enabled = true;
- } else
- unknown(op, var, argc, argv);
+ // TODO: Fill in function...
}
+void Mechanical::o_fortressSimulation_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Fortress rotation simulator init", op);
-static struct {
- bool enabled;
-} g_opcode209Parameters;
+ _fortressSimulationHolo = static_cast<MystResourceType6 *>(_invokingResource);
-void Mechanical::opcode_209_run() {
- // Used for Card 6044 (Fortress Rotation Simulator)
+ _fortressSimulationStartSound1 = argv[0];
+ _fortressSimulationStartSound2 = argv[1];
- // TODO: Implement Function For Secret Panel State as
- // per Opcode 200 function (Mechanical)
-}
+ _fortressRotationSounds[0] = argv[2];
+ _fortressRotationSounds[1] = argv[3];
+ _fortressRotationSounds[2] = argv[4];
+ _fortressRotationSounds[3] = argv[5];
+
+ _fortressSimulationBrake = 0;
-void Mechanical::opcode_209_disable() {
- g_opcode209Parameters.enabled = false;
+ _fortressSimulationRunning = true;
}
-void Mechanical::opcode_209(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void Mechanical::o_fortressSimulationStartup_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Fortress rotation simulator startup init", op);
- // Used for Card 6044 (Fortress Rotation Simulator)
- if (argc == 0)
- g_opcode209Parameters.enabled = true;
- else
- unknown(op, var, argc, argv);
+ _fortressSimulationStartup = static_cast<MystResourceType6 *>(_invokingResource);
}
} // End of namespace MystStacks