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

bgk at users.sourceforge.net bgk at users.sourceforge.net
Sun Jan 30 21:38:00 CET 2011


Revision: 55665
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55665&view=rev
Author:   bgk
Date:     2011-01-30 20:37:59 +0000 (Sun, 30 Jan 2011)

Log Message:
-----------
MOHAWK: Implement Stoneship telescope

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

Modified: scummvm/trunk/engines/mohawk/myst_stacks/stoneship.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/stoneship.cpp	2011-01-30 20:36:17 UTC (rev 55664)
+++ scummvm/trunk/engines/mohawk/myst_stacks/stoneship.cpp	2011-01-30 20:37:59 UTC (rev 55665)
@@ -70,6 +70,9 @@
 	OPCODE(102, o_cabinBookMovie);
 	OPCODE(103, o_drawerOpenSirius);
 	OPCODE(104, o_drawerClose);
+	OPCODE(105, o_telescopeStart);
+	OPCODE(106, o_telescopeMove);
+	OPCODE(107, o_telescopeStop);
 	OPCODE(108, o_generatorStart);
 	OPCODE(109, NOP);
 	OPCODE(110, o_generatorStop);
@@ -96,23 +99,27 @@
 	OPCODE(205, opcode_205);
 	OPCODE(206, opcode_206);
 	OPCODE(207, o_chest_init);
-	OPCODE(208, opcode_208);
+	OPCODE(208, o_telescope_init);
 	OPCODE(209, o_achenarDrawers_init);
 	OPCODE(210, o_cloudOrb_init);
 
 	// "Exit" Opcodes
-	OPCODE(300, opcode_300);
+	OPCODE(300, NOP);
 }
 
 #undef OPCODE
 
 void MystScriptParser_Stoneship::disablePersistentScripts() {
 	_batteryCharging = false;
+	_telescopeRunning = false;
 }
 
 void MystScriptParser_Stoneship::runPersistentScripts() {
 	if (_batteryCharging)
 		chargeBattery_run();
+
+	if (_telescopeRunning)
+		telescope_run();
 }
 
 uint16 MystScriptParser_Stoneship::getVar(uint16 var) {
@@ -432,6 +439,35 @@
 	drawerClose(argv[0]);
 }
 
+void MystScriptParser_Stoneship::o_telescopeStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+	_telescopeOldMouse = mouse.x;
+	_vm->_cursor->setCursor(700);
+}
+
+void MystScriptParser_Stoneship::o_telescopeMove(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Telescope move", op);
+
+	MystResourceType11 *display = static_cast<MystResourceType11 *>(_invokingResource);
+	const Common::Point &mouse = _vm->_system->getEventManager()->getMousePos();
+
+	// Compute telescope position
+	_telescopePosition = (_telescopePosition - (mouse.x - _telescopeOldMouse) / 2 + 3240) % 3240;
+	_telescopeOldMouse = mouse.x;
+
+	// Copy image to screen
+    Common::Rect src = Common::Rect(_telescopePosition, 0, _telescopePosition + 112, 112);
+    _vm->_gfx->copyImageSectionToScreen(_telescopePanorama, src, display->getRect());
+
+    // Draw lighthouse
+    telescopeLighthouseDraw();
+    _vm->_system->updateScreen();
+}
+
+void MystScriptParser_Stoneship::o_telescopeStop(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	_vm->checkCursorHints();
+}
+
 void MystScriptParser_Stoneship::o_generatorStart(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	debugC(kDebugScript, "Opcode %d: Generator start", op);
 
@@ -840,25 +876,55 @@
 	_state.chestOpenState = 0;
 }
 
-void MystScriptParser_Stoneship::opcode_208(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void MystScriptParser_Stoneship::o_telescope_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Telescope init", op);
 
 	// Used in Card 2218 (Telescope view)
-	if (argc == 3) {
-		debugC(kDebugScript, "Opcode %d: Telescope View", op);
-		uint16 imagePanorama = argv[0];
-		uint16 imageLighthouseOff = argv[1];
-		uint16 imageLighthouseOn = argv[2];
+	_telescopePanorama = argv[0];
+	_telescopeLighthouseOff = argv[1];
+	_telescopeLighthouseOn = argv[2];
+	_telescopePosition = 0;
 
-		debugC(kDebugScript, "Image (Panorama): %d", imagePanorama);
-		debugC(kDebugScript, "Image (Lighthouse Off): %d", imageLighthouseOff);
-		debugC(kDebugScript, "Image (Lighthouse On): %d", imageLighthouseOn);
+	_telescopeRunning = true;
+	_telescopeLighthouseState = false;
+	_telescopeNexTime = _vm->_system->getMillis() + 1000;
+}
 
-		// TODO: Fill in Logic.
-	} else
-		unknown(op, var, argc, argv);
+void MystScriptParser_Stoneship::telescope_run() {
+	uint32 time = _vm->_system->getMillis();
+
+	if (time > _telescopeNexTime) {
+
+		_telescopeNexTime = time + 1000;
+		_telescopeLighthouseState = !_telescopeLighthouseState;
+
+		telescopeLighthouseDraw();
+		_vm->_system->updateScreen();
+	}
 }
 
+void MystScriptParser_Stoneship::telescopeLighthouseDraw() {
+	if (_telescopePosition > 1137 && _telescopePosition < 1294) {
+		uint16 imageId = _telescopeLighthouseOff;
+
+		if (_state.generatorPowerAvailable == 1 && _telescopeLighthouseState)
+			imageId = _telescopeLighthouseOn;
+
+		Common::Rect src(1205, 0, 1205 + 131, 112);
+		src.clip(Common::Rect(_telescopePosition, 0, _telescopePosition + 112, 112));
+		src.translate(-1205, 0);
+		src.clip(131, 112);
+
+		Common::Rect dest(_telescopePosition, 0, _telescopePosition + 112, 112);
+		dest.clip(Common::Rect(1205, 0, 1205 + 131, 112));
+		dest.translate(-_telescopePosition, 0);
+		dest.clip(112, 112);
+		dest.translate(222, 112);
+
+		_vm->_gfx->copyImageSectionToScreen(imageId, src, dest);
+	}
+}
+
 void MystScriptParser_Stoneship::o_achenarDrawers_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	debugC(kDebugScript, "Opcode %d: Achenar's Room Drawers Init", op);
 
@@ -885,10 +951,4 @@
 	_cloudOrbStopSound = argv[1];
 }
 
-void MystScriptParser_Stoneship::opcode_300(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	// Used in Card 2218 (Telescope view)
-	varUnusedCheck(op, var);
-	// TODO: Fill in Logic. Clearing Variable for View?
-}
-
 } // End of namespace Mohawk

Modified: scummvm/trunk/engines/mohawk/myst_stacks/stoneship.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/stoneship.h	2011-01-30 20:36:17 UTC (rev 55664)
+++ scummvm/trunk/engines/mohawk/myst_stacks/stoneship.h	2011-01-30 20:37:59 UTC (rev 55665)
@@ -56,6 +56,9 @@
 	DECLARE_OPCODE(o_cabinBookMovie);
 	DECLARE_OPCODE(o_drawerOpenSirius);
 	DECLARE_OPCODE(o_drawerClose);
+	DECLARE_OPCODE(o_telescopeStart);
+	DECLARE_OPCODE(o_telescopeMove);
+	DECLARE_OPCODE(o_telescopeStop);
 	DECLARE_OPCODE(o_generatorStart);
 	DECLARE_OPCODE(o_generatorStop);
 	DECLARE_OPCODE(o_drawerOpenAchenar);
@@ -80,12 +83,10 @@
 	DECLARE_OPCODE(opcode_205);
 	DECLARE_OPCODE(opcode_206);
 	DECLARE_OPCODE(o_chest_init);
-	DECLARE_OPCODE(opcode_208);
+	DECLARE_OPCODE(o_telescope_init);
 	DECLARE_OPCODE(o_achenarDrawers_init);
 	DECLARE_OPCODE(o_cloudOrb_init);
 
-	DECLARE_OPCODE(opcode_300);
-
 	void chargeBattery_run();
 
 	MystGameState::Stoneship &_state;
@@ -109,6 +110,17 @@
 	MystResourceType6 *_hologramSelection; // 88
 	uint16 _hologramDisplayPos;
 
+	uint16 _telescopePosition; // 112
+	uint16 _telescopePanorama;
+	uint16 _telescopeOldMouse;
+	uint16 _telescopeLighthouseOff; // 130
+	uint16 _telescopeLighthouseOn; // 128
+	bool _telescopeLighthouseState; // 124
+	bool _telescopeRunning;
+	uint32 _telescopeNexTime;
+	void telescope_run();
+	void telescopeLighthouseDraw();
+
 	MystResourceType6 *_cloudOrbMovie; // 136
 	uint16 _cloudOrbSound; // 140
 	uint16 _cloudOrbStopSound; // 142


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