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

bgk at users.sourceforge.net bgk at users.sourceforge.net
Thu Dec 16 17:12:39 CET 2010


Revision: 54933
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54933&view=rev
Author:   bgk
Date:     2010-12-16 16:12:38 +0000 (Thu, 16 Dec 2010)

Log Message:
-----------
MOHAWK: Added the "resources" command to Myst's debug console, which lists the resources in the current card.
Allow the "drawRect" debug command to take a resource id as a parameter, to draw the resource's bounding rect.

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

Modified: scummvm/trunk/engines/mohawk/console.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/console.cpp	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/console.cpp	2010-12-16 16:12:38 UTC (rev 54933)
@@ -25,6 +25,7 @@
 
 #include "mohawk/console.h"
 #include "mohawk/myst.h"
+#include "mohawk/myst_areas.h"
 #include "mohawk/myst_scripts.h"
 #include "mohawk/graphics.h"
 #include "mohawk/riven.h"
@@ -49,6 +50,7 @@
 	DCmd_Register("playMovie",			WRAP_METHOD(MystConsole, Cmd_PlayMovie));
 	DCmd_Register("disableInitOpcodes",	WRAP_METHOD(MystConsole, Cmd_DisableInitOpcodes));
 	DCmd_Register("cache",				WRAP_METHOD(MystConsole, Cmd_Cache));
+	DCmd_Register("resources",			WRAP_METHOD(MystConsole, Cmd_Resources));
 }
 
 MystConsole::~MystConsole() {
@@ -179,12 +181,20 @@
 }
 
 bool MystConsole::Cmd_DrawRect(int argc, const char **argv) {
-	if (argc < 5) {
+	if (argc != 5 && argc != 2) {
 		DebugPrintf("Usage: drawRect <left> <top> <right> <bottom>\n");
+		DebugPrintf("Usage: drawRect <resource id>\n");
 		return true;
 	}
 
-	_vm->_gfx->drawRect(Common::Rect((uint16)atoi(argv[1]), (uint16)atoi(argv[2]), (uint16)atoi(argv[3]), (uint16)atoi(argv[4])), kRectEnabled);
+	if (argc == 5) {
+		_vm->_gfx->drawRect(Common::Rect((uint16)atoi(argv[1]), (uint16)atoi(argv[2]), (uint16)atoi(argv[3]), (uint16)atoi(argv[4])), kRectEnabled);
+	} else if (argc == 2) {
+		uint16 resourceId = (uint16)atoi(argv[1]);
+		if (resourceId < _vm->_resources.size())
+			_vm->_resources[resourceId]->drawBoundingRect();
+	}
+
 	return false;
 }
 
@@ -286,6 +296,16 @@
 	return true;
 }
 
+bool MystConsole::Cmd_Resources(int argc, const char **argv) {
+	DebugPrintf("Resources in card %d:\n", _vm->getCurCard());
+
+	for (uint i = 0; i < _vm->_resources.size(); i++) {
+		DebugPrintf("#%2d %s\n", i, _vm->_resources[i]->describe().c_str());
+	}
+
+	return true;
+}
+
 RivenConsole::RivenConsole(MohawkEngine_Riven *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("changeCard",		WRAP_METHOD(RivenConsole, Cmd_ChangeCard));
 	DCmd_Register("curCard",		WRAP_METHOD(RivenConsole, Cmd_CurCard));

Modified: scummvm/trunk/engines/mohawk/console.h
===================================================================
--- scummvm/trunk/engines/mohawk/console.h	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/console.h	2010-12-16 16:12:38 UTC (rev 54933)
@@ -55,6 +55,7 @@
 	bool Cmd_PlayMovie(int argc, const char **argv);
 	bool Cmd_DisableInitOpcodes(int argc, const char **argv);
 	bool Cmd_Cache(int argc, const char **argv);
+	bool Cmd_Resources(int argc, const char **argv);
 };
 
 class RivenConsole : public GUI::Debugger {

Modified: scummvm/trunk/engines/mohawk/graphics.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.cpp	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/graphics.cpp	2010-12-16 16:12:38 UTC (rev 54933)
@@ -523,12 +523,16 @@
 	if (rect.left < 0 || rect.top < 0 || rect.right > 544 || rect.bottom > 333 || !rect.isValidRect() || rect.width() == 0 || rect.height() == 0)
 		return;
 
+	Graphics::Surface *screen = _vm->_system->lockScreen();
+
 	if (state == kRectEnabled)
-		_backBuffer->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
+		screen->frameRect(rect, _pixelFormat.RGBToColor(0, 255, 0));
 	else if (state == kRectUnreachable)
-		_backBuffer->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255));
+		screen->frameRect(rect, _pixelFormat.RGBToColor(0, 0, 255));
 	else
-		_backBuffer->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));
+		screen->frameRect(rect, _pixelFormat.RGBToColor(255, 0, 0));
+
+	_vm->_system->unlockScreen();
 }
 
 void MystGraphics::drawLine(const Common::Point &p1, const Common::Point &p2, uint32 color) {

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-12-16 16:12:38 UTC (rev 54933)
@@ -562,28 +562,21 @@
 	_curResource = -1;
 	checkCurrentResource();
 
-	// Debug: Show resource rects
-	if (_showResourceRects)
-		drawResourceRects();
-
 	// Make sure the screen is updated
 	if (updateScreen) {
 		_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
 		_system->updateScreen();
 	}
+
+	// Debug: Show resource rects
+	if (_showResourceRects)
+		drawResourceRects();
 }
 
 void MohawkEngine_Myst::drawResourceRects() {
 	for (uint16 i = 0; i < _resources.size(); i++) {
 		_resources[i]->getRect().debugPrint(0);
-		if (_resources[i]->getRect().isValidRect()) {
-			if (!_resources[i]->canBecomeActive())
-				_gfx->drawRect(_resources[i]->getRect(), kRectUnreachable);
-			else if (_resources[i]->isEnabled())
-				_gfx->drawRect(_resources[i]->getRect(), kRectEnabled);
-			else
-				_gfx->drawRect(_resources[i]->getRect(), kRectDisabled);
-		}
+		_resources[i]->drawBoundingRect();
 	}
 
 	_system->updateScreen();

Modified: scummvm/trunk/engines/mohawk/myst_areas.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/myst_areas.cpp	2010-12-16 16:12:38 UTC (rev 54933)
@@ -95,6 +95,27 @@
 	}
 }
 
+const Common::String MystResource::describe() {
+	Common::String desc = Common::String::format("type: %2d rect: (%3d %3d %3d %3d)",
+			type, _rect.left, _rect.top, _rect.width(), _rect.height());
+
+	if (_dest != 0)
+		desc += Common::String::format(" dest: %4d", _dest);
+
+	return desc;
+}
+
+void MystResource::drawBoundingRect() {
+	if (_rect.isValidRect()) {
+		if (!canBecomeActive())
+			_vm->_gfx->drawRect(_rect, kRectUnreachable);
+		else if (isEnabled())
+			_vm->_gfx->drawRect(_rect, kRectEnabled);
+		else
+			_vm->_gfx->drawRect(_rect, kRectDisabled);
+	}
+}
+
 MystResourceType5::MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResource(vm, rlstStream, parent) {
 	debugC(kDebugResource, "\tResource Type 5 Script:");
 
@@ -105,6 +126,20 @@
 	_vm->_scriptParser->runScript(_script, this);
 }
 
+const Common::String MystResourceType5::describe() {
+	Common::String desc = MystResource::describe();
+
+	if (_script->size() != 0) {
+		desc += " ops:";
+
+		for (uint i = 0; i < _script->size(); i++) {
+			desc += " " + _vm->_scriptParser->getOpcodeDesc(_script->operator[](i).opcode);
+		}
+	}
+
+	return desc;
+}
+
 // In Myst/Making of Myst, the paths are hardcoded ala Windows style without extension. Convert them.
 Common::String MystResourceType6::convertMystVideoName(Common::String name) {
 	Common::String temp;
@@ -436,6 +471,20 @@
 	return _var8;
 }
 
+const Common::String MystResourceType8::describe() {
+	Common::String desc = Common::String::format("%s var: %2d",
+			MystResourceType7::describe().c_str(), _var8);
+
+	if (_numSubImages > 0) {
+		desc +=  " subImgs:";
+		for (uint i = 0; i < _numSubImages; i++) {
+			desc += Common::String::format(" %d", (int16)_subImages[i].wdib);
+		}
+	}
+
+	return desc;
+}
+
 // No MystResourceType9!
 
 MystResourceType10::MystResourceType10(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent) : MystResourceType11(vm, rlstStream, parent) {
@@ -678,6 +727,14 @@
 	_vm->_scriptParser->runOpcode(_mouseDragOpcode, _var8);
 }
 
+const Common::String MystResourceType11::describe() {
+	return Common::String::format("%s down: %s drag: %s up: %s",
+			MystResourceType8::describe().c_str(),
+			_vm->_scriptParser->getOpcodeDesc(_mouseDownOpcode).c_str(),
+			_vm->_scriptParser->getOpcodeDesc(_mouseDragOpcode).c_str(),
+			_vm->_scriptParser->getOpcodeDesc(_mouseUpOpcode).c_str());
+}
+
 void MystResourceType11::setPositionClipping(const Common::Point &mouse, Common::Point &dest) {
 	if (_flagHV & 2) {
 		dest.y = CLIP<uint16>(mouse.y, _minV, _maxV);
@@ -766,4 +823,11 @@
 	// i.e. MystResource::handleMouseUp
 }
 
+const Common::String MystResourceType13::describe() {
+	return Common::String::format("%s enter: %s leave: %s",
+			MystResource::describe().c_str(),
+			_vm->_scriptParser->getOpcodeDesc(_enterOpcode).c_str(),
+			_vm->_scriptParser->getOpcodeDesc(_leaveOpcode).c_str());
+}
+
 } // End of namespace Mohawk

Modified: scummvm/trunk/engines/mohawk/myst_areas.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_areas.h	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/myst_areas.h	2010-12-16 16:12:38 UTC (rev 54933)
@@ -60,6 +60,8 @@
 public:
 	MystResource(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	virtual ~MystResource();
+	virtual const Common::String describe();
+	void drawBoundingRect();
 
 	MystResource *_parent;
 	ResourceType type;
@@ -95,6 +97,7 @@
 public:
 	MystResourceType5(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	void handleMouseUp(const Common::Point &mouse);
+	const Common::String describe();
 
 protected:
 	MystScript _script;
@@ -145,6 +148,8 @@
 public:
 	MystResourceType8(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	virtual ~MystResourceType8();
+	virtual const Common::String describe();
+
 	virtual void drawDataToScreen();
 	void drawConditionalDataToScreen(uint16 state, bool update = true);
 	uint16 getType8Var();
@@ -165,6 +170,8 @@
 public:
 	MystResourceType11(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
 	virtual ~MystResourceType11();
+	const Common::String describe();
+
 	void handleMouseDown(const Common::Point &mouse);
 	void handleMouseUp(const Common::Point &mouse);
 	void handleMouseDrag(const Common::Point &mouse);
@@ -237,6 +244,8 @@
 class MystResourceType13 : public MystResource {
 public:
 	MystResourceType13(MohawkEngine_Myst *vm, Common::SeekableReadStream *rlstStream, MystResource *parent);
+	const Common::String describe();
+
 	void handleMouseUp(const Common::Point &mouse);
 	void handleMouseEnter();
 	void handleMouseLeave();

Modified: scummvm/trunk/engines/mohawk/myst_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/myst_scripts.cpp	2010-12-16 16:12:38 UTC (rev 54933)
@@ -181,12 +181,12 @@
 		warning("Trying to run invalid opcode %d", op);
 }
 
-const char *MystScriptParser::getOpcodeDesc(uint16 op) {
+const Common::String MystScriptParser::getOpcodeDesc(uint16 op) {
 	for (uint16 i = 0; i < _opcodes.size(); i++)
 		if (_opcodes[i]->op == op)
 			return _opcodes[i]->desc;
 
-	return "unknown";
+	return Common::String::format("%d", op);
 }
 
 MystScript MystScriptParser::readScript(Common::SeekableReadStream *stream, MystScriptType type) {

Modified: scummvm/trunk/engines/mohawk/myst_scripts.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_scripts.h	2010-12-16 13:25:29 UTC (rev 54932)
+++ scummvm/trunk/engines/mohawk/myst_scripts.h	2010-12-16 16:12:38 UTC (rev 54933)
@@ -66,7 +66,7 @@
 
 	void runScript(MystScript script, MystResource *invokingResource = NULL);
 	void runOpcode(uint16 op, uint16 var = 0, uint16 argc = 0, uint16 *argv = NULL);
-	const char *getOpcodeDesc(uint16 op);
+	const Common::String getOpcodeDesc(uint16 op);
 	MystScript readScript(Common::SeekableReadStream *stream, MystScriptType type);
 	void setInvokingResource(MystResource *resource) { _invokingResource = resource; }
 


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