[Scummvm-cvs-logs] SF.net SVN: scummvm:[54931] scummvm/trunk/engines/mohawk

bgk at users.sourceforge.net bgk at users.sourceforge.net
Thu Dec 16 09:03:19 CET 2010


Revision: 54931
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54931&view=rev
Author:   bgk
Date:     2010-12-16 08:03:19 +0000 (Thu, 16 Dec 2010)

Log Message:
-----------
MOHAWK: Implement Myst opcodes 147, 169, 182 : Cabin match

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/myst.cpp
    scummvm/trunk/engines/mohawk/myst_areas.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
    scummvm/trunk/engines/mohawk/myst_stacks/myst.h

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-12-16 02:02:53 UTC (rev 54930)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-12-16 08:03:19 UTC (rev 54931)
@@ -592,15 +592,13 @@
 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 @@
 	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();
 }
 

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-16 02:02:53 UTC (rev 54930)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-16 08:03:19 UTC (rev 54931)
@@ -76,7 +76,7 @@
 }
 
 bool MystResource::canBecomeActive() {
-	return !unreachableZipDest() && (isEnabled() || (_flags & kMystUnknownFlag));
+	return !unreachableZipDest() && (isEnabled() || (_flags & kMystUnknownFlag) || type == kMystHoverArea);
 }
 
 bool MystResource::unreachableZipDest() {

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-16 02:02:53 UTC (rev 54930)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-16 08:03:19 UTC (rev 54931)
@@ -46,7 +46,8 @@
 	_savedCardId = 4329;
 	_libraryBookcaseChanged = false;
 	_dockVaultState = 0;
-	_cabinMatchboxState = 2;
+	_cabinMatchState = 2;
+	_matchBurning = false;
 }
 
 MystScriptParser_Myst::~MystScriptParser_Myst() {
@@ -91,7 +92,8 @@
 	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 @@
 	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 @@
 	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 @@
 	if (_clockTurningWheel)
 		clockWheel_run();
 
+	if (_matchBurning)
+		matchBurn_run();
+
 	opcode_212_run();
 }
 
@@ -372,7 +377,7 @@
 	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 @@
 			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 @@
 		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 @@
 		}
 		break;
 	case 70: // Cabin Safe Matchbox State
-		if (_cabinMatchboxState != value) {
-			_cabinMatchboxState = value;
+		if (_cabinMatchState != value) {
+			_cabinMatchState = value;
 			refresh = true;
 		}
 		break;
@@ -1283,14 +1305,20 @@
 	// 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 @@
 	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 @@
 	_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 @@
 		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);

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.h	2010-12-16 02:02:53 UTC (rev 54930)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.h	2010-12-16 08:03:19 UTC (rev 54931)
@@ -62,6 +62,7 @@
 	void opcode_212_disable();
 	void libraryCombinationBook_run();
 	void clockWheel_run();
+	void matchBurn_run();
 
 
 	DECLARE_OPCODE(o_libraryBookPageTurnLeft);
@@ -97,7 +98,7 @@
 	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 @@
 	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 @@
 	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 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list