aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Bouclet2010-12-16 08:03:19 +0000
committerBastien Bouclet2010-12-16 08:03:19 +0000
commit1b267f52819f9e5d173e78dd4a732cdf12e26301 (patch)
tree614a2cb3401e48811c47b7ccb740a0398c46fc13
parent9285986e62c5bf4985dc2680d1393e67d65c6656 (diff)
downloadscummvm-rg350-1b267f52819f9e5d173e78dd4a732cdf12e26301.tar.gz
scummvm-rg350-1b267f52819f9e5d173e78dd4a732cdf12e26301.tar.bz2
scummvm-rg350-1b267f52819f9e5d173e78dd4a732cdf12e26301.zip
MOHAWK: Implement Myst opcodes 147, 169, 182 : Cabin match
svn-id: r54931
-rw-r--r--engines/mohawk/myst.cpp13
-rw-r--r--engines/mohawk/myst_areas.cpp2
-rw-r--r--engines/mohawk/myst_stacks/myst.cpp129
-rw-r--r--engines/mohawk/myst_stacks/myst.h14
4 files changed, 103 insertions, 55 deletions
diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp
index 7cafaf69a3..4f5e666e2c 100644
--- a/engines/mohawk/myst.cpp
+++ b/engines/mohawk/myst.cpp
@@ -592,15 +592,13 @@ void MohawkEngine_Myst::drawResourceRects() {
void MohawkEngine_Myst::checkCurrentResource() {
// See what resource we're over
bool foundResource = false;
+ int16 oldResource = _curResource;
for (uint16 i = 0; i < _resources.size(); i++)
if (_resources[i]->canBecomeActive() &&
_resources[i]->contains(_system->getEventManager()->getMousePos())) {
- if (_curResource != i) {
- if (_curResource != -1 && _resources[_curResource]->isEnabled())
- _resources[_curResource]->handleMouseLeave();
-
- if (_resources[i]->isEnabled())
+ if (oldResource != i) {
+ if (_resources[i]->type == kMystHoverArea)
_resources[i]->handleMouseEnter();
}
@@ -613,6 +611,11 @@ void MohawkEngine_Myst::checkCurrentResource() {
if (!foundResource)
_curResource = -1;
+ // Tell previous resource the mouse is no longer hovering it
+ if (oldResource != -1 && _curResource != oldResource
+ && _resources[oldResource]->type == kMystHoverArea)
+ _resources[oldResource]->handleMouseLeave();
+
checkCursorHints();
}
diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp
index 030b5954bf..a102606936 100644
--- a/engines/mohawk/myst_areas.cpp
+++ b/engines/mohawk/myst_areas.cpp
@@ -76,7 +76,7 @@ void MystResource::handleMouseUp(const Common::Point &mouse) {
}
bool MystResource::canBecomeActive() {
- return !unreachableZipDest() && (isEnabled() || (_flags & kMystUnknownFlag));
+ return !unreachableZipDest() && (isEnabled() || (_flags & kMystUnknownFlag) || type == kMystHoverArea);
}
bool MystResource::unreachableZipDest() {
diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp
index 2fc763ade9..c8f581a491 100644
--- a/engines/mohawk/myst_stacks/myst.cpp
+++ b/engines/mohawk/myst_stacks/myst.cpp
@@ -46,7 +46,8 @@ MystScriptParser_Myst::MystScriptParser_Myst(MohawkEngine_Myst *vm) : MystScript
_savedCardId = 4329;
_libraryBookcaseChanged = false;
_dockVaultState = 0;
- _cabinMatchboxState = 2;
+ _cabinMatchState = 2;
+ _matchBurning = false;
}
MystScriptParser_Myst::~MystScriptParser_Myst() {
@@ -91,7 +92,8 @@ void MystScriptParser_Myst::setupOpcodes() {
OPCODE(142, o_circuitBreakerMove);
OPCODE(143, o_circuitBreakerEndMove);
OPCODE(146, opcode_146);
- OPCODE(147, opcode_147);
+ OPCODE(147, o_boilerLightPilot);
+ OPCODE(148, NOP);
OPCODE(149, opcode_149);
OPCODE(150, opcode_150);
OPCODE(151, opcode_151);
@@ -102,7 +104,7 @@ void MystScriptParser_Myst::setupOpcodes() {
OPCODE(164, o_rocketOpenBook);
OPCODE(165, o_rocketLeverMove);
OPCODE(166, o_rocketLeverEndMove);
- OPCODE(169, opcode_169);
+ OPCODE(169, o_cabinLeave);
OPCODE(170, opcode_170);
OPCODE(171, opcode_171);
OPCODE(172, opcode_172);
@@ -112,11 +114,11 @@ void MystScriptParser_Myst::setupOpcodes() {
OPCODE(176, opcode_176);
OPCODE(177, opcode_177);
OPCODE(180, o_libraryCombinationBookStop);
- OPCODE(181, opcode_181);
- OPCODE(182, opcode_182);
+ OPCODE(181, NOP);
+ OPCODE(182, o_cabinMatchLight);
OPCODE(183, opcode_183);
OPCODE(184, opcode_184);
- OPCODE(185, opcode_185);
+ OPCODE(185, NOP);
OPCODE(186, o_clockMinuteWheelStartTurn);
OPCODE(187, NOP);
OPCODE(188, o_clockWheelEndTurn);
@@ -204,6 +206,9 @@ void MystScriptParser_Myst::runPersistentScripts() {
if (_clockTurningWheel)
clockWheel_run();
+ if (_matchBurning)
+ matchBurn_run();
+
opcode_212_run();
}
@@ -372,7 +377,7 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {
case 69: // Cabin Safe Lock Number #3 - Right
return myst.cabinSafeCombination % 10;
case 70: // Cabin Safe Matchbox State
- return _cabinMatchboxState;
+ return _cabinMatchState;
case 93: // Breaker nearest Generator Room Blown
return myst.generatorBreakers == 1;
case 94: // Breaker nearest Rocket Ship Blown
@@ -384,6 +389,10 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {
return 0;
else
return myst.generatorVoltage / 4;
+ case 98: // Cabin Boiler Pilot Light Lit
+ return myst.cabinPilotLightLit;
+ case 99: // Cabin Boiler Gas Valve Position
+ return myst.cabinValvePosition % 6;
case 102: // Red page
if (globals.ending != 4) {
return !(globals.redPagesInBook & 1) && (globals.heldPage != 7);
@@ -402,6 +411,19 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {
return myst.greenBookOpenedBefore;
case 304: // Tower Rotation Map Initialized
return _towerRotationMapInitialized;
+ case 305: // Cabin Boiler Lit
+ return myst.cabinPilotLightLit == 1 && myst.cabinValvePosition > 0;
+ case 306: // Cabin Boiler Steam Sound Control
+ if (myst.cabinPilotLightLit == 1) {
+ if (myst.cabinValvePosition <= 0)
+ return 26;
+ else
+ return 27;
+ } else {
+ return myst.cabinValvePosition;
+ }
+ case 307: // Cabin Boiler Fully Pressurised
+ return myst.cabinPilotLightLit == 1 && myst.cabinValvePosition > 12;
default:
return MystScriptParser::getVar(var);
}
@@ -508,8 +530,8 @@ bool MystScriptParser_Myst::setVarValue(uint16 var, uint16 value) {
}
break;
case 70: // Cabin Safe Matchbox State
- if (_cabinMatchboxState != value) {
- _cabinMatchboxState = value;
+ if (_cabinMatchState != value) {
+ _cabinMatchState = value;
refresh = true;
}
break;
@@ -1283,14 +1305,20 @@ void MystScriptParser_Myst::opcode_146(uint16 op, uint16 var, uint16 argc, uint1
// TODO: Boiler wheel clockwise mouse down
}
-void MystScriptParser_Myst::opcode_147(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void MystScriptParser_Myst::o_boilerLightPilot(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Boiler light pilot", op);
+ MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
- if (argc == 0) {
- // TODO: Extra Logic to do this in INIT process watching cursor and var 98?
- _vm->_varStore->setVar(98, 0);
- } else
- unknown(op, var, argc, argv);
+ // Match is lit
+ if (_cabinMatchState == 1) {
+ myst.cabinPilotLightLit = 1;
+ _vm->redrawArea(98);
+
+ // Put out match
+ _matchGoOutTime = _vm->_system->getMillis();
+
+ // TODO: Complete. Play fire movie. Handle case where pressure is already right
+ }
}
void MystScriptParser_Myst::opcode_149(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -1489,11 +1517,16 @@ void MystScriptParser_Myst::o_rocketLeverEndMove(uint16 op, uint16 var, uint16 a
lever->drawFrame(0);
}
-void MystScriptParser_Myst::opcode_169(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void MystScriptParser_Myst::o_cabinLeave(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ debugC(kDebugScript, "Opcode %d: Leave cabin", op);
- // Used on Card 4099 (In Cabin, Looking Out Door)
- // TODO: Finish Implementation...
+ // If match is lit, put out
+ if (_cabinMatchState == 1) {
+ _matchGoOutTime = _vm->_system->getMillis();
+ } else if (_cabinMatchState == 0) {
+ _vm->setMainCursor(_savedCursorId);
+ _cabinMatchState = 2;
+ }
}
void MystScriptParser_Myst::opcode_170(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -1541,22 +1574,43 @@ void MystScriptParser_Myst::o_libraryCombinationBookStop(uint16 op, uint16 var,
_libraryCombinationBookPagesTurning = false;
}
-void MystScriptParser_Myst::opcode_181(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void MystScriptParser_Myst::o_cabinMatchLight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+ if (!_cabinMatchState) {
+ _vm->_sound->playSound(4103);
- if (argc == 0) {
- // TODO: Logic for lighting the match
- } else
- unknown(op, var, argc, argv);
+ // Match is lit
+ _cabinMatchState = 1;
+ _matchBurning = true;
+ _matchGoOutCnt = 0;
+ _vm->setMainCursor(kLitMatchCursor);
+
+ // Match will stay lit for one minute
+ _matchGoOutTime = _vm->_system->getMillis() + 60 * 1000;
+ }
}
-void MystScriptParser_Myst::opcode_182(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
+void MystScriptParser_Myst::matchBurn_run() {
+ uint32 time = _vm->_system->getMillis();
- if (argc == 0) {
- // TODO: Logic for lighting the match
- } else
- unknown(op, var, argc, argv);
+ if (time > _matchGoOutTime) {
+ _matchGoOutTime = time + 150;
+
+ // Switch between lit match and dead match every 150 ms when match is dying
+ if (_matchGoOutCnt % 2)
+ _vm->setMainCursor(kLitMatchCursor);
+ else
+ _vm->setMainCursor(kDeadMatchCursor);
+
+ _matchGoOutCnt++;
+
+ // Match is dead
+ if (_matchGoOutCnt >= 5) {
+ _matchBurning = false;
+ _vm->setMainCursor(_savedCursorId);
+
+ _cabinMatchState = 2;
+ }
+ }
}
void MystScriptParser_Myst::opcode_183(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -1579,17 +1633,6 @@ void MystScriptParser_Myst::opcode_184(uint16 op, uint16 var, uint16 argc, uint1
unknown(op, var, argc, argv);
}
-void MystScriptParser_Myst::opcode_185(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
- varUnusedCheck(op, var);
-
- if (argc == 0) {
- // Used for Myst Card 4098 (Cabin Boiler Pilot Light)
- // TODO: Extra Logic to do this in INIT process watching cursor and var 98?
- _vm->_varStore->setVar(98, 1);
- } else
- unknown(op, var, argc, argv);
-}
-
void MystScriptParser_Myst::o_clockMinuteWheelStartTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
// Used on Card 4006
debugC(kDebugScript, "Opcode %d: Minute wheel start turn", op);
diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h
index 1e13f79083..057f8de3c7 100644
--- a/engines/mohawk/myst_stacks/myst.h
+++ b/engines/mohawk/myst_stacks/myst.h
@@ -62,6 +62,7 @@ private:
void opcode_212_disable();
void libraryCombinationBook_run();
void clockWheel_run();
+ void matchBurn_run();
DECLARE_OPCODE(o_libraryBookPageTurnLeft);
@@ -97,7 +98,7 @@ private:
DECLARE_OPCODE(o_circuitBreakerMove);
DECLARE_OPCODE(o_circuitBreakerEndMove);
DECLARE_OPCODE(opcode_146);
- DECLARE_OPCODE(opcode_147);
+ DECLARE_OPCODE(o_boilerLightPilot);
DECLARE_OPCODE(opcode_149);
DECLARE_OPCODE(opcode_150);
DECLARE_OPCODE(opcode_151);
@@ -108,7 +109,7 @@ private:
DECLARE_OPCODE(o_rocketOpenBook);
DECLARE_OPCODE(o_rocketLeverMove);
DECLARE_OPCODE(o_rocketLeverEndMove);
- DECLARE_OPCODE(opcode_169);
+ DECLARE_OPCODE(o_cabinLeave);
DECLARE_OPCODE(opcode_170);
DECLARE_OPCODE(opcode_171);
DECLARE_OPCODE(opcode_172);
@@ -118,11 +119,9 @@ private:
DECLARE_OPCODE(opcode_176);
DECLARE_OPCODE(opcode_177);
DECLARE_OPCODE(o_libraryCombinationBookStop);
- DECLARE_OPCODE(opcode_181);
- DECLARE_OPCODE(opcode_182);
+ DECLARE_OPCODE(o_cabinMatchLight);
DECLARE_OPCODE(opcode_183);
DECLARE_OPCODE(opcode_184);
- DECLARE_OPCODE(opcode_185);
DECLARE_OPCODE(o_clockMinuteWheelStartTurn);
DECLARE_OPCODE(o_clockWheelEndTurn);
DECLARE_OPCODE(o_clockHourWheelStartTurn);
@@ -210,8 +209,11 @@ private:
bool _towerRotationMapClicked; // 132
bool _towerRotationOverSpot; // 136
+ bool _matchBurning;
+ uint16 _matchGoOutCnt;
uint16 _cabinDoorOpened; // 56
- uint16 _cabinMatchboxState; // 60
+ uint16 _cabinMatchState; // 60
+ uint32 _matchGoOutTime; // 144
void generatorRedrawRocket();
void generatorButtonValue(MystResource *button, uint16 &offset, uint16 &value);