diff options
| -rw-r--r-- | engines/mohawk/myst_areas.cpp | 12 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts.h | 1 | ||||
| -rw-r--r-- | engines/mohawk/myst_stacks/myst.cpp | 143 | ||||
| -rw-r--r-- | engines/mohawk/myst_stacks/myst.h | 15 | 
4 files changed, 119 insertions, 52 deletions
| diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index f213981c69..d38cccf874 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -721,24 +721,24 @@ void MystResourceType11::setPositionClipping(const Common::Point &mouse, Common:  }  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; diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h index 654d8d68ea..92f4a765f0 100644 --- a/engines/mohawk/myst_scripts.h +++ b/engines/mohawk/myst_scripts.h @@ -141,6 +141,7 @@ protected:  	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[]; diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index ac3dc54c6b..da85df44e2 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -64,7 +64,7 @@ void MystScriptParser_Myst::setupOpcodes() {  	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 @@ void MystScriptParser_Myst::setupOpcodes() {  	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 @@ void MystScriptParser_Myst::disablePersistentScripts() {  	_libraryBookcaseMoving = false;  	_generatorControlRoomRunning = false;  	_libraryCombinationBookPagesTurning = false; +	_clockTurningWheel = 0;  	opcode_212_disable();  } @@ -190,6 +192,9 @@ void MystScriptParser_Myst::runPersistentScripts() {  	if (_libraryBookcaseMoving)  		libraryBookcaseTransform_run(); +	if (_clockTurningWheel) +		clockWheel_run(); +  	opcode_212_run();  } @@ -208,6 +213,8 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {  		} 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 @@ uint16 MystScriptParser_Myst::getVar(uint16 var) {  		} 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::o_bookGivePage(uint16 op, uint16 var, uint16 argc, u  	}  } -void MystScriptParser_Myst::opcode_116(uint16 op, uint16 var, uint16 argc, uint16 *argv) { -	varUnusedCheck(op, var); - -	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); +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]; -		uint16 bridgeState = _vm->_varStore->getVar(12); -		uint16 currentTime = _vm->_varStore->getVar(43); +	debugC(kDebugScript, "Opcode %d: Clock Tower Bridge Puzzle Execute Button", op); -		const uint16 correctTime = 32; // 2:40 i.e. From 12 Noon in 5 min increments +	// Correct time is 2:40 +	bool correctTime = myst.clockTowerHourPosition == 2 +						&& myst.clockTowerMinutePosition == 40; -		if (!bridgeState && currentTime == correctTime) { -			_vm->_sound->playSound(soundId); +	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 1st half of movie i.e. gears rise up, from 0 to 650 +		_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); +		myst.clockTowerBridgeOpen = 1; +		_vm->redrawArea(12); +	} else if (myst.clockTowerBridgeOpen && !correctTime) { +		_vm->_sound->playSound(soundId); +		_vm->_system->delayMillis(500); -			// TODO: Play only 2nd half of movie i.e. gears sink down -			_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 = 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,19 +1383,72 @@ void MystScriptParser_Myst::opcode_185(uint16 op, uint16 var, uint16 argc, uint1  		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) { @@ -1395,7 +1456,7 @@ void MystScriptParser_Myst::o_libraryCombinationBookStartRight(uint16 op, uint16  	_tempVar = 0;  	libraryCombinationBookTurnRight(); -	_libraryCombinationBookStart = _vm->_system->getMillis(); +	_startTime = _vm->_system->getMillis();  	_libraryCombinationBookPagesTurning = true;  } @@ -1404,7 +1465,7 @@ void MystScriptParser_Myst::o_libraryCombinationBookStartLeft(uint16 op, uint16  	_tempVar = 0;  	libraryCombinationBookTurnLeft(); -	_libraryCombinationBookStart = _vm->_system->getMillis(); +	_startTime = _vm->_system->getMillis();  	_libraryCombinationBookPagesTurning = true;  } @@ -1462,13 +1523,13 @@ void MystScriptParser_Myst::libraryCombinationBookTurnRight() {  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;  		}  	}  } diff --git a/engines/mohawk/myst_stacks/myst.h b/engines/mohawk/myst_stacks/myst.h index 371bf0c34d..0fdadc387b 100644 --- a/engines/mohawk/myst_stacks/myst.h +++ b/engines/mohawk/myst_stacks/myst.h @@ -62,6 +62,7 @@ private:  	void opcode_212_run();  	void opcode_212_disable();  	void libraryCombinationBook_run(); +	void clockWheel_run();  	DECLARE_OPCODE(o_libraryBookPageTurnLeft); @@ -73,7 +74,7 @@ private:  	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 @@ private:  	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 @@ private:  	uint16 _rocketLeverPosition; // 296  	bool _libraryCombinationBookPagesTurning; -	uint32 _libraryCombinationBookStart; // 8  	int16 _libraryBookPage; // 86  	uint16 _libraryBookNumPages; // 88  	uint16 _libraryBookBaseImage; // 90 @@ -194,6 +194,8 @@ private:  	uint16 _fireplaceLines[6]; // 74 to 84 +	uint16 _clockTurningWheel; +  	void generatorRedrawRocket();  	void generatorButtonValue(MystResource *button, uint16 &offset, uint16 &value); @@ -205,6 +207,9 @@ private:  	void libraryCombinationBookTurnLeft();  	uint16 bookCountPages(uint16 var); + +	void clockWheelStartTurn(uint16 wheel); +	void clockWheelTurn(uint16 var);  };  } // End of namespace Mohawk | 
