[Scummvm-cvs-logs] SF.net SVN: scummvm:[36259] scummvm/trunk

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Wed Feb 11 11:03:01 CET 2009


Revision: 36259
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36259&view=rev
Author:   dreammaster
Date:     2009-02-11 10:03:01 +0000 (Wed, 11 Feb 2009)

Log Message:
-----------
Added debugger console

Modified Paths:
--------------
    scummvm/trunk/dists/msvc8/cruise.vcproj
    scummvm/trunk/dists/msvc9/cruise.vcproj
    scummvm/trunk/engines/cruise/cruise.cpp
    scummvm/trunk/engines/cruise/cruise.h
    scummvm/trunk/engines/cruise/cruise_main.cpp
    scummvm/trunk/engines/cruise/gfxModule.cpp
    scummvm/trunk/engines/cruise/module.mk
    scummvm/trunk/engines/cruise/object.cpp
    scummvm/trunk/engines/cruise/object.h

Added Paths:
-----------
    scummvm/trunk/engines/cruise/debugger.cpp
    scummvm/trunk/engines/cruise/debugger.h

Modified: scummvm/trunk/dists/msvc8/cruise.vcproj
===================================================================
--- scummvm/trunk/dists/msvc8/cruise.vcproj	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/dists/msvc8/cruise.vcproj	2009-02-11 10:03:01 UTC (rev 36259)
@@ -231,6 +231,14 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\engines\cruise\debugger.cpp"
+			>
+		</File>
+		<File
+			RelativePath="..\..\engines\cruise\debugger.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\engines\cruise\delphine-unpack.cpp"
 			>
 		</File>

Modified: scummvm/trunk/dists/msvc9/cruise.vcproj
===================================================================
--- scummvm/trunk/dists/msvc9/cruise.vcproj	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/dists/msvc9/cruise.vcproj	2009-02-11 10:03:01 UTC (rev 36259)
@@ -232,6 +232,14 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\engines\cruise\debugger.cpp"
+			>
+		</File>
+		<File
+			RelativePath="..\..\engines\cruise\debugger.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\engines\cruise\delphine-unpack.cpp"
 			>
 		</File>

Modified: scummvm/trunk/engines/cruise/cruise.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise.cpp	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/engines/cruise/cruise.cpp	2009-02-11 10:03:01 UTC (rev 36259)
@@ -59,6 +59,7 @@
 	                              ConfMan.getInt("music_volume"));
 
 	_vm = this;
+	_debugger = new Debugger();
 
 	syst->getEventManager()->registerRandomSource(_rnd, "cruise");
 }
@@ -67,6 +68,7 @@
 #ifdef PALMOS_MODE
 	delete _currentVolumeFile;
 #endif
+	delete _debugger;
 }
 
 Common::Error CruiseEngine::init() {

Modified: scummvm/trunk/engines/cruise/cruise.h
===================================================================
--- scummvm/trunk/engines/cruise/cruise.h	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/engines/cruise/cruise.h	2009-02-11 10:03:01 UTC (rev 36259)
@@ -32,6 +32,7 @@
 #include "engines/engine.h"
 
 #include "cruise/cruise_main.h"
+#include "cruise/debugger.h"
 
 namespace Cruise {
 
@@ -42,7 +43,14 @@
 struct CRUISEGameDescription;
 
 class CruiseEngine: public Engine {
+private:
+	void initialize(void);
+	bool makeLoad(char *saveName);
+	void mainLoop(int bootScriptIdx);
 
+	bool _preLoad;
+	Debugger *_debugger;
+
 protected:
 	// Engine APIs
 	virtual Common::Error init();
@@ -60,6 +68,7 @@
 	uint32 getFeatures() const;
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
+	virtual GUI::Debugger *getDebugger() { return _debugger; }
 
 	bool loadSaveDirectory(void);
 	void makeSystemMenu(void);
@@ -67,13 +76,6 @@
 	const CRUISEGameDescription *_gameDescription;
 
 	Common::RandomSource _rnd;
-
-private:
-	void initialize(void);
-	bool makeLoad(char *saveName);
-	void mainLoop(int bootScriptIdx);
-
-	bool _preLoad;
 };
 
 extern CruiseEngine *_vm;

Modified: scummvm/trunk/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.cpp	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/engines/cruise/cruise_main.cpp	2009-02-11 10:03:01 UTC (rev 36259)
@@ -27,6 +27,7 @@
 #include "common/events.h"
 #include "common/system.h"	// for g_system->getEventManager()
 
+#include "cruise/cruise.h"
 #include "cruise/cruise_main.h"
 #include "cruise/cell.h"
 #include "cruise/staticres.h"
@@ -747,32 +748,6 @@
 	return ptr;
 }
 
-const char *getObjectName(int index, const char *string) {
-	const char *ptr = string;
-
-	if (!string)
-		return NULL;
-
-	int i = 0;
-//	int j = 0;
-
-	while (i < index) {
-		ptr += strlen(ptr) + 1;
-		i++;
-	}
-	return ptr;
-}
-
-int getObjectClass(int overlayIdx, int objIdx) {
-	objDataStruct *pObjectData = getObjectDataFromOverlay(overlayIdx, objIdx);
-
-	if (pObjectData) {
-		return pObjectData->_class;
-	} else {
-		return -11;
-	}
-}
-
 void buildInventory(int X, int Y) {
 	menuStruct *pMenu;
 
@@ -1682,6 +1657,7 @@
 			if (event.kbd.flags == Common::KBD_CTRL) {
 				if (event.kbd.keycode == Common::KEYCODE_d) {
 					// Start the debugger
+					_vm->getDebugger()->attach();
 					keyboardCode = Common::KEYCODE_INVALID;
 				} else if (event.kbd.keycode == Common::KEYCODE_f) {
 					bFastMode = !bFastMode;

Added: scummvm/trunk/engines/cruise/debugger.cpp
===================================================================
--- scummvm/trunk/engines/cruise/debugger.cpp	                        (rev 0)
+++ scummvm/trunk/engines/cruise/debugger.cpp	2009-02-11 10:03:01 UTC (rev 36259)
@@ -0,0 +1,112 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "cruise/debugger.h"
+#include "cruise/cell.h"
+#include "cruise/cruise_main.h"
+#include "cruise/object.h"
+#include "cruise/overlay.h"
+
+namespace Cruise {
+
+Debugger::Debugger(): GUI::Debugger() {
+	DCmd_Register("continue",			WRAP_METHOD(Debugger, Cmd_Exit));
+	DCmd_Register("hotspots",				WRAP_METHOD(Debugger, cmd_hotspots));
+	DCmd_Register("items",				WRAP_METHOD(Debugger, cmd_items));
+}
+
+/**
+ * Preliminary command to list the currently loaded hotspots
+ */
+bool Debugger::cmd_hotspots(int argc, const char **argv) {
+	const char *pObjType;
+	objectParamsQuery params;
+
+	cellStruct *currentObject = cellHead.prev;
+
+	while (currentObject) {
+		if (currentObject->overlay > 0 && overlayTable[currentObject->overlay].alreadyLoaded && 
+			(currentObject->type == OBJ_TYPE_SPRITE || currentObject->type == OBJ_TYPE_MASK || 
+			currentObject->type == OBJ_TYPE_EXIT || currentObject->type == OBJ_TYPE_VIRTUEL)) {
+			const char *pObjectName = getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->arrayNameObj);
+
+			switch (currentObject->type) {
+			case OBJ_TYPE_SPRITE:
+				pObjType = "SPRITE";
+				break;
+			case OBJ_TYPE_MASK:
+				pObjType = "MASK";
+				break;
+			case OBJ_TYPE_EXIT:
+				pObjType = "EXIT";
+				break;
+			case OBJ_TYPE_VIRTUEL:
+				pObjType = "VIRTUEL";
+				break;
+			default:
+				pObjType = "UNKNOWN";
+				break;
+			}
+
+			if (*pObjectName) {
+				getMultipleObjectParam(currentObject->overlay, currentObject->idx, &params);
+
+				DebugPrintf("%s %s - %d,%d\n", pObjectName, pObjType, params.X, params.Y);
+			}
+		}
+
+		currentObject = currentObject->prev;
+	}
+
+	return true;
+}
+
+/**
+ * Preliminary command to list the current items in the player's inventory
+ */
+bool Debugger::cmd_items(int argc, const char **argv) {
+	for (int i = 1; i < numOfLoadedOverlay; i++) {
+		ovlDataStruct *pOvlData = overlayTable[i].ovlData;
+
+		if (overlayTable[i].alreadyLoaded) {
+			if (overlayTable[i].ovlData->arrayObject) {
+				for (int j = 0; j < pOvlData->numObj; j++) {
+					if (getObjectClass(i, j) != 3) {
+						int16 returnVar;
+
+						getSingleObjectParam(i, j, 5, &returnVar);
+
+						if (returnVar < -1)
+							DebugPrintf("%s\n", getObjectName(j, pOvlData->arrayNameObj));
+					}
+				}
+			}
+		}
+	}
+
+	return true;
+}
+
+} // End of namespace Cruise


Property changes on: scummvm/trunk/engines/cruise/debugger.cpp
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + Date Rev Author URL Id
Added: svn:eol-style
   + native

Added: scummvm/trunk/engines/cruise/debugger.h
===================================================================
--- scummvm/trunk/engines/cruise/debugger.h	                        (rev 0)
+++ scummvm/trunk/engines/cruise/debugger.h	2009-02-11 10:03:01 UTC (rev 36259)
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef CRUISE_DEBUGGER_H
+#define CRUISE_DEBUGGER_H
+
+#include "gui/debugger.h"
+
+namespace Cruise {
+
+class Debugger : public GUI::Debugger {
+public:
+	Debugger();
+	virtual ~Debugger() {}  // we need this for __SYMBIAN32__ archaic gcc/UIQ
+
+protected:
+	bool cmd_hotspots(int argc, const char **argv);
+	bool cmd_items(int argc, const char **argv);
+};
+
+} // End of namespace Cruise
+
+#endif


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

Modified: scummvm/trunk/engines/cruise/gfxModule.cpp
===================================================================
--- scummvm/trunk/engines/cruise/gfxModule.cpp	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/engines/cruise/gfxModule.cpp	2009-02-11 10:03:01 UTC (rev 36259)
@@ -27,6 +27,7 @@
 #include "common/system.h"
 #include "common/endian.h"
 
+#include "cruise/cruise.h"
 #include "cruise/cruise_main.h"
 
 namespace Cruise {
@@ -223,7 +224,7 @@
 
 extern bool bFastMode;
 
-static uint32 lastTick;
+static uint32 lastTick = 0, lastTickDebug = 0;
 
 void flip() {
 	int i;
@@ -246,6 +247,13 @@
 
 	uint32 currentTick = g_system->getMillis();
 
+	if (currentTick >= (lastTickDebug + 10)) {
+		lastTickDebug = currentTick;
+
+		if (_vm->getDebugger()->isAttached())
+			_vm->getDebugger()->onFrame();
+	}
+
 	if (!bFastMode) {
 		uint32 speed = 50;
 		if (lastTick + speed > currentTick) {

Modified: scummvm/trunk/engines/cruise/module.mk
===================================================================
--- scummvm/trunk/engines/cruise/module.mk	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/engines/cruise/module.mk	2009-02-11 10:03:01 UTC (rev 36259)
@@ -9,6 +9,7 @@
 	cruise_main.o \
 	ctp.o \
 	dataLoader.o \
+	debugger.o \
 	decompiler.o \
 	delphine-unpack.o \
 	detection.o \

Modified: scummvm/trunk/engines/cruise/object.cpp
===================================================================
--- scummvm/trunk/engines/cruise/object.cpp	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/engines/cruise/object.cpp	2009-02-11 10:03:01 UTC (rev 36259)
@@ -306,4 +306,30 @@
 	}
 }
 
+const char *getObjectName(int index, const char *string) {
+	const char *ptr = string;
+
+	if (!string)
+		return NULL;
+
+	int i = 0;
+//	int j = 0;
+
+	while (i < index) {
+		ptr += strlen(ptr) + 1;
+		i++;
+	}
+	return ptr;
+}
+
+int getObjectClass(int overlayIdx, int objIdx) {
+	objDataStruct *pObjectData = getObjectDataFromOverlay(overlayIdx, objIdx);
+
+	if (pObjectData) {
+		return pObjectData->_class;
+	} else {
+		return -11;
+	}
+}
+
 } // End of namespace Cruise

Modified: scummvm/trunk/engines/cruise/object.h
===================================================================
--- scummvm/trunk/engines/cruise/object.h	2009-02-11 09:02:30 UTC (rev 36258)
+++ scummvm/trunk/engines/cruise/object.h	2009-02-11 10:03:01 UTC (rev 36259)
@@ -26,6 +26,8 @@
 #ifndef CRUISE_OBJECT_H
 #define CRUISE_OBJECT_H
 
+#include "cruise/overlay.h"
+
 namespace Cruise {
 
 struct gfxEntryStruct {
@@ -52,6 +54,9 @@
 int16 getSingleObjectParam(int16 overlayIdx, int16 param2, int16 param3, int16 * returnParam);
 int16 getMultipleObjectParam(int16 overlayIdx, int16 objectIdx, objectParamsQuery * returnParam);
 void objectReset(void);
+const char *getObjectName(int index, const char *string);
+int getObjectClass(int overlayIdx, int objIdx);
+
 } // End of namespace Cruise
 
 #endif


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