aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2010-12-05 08:36:41 +0000
committerBastien Bouclet2010-12-05 08:36:41 +0000
commit24a0b50ac399e71634725ddaaf4ac87288916d3c (patch)
tree5f8d5b624422c043251a6ecc62fe3e7d4299d617 /engines
parent70ab5a21da160ce5a56b2261f0dc4b596a1d623a (diff)
downloadscummvm-rg350-24a0b50ac399e71634725ddaaf4ac87288916d3c.tar.gz
scummvm-rg350-24a0b50ac399e71634725ddaaf4ac87288916d3c.tar.bz2
scummvm-rg350-24a0b50ac399e71634725ddaaf4ac87288916d3c.zip
MOHAWK: Implement Myst opcodes 158 to 166: Rocket sliders + check lever + link book
svn-id: r54776
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/myst.cpp1
-rw-r--r--engines/mohawk/myst_areas.cpp6
-rw-r--r--engines/mohawk/myst_areas.h1
-rw-r--r--engines/mohawk/myst_saveload.h1
-rw-r--r--engines/mohawk/myst_scripts.cpp4
-rw-r--r--engines/mohawk/myst_stacks/myst.cpp263
-rw-r--r--engines/mohawk/myst_stacks/myst.h24
7 files changed, 254 insertions, 46 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index cf28b6d0bf..026cd18fa1 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -329,6 +329,7 @@ Common::Error MohawkEngine_Myst::run() {
debug(2, "Sending mouse up event to resource %d", _curResource);
_resources[_curResource]->handleMouseUp(event.mouse);
}
+ checkCurrentResource();
break;
case Common::EVENT_LBUTTONDOWN:
_mouseClicked = true;
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 217fca8472..d5bda54d52 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -482,6 +482,12 @@ void MystResourceType10::setStep(uint16 step) {
_subImages[0].rect.bottom = 333 - _rect.top - 1;
}
+void MystResourceType10::setPosition(uint16 pos) {
+ Common::Point mouse;
+ mouse.y = pos;
+ updatePosition(mouse);
+}
+
Common::Rect MystResourceType10::boundingBox() {
Common::Rect bb;
diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index f9aeb8d721..c4fbcacc06 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -206,6 +206,7 @@ public:
void handleMouseUp(const Common::Point &mouse);
void handleMouseDrag(const Common::Point &mouse);
void setStep(uint16 step);
+ void setPosition(uint16 pos);
protected:
Common::Rect boundingBox();
diff --git a/engines/mohawk/myst_saveload.h b/engines/mohawk/myst_saveload.h
index bc05fb1b19..a0c9ae2fca 100644
--- a/engines/mohawk/myst_saveload.h
+++ b/engines/mohawk/myst_saveload.h
@@ -119,6 +119,7 @@ struct MystVariables {
uint16 generatorBreakers;
uint16 generatorButtons;
uint16 generatorVoltage;
+ uint16 rocketSliderPosition[5];
} myst;
diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp
index 1af2df013c..9f39658861 100644
--- a/engines/mohawk/myst_scripts.cpp
+++ b/engines/mohawk/myst_scripts.cpp
@@ -302,11 +302,15 @@ void MystScriptParser::NOP(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
}
void MystScriptParser::o_toggleVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Toggle var %d", op, var);
+
toggleVar(var);
_vm->redrawArea(var);
}
void MystScriptParser::o_setVar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Set var %d: %d", op, var, argv[0]);
+
if (setVarValue(var, argv[0])) {
_vm->redrawArea(var);
}
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index d425493834..d14152c710 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -43,8 +43,7 @@ MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : MystScript
// Card ID preinitialized by the engine for use by opcode 18
// when linking back to Myst in the library
- if (_vm->getCurStack() == kMystStack)
- _savedCardId = 4329;
+ _savedCardId = 4329;
}
MystScriptParser_Myst::~MystScriptParser_Myst() {
@@ -88,7 +87,13 @@ void MystScriptParser_Myst::setupOpcodes() {
OPCODE(149, opcode_149);
OPCODE(150, opcode_150);
OPCODE(151, opcode_151);
- OPCODE(164, opcode_164);
+ OPCODE(158, o_rocketSoundSliderStartMove);
+ OPCODE(159, o_rocketSoundSliderMove);
+ OPCODE(160, o_rocketSoundSliderEndMove);
+ OPCODE(163, o_rocketLeverStartMove);
+ OPCODE(164, o_rocketOpenBook);
+ OPCODE(165, o_rocketLeverMove);
+ OPCODE(166, o_rocketLeverEndMove);
OPCODE(169, opcode_169);
OPCODE(170, opcode_170);
OPCODE(171, opcode_171);
@@ -136,8 +141,8 @@ void MystScriptParser_Myst::setupOpcodes() {
OPCODE(216, opcode_216);
OPCODE(217, opcode_217);
OPCODE(218, opcode_218);
- OPCODE(219, opcode_219);
- OPCODE(220, opcode_220);
+ OPCODE(219, o_rocketSliders_init);
+ OPCODE(220, o_rocketLinkVideo_init);
OPCODE(221, opcode_221);
OPCODE(222, opcode_222);
@@ -247,6 +252,8 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {
return 0;
else
return myst.generatorVoltage / 4;
+ case 300: // Rocket Ship Music Puzzle Slider State
+ return 1;
default:
return MystScriptParser::getVar(var);
}
@@ -777,11 +784,7 @@ void MystScriptParser_Myst::o_circuitBreakerMove(uint16 op, uint16 var, uint16 a
int16 maxStep = breaker->getStepsV() - 1;
int16 step = ((_vm->_mouse.y - 80) * breaker->getStepsV()) / 65;
-
- if (step > maxStep)
- step = maxStep;
- else if (step < 0)
- step = 0;
+ step = CLIP<uint16>(step, 0, maxStep);
breaker->drawFrame(step);
@@ -864,13 +867,185 @@ void MystScriptParser_Myst::opcode_151(uint16 op, uint16 var, uint16 argc, uint1
// TODO: Boiler wheel counter-clockwise mouse up
}
-void MystScriptParser_Myst::opcode_164(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void MystScriptParser_Myst::o_rocketSoundSliderStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket slider start move", op);
- // Used on Card 4530 (Rocketship Music Slider Controls)
- // TODO: Finish Implementation...
- // Var 105 is used to set between 0 to 2 = No Function, Movie Playback and Linkable...
- // This is called when Var 105 = 1 i.e. this plays back Movie...
+ _rocketSliderSound = 0;
+ _vm->_cursor->setCursor(700);
+ _vm->_sound->pauseBackground();
+ rocketSliderMove();
+}
+
+void MystScriptParser_Myst::o_rocketSoundSliderMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket slider move", op);
+
+ rocketSliderMove();
+}
+
+void MystScriptParser_Myst::o_rocketSoundSliderEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket slider end move", op);
+
+ MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+
+ _vm->checkCursorHints();
+
+ if (myst.generatorVoltage == 59 && !myst.generatorBreakers) {
+ if (_rocketSliderSound)
+ _vm->_sound->stopSound();
+ }
+
+ if (_invokingResource == _rocketSlider1) {
+ myst.rocketSliderPosition[0] = _rocketSlider1->_pos.y;
+ } else if (_invokingResource == _rocketSlider2) {
+ myst.rocketSliderPosition[1] = _rocketSlider2->_pos.y;
+ } else if (_invokingResource == _rocketSlider3) {
+ myst.rocketSliderPosition[2] = _rocketSlider3->_pos.y;
+ } else if (_invokingResource == _rocketSlider4) {
+ myst.rocketSliderPosition[3] = _rocketSlider4->_pos.y;
+ } else if (_invokingResource == _rocketSlider5) {
+ myst.rocketSliderPosition[4] = _rocketSlider5->_pos.y;
+ }
+
+ _vm->_sound->resumeBackground();
+}
+
+void MystScriptParser_Myst::rocketSliderMove() {
+ MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+
+ MystResourceType10 *slider = static_cast<MystResourceType10 *>(_invokingResource);
+
+ if (myst.generatorVoltage == 59 && !myst.generatorBreakers) {
+ uint16 soundId = rocketSliderGetSound(slider->_pos.y);
+ if (soundId != _rocketSliderSound) {
+ _rocketSliderSound = soundId;
+ _vm->_sound->replaceSound(soundId, Audio::Mixer::kMaxChannelVolume, true);
+ }
+ }
+}
+
+uint16 MystScriptParser_Myst::rocketSliderGetSound(uint16 pos) {
+ return 9530 + (pos - 216) * 35.0 * 0.01639344262295082;
+}
+
+void MystScriptParser_Myst::rocketCheckSolution() {
+ _vm->_cursor->hideCursor();
+
+ uint16 soundId;
+ bool solved = true;
+
+ soundId = rocketSliderGetSound(_rocketSlider1->_pos.y);
+ _vm->_sound->replaceSound(soundId);
+ _rocketSlider1->drawConditionalDataToScreen(2);
+ _vm->_system->delayMillis(250);
+ if (soundId != 9558)
+ solved = false;
+
+ soundId = rocketSliderGetSound(_rocketSlider2->_pos.y);
+ _vm->_sound->replaceSound(soundId);
+ _rocketSlider2->drawConditionalDataToScreen(2);
+ _vm->_system->delayMillis(250);
+ if (soundId != 9546)
+ solved = false;
+
+ soundId = rocketSliderGetSound(_rocketSlider3->_pos.y);
+ _vm->_sound->replaceSound(soundId);
+ _rocketSlider3->drawConditionalDataToScreen(2);
+ _vm->_system->delayMillis(250);
+ if (soundId != 9543)
+ solved = false;
+
+ soundId = rocketSliderGetSound(_rocketSlider4->_pos.y);
+ _vm->_sound->replaceSound(soundId);
+ _rocketSlider4->drawConditionalDataToScreen(2);
+ _vm->_system->delayMillis(250);
+ if (soundId != 9553)
+ solved = false;
+
+ soundId = rocketSliderGetSound(_rocketSlider5->_pos.y);
+ _vm->_sound->replaceSound(soundId);
+ _rocketSlider5->drawConditionalDataToScreen(2);
+ _vm->_system->delayMillis(250);
+ if (soundId != 9560)
+ solved = false;
+
+ _vm->_sound->stopSound();
+
+ if (solved) {
+ _vm->_video->playBackgroundMovie(_vm->wrapMovieFilename("selenbok", kMystStack), 224, 41, true);
+
+ // TODO: Movie control
+ // Play from 0 to 660
+ // Then from 660 to 3500, looping
+
+ _tempVar = 1;
+ }
+
+ _rocketSlider1->drawConditionalDataToScreen(1);
+ _rocketSlider2->drawConditionalDataToScreen(1);
+ _rocketSlider3->drawConditionalDataToScreen(1);
+ _rocketSlider4->drawConditionalDataToScreen(1);
+ _rocketSlider5->drawConditionalDataToScreen(1);
+
+ _vm->_cursor->showCursor();
+}
+
+void MystScriptParser_Myst::o_rocketLeverStartMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket lever start move", op);
+
+ MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+
+ _vm->_cursor->setCursor(700);
+ _rocketLeverPosition = 0;
+ lever->drawFrame(0);
+}
+
+void MystScriptParser_Myst::o_rocketOpenBook(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket open link book", op);
+
+ // TODO: Update video playing
+ // Play from 3500 to 13100, looping
+
+ // Set linkable
+ _tempVar = 2;
+}
+
+void MystScriptParser_Myst::o_rocketLeverMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket lever move", op);
+
+ MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+ MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+
+ // Make the lever follow the mouse
+ int16 maxStep = lever->getStepsV() - 1;
+ Common::Rect rect = lever->getRect();
+ int16 step = ((_vm->_mouse.y - rect.top) * lever->getStepsV()) / rect.height();
+ step = CLIP<uint16>(step, 0, maxStep);
+
+ lever->drawFrame(step);
+
+ // If lever pulled
+ if (step == maxStep && step != _rocketLeverPosition) {
+ uint16 soundId = lever->getList2(0);
+ if (soundId)
+ _vm->_sound->playSound(soundId);
+
+ // If rocket correctly powered
+ if (myst.generatorVoltage == 59 && !myst.generatorBreakers) {
+ rocketCheckSolution();
+ }
+ }
+
+ _rocketLeverPosition = step;
+}
+
+void MystScriptParser_Myst::o_rocketLeverEndMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket lever end move", op);
+
+ MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+
+ _vm->checkCursorHints();
+ _rocketLeverPosition = 0;
+ lever->drawFrame(0);
}
void MystScriptParser_Myst::opcode_169(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -1346,14 +1521,17 @@ void MystScriptParser_Myst::opcode_209(uint16 op, uint16 var, uint16 argc, uint1
void MystScriptParser_Myst::o_generatorControlRoom_run(void) {
MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+
if (_generatorVoltage == myst.generatorVoltage) {
generatorRedrawRocket();
} else {
+ // Animate generator gauge
if (_generatorVoltage > myst.generatorVoltage)
_generatorVoltage--;
else
_generatorVoltage++;
+ // Redraw generator gauge
_vm->redrawArea(62);
_vm->redrawArea(63);
_vm->redrawArea(96);
@@ -1568,38 +1746,37 @@ void MystScriptParser_Myst::opcode_218(uint16 op, uint16 var, uint16 argc, uint1
}
}
-void MystScriptParser_Myst::opcode_219(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void MystScriptParser_Myst::o_rocketSliders_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket sliders init", op);
- // Used for Card 4530 (Rocketship Music Puzzle)
- if (argc == 5) {
- debugC(kDebugScript, "Opcode %d: Unknown...", op);
+ MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
- uint16 u0 = argv[0];
- uint16 u1 = argv[1];
- uint16 u2 = argv[2];
- uint16 u3 = argv[3];
- uint16 u4 = argv[4];
+ _rocketSlider1 = static_cast<MystResourceType10 *>(_vm->_resources[argv[0]]);
+ _rocketSlider2 = static_cast<MystResourceType10 *>(_vm->_resources[argv[1]]);
+ _rocketSlider3 = static_cast<MystResourceType10 *>(_vm->_resources[argv[2]]);
+ _rocketSlider4 = static_cast<MystResourceType10 *>(_vm->_resources[argv[3]]);
+ _rocketSlider5 = static_cast<MystResourceType10 *>(_vm->_resources[argv[4]]);
- debugC(kDebugScript, "\tu0: %d", u0);
- debugC(kDebugScript, "\tu1: %d", u1);
- debugC(kDebugScript, "\tu2: %d", u2);
- debugC(kDebugScript, "\tu3: %d", u3);
- debugC(kDebugScript, "\tu4: %d", u4);
- // TODO: Fill in logic...
- } else
- unknown(op, var, argc, argv);
+ if (myst.rocketSliderPosition[0]) {
+ _rocketSlider1->setPosition(myst.rocketSliderPosition[0]);
+ }
+ if (myst.rocketSliderPosition[1]) {
+ _rocketSlider2->setPosition(myst.rocketSliderPosition[1]);
+ }
+ if (myst.rocketSliderPosition[2]) {
+ _rocketSlider3->setPosition(myst.rocketSliderPosition[2]);
+ }
+ if (myst.rocketSliderPosition[3]) {
+ _rocketSlider4->setPosition(myst.rocketSliderPosition[3]);
+ }
+ if (myst.rocketSliderPosition[4]) {
+ _rocketSlider5->setPosition(myst.rocketSliderPosition[4]);
+ }
}
-void MystScriptParser_Myst::opcode_220(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
-
- // Used for Card 4530 (Rocketship Music Puzzle Video)
- // TODO: Fill in logic.
- if (false) {
- // loop?
- _vm->_video->playMovie(_vm->wrapMovieFilename("selenbok", kMystStack), 224, 41);
- }
+void MystScriptParser_Myst::o_rocketLinkVideo_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Rocket link video init", op);
+ _tempVar = 0;
}
void MystScriptParser_Myst::opcode_221(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index 8f0827277a..d6cc2f6b49 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -101,7 +101,13 @@ private:
DECLARE_OPCODE(opcode_149);
DECLARE_OPCODE(opcode_150);
DECLARE_OPCODE(opcode_151);
- DECLARE_OPCODE(opcode_164);
+ DECLARE_OPCODE(o_rocketSoundSliderStartMove);
+ DECLARE_OPCODE(o_rocketSoundSliderMove);
+ DECLARE_OPCODE(o_rocketSoundSliderEndMove);
+ DECLARE_OPCODE(o_rocketLeverStartMove);
+ DECLARE_OPCODE(o_rocketOpenBook);
+ DECLARE_OPCODE(o_rocketLeverMove);
+ DECLARE_OPCODE(o_rocketLeverEndMove);
DECLARE_OPCODE(opcode_169);
DECLARE_OPCODE(opcode_170);
DECLARE_OPCODE(opcode_171);
@@ -148,8 +154,8 @@ private:
DECLARE_OPCODE(opcode_216);
DECLARE_OPCODE(opcode_217);
DECLARE_OPCODE(opcode_218);
- DECLARE_OPCODE(opcode_219);
- DECLARE_OPCODE(opcode_220);
+ DECLARE_OPCODE(o_rocketSliders_init);
+ DECLARE_OPCODE(o_rocketLinkVideo_init);
DECLARE_OPCODE(opcode_221);
DECLARE_OPCODE(opcode_222);
@@ -168,8 +174,20 @@ private:
bool _generatorControlRoomRunning;
uint16 _generatorVoltage; // 58
+ MystResourceType10 *_rocketSlider1; // 248
+ MystResourceType10 *_rocketSlider2; // 252
+ MystResourceType10 *_rocketSlider3; // 256
+ MystResourceType10 *_rocketSlider4; // 260
+ MystResourceType10 *_rocketSlider5; // 264
+ uint16 _rocketSliderSound; // 294
+ uint16 _rocketLeverPosition; // 296
+
void generatorRedrawRocket();
void generatorButtonValue(MystResource *button, uint16 &offset, uint16 &value);
+
+ void rocketSliderMove();
+ uint16 rocketSliderGetSound(uint16 pos);
+ void rocketCheckSolution();
};
} // End of namespace Mohawk