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

bgk at users.sourceforge.net bgk at users.sourceforge.net
Sat Dec 11 12:40:12 CET 2010


Revision: 54863
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54863&view=rev
Author:   bgk
Date:     2010-12-11 11:40:12 +0000 (Sat, 11 Dec 2010)

Log Message:
-----------
MOHAWK: Implement Myst opcodes 116, 186, 188, 189, clock tower time controls

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

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-11 09:40:32 UTC (rev 54862)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-11 11:40:12 UTC (rev 54863)
@@ -721,24 +721,24 @@
 }
 
 uint16 MystResourceType11::getList1(uint16 index) {
-	if (index < _lists[1].listCount) {
-		return _lists[1].list[index];
+	if (index < _lists[0].listCount) {
+		return _lists[0].list[index];
 	}
 
 	return 0;
 }
 
 uint16 MystResourceType11::getList2(uint16 index) {
-	if (index < _lists[2].listCount) {
-		return _lists[2].list[index];
+	if (index < _lists[1].listCount) {
+		return _lists[1].list[index];
 	}
 
 	return 0;
 }
 
 uint16 MystResourceType11::getList3(uint16 index) {
-	if (index < _lists[3].listCount) {
-		return _lists[3].list[index];
+	if (index < _lists[2].listCount) {
+		return _lists[2].list[index];
 	}
 
 	return 0;

Modified: scummvm/trunk/engines/mohawk/myst_scripts.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.h	2010-12-11 09:40:32 UTC (rev 54862)
+++ scummvm/trunk/engines/mohawk/myst_scripts.h	2010-12-11 11:40:12 UTC (rev 54863)
@@ -141,6 +141,7 @@
 	uint16 _savedCardId;
 	uint16 _savedCursorId;
 	int16 _tempVar; // Generic temp var used by the scripts
+	uint32 _startTime; // Generic start time used by the scripts
 
 	static const uint8 _stackMap[];
 	static const uint16 _startCard[];

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-11 09:40:32 UTC (rev 54862)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.cpp	2010-12-11 11:40:12 UTC (rev 54863)
@@ -64,7 +64,7 @@
 	OPCODE(113, opcode_113);
 	OPCODE(114, opcode_114);
 	OPCODE(115, o_bookGivePage);
-	OPCODE(116, opcode_116);
+	OPCODE(116, o_clockWheelsExecute);
 	OPCODE(117, opcode_117);
 	OPCODE(118, opcode_118);
 	OPCODE(119, opcode_119);
@@ -111,9 +111,10 @@
 	OPCODE(183, opcode_183);
 	OPCODE(184, opcode_184);
 	OPCODE(185, opcode_185);
-	OPCODE(186, opcode_186);
-	OPCODE(188, opcode_188);
-	OPCODE(189, opcode_189);
+	OPCODE(186, o_clockMinuteWheelStartTurn);
+	OPCODE(187, NOP);
+	OPCODE(188, o_clockWheelEndTurn);
+	OPCODE(189, o_clockHourWheelStartTurn);
 	OPCODE(190, o_libraryCombinationBookStartRight);
 	OPCODE(191, o_libraryCombinationBookStartLeft);
 	OPCODE(192, opcode_192);
@@ -172,6 +173,7 @@
 	_libraryBookcaseMoving = false;
 	_generatorControlRoomRunning = false;
 	_libraryCombinationBookPagesTurning = false;
+	_clockTurningWheel = 0;
 
 	opcode_212_disable();
 }
@@ -190,6 +192,9 @@
 	if (_libraryBookcaseMoving)
 		libraryBookcaseTransform_run();
 
+	if (_clockTurningWheel)
+		clockWheel_run();
+
 	opcode_212_run();
 }
 
@@ -208,6 +213,8 @@
 		} else {
 			return 3;
 		}
+	case 12: // Clock tower gears bridge
+		return myst.clockTowerBridgeOpen;
 	case 23: // Fireplace Pattern Correct
 		return _fireplaceLines[0] == 195
 				&& _fireplaceLines[1] == 107
@@ -227,6 +234,10 @@
 		} else {
 			return 0;
 		}
+	case 37: // Clock Tower Control Wheels Position
+		return 3 * ((myst.clockTowerMinutePosition / 5) % 3) + myst.clockTowerHourPosition % 3;
+	case 43: // Clock Tower Time
+		return myst.clockTowerHourPosition * 12 + myst.clockTowerMinutePosition / 5;
 	case 44: // Rocket ship power state
 		if (myst.generatorBreakers || myst.generatorVoltage == 0)
 			return 0;
@@ -722,39 +733,36 @@
 	}
 }
 
-void MystScriptParser_Myst::opcode_116(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void MystScriptParser_Myst::o_clockWheelsExecute(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	// Used on Card 4006 (Clock Tower Time Controls)
+	MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+	uint16 soundId = argv[0];
 
-	if (argc == 1) {
-		// Used on Card 4006 (Clock Tower Time Controls)
-		uint16 soundId = argv[0];
+	debugC(kDebugScript, "Opcode %d: Clock Tower Bridge Puzzle Execute Button", op);
 
-		debugC(kDebugScript, "Opcode %d: Clock Tower Bridge Puzzle Execute Button", op);
+	// Correct time is 2:40
+	bool correctTime = myst.clockTowerHourPosition == 2
+						&& myst.clockTowerMinutePosition == 40;
 
-		uint16 bridgeState = _vm->_varStore->getVar(12);
-		uint16 currentTime = _vm->_varStore->getVar(43);
+	if (!myst.clockTowerBridgeOpen && correctTime) {
+		_vm->_sound->playSound(soundId);
+		_vm->_system->delayMillis(500);
 
-		const uint16 correctTime = 32; // 2:40 i.e. From 12 Noon in 5 min increments
+		// 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);
 
-		if (!bridgeState && currentTime == correctTime) {
-			_vm->_sound->playSound(soundId);
+		myst.clockTowerBridgeOpen = 1;
+		_vm->redrawArea(12);
+	} else if (myst.clockTowerBridgeOpen && !correctTime) {
+		_vm->_sound->playSound(soundId);
+		_vm->_system->delayMillis(500);
 
-			// TODO: Play only 1st half of movie i.e. gears rise up
-			_vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 36);
+		// 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);
 
-			bridgeState = 1;
-			_vm->_varStore->setVar(12, bridgeState);
-		} else if (bridgeState && currentTime != correctTime) {
-			_vm->_sound->playSound(soundId);
-
-			// TODO: Play only 2nd half of movie i.e. gears sink down
-			_vm->_video->playMovie(_vm->wrapMovieFilename("gears", kMystStack), 305, 36);
-
-			bridgeState = 0;
-			_vm->_varStore->setVar(12, bridgeState);
-		}
-	} else
-		unknown(op, var, argc, argv);
+		myst.clockTowerBridgeOpen = 0;
+		_vm->redrawArea(12);
+	}
 }
 
 void MystScriptParser_Myst::opcode_117(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -1375,27 +1383,80 @@
 		unknown(op, var, argc, argv);
 }
 
-void MystScriptParser_Myst::opcode_186(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+void MystScriptParser_Myst::o_clockMinuteWheelStartTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	// Used on Card 4006
-	// TODO: Minute wheel turn
+	debugC(kDebugScript, "Opcode %d: Minute wheel start turn", op);
+
+	clockWheelStartTurn(2);
 }
 
-void MystScriptParser_Myst::opcode_188(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+void MystScriptParser_Myst::o_clockWheelEndTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	// Used on Card 4006
-	// TODO: Redraw time wheels?
+	debugC(kDebugScript, "Opcode %d: Wheel end turn", op);
+
+	_clockTurningWheel = 0;
 }
 
-void MystScriptParser_Myst::opcode_189(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+void MystScriptParser_Myst::o_clockHourWheelStartTurn(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	// Used on Card 4006
-	// TODO: Hour wheel turn
+	debugC(kDebugScript, "Opcode %d: Hour wheel start turn", op);
+
+	clockWheelStartTurn(1);
 }
 
+void MystScriptParser_Myst::clockWheel_run() {
+	// Turn wheel one step each second
+	uint32 time = _vm->_system->getMillis();
+	if (time > _startTime + 1000) {
+		_startTime = time;
+
+		if (_clockTurningWheel == 1) {
+			clockWheelTurn(39);
+		} else {
+			clockWheelTurn(38);
+		}
+		_vm->redrawArea(37);
+	}
+
+}
+
+void MystScriptParser_Myst::clockWheelStartTurn(uint16 wheel) {
+	MystResourceType11 *resource = static_cast<MystResourceType11 *>(_invokingResource);
+	uint16 soundId = resource->getList1(0);
+	if (soundId)
+		_vm->_sound->playSound(soundId);
+
+	// Turn wheel one step
+	if (wheel == 1) {
+		clockWheelTurn(39);
+	} else {
+		clockWheelTurn(38);
+	}
+	_vm->redrawArea(37);
+
+	// Continue turning wheel until mouse button is released
+	_clockTurningWheel = wheel;
+	_startTime = _vm->_system->getMillis();
+}
+
+void MystScriptParser_Myst::clockWheelTurn(uint16 var) {
+	MystVariables::Myst &myst = _vm->_saveLoad->_v->myst;
+
+	if (var == 38) {
+		// Hours
+		myst.clockTowerHourPosition = (myst.clockTowerHourPosition + 1) % 12;
+	} else {
+		// Minutes
+		myst.clockTowerMinutePosition = (myst.clockTowerMinutePosition + 5) % 60;
+	}
+}
+
 void MystScriptParser_Myst::o_libraryCombinationBookStartRight(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	debugC(kDebugScript, "Opcode %d: Combination book start turning pages right", op);
 
 	_tempVar = 0;
 	libraryCombinationBookTurnRight();
-	_libraryCombinationBookStart = _vm->_system->getMillis();
+	_startTime = _vm->_system->getMillis();
 	_libraryCombinationBookPagesTurning = true;
 }
 
@@ -1404,7 +1465,7 @@
 
 	_tempVar = 0;
 	libraryCombinationBookTurnLeft();
-	_libraryCombinationBookStart = _vm->_system->getMillis();
+	_startTime = _vm->_system->getMillis();
 	_libraryCombinationBookPagesTurning = true;
 }
 
@@ -1462,13 +1523,13 @@
 
 void MystScriptParser_Myst::libraryCombinationBook_run() {
 	uint32 time = _vm->_system->getMillis();
-	if (time >= _libraryCombinationBookStart + 500) {
+	if (time >= _startTime + 500) {
 		if (_tempVar > 0) {
 			libraryCombinationBookTurnRight();
-			_libraryCombinationBookStart = time;
+			_startTime = time;
 		} else if (_tempVar < 0) {
 			libraryCombinationBookTurnLeft();
-			_libraryCombinationBookStart = time;
+			_startTime = time;
 		}
 	}
 }

Modified: scummvm/trunk/engines/mohawk/myst_stacks/myst.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/myst.h	2010-12-11 09:40:32 UTC (rev 54862)
+++ scummvm/trunk/engines/mohawk/myst_stacks/myst.h	2010-12-11 11:40:12 UTC (rev 54863)
@@ -62,6 +62,7 @@
 	void opcode_212_run();
 	void opcode_212_disable();
 	void libraryCombinationBook_run();
+	void clockWheel_run();
 
 
 	DECLARE_OPCODE(o_libraryBookPageTurnLeft);
@@ -73,7 +74,7 @@
 	DECLARE_OPCODE(opcode_113);
 	DECLARE_OPCODE(opcode_114);
 	DECLARE_OPCODE(o_bookGivePage);
-	DECLARE_OPCODE(opcode_116);
+	DECLARE_OPCODE(o_clockWheelsExecute);
 	DECLARE_OPCODE(opcode_117);
 	DECLARE_OPCODE(opcode_118);
 	DECLARE_OPCODE(opcode_119);
@@ -120,9 +121,9 @@
 	DECLARE_OPCODE(opcode_183);
 	DECLARE_OPCODE(opcode_184);
 	DECLARE_OPCODE(opcode_185);
-	DECLARE_OPCODE(opcode_186);
-	DECLARE_OPCODE(opcode_188);
-	DECLARE_OPCODE(opcode_189);
+	DECLARE_OPCODE(o_clockMinuteWheelStartTurn);
+	DECLARE_OPCODE(o_clockWheelEndTurn);
+	DECLARE_OPCODE(o_clockHourWheelStartTurn);
 	DECLARE_OPCODE(o_libraryCombinationBookStartRight);
 	DECLARE_OPCODE(o_libraryCombinationBookStartLeft);
 	DECLARE_OPCODE(opcode_192);
@@ -180,7 +181,6 @@
 	uint16 _rocketLeverPosition; // 296
 
 	bool _libraryCombinationBookPagesTurning;
-	uint32 _libraryCombinationBookStart; // 8
 	int16 _libraryBookPage; // 86
 	uint16 _libraryBookNumPages; // 88
 	uint16 _libraryBookBaseImage; // 90
@@ -194,6 +194,8 @@
 
 	uint16 _fireplaceLines[6]; // 74 to 84
 
+	uint16 _clockTurningWheel;
+
 	void generatorRedrawRocket();
 	void generatorButtonValue(MystResource *button, uint16 &offset, uint16 &value);
 
@@ -205,6 +207,9 @@
 	void libraryCombinationBookTurnLeft();
 
 	uint16 bookCountPages(uint16 var);
+
+	void clockWheelStartTurn(uint16 wheel);
+	void clockWheelTurn(uint16 var);
 };
 
 } // End of namespace Mohawk


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