aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/myst_stacks/mechanical.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2011-05-14 10:47:42 +0200
committerBastien Bouclet2011-05-14 10:51:55 +0200
commit3537456eb51ed65b67c888ef01a0638719410fdb (patch)
treeb87fe5b487a0cbab3ec5a50f7a5383a7552c17f9 /engines/mohawk/myst_stacks/mechanical.cpp
parent0bbb41224939568e4ee0ac5db2837ff4297b2ae8 (diff)
downloadscummvm-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/mohawk/myst_stacks/mechanical.cpp')
-rw-r--r--engines/mohawk/myst_stacks/mechanical.cpp125
1 files changed, 100 insertions, 25 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 {