aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/myst_stacks
diff options
context:
space:
mode:
authorBastien Bouclet2011-05-12 20:53:53 +0200
committerBastien Bouclet2011-05-12 20:53:53 +0200
commit4f5ecc4861f170c4a7881140533846db1095fa5b (patch)
tree12c531a0320f00c27cc552d8af28cc581044dee7 /engines/mohawk/myst_stacks
parent35086fe17cb2fee7fc4b91fa720031840d2f2c28 (diff)
downloadscummvm-rg350-4f5ecc4861f170c4a7881140533846db1095fa5b.tar.gz
scummvm-rg350-4f5ecc4861f170c4a7881140533846db1095fa5b.tar.bz2
scummvm-rg350-4f5ecc4861f170c4a7881140533846db1095fa5b.zip
MOHAWK: Implement Mechanical opcodes 101, 103 and 202. Singing Bird.
Diffstat (limited to 'engines/mohawk/myst_stacks')
-rw-r--r--engines/mohawk/myst_stacks/mechanical.cpp68
-rw-r--r--engines/mohawk/myst_stacks/mechanical.h13
2 files changed, 60 insertions, 21 deletions
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 452c8c8ed1..b8a6b3110e 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -51,6 +51,9 @@ Mechanical::~Mechanical() {
void Mechanical::setupOpcodes() {
// "Stack-Specific" Opcodes
OPCODE(100, o_throneEnablePassage);
+ OPCODE(101, o_birdCrankStart);
+ OPCODE(102, NOP);
+ OPCODE(103, o_birdCrankStop);
OPCODE(104, o_snakeBoxTrigger);
OPCODE(105, o_fortressStaircaseMovie);
OPCODE(106, o_elevatorRotationStart);
@@ -72,7 +75,7 @@ void Mechanical::setupOpcodes() {
// "Init" Opcodes
OPCODE(200, o_throne_init);
OPCODE(201, o_fortressStaircase_init);
- OPCODE(202, opcode_202);
+ OPCODE(202, o_bird_init);
OPCODE(203, o_snakeBox_init);
OPCODE(204, o_elevatorRotation_init);
OPCODE(205, opcode_205);
@@ -86,15 +89,16 @@ void Mechanical::setupOpcodes() {
#undef OPCODE
void Mechanical::disablePersistentScripts() {
- opcode_202_disable();
opcode_205_disable();
opcode_206_disable();
opcode_209_disable();
_elevatorGoingMiddle = false;
+ _birdSinging = false;
}
void Mechanical::runPersistentScripts() {
- opcode_202_run();
+ if (_birdSinging)
+ birdSing_run();
if (_elevatorRotationLeverMoving)
elevatorRotation_run();
@@ -242,6 +246,38 @@ void Mechanical::o_throneEnablePassage(uint16 op, uint16 var, uint16 argc, uint1
_vm->_resources[argv[0]]->setEnabled(getVar(var));
}
+void Mechanical::o_birdCrankStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Mechanical bird crank start", op);
+
+ MystResourceType11 *crank = static_cast<MystResourceType11 *>(_invokingResource);
+
+ uint16 crankSoundId = crank->getList2(0);
+ _vm->_sound->replaceSoundMyst(crankSoundId, Audio::Mixer::kMaxChannelVolume, true);
+
+ _birdSingEndTime = 0;
+ _birdCrankStartTime = _vm->_system->getMillis();
+
+ MystResourceType6 *crankMovie = static_cast<MystResourceType6 *>(crank->getSubResource(0));
+ crankMovie->playMovie();
+}
+
+void Mechanical::o_birdCrankStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Mechanical bird crank stop", op);
+
+ MystResourceType11 *crank = static_cast<MystResourceType11 *>(_invokingResource);
+
+ MystResourceType6 *crankMovie = static_cast<MystResourceType6 *>(crank->getSubResource(0));
+ crankMovie->pauseMovie(true);
+
+ uint16 crankSoundId = crank->getList2(1);
+ _vm->_sound->replaceSoundMyst(crankSoundId);
+
+ _birdSingEndTime = 2 * _vm->_system->getMillis() - _birdCrankStartTime;
+ _birdSinging = true;
+
+ _bird->playMovie();
+}
+
void Mechanical::o_snakeBoxTrigger(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Trigger Playing Of Snake Movie", op);
@@ -512,25 +548,21 @@ void Mechanical::o_fortressStaircase_init(uint16 op, uint16 var, uint16 argc, ui
_vm->_resources[argv[2]]->setEnabled(_state.staircaseState);
}
-static struct {
- bool enabled;
-} g_opcode202Parameters;
-
-void Mechanical::opcode_202_run() {
+void Mechanical::birdSing_run() {
// Used for Card 6220 (Sirrus' Mechanical Bird)
- // TODO: Fill in Function
+ uint32 time = _vm->_system->getMillis();
+ if (_birdSingEndTime < time) {
+ _bird->pauseMovie(true);
+ _birdSinging = false;
+ }
}
-void Mechanical::opcode_202_disable() {
- g_opcode202Parameters.enabled = false;
-}
+void Mechanical::o_bird_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Mechanical bird init", op);
-void Mechanical::opcode_202(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- // Used for Card 6220 (Sirrus' Mechanical Bird)
- if (argc == 0)
- g_opcode202Parameters.enabled = true;
- else
- unknown(op, var, argc, argv);
+ _birdSinging = false;
+ _birdSingEndTime = 0;
+ _bird = static_cast<MystResourceType6 *>(_invokingResource);
}
void Mechanical::o_snakeBox_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index 60b7d129fc..320fbb77cd 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -49,8 +49,7 @@ private:
void toggleVar(uint16 var);
bool setVarValue(uint16 var, uint16 value);
- void opcode_202_run();
- void opcode_202_disable();
+ void birdSing_run();
void elevatorRotation_run();
void elevatorGoMiddle_run();
void opcode_205_run();
@@ -61,6 +60,8 @@ private:
void opcode_209_disable();
DECLARE_OPCODE(o_throneEnablePassage);
+ DECLARE_OPCODE(o_birdCrankStart);
+ DECLARE_OPCODE(o_birdCrankStop);
DECLARE_OPCODE(o_snakeBoxTrigger);
DECLARE_OPCODE(o_fortressStaircaseMovie);
DECLARE_OPCODE(o_elevatorRotationStart);
@@ -81,7 +82,7 @@ private:
DECLARE_OPCODE(o_throne_init);
DECLARE_OPCODE(o_fortressStaircase_init);
- DECLARE_OPCODE(opcode_202);
+ DECLARE_OPCODE(o_bird_init);
DECLARE_OPCODE(o_snakeBox_init);
DECLARE_OPCODE(o_elevatorRotation_init);
DECLARE_OPCODE(opcode_205);
@@ -110,6 +111,12 @@ private:
uint16 _crystalLit; // 130
+ bool _birdSinging; // 144
+ uint32 _birdCrankStartTime; // 136
+ uint32 _birdSingEndTime; // 140
+ MystResourceType6 *_bird; // 152
+
+
MystResourceType6 *_snakeBox; // 156
};