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

bgk at users.sourceforge.net bgk at users.sourceforge.net
Wed Feb 9 21:07:55 CET 2011


Revision: 55860
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55860&view=rev
Author:   bgk
Date:     2011-02-09 20:07:55 +0000 (Wed, 09 Feb 2011)

Log Message:
-----------
MOHAWK: Implement Stoneship battery depletion

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

Modified: scummvm/trunk/engines/mohawk/myst_areas.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.h	2011-02-09 17:54:34 UTC (rev 55859)
+++ scummvm/trunk/engines/mohawk/myst_areas.h	2011-02-09 20:07:55 UTC (rev 55860)
@@ -70,7 +70,8 @@
 	bool contains(Common::Point point) { return _rect.contains(point); }
 	virtual void drawDataToScreen() {}
 	virtual void handleCardChange() {}
-	virtual Common::Rect getRect() { return _rect; }
+	Common::Rect getRect() { return _rect; }
+	void setRect(const Common::Rect &rect) { _rect = rect; }
 	bool isEnabled();
 	void setEnabled(bool enabled);
 	bool isDrawSubimages() { return _flags & kMystSubimageEnableFlag; }

Modified: scummvm/trunk/engines/mohawk/myst_stacks/stoneship.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/stoneship.cpp	2011-02-09 17:54:34 UTC (rev 55859)
+++ scummvm/trunk/engines/mohawk/myst_stacks/stoneship.cpp	2011-02-09 20:07:55 UTC (rev 55860)
@@ -93,9 +93,9 @@
 	// "Init" Opcodes
 	OPCODE(200, o_hologramDisplay_init);
 	OPCODE(201, o_hologramSelection_init);
-	OPCODE(202, opcode_202);
+	OPCODE(202, o_battery_init);
 	OPCODE(203, opcode_203);
-	OPCODE(204, opcode_204);
+	OPCODE(204, o_batteryGauge_init);
 	OPCODE(205, opcode_205);
 	OPCODE(206, opcode_206);
 	OPCODE(207, o_chest_init);
@@ -111,6 +111,8 @@
 
 void MystScriptParser_Stoneship::disablePersistentScripts() {
 	_batteryCharging = false;
+	_batteryDepleting = false;
+	_batteryGaugeRunning = false;
 	_telescopeRunning = false;
 }
 
@@ -120,6 +122,12 @@
 
 	if (_telescopeRunning)
 		telescope_run();
+
+	if (_batteryGaugeRunning)
+		batteryGauge_run();
+
+	if (_batteryDepleting)
+		batteryDeplete_run();
 }
 
 uint16 MystScriptParser_Stoneship::getVar(uint16 var) {
@@ -481,6 +489,7 @@
 		_state.generatorDuration -= _vm->_system->getMillis() - _state.generatorDepletionTime;
 
 	// Start charging the battery
+	_batteryDepleting = false;
 	_batteryCharging = true;
 	_batteryNextTime = _vm->_system->getMillis() + 1000;
 
@@ -507,6 +516,7 @@
 		_state.generatorDepletionTime = _vm->_system->getMillis() + _state.generatorDuration;
 		_state.generatorPowerAvailable = 1;
 		_batteryDepleting = true;
+		_batteryNextTime = _vm->_system->getMillis() + 60000;
 	}
 
 	// Pause handle movie
@@ -529,13 +539,36 @@
 }
 
 uint16 MystScriptParser_Stoneship::batteryRemainingCharge() {
-	if (_state.generatorDepletionTime) {
-		return (_state.generatorDepletionTime - _vm->_system->getMillis()) / 7500;
+	uint32 time = _vm->_system->getMillis();
+
+	if (_state.generatorDepletionTime > time) {
+		return (_state.generatorDepletionTime - time) / 7500;
 	} else {
 		return 0;
 	}
 }
 
+void MystScriptParser_Stoneship::batteryDeplete_run() {
+	uint32 time = _vm->_system->getMillis();
+
+	if (time > _batteryNextTime) {
+		if (_state.generatorDuration > 60000) {
+			_state.generatorDuration -= 60000;
+			_batteryNextTime = time + 60000;
+		} else { // Battery depleted
+			_state.generatorDuration = 0;
+			_state.generatorDepletionTime = 0;
+
+			if (_state.sideDoorOpened)
+				_state.generatorPowerAvailable = 2;
+			else
+				_state.generatorPowerAvailable = 0;
+
+			_batteryDepleting = false;
+		}
+	}
+}
+
 void MystScriptParser_Stoneship::o_drawerOpenAchenar(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	debugC(kDebugScript, "Opcode %d: Open drawer", op);
 
@@ -771,13 +804,27 @@
 	_hologramSelection = static_cast<MystResourceType6 *>(_invokingResource);
 }
 
-void MystScriptParser_Stoneship::opcode_202(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void MystScriptParser_Stoneship::batteryGaugeUpdate() {
+	uint16 charge = 0;
 
+	if (_state.generatorDepletionTime) {
+		charge = batteryRemainingCharge();
+	}
+
+	Common::Rect rect = _batteryGauge->getRect();
+
+	rect.top = rect.bottom - charge;
+
+	_batteryGauge->setRect(rect);
+}
+
+void MystScriptParser_Stoneship::o_battery_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
 	// Used for Card 2160 (Lighthouse Battery Pack Closeup)
-	// TODO: Implement Code...
-	// Not Sure of Purpose - Update of Light / Discharge?
-	unknown(op, var, argc, argv);
+	debugC(kDebugScript, "Opcode %d: Battery init", op);
+
+	_batteryGauge = static_cast<MystResourceType8 *>(_invokingResource);
+
+	batteryGaugeUpdate();
 }
 
 void MystScriptParser_Stoneship::opcode_203(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
@@ -813,16 +860,26 @@
 		unknown(op, var, argc, argv);
 }
 
-void MystScriptParser_Stoneship::opcode_204(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
-	varUnusedCheck(op, var);
+void MystScriptParser_Stoneship::o_batteryGauge_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
+	debugC(kDebugScript, "Opcode %d: Battery gauge init", op);
+	_batteryLastCharge = batteryRemainingCharge();
+	_batteryGaugeRunning = true;
+}
 
-	// Used for Card 2160 (Lighthouse Battery Pack Closeup)
-	if (argc == 0) {
-		// TODO: Implement Code For Battery Meter Level
-		// Overwrite _vm->_resources[1]->_subImages[0].rect.bottom 1 to 80
-		// Add accessor functions for this...
-	} else
-		unknown(op, var, argc, argv);
+void MystScriptParser_Stoneship::batteryGauge_run() {
+	uint16 batteryCharge = batteryRemainingCharge();
+
+	if (batteryCharge != _batteryLastCharge) {
+		batteryGaugeUpdate();
+
+		_batteryLastCharge = batteryCharge;
+
+		// Redraw card
+		_vm->drawCardBackground();
+		_vm->drawResourceImages();
+		_vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
+		_vm->_system->updateScreen();
+	}
 }
 
 void MystScriptParser_Stoneship::opcode_205(uint16 op, uint16 var, uint16 argc, uint16 *argv) {

Modified: scummvm/trunk/engines/mohawk/myst_stacks/stoneship.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_stacks/stoneship.h	2011-02-09 17:54:34 UTC (rev 55859)
+++ scummvm/trunk/engines/mohawk/myst_stacks/stoneship.h	2011-02-09 20:07:55 UTC (rev 55860)
@@ -77,9 +77,9 @@
 
 	DECLARE_OPCODE(o_hologramDisplay_init);
 	DECLARE_OPCODE(o_hologramSelection_init);
-	DECLARE_OPCODE(opcode_202);
+	DECLARE_OPCODE(o_battery_init);
 	DECLARE_OPCODE(opcode_203);
-	DECLARE_OPCODE(opcode_204);
+	DECLARE_OPCODE(o_batteryGauge_init);
 	DECLARE_OPCODE(opcode_205);
 	DECLARE_OPCODE(opcode_206);
 	DECLARE_OPCODE(o_chest_init);
@@ -88,6 +88,7 @@
 	DECLARE_OPCODE(o_cloudOrb_init);
 
 	void chargeBattery_run();
+	void batteryDeplete_run();
 
 	MystGameState::Stoneship &_state;
 
@@ -95,6 +96,12 @@
 	bool _batteryDepleting;
 	uint32 _batteryNextTime;
 
+	bool _batteryGaugeRunning;
+	uint16 _batteryLastCharge; // 92
+	MystResourceType8 *_batteryGauge; // 96
+	void batteryGaugeUpdate();
+	void batteryGauge_run();
+
 	uint16 _cabinMystBookPresent; // 64
 
 	uint16 _siriusDrawerDrugsOpen; // 72


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