diff options
| -rw-r--r-- | engines/mohawk/console.cpp | 24 | ||||
| -rw-r--r-- | engines/mohawk/console.h | 1 | ||||
| -rw-r--r-- | engines/mohawk/graphics.cpp | 10 | ||||
| -rw-r--r-- | engines/mohawk/myst.cpp | 17 | ||||
| -rw-r--r-- | engines/mohawk/myst_areas.cpp | 64 | ||||
| -rw-r--r-- | engines/mohawk/myst_areas.h | 9 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts.cpp | 4 | ||||
| -rw-r--r-- | engines/mohawk/myst_scripts.h | 2 | 
8 files changed, 111 insertions, 20 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index edf7247e22..d406d7575c 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -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 @@ MystConsole::MystConsole(MohawkEngine_Myst *vm) : GUI::Debugger(), _vm(vm) {  	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_DrawImage(int argc, const char **argv) {  }  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 @@ bool MystConsole::Cmd_Cache(int argc, const char **argv) {  	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)); diff --git a/engines/mohawk/console.h b/engines/mohawk/console.h index f7f37f0211..41949c3d06 100644 --- a/engines/mohawk/console.h +++ b/engines/mohawk/console.h @@ -55,6 +55,7 @@ private:  	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 { diff --git a/engines/mohawk/graphics.cpp b/engines/mohawk/graphics.cpp index 46f2d3c0d7..c664b3574a 100644 --- a/engines/mohawk/graphics.cpp +++ b/engines/mohawk/graphics.cpp @@ -523,12 +523,16 @@ void MystGraphics::drawRect(Common::Rect rect, RectState state) {  	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) { diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index 4f5e666e2c..08873ae455 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -562,28 +562,21 @@ void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {  	_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(); diff --git a/engines/mohawk/myst_areas.cpp b/engines/mohawk/myst_areas.cpp index a102606936..5b27a69ab9 100644 --- a/engines/mohawk/myst_areas.cpp +++ b/engines/mohawk/myst_areas.cpp @@ -95,6 +95,27 @@ void MystResource::setEnabled(bool enabled) {  	}  } +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 @@ void MystResourceType5::handleMouseUp(const Common::Point &mouse) {  	_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 @@ uint16 MystResourceType8::getType8Var() {  	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 @@ void MystResourceType11::handleMouseDrag(const Common::Point &mouse) {  	_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 @@ void MystResourceType13::handleMouseUp(const Common::Point &mouse) {  	// 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 diff --git a/engines/mohawk/myst_areas.h b/engines/mohawk/myst_areas.h index c65c91ba55..0aa5f082f6 100644 --- a/engines/mohawk/myst_areas.h +++ b/engines/mohawk/myst_areas.h @@ -60,6 +60,8 @@ class MystResource {  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 @@ class MystResourceType5 : public MystResource {  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 @@ class MystResourceType8 : public MystResourceType7 {  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 @@ class MystResourceType11 : public MystResourceType8 {  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 @@ private:  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(); diff --git a/engines/mohawk/myst_scripts.cpp b/engines/mohawk/myst_scripts.cpp index de9d67e8ff..279de90226 100644 --- a/engines/mohawk/myst_scripts.cpp +++ b/engines/mohawk/myst_scripts.cpp @@ -181,12 +181,12 @@ void MystScriptParser::runOpcode(uint16 op, uint16 var, uint16 argc, uint16 *arg  		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) { diff --git a/engines/mohawk/myst_scripts.h b/engines/mohawk/myst_scripts.h index ecf82ea6ce..f455daf66d 100644 --- a/engines/mohawk/myst_scripts.h +++ b/engines/mohawk/myst_scripts.h @@ -66,7 +66,7 @@ public:  	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; }  | 
