aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mohawk/myst_stacks/mechanical.cpp166
-rw-r--r--engines/mohawk/myst_stacks/mechanical.h23
2 files changed, 123 insertions, 66 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
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index 9b383fe435..112d28eea9 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -53,11 +53,7 @@ private:
void elevatorRotation_run();
void elevatorGoMiddle_run();
void fortressRotation_run();
- void opcode_205_disable();
- void opcode_206_run();
- void opcode_206_disable();
- void opcode_209_run();
- void opcode_209_disable();
+ void fortressSimulation_run();
DECLARE_OPCODE(o_throneEnablePassage);
DECLARE_OPCODE(o_birdCrankStart);
@@ -73,6 +69,12 @@ private:
DECLARE_OPCODE(o_fortressRotationBrakeStart);
DECLARE_OPCODE(o_fortressRotationBrakeMove);
DECLARE_OPCODE(o_fortressRotationBrakeStop);
+ DECLARE_OPCODE(o_fortressSimulationSpeedStart);
+ DECLARE_OPCODE(o_fortressSimulationSpeedMove);
+ DECLARE_OPCODE(o_fortressSimulationSpeedStop);
+ DECLARE_OPCODE(o_fortressSimulationBrakeStart);
+ DECLARE_OPCODE(o_fortressSimulationBrakeMove);
+ DECLARE_OPCODE(o_fortressSimulationBrakeStop);
DECLARE_OPCODE(o_elevatorWindowMovie);
DECLARE_OPCODE(o_elevatorGoMiddle);
DECLARE_OPCODE(o_elevatorTopMovie);
@@ -92,8 +94,8 @@ private:
DECLARE_OPCODE(o_snakeBox_init);
DECLARE_OPCODE(o_elevatorRotation_init);
DECLARE_OPCODE(o_fortressRotation_init);
- DECLARE_OPCODE(opcode_206);
- DECLARE_OPCODE(opcode_209);
+ DECLARE_OPCODE(o_fortressSimulation_init);
+ DECLARE_OPCODE(o_fortressSimulationStartup_init);
MystGameState::Mechanical &_state;
@@ -106,6 +108,13 @@ private:
uint16 _fortressRotationSounds[4]; // 86 to 92
MystResourceType6 *_fortressRotationGears; // 172
+ bool _fortressSimulationRunning;
+ uint16 _fortressSimulationSpeed; // 96
+ uint16 _fortressSimulationBrake; // 98
+ uint16 _fortressSimulationStartSound1; // 102
+ uint16 _fortressSimulationStartSound2; // 100
+ MystResourceType6 *_fortressSimulationHolo; // 160
+ MystResourceType6 *_fortressSimulationStartup; // 164
uint16 _elevatorGoingDown; // 112