diff options
-rw-r--r-- | dists/msvc8/cruise.vcproj | 8 | ||||
-rw-r--r-- | dists/msvc9/cruise.vcproj | 8 | ||||
-rw-r--r-- | engines/cruise/cruise.cpp | 2 | ||||
-rw-r--r-- | engines/cruise/cruise.h | 16 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 28 | ||||
-rw-r--r-- | engines/cruise/debugger.cpp | 112 | ||||
-rw-r--r-- | engines/cruise/debugger.h | 45 | ||||
-rw-r--r-- | engines/cruise/gfxModule.cpp | 10 | ||||
-rw-r--r-- | engines/cruise/module.mk | 1 | ||||
-rw-r--r-- | engines/cruise/object.cpp | 26 | ||||
-rw-r--r-- | engines/cruise/object.h | 5 |
11 files changed, 227 insertions, 34 deletions
diff --git a/dists/msvc8/cruise.vcproj b/dists/msvc8/cruise.vcproj index e55157aeef..ef7f08cb73 100644 --- a/dists/msvc8/cruise.vcproj +++ b/dists/msvc8/cruise.vcproj @@ -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> diff --git a/dists/msvc9/cruise.vcproj b/dists/msvc9/cruise.vcproj index 0f350b662d..ff12a391ae 100644 --- a/dists/msvc9/cruise.vcproj +++ b/dists/msvc9/cruise.vcproj @@ -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> diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp index 43eb32a6d3..71ab343daa 100644 --- a/engines/cruise/cruise.cpp +++ b/engines/cruise/cruise.cpp @@ -59,6 +59,7 @@ CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc ConfMan.getInt("music_volume")); _vm = this; + _debugger = new Debugger(); syst->getEventManager()->registerRandomSource(_rnd, "cruise"); } @@ -67,6 +68,7 @@ CruiseEngine::~CruiseEngine() { #ifdef PALMOS_MODE delete _currentVolumeFile; #endif + delete _debugger; } Common::Error CruiseEngine::init() { diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h index e87223df57..0ed3e57d1b 100644 --- a/engines/cruise/cruise.h +++ b/engines/cruise/cruise.h @@ -32,6 +32,7 @@ #include "engines/engine.h" #include "cruise/cruise_main.h" +#include "cruise/debugger.h" namespace Cruise { @@ -42,6 +43,13 @@ enum CruiseGameType { 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 @@ -60,6 +68,7 @@ public: 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 @@ public: const CRUISEGameDescription *_gameDescription; Common::RandomSource _rnd; - -private: - void initialize(void); - bool makeLoad(char *saveName); - void mainLoop(int bootScriptIdx); - - bool _preLoad; }; extern CruiseEngine *_vm; diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index ada2c49bc1..7e6d602079 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -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 @@ void *allocAndZero(int size) { 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 @@ void manageEvents() { 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; diff --git a/engines/cruise/debugger.cpp b/engines/cruise/debugger.cpp new file mode 100644 index 0000000000..62a4e34b15 --- /dev/null +++ b/engines/cruise/debugger.cpp @@ -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, ¶ms); + + 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 diff --git a/engines/cruise/debugger.h b/engines/cruise/debugger.h new file mode 100644 index 0000000000..2c5b2a906f --- /dev/null +++ b/engines/cruise/debugger.h @@ -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 diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index 2ffd0a08f2..400192636a 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -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 @@ void gfxModuleData_flipScreen(void) { extern bool bFastMode; -static uint32 lastTick; +static uint32 lastTick = 0, lastTickDebug = 0; void flip() { int i; @@ -246,6 +247,13 @@ void flip() { 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) { diff --git a/engines/cruise/module.mk b/engines/cruise/module.mk index 75548cd1ec..96d8f63fea 100644 --- a/engines/cruise/module.mk +++ b/engines/cruise/module.mk @@ -9,6 +9,7 @@ MODULE_OBJS := \ cruise_main.o \ ctp.o \ dataLoader.o \ + debugger.o \ decompiler.o \ delphine-unpack.o \ detection.o \ diff --git a/engines/cruise/object.cpp b/engines/cruise/object.cpp index e0426c7273..044f779f83 100644 --- a/engines/cruise/object.cpp +++ b/engines/cruise/object.cpp @@ -306,4 +306,30 @@ void objectReset(void) { } } +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 diff --git a/engines/cruise/object.h b/engines/cruise/object.h index 57c5287cf4..73c430ad01 100644 --- a/engines/cruise/object.h +++ b/engines/cruise/object.h @@ -26,6 +26,8 @@ #ifndef CRUISE_OBJECT_H #define CRUISE_OBJECT_H +#include "cruise/overlay.h" + namespace Cruise { struct gfxEntryStruct { @@ -52,6 +54,9 @@ objDataStruct *getObjectDataFromOverlay(int ovlIdx, int objIdx); 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 |