[Scummvm-cvs-logs] SF.net SVN: scummvm: [26755] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun May 6 10:52:29 CEST 2007


Revision: 26755
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26755&view=rev
Author:   peres001
Date:     2007-05-06 01:52:27 -0700 (Sun, 06 May 2007)

Log Message:
-----------
Added embryonic debugger, and some adjustments to make basic commands work.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/debug.cpp
    scummvm/trunk/engines/parallaction/inventory.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/zone.cpp

Added Paths:
-----------
    scummvm/trunk/engines/parallaction/debug.h

Modified: scummvm/trunk/engines/parallaction/debug.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/debug.cpp	2007-05-05 23:54:29 UTC (rev 26754)
+++ scummvm/trunk/engines/parallaction/debug.cpp	2007-05-06 08:52:27 UTC (rev 26755)
@@ -26,6 +26,8 @@
 #include "parallaction/parallaction.h"
 #include "parallaction/graphics.h"
 
+#include "parallaction/debug.h"
+
 namespace Parallaction {
 
 
@@ -54,14 +56,62 @@
 	"21 - erase mouse"
 };
 
-void beep() {
-//	sound(1500);
-//	delay(100);
-//	nosound();
-	return;
+Debugger::Debugger(Parallaction *vm)
+	: GUI::Debugger() {
+	_vm = vm;
+
+	DCmd_Register("continue", WRAP_METHOD(Debugger, Cmd_Exit));
+	DCmd_Register("location",    WRAP_METHOD(Debugger, Cmd_Location));
+	DCmd_Register("give",    WRAP_METHOD(Debugger, Cmd_Give));
 }
 
 
+void Debugger::preEnter() {
+}
 
 
+void Debugger::postEnter() {
+}
+
+bool Debugger::Cmd_Location(int argc, const char **argv) {
+
+	char *character = _vm->_characterName;
+	char *location = _vm->_location._name;
+
+	switch (argc) {
+	case 3:
+		character = const_cast<char*>(argv[2]);
+		// fallthru is intentional here
+
+	case 2:
+		location = const_cast<char*>(argv[1]);
+		sprintf(_vm->_location._name, "%s.%s", location, character);
+		// TODO: check if location exists
+		_engineFlags |= kEngineChangeLocation;
+		break;
+
+	case 1:
+		DebugPrintf("location <location name> [character name]\n");
+
+	}
+
+	return true;
+}
+
+
+bool Debugger::Cmd_Give(int argc, const char **argv) {
+
+	if (argc == 1) {
+		DebugPrintf("give <item name>\n");
+	} else {
+		int index = _vm->_objectsNames->lookup(argv[1]);
+		if (index != -1)
+			_vm->addInventoryItem(index + 4);
+		else
+			DebugPrintf("invalid item name '%s'\n", argv[1]);
+	}
+
+	return true;
+}
+
 } // namespace Parallaction

Added: scummvm/trunk/engines/parallaction/debug.h
===================================================================
--- scummvm/trunk/engines/parallaction/debug.h	                        (rev 0)
+++ scummvm/trunk/engines/parallaction/debug.h	2007-05-06 08:52:27 UTC (rev 26755)
@@ -0,0 +1,29 @@
+
+#ifndef PARALLACTION_DEBUGGER_H
+#define PARALLACTION_DEBUGGER_H
+
+#include "gui/debugger.h"
+
+namespace Parallaction {
+
+class Parallaction;
+
+class Debugger : public GUI::Debugger {
+public:
+	Debugger(Parallaction *vm);
+	virtual ~Debugger() {}  // we need this for __SYMBIAN32__ archaic gcc/UIQ
+
+protected:
+	Parallaction *_vm;
+
+	virtual void preEnter();
+	virtual void postEnter();
+
+	bool Cmd_DebugLevel(int argc, const char **argv);
+	bool Cmd_Location(int argc, const char **argv);
+	bool Cmd_Give(int argc, const char **argv);
+};
+
+} // End of namespace Parallaction
+
+#endif


Property changes on: scummvm/trunk/engines/parallaction/debug.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Date Rev Author URL Id
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/parallaction/inventory.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.cpp	2007-05-05 23:54:29 UTC (rev 26754)
+++ scummvm/trunk/engines/parallaction/inventory.cpp	2007-05-06 08:52:27 UTC (rev 26755)
@@ -116,37 +116,19 @@
 }
 
 
-int16 Parallaction::pickupItem(Zone *z) {
+int Parallaction::addInventoryItem(uint16 item) {
 
-	uint16 _si;
-	for (_si = 0; _inventory[_si]._id != 0; _si++) ;
+	uint16 _si = 0;
+	while (_inventory[_si]._id != 0) _si++;
 	if (_si == INVENTORY_MAX_ITEMS)
 		return -1;
 
-	_inventory[_si]._id = MAKE_INVENTORY_ID(z->u.get->_icon);
-	_inventory[_si]._index = z->u.get->_icon;
-
-	addJob(&jobRemovePickedItem, z, kPriority17 );
-
-	if (_inventory[_si]._id == 0) return 0;
-
-	refreshInventoryItem(_characterName, _si);
-
-	return 0;
-}
-
-
-void Parallaction::addInventoryItem(uint16 item) {
-
-	uint16 _si = 0;
-	while (_inventory[_si]._id != 0) _si++;
-
 	_inventory[_si]._id = MAKE_INVENTORY_ID(item);
 	_inventory[_si]._index = item;
 
 	refreshInventoryItem(_characterName, _si);
 
-	return;
+	return 0;
 }
 
 

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-05-05 23:54:29 UTC (rev 26754)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-05-06 08:52:27 UTC (rev 26755)
@@ -31,6 +31,7 @@
 #include "sound/mixer.h"
 
 #include "parallaction/parallaction.h"
+#include "parallaction/debug.h"
 #include "parallaction/menu.h"
 #include "parallaction/parser.h"
 #include "parallaction/disk.h"
@@ -124,6 +125,8 @@
 
 
 Parallaction::~Parallaction() {
+	delete _debugger;
+
 	delete _soundMan;
 	delete _disk;
 	delete _globalTable;
@@ -214,6 +217,8 @@
 		_soundMan = new AmigaSoundMan(this);
 	}
 
+	_debugger = new Debugger(this);
+
 	return 0;
 }
 
@@ -283,6 +288,8 @@
 		case Common::EVENT_KEYDOWN:
 			if (e.kbd.ascii == 'l') KeyDown = kEvLoadGame;
 			if (e.kbd.ascii == 's') KeyDown = kEvSaveGame;
+			if (e.kbd.flags == Common::KBD_CTRL && e.kbd.keycode == 'd')
+				_debugger->attach();
 			break;
 
 		case Common::EVENT_LBUTTONDOWN:
@@ -316,6 +323,9 @@
 
 	}
 
+	if (_debugger->isAttached())
+		_debugger->onFrame();
+
 	return KeyDown;
 
 }

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-05-05 23:54:29 UTC (rev 26754)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-05-06 08:52:27 UTC (rev 26755)
@@ -281,6 +281,7 @@
 
 
 class Parallaction : public Engine {
+	friend class Debugger;
 
 public:
 
@@ -368,6 +369,8 @@
 
 protected:		// data
 
+	Debugger	*_debugger;
+
 	struct InputData {
 		uint16			_event;
 		Common::Point	_mousePos;
@@ -449,7 +452,7 @@
 	void 		enterDialogue();
 	void 		exitDialogue();
 
-	void 		addInventoryItem(uint16 item);
+	int 		addInventoryItem(uint16 item);
 	void 		dropItem(uint16 item);
 	int16 		pickupItem(Zone *z);
 	int16 		isItemInInventory(int32 v);

Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp	2007-05-05 23:54:29 UTC (rev 26754)
+++ scummvm/trunk/engines/parallaction/zone.cpp	2007-05-06 08:52:27 UTC (rev 26755)
@@ -457,13 +457,18 @@
 
 
 
-
-
-
 //
 //	ZONE TYPE: GET
 //
 
+int16 Parallaction::pickupItem(Zone *z) {
+	int r = addInventoryItem(z->u.get->_icon);
+	if (r == 0)
+		addJob(&jobRemovePickedItem, z, kPriority17 );
+
+	return r;
+}
+
 void jobRemovePickedItem(void *parm, Job *j) {
 
 	Zone *z = (Zone*)parm;


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