[Scummvm-cvs-logs] scummvm master -> 285d33d9c2aca243ede2af3117c7c94e6dd818e2

bgK bastien.bouclet at gmail.com
Tue Feb 22 20:39:23 CET 2011


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bc39d327ac MOHAWK: Implement Mechanical elevator rotation
e507115405 MOHAWK: Implement Mechanical elevator movies
285d33d9c2 MOHAWK: Implement Mechanical elevator top movie


Commit: bc39d327acd6fe5622848f7f98f4159c0e4afb4c
    https://github.com/scummvm/scummvm/commit/bc39d327acd6fe5622848f7f98f4159c0e4afb4c
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2011-02-22T11:38:54-08:00

Commit Message:
MOHAWK: Implement Mechanical elevator rotation

Changed paths:
    engines/mohawk/myst_areas.h
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/mechanical.h



diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h
index 66430f2..aa06d1a 100644
--- a/engines/mohawk/myst_areas.h
+++ b/engines/mohawk/myst_areas.h
@@ -233,6 +233,7 @@ public:
 	void drawFrame(uint16 frame);
 	bool pullLeverV();
 	void releaseLeverV();
+	uint16 getNumFrames() { return _numFrames; }
 
 protected:
 	uint16 _numFrames;
diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 0ae9078..0596d29 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -23,6 +23,7 @@
  *
  */
 
+#include "mohawk/cursors.h"
 #include "mohawk/myst.h"
 #include "mohawk/graphics.h"
 #include "mohawk/myst_areas.h"
@@ -54,6 +55,9 @@ void Mechanical::setupOpcodes() {
 	OPCODE(100, o_throneEnablePassage);
 	OPCODE(104, o_snakeBoxTrigger);
 	OPCODE(105, o_fortressStaircaseMovie);
+	OPCODE(106, o_elevatorRotationStart);
+	OPCODE(107, o_elevatorRotationMove);
+	OPCODE(108, o_elevatorRotationStop);
 	OPCODE(121, opcode_121);
 	OPCODE(122, opcode_122);
 	OPCODE(123, opcode_123);
@@ -72,7 +76,7 @@ void Mechanical::setupOpcodes() {
 	OPCODE(201, o_fortressStaircase_init);
 	OPCODE(202, opcode_202);
 	OPCODE(203, o_snakeBox_init);
-	OPCODE(204, opcode_204);
+	OPCODE(204, o_elevatorRotation_init);
 	OPCODE(205, opcode_205);
 	OPCODE(206, opcode_206);
 	OPCODE(209, opcode_209);
@@ -85,7 +89,6 @@ void Mechanical::setupOpcodes() {
 
 void Mechanical::disablePersistentScripts() {
 	opcode_202_disable();
-	opcode_204_disable();
 	opcode_205_disable();
 	opcode_206_disable();
 	opcode_209_disable();
@@ -93,7 +96,10 @@ void Mechanical::disablePersistentScripts() {
 
 void Mechanical::runPersistentScripts() {
 	opcode_202_run();
-	opcode_204_run();
+
+	if (_elevatorRotationLeverMoving)
+		elevatorRotation_run();
+
 	opcode_205_run();
 	opcode_206_run();
 	opcode_209_run();
@@ -131,13 +137,8 @@ uint16 Mechanical::getVar(uint16 var) {
 		return _state.staircaseState;
 	case 11: // Fortress Elevator Rotation Position
 		return _state.elevatorRotation;
-//	case 12: // Fortress Elevator Rotation Cog Position
-//		return 0;
-//		return 1;
-//		return 2;
-//		return 3;
-//		return 4;
-//		return 5;
+	case 12: // Fortress Elevator Rotation Cog Position
+		return 5 - (uint16)(_elevatorRotationGearPosition + 0.5) % 6;
 	case 15: // Code Lock Execute Button Script
 		if (_mystStaircaseState)
 			return 0;
@@ -245,6 +246,85 @@ void Mechanical::o_fortressStaircaseMovie(uint16 op, uint16 var, uint16 argc, ui
 	_vm->_video->waitUntilMovieEnds(staircase);
 }
 
+void Mechanical::o_elevatorRotationStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Elevator rotation lever start", op);
+
+	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+	lever->drawFrame(0);
+
+	_elevatorRotationLeverMoving = true;
+	_elevatorRotationSpeed = 0;
+
+	_vm->_sound->stopBackgroundMyst();
+
+	_vm->_cursor->setCursor(700);
+}
+
+void Mechanical::o_elevatorRotationMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Elevator rotation lever move", op);
+
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+
+	// Make the handle follow the mouse
+	int16 maxStep = lever->getNumFrames() - 1;
+	Common::Rect rect = lever->getRect();
+	int16 step = ((rect.bottom - mouse.y) * lever->getNumFrames()) / rect.height();
+	step = CLIP<int16>(step, 0, maxStep);
+
+	_elevatorRotationSpeed = step * 0.1;
+
+	// Draw current frame
+	lever->drawFrame(step);
+}
+
+void Mechanical::o_elevatorRotationStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Elevator rotation lever stop", op);
+
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+	MystResourceType12 *lever = static_cast<MystResourceType12 *>(_invokingResource);
+
+	// Get current lever frame
+	int16 maxStep = lever->getNumFrames() - 1;
+	Common::Rect rect = lever->getRect();
+	int16 step = ((rect.bottom - mouse.y) * lever->getNumFrames()) / rect.height();
+	step = CLIP<int16>(step, 0, maxStep);
+
+	// Release lever
+	for (int i = step; i >= 0; i--) {
+		lever->drawFrame(i);
+		_vm->_system->delayMillis(10);
+	}
+
+	// Stop persistent script
+	_elevatorRotationLeverMoving = false;
+
+	float speed = _elevatorRotationSpeed * 10;
+
+	if (speed > 0) {
+
+		// Decrease speed
+		while (speed > 2) {
+			speed -= 0.5;
+
+			_elevatorRotationGearPosition += speed * 0.1;
+
+			if (_elevatorRotationGearPosition > 12)
+				break;
+
+			_vm->redrawArea(12);
+			_vm->_system->delayMillis(100);
+		}
+
+		// Increment position
+		_state.elevatorRotation = (_state.elevatorRotation + 1) % 10;
+
+		_vm->_sound->replaceSoundMyst(_elevatorRotationSoundId);
+		_vm->redrawArea(11);
+	}
+
+	_vm->checkCursorHints();
+}
 
 void Mechanical::opcode_121(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	varUnusedCheck(op, var);
@@ -403,36 +483,29 @@ void Mechanical::o_snakeBox_init(uint16 op, uint16 var, uint16 argc, uint16 *arg
 	_snakeBox = static_cast<MystResourceType6 *>(_invokingResource);
 }
 
-static struct {
-	bool enabled;
-	uint16 soundId;
-} g_opcode204Parameters;
-
-void Mechanical::opcode_204_run() {
-	if (g_opcode204Parameters.enabled) {
-		// TODO: Fill in Logic.
-		// Var 12 holds Large Cog Position in range 0 to 5
-		// - For animation
-		// Var 11 holds C position in range 0 to 9
-		// - 4 for Correct Answer
-		// C Movement Sound
-		//_vm->_sound->playSound(g_opcode204Parameters.soundId);
-	}
-}
+void Mechanical::elevatorRotation_run() {
+	_vm->redrawArea(12);
+
+	_elevatorRotationGearPosition += _elevatorRotationSpeed;
+
+	if (_elevatorRotationGearPosition > 12) {
+		uint16 position = (uint16)_elevatorRotationGearPosition;
+		_elevatorRotationGearPosition = _elevatorRotationGearPosition - position + position % 6;
 
-void Mechanical::opcode_204_disable() {
-	g_opcode204Parameters.enabled = false;
+		_state.elevatorRotation = (_state.elevatorRotation + 1) % 10;
+
+		_vm->_sound->replaceSoundMyst(_elevatorRotationSoundId);
+		_vm->redrawArea(11);
+		_vm->_system->delayMillis(100);
+	}
 }
 
-void Mechanical::opcode_204(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void Mechanical::o_elevatorRotation_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Elevator rotation init", op);
 
-	// Used for Card 6180 (Lower Elevator Puzzle)
-	if (argc == 1) {
-		g_opcode204Parameters.soundId = argv[0];
-		g_opcode204Parameters.enabled = true;
-	} else
-		unknown(op, var, argc, argv);
+	_elevatorRotationSoundId = argv[0];
+	_elevatorRotationGearPosition = 0;
+	_elevatorRotationLeverMoving = false;
 }
 
 static struct {
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index 7142425..0e20b8e 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -54,8 +54,7 @@ private:
 
 	void opcode_202_run();
 	void opcode_202_disable();
-	void opcode_204_run();
-	void opcode_204_disable();
+	void elevatorRotation_run();
 	void opcode_205_run();
 	void opcode_205_disable();
 	void opcode_206_run();
@@ -66,6 +65,9 @@ private:
 	DECLARE_OPCODE(o_throneEnablePassage);
 	DECLARE_OPCODE(o_snakeBoxTrigger);
 	DECLARE_OPCODE(o_fortressStaircaseMovie);
+	DECLARE_OPCODE(o_elevatorRotationStart);
+	DECLARE_OPCODE(o_elevatorRotationMove);
+	DECLARE_OPCODE(o_elevatorRotationStop);
 	DECLARE_OPCODE(opcode_121);
 	DECLARE_OPCODE(opcode_122);
 	DECLARE_OPCODE(opcode_123);
@@ -83,7 +85,7 @@ private:
 	DECLARE_OPCODE(o_fortressStaircase_init);
 	DECLARE_OPCODE(opcode_202);
 	DECLARE_OPCODE(o_snakeBox_init);
-	DECLARE_OPCODE(opcode_204);
+	DECLARE_OPCODE(o_elevatorRotation_init);
 	DECLARE_OPCODE(opcode_205);
 	DECLARE_OPCODE(opcode_206);
 	DECLARE_OPCODE(opcode_209);
@@ -96,6 +98,11 @@ private:
 
 	uint16 _fortressPosition; // 82
 
+	float _elevatorRotationSpeed; // 120
+	float _elevatorRotationGearPosition; // 124
+	uint16 _elevatorRotationSoundId; // 128
+	bool _elevatorRotationLeverMoving; // 184
+
 	uint16 _crystalLit; // 130
 
 	MystResourceType6 *_snakeBox; // 156


Commit: e507115405d50a2e2f8c006238b33f0910db2354
    https://github.com/scummvm/scummvm/commit/e507115405d50a2e2f8c006238b33f0910db2354
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2011-02-22T11:38:54-08:00

Commit Message:
MOHAWK: Implement Mechanical elevator movies

Changed paths:
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/mechanical.h



diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 0596d29..3bf7f21 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -58,7 +58,7 @@ void Mechanical::setupOpcodes() {
 	OPCODE(106, o_elevatorRotationStart);
 	OPCODE(107, o_elevatorRotationMove);
 	OPCODE(108, o_elevatorRotationStop);
-	OPCODE(121, opcode_121);
+	OPCODE(121, o_elevatorWindowMovie);
 	OPCODE(122, opcode_122);
 	OPCODE(123, opcode_123);
 	OPCODE(124, opcode_124);
@@ -326,19 +326,16 @@ void Mechanical::o_elevatorRotationStop(uint16 op, uint16 var, uint16 argc, uint
 	_vm->checkCursorHints();
 }
 
-void Mechanical::opcode_121(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void Mechanical::o_elevatorWindowMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 
-	if (argc == 2) {
-		uint16 startTime = argv[0];
-		uint16 endTime = argv[1];
+	uint16 startTime = argv[0];
+	uint16 endTime = argv[1];
 
-		warning("TODO: Opcode %d Movie Time Index %d to %d\n", op, startTime, endTime);
-		// TODO: Need version of playMovie blocking which allows selection
-		//       of start and finish points.
-		_vm->_video->playMovieBlocking(_vm->wrapMovieFilename("ewindow", kMechanicalStack), 253, 0);
-	} else
-		unknown(op, var, argc, argv);
+	debugC(kDebugScript, "Opcode %d Movie Time Index %d to %d", op, startTime, endTime);
+
+	VideoHandle window = _vm->_video->playMovie(_vm->wrapMovieFilename("ewindow", kMechanicalStack), 253, 0);
+	_vm->_video->setVideoBounds(window, Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, endTime, 600));
+	_vm->_video->waitUntilMovieEnds(window);
 }
 
 void Mechanical::opcode_122(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index 0e20b8e..065f27d 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -68,7 +68,7 @@ private:
 	DECLARE_OPCODE(o_elevatorRotationStart);
 	DECLARE_OPCODE(o_elevatorRotationMove);
 	DECLARE_OPCODE(o_elevatorRotationStop);
-	DECLARE_OPCODE(opcode_121);
+	DECLARE_OPCODE(o_elevatorWindowMovie);
 	DECLARE_OPCODE(opcode_122);
 	DECLARE_OPCODE(opcode_123);
 	DECLARE_OPCODE(opcode_124);


Commit: 285d33d9c2aca243ede2af3117c7c94e6dd818e2
    https://github.com/scummvm/scummvm/commit/285d33d9c2aca243ede2af3117c7c94e6dd818e2
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2011-02-22T11:38:55-08:00

Commit Message:
MOHAWK: Implement Mechanical elevator top movie

Changed paths:
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/mechanical.h



diff --git a/engines/mohawk/myst_stacks/mechanical.cpp b/engines/mohawk/myst_stacks/mechanical.cpp
index 3bf7f21..01390f0 100644
--- a/engines/mohawk/myst_stacks/mechanical.cpp
+++ b/engines/mohawk/myst_stacks/mechanical.cpp
@@ -60,7 +60,7 @@ void Mechanical::setupOpcodes() {
 	OPCODE(108, o_elevatorRotationStop);
 	OPCODE(121, o_elevatorWindowMovie);
 	OPCODE(122, opcode_122);
-	OPCODE(123, opcode_123);
+	OPCODE(123, o_elevatorTopMovie);
 	OPCODE(124, opcode_124);
 	OPCODE(125, o_mystStaircaseMovie);
 	OPCODE(126, opcode_126);
@@ -139,6 +139,8 @@ uint16 Mechanical::getVar(uint16 var) {
 		return _state.elevatorRotation;
 	case 12: // Fortress Elevator Rotation Cog Position
 		return 5 - (uint16)(_elevatorRotationGearPosition + 0.5) % 6;
+	case 14: // Elevator going down when at top
+		return _elevatorGoingDown; // TODO add too late value (2)
 	case 15: // Code Lock Execute Button Script
 		if (_mystStaircaseState)
 			return 0;
@@ -211,6 +213,9 @@ bool Mechanical::setVarValue(uint16 var, uint16 value) {
 	bool refresh = false;
 
 	switch (var) {
+	case 14: // Elevator going down when at top
+		_elevatorGoingDown = value;
+		break;
 	default:
 		refresh = MystScriptParser::setVarValue(var, value);
 		break;
@@ -327,7 +332,6 @@ void Mechanical::o_elevatorRotationStop(uint16 op, uint16 var, uint16 argc, uint
 }
 
 void Mechanical::o_elevatorWindowMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-
 	uint16 startTime = argv[0];
 	uint16 endTime = argv[1];
 
@@ -348,21 +352,15 @@ void Mechanical::opcode_122(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 		unknown(op, var, argc, argv);
 }
 
-void Mechanical::opcode_123(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void Mechanical::o_elevatorTopMovie(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	uint16 startTime = argv[0];
+	uint16 endTime = argv[1];
 
-	if (argc == 2) {
-		// Used on Card 6154
-		uint16 start_time = argv[0];
-		uint16 end_time = argv[1];
+	debugC(kDebugScript, "Opcode %d Movie Time Index %d to %d", op, startTime, endTime);
 
-		warning("TODO: Opcode %d Movie Time Index %d to %d\n", op, start_time, end_time);
-		// TODO: Need version of playMovie blocking which allows selection
-		//       of start and finish points.
-		// TODO: Not 100% sure about movie position
-		_vm->_video->playMovieBlocking(_vm->wrapMovieFilename("hcelev", kMechanicalStack), 205, 40);
-	} else
-		unknown(op, var, argc, argv);
+	VideoHandle window = _vm->_video->playMovie(_vm->wrapMovieFilename("hcelev", kMechanicalStack), 206, 38);
+	_vm->_video->setVideoBounds(window, Audio::Timestamp(0, startTime, 600), Audio::Timestamp(0, endTime, 600));
+	_vm->_video->waitUntilMovieEnds(window);
 }
 
 void Mechanical::opcode_124(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
diff --git a/engines/mohawk/myst_stacks/mechanical.h b/engines/mohawk/myst_stacks/mechanical.h
index 065f27d..24c6c73 100644
--- a/engines/mohawk/myst_stacks/mechanical.h
+++ b/engines/mohawk/myst_stacks/mechanical.h
@@ -70,7 +70,7 @@ private:
 	DECLARE_OPCODE(o_elevatorRotationStop);
 	DECLARE_OPCODE(o_elevatorWindowMovie);
 	DECLARE_OPCODE(opcode_122);
-	DECLARE_OPCODE(opcode_123);
+	DECLARE_OPCODE(o_elevatorTopMovie);
 	DECLARE_OPCODE(opcode_124);
 	DECLARE_OPCODE(o_mystStaircaseMovie);
 	DECLARE_OPCODE(opcode_126);
@@ -98,6 +98,8 @@ private:
 
 	uint16 _fortressPosition; // 82
 
+	uint16 _elevatorGoingDown; // 112
+
 	float _elevatorRotationSpeed; // 120
 	float _elevatorRotationGearPosition; // 124
 	uint16 _elevatorRotationSoundId; // 128






More information about the Scummvm-git-logs mailing list