aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorBastien Bouclet2010-12-18 08:07:16 +0000
committerBastien Bouclet2010-12-18 08:07:16 +0000
commit03da126ec7c5e2c8d1406a4fdd7b9b0e73616be5 (patch)
tree306deebdbc763e0a6a5865e7fda9b4b379b8e321 /engines/mohawk
parent222d2809e93fd774c44c78c23628a478ec68b7a1 (diff)
downloadscummvm-rg350-03da126ec7c5e2c8d1406a4fdd7b9b0e73616be5.tar.gz
scummvm-rg350-03da126ec7c5e2c8d1406a4fdd7b9b0e73616be5.tar.bz2
scummvm-rg350-03da126ec7c5e2c8d1406a4fdd7b9b0e73616be5.zip
MOHAWK: Implement Myst opcodes 157, 161 and 162: Rocket piano
svn-id: r54949
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/myst.cpp9
-rw-r--r--engines/mohawk/myst.h1
-rw-r--r--engines/mohawk/myst_stacks/myst.cpp100
-rw-r--r--engines/mohawk/myst_stacks/myst.h3
4 files changed, 111 insertions, 2 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 08873ae455..15232966dd 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -612,6 +612,15 @@ void MohawkEngine_Myst::checkCurrentResource() {
checkCursorHints();
}
+MystResource *MohawkEngine_Myst::updateCurrentResource() {
+ checkCurrentResource();
+
+ if (_curResource >= 0)
+ return _resources[_curResource];
+ else
+ return 0;
+}
+
void MohawkEngine_Myst::loadCard() {
debugC(kDebugView, "Loading Card View:");
diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h
index 5d7aa0f038..d3a6a91e53 100644
--- a/engines/mohawk/myst.h
+++ b/engines/mohawk/myst.h
@@ -160,6 +160,7 @@ public:
void setMainCursor(uint16 cursor);
uint16 getMainCursor() { return _mainCursor; }
void checkCursorHints();
+ MystResource *updateCurrentResource();
MystVar *_varStore;
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index 3df9f0a8bd..aa0b08546a 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -32,6 +32,8 @@
#include "mohawk/video.h"
#include "mohawk/myst_stacks/myst.h"
+#include "common/events.h"
+
#include "gui/message.h"
namespace Mohawk {
@@ -109,9 +111,12 @@ void MystScriptParser_Myst::setupOpcodes() {
OPCODE(154, o_basementIncreasePressureStop);
OPCODE(155, o_basementDecreasePressureStart);
OPCODE(156, o_basementDecreasePressureStop);
+ OPCODE(157, o_rocketPianoMove);
OPCODE(158, o_rocketSoundSliderStartMove);
OPCODE(159, o_rocketSoundSliderMove);
OPCODE(160, o_rocketSoundSliderEndMove);
+ OPCODE(161, o_rocketPianoStart);
+ OPCODE(162, o_rocketPianoStop);
OPCODE(163, o_rocketLeverStartMove);
OPCODE(164, o_rocketOpenBook);
OPCODE(165, o_rocketLeverMove);
@@ -979,7 +984,7 @@ void MystScriptParser_Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 a
_vm->_system->delayMillis(500);
// TODO: Play only 1st half of movie i.e. gears rise up, from 0 to 650
- _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 36);
+ _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 33);
myst.clockTowerBridgeOpen = 1;
_vm->redrawArea(12);
@@ -988,7 +993,7 @@ void MystScriptParser_Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 a
_vm->_system->delayMillis(500);
// TODO: Play only 2nd half of movie i.e. gears sink down, from 700 to 1300
- _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 36);
+ _vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 33);
myst.clockTowerBridgeOpen = 0;
_vm->redrawArea(12);
@@ -1576,6 +1581,8 @@ void MystScriptParser_Myst::tree_run() {
// Stop background music if going up from book room
if (_vm->getCurCard() == 4630 && myst.treePosition > 0) {
_vm->_sound->stopBackground();
+ } else {
+ _vm->_sound->replaceBackground(4630, 24576);
}
// Redraw tree
@@ -1729,6 +1736,95 @@ void MystScriptParser_Myst::rocketCheckSolution() {
_vm->_cursor->showCursor();
}
+void MystScriptParser_Myst::o_rocketPianoStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket piano start move", op);
+
+ MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+ MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
+
+ // What the hell ??
+ Common::Rect src = key->_subImages[1].rect;
+ Common::Rect rect = key->_subImages[0].rect;
+ Common::Rect dest = rect;
+ dest.top = 332 - rect.bottom;
+ dest.bottom = 332 - rect.top;
+
+ // Draw pressed piano key
+ _vm->_gfx->copyImageSectionToScreen(key->_subImages[1].wdib, src, dest);
+ _vm->_system->updateScreen();
+
+ // Play note
+ if (myst.generatorVoltage == 59 && !myst.generatorBreakers) {
+ uint16 soundId = key->getList1(0);
+ _vm->_sound->replaceSound(soundId, Audio::Mixer::kMaxChannelVolume, true);
+ }
+}
+
+void MystScriptParser_Myst::o_rocketPianoMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket piano move", op);
+
+ const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+ Common::Rect piano = Common::Rect(85, 123, 460, 270);
+ MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+
+ // Unpress previous key
+ MystResourceType11 *key = static_cast<MystResourceType11 *>(_invokingResource);
+
+ Common::Rect src = key->_subImages[0].rect;
+ Common::Rect dest = src;
+ dest.top = 332 - src.bottom;
+ dest.bottom = 332 - src.top;
+
+ // Draw unpressed piano key
+ _vm->_gfx->copyImageSectionToScreen(key->_subImages[0].wdib, src, dest);
+
+ if (piano.contains(mouse)) {
+ MystResource *resource = _vm->updateCurrentResource();
+ if (resource && resource->type == kMystDragArea) {
+ // Press new key
+ key = static_cast<MystResourceType11 *>(resource);
+ src = key->_subImages[1].rect;
+ Common::Rect rect = key->_subImages[0].rect;
+ dest = rect;
+ dest.top = 332 - rect.bottom;
+ dest.bottom = 332 - rect.top;
+
+ // Draw pressed piano key
+ _vm->_gfx->copyImageSectionToScreen(key->_subImages[1].wdib, src, dest);
+
+ // Play note
+ if (myst.generatorVoltage == 59 && !myst.generatorBreakers) {
+ uint16 soundId = key->getList1(0);
+ _vm->_sound->replaceSound(soundId, Audio::Mixer::kMaxChannelVolume, true);
+ }
+ } else {
+ // Not pressing a key anymore
+ _vm->_sound->stopSound();
+ _vm->_sound->resumeBackground();
+ }
+ }
+
+ _vm->_system->updateScreen();
+}
+
+void MystScriptParser_Myst::o_rocketPianoStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket piano end move", op);
+
+ MystResourceType8 *key = static_cast<MystResourceType8 *>(_invokingResource);
+
+ Common::Rect &src = key->_subImages[0].rect;
+ Common::Rect dest = src;
+ dest.top = 332 - src.bottom;
+ dest.bottom = 332 - src.top;
+
+ // Draw unpressed piano key
+ _vm->_gfx->copyImageSectionToScreen(key->_subImages[0].wdib, src, dest);
+ _vm->_system->updateScreen();
+
+ _vm->_sound->stopSound();
+ _vm->_sound->resumeBackground();
+}
+
void MystScriptParser_Myst::o_rocketLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Rocket lever start move", op);
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index c37fecd29b..19c7200ec7 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -111,6 +111,9 @@ private:
DECLARE_OPCODE(o_basementIncreasePressureStop);
DECLARE_OPCODE(o_basementDecreasePressureStart);
DECLARE_OPCODE(o_basementDecreasePressureStop);
+ DECLARE_OPCODE(o_rocketPianoStart);
+ DECLARE_OPCODE(o_rocketPianoMove);
+ DECLARE_OPCODE(o_rocketPianoStop);
DECLARE_OPCODE(o_rocketSoundSliderStartMove);
DECLARE_OPCODE(o_rocketSoundSliderMove);
DECLARE_OPCODE(o_rocketSoundSliderEndMove);