[Scummvm-cvs-logs] CVS: scummvm/scumm debug.cpp,1.9,1.10 debug.h,1.1.1.1,1.2 scumm.h,1.80,1.81
Max Horn
fingolfin at users.sourceforge.net
Sat Dec 14 16:40:02 CET 2002
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv32158
Modified Files:
debug.cpp debug.h scumm.h
Log Message:
debugger can now use the console (experimental, and thus disabled by default)
Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debug.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- debug.cpp 9 Dec 2002 01:27:39 -0000 1.9
+++ debug.cpp 15 Dec 2002 00:39:33 -0000 1.10
@@ -29,9 +29,14 @@
#include "debug.h"
#include "common/util.h"
+#ifdef USE_CONSOLE
+#include "gui/console.h"
+#define printf _s->_debuggerDialog->printf
+#else
#ifdef HAVE_READLINE
#include "debugrl.h"
#endif
+#endif
enum {
CMD_INVALID,
@@ -50,7 +55,6 @@
extern uint16 _debugLevel;
-
void ScummDebugger::attach(Scumm *s)
{
if (_s)
@@ -66,9 +70,9 @@
#endif
}
-bool ScummDebugger::do_command()
+bool ScummDebugger::do_command(int cmd)
{
- switch (get_command()) {
+ switch (cmd) {
case CMD_HELP:
printf("Debugger commands:\n"
"(a)ctor [actornum] -> show actor information\n"
@@ -174,16 +178,48 @@
}
}
+#ifdef USE_CONSOLE
+bool ScummDebugger::debuggerInputCallback(ConsoleDialog *console, const char *input, void *refCon)
+{
+ ScummDebugger *debugger = (ScummDebugger *)refCon;
+ int cmd = debugger->parse_command((char *)input);
+ if (cmd >= 0) {
+ return debugger->do_command(cmd);
+ } else {
+ for (char *s = (char *)input; *s; s++) {
+ if (*s == ' ') {
+ *s = 0;
+ break;
+ }
+ }
+ debugger->printf("Invalid command '%s'. Type 'help' for a list of available commands.\n", input);
+ return true;
+ }
+}
+#endif
+
void ScummDebugger::enter()
{
+#ifdef USE_CONSOLE
+ if (!_s->_debuggerDialog)
+ _s->_debuggerDialog = new ConsoleDialog(_s->_newgui);
+ _s->_debuggerDialog->setInputeCallback(debuggerInputCallback, this);
+ if (_welcome) {
+ _welcome = false;
+ printf("Debugging Mode entered!\n"
+ "Enter h to list all the debug commands\n");
+ }
+ _s->_debuggerDialog->runModal();
+#else
if (_welcome) {
_welcome = false;
printf
("Debugging Mode entered!, please switch to this console for input.\n"
"Enter h to list all the debug commands\n");
}
- while (do_command()) {
+ while (do_command(get_command())) {
}
+#endif
}
@@ -191,7 +227,8 @@
{
if (_go_amount == 0)
return;
- if (!--_go_amount)
+ --_go_amount;
+ if (!_go_amount)
enter();
}
@@ -200,6 +237,9 @@
{
_s->_debugger = NULL;
_s = NULL;
+#ifdef USE_CONSOLE
+ _s->_debuggerDialog->setInputeCallback(0, 0);
+#endif
}
struct DebuggerCommands {
@@ -225,7 +265,6 @@
int ScummDebugger::get_command()
{
- const DebuggerCommands *dc;
char *s;
int i;
char *buf;
@@ -259,22 +298,12 @@
add_history(buf);
#endif
- dc = debugger_commands;
- do {
- if (!strncmp(buf, dc->text, dc->len)) {
- for (s = buf; *s; s++) {
- if (*s == 32) {
- s++;
- break;
- }
- }
- _parameters = s;
- return _command = dc->id;
- }
- } while ((++dc)->text[0]);
+ int cmd = parse_command(buf);
+ if (cmd >= 0)
+ return cmd;
for (s = buf; *s; s++)
- if (*s == 32) {
+ if (*s == ' ') {
*s = 0;
break;
}
@@ -282,25 +311,46 @@
} while (1);
}
+int ScummDebugger::parse_command(char *buf)
+{
+ const DebuggerCommands *dc;
+ char *s;
+ dc = debugger_commands;
+ do {
+ if (!strncmp(buf, dc->text, dc->len)) {
+ for (s = buf; *s; s++) {
+ if (*s == ' ') {
+ s++;
+ break;
+ }
+ }
+ _parameters = s;
+ return _command = dc->id;
+ }
+ } while ((++dc)->text[0]);
+
+ return -1;
+}
+
void ScummDebugger::printActors(int act)
{
int i;
Actor *a;
- printf("+------------------------------------------------------------------+\n");
- printf("|# |room| x y |elev|cos|width|box|mov|zp|frame|scale|spd|dir|cls|\n");
- printf("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+---+\n");
+ printf("+-----------------------------------------------------------------+\n");
+ printf("|# |room| x | y |elev|cos|width|box|mov|zp|frame|scale|spd|dir|cls|\n");
+ printf("+--+----+---+---+----+---+-----+---+---+--+-----+-----+---+---+---+\n");
for (i = 1; i < _s->NUM_ACTORS; i++) {
if (act == -1 || act == i) {
a = &_s->_actors[i];
if (a->visible)
- printf("|%2d|%4d|%3d %3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|$%02x|\n",
+ printf("|%2d|%4d|%3d|%3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|$%02x|\n",
a->number, a->room, a->x, a->y, a->elevation, a->costume,
a->width, a->walkbox, a->moving, a->forceClip, a->frame,
a->scalex, a->speedx, a->facing, int(_s->_classData[a->number]&0xFF));
}
}
- printf("+--------------------------------------------------------------+\n");
+ printf("+-----------------------------------------------------------------+\n");
}
void ScummDebugger::printScripts()
@@ -308,7 +358,7 @@
int i;
ScriptSlot *ss;
- printf("+------------------------------\n");
+ printf("+-----------------------------+\n");
printf("|# |num|sta|typ|un1|un2|fc|cut|\n");
printf("+--+---+---+---+---+---+--+---+\n");
for (i = 0; i < 25; i++) {
@@ -319,7 +369,7 @@
ss->freezeCount, ss->cutsceneOverride);
}
}
- printf("+-------------------------------------+\n");
+ printf("+-----------------------------+\n");
}
@@ -365,9 +415,6 @@
/************ ENDER: Temporary debug code for boxen **************/
-/*
-int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color)
-*/
static int gfxPrimitivesCompareInt(const void *a, const void *b);
@@ -386,7 +433,7 @@
_s->_screenStartStrip * 8 + (_s->camera._cur.y - (_s->_realHeight / 2)) * _s->_realWidth;
}
-static void hline(Scumm *scumm, int x1, int x2, int y, byte color)
+static void hlineColor(Scumm *scumm, int x1, int x2, int y, byte color)
{
byte *ptr;
@@ -474,7 +521,7 @@
qsort(gfxPrimitivesPolyInts, ints, sizeof(int), gfxPrimitivesCompareInt);
for (i = 0; (i < ints); i += 2) {
- hline(scumm, gfxPrimitivesPolyInts[i], gfxPrimitivesPolyInts[i + 1], y, color);
+ hlineColor(scumm, gfxPrimitivesPolyInts[i], gfxPrimitivesPolyInts[i + 1], y, color);
}
}
Index: debug.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debug.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- debug.h 21 Aug 2002 16:07:27 -0000 1.1.1.1
+++ debug.h 15 Dec 2002 00:39:33 -0000 1.2
@@ -23,7 +23,18 @@
class Scumm;
-struct ScummDebugger {
+//
+// HACK FIXME TODO - enable this for the PURELY EXPERIMENTAL console debug mode
+//
+//#define USE_CONSOLE 1
+
+
+class ScummDebugger {
+public:
+ void on_frame();
+ void attach(Scumm *s);
+
+protected:
Scumm *_s;
byte _command;
char *_parameters;
@@ -34,11 +45,10 @@
char _cmd_buffer[256];
- void on_frame();
- bool do_command();
+ bool do_command(int cmd);
void enter();
int get_command();
- void attach(Scumm *s);
+ int parse_command(char *buf);
void detach();
void printActors(int act);
@@ -47,6 +57,10 @@
void printBox(int box);
void printBoxes();
void boxTest(int box);
+
+#ifdef USE_CONSOLE
+ static bool ScummDebugger::debuggerInputCallback(ConsoleDialog *console, const char *input, void *refCon);
+#endif
};
#endif
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- scumm.h 14 Dec 2002 10:46:00 -0000 1.80
+++ scumm.h 15 Dec 2002 00:39:33 -0000 1.81
@@ -32,13 +32,14 @@
class GameDetector;
class NewGui;
class Dialog;
+class ConsoleDialog;
class Scumm;
class IMuse;
class IMuseDigital;
class Actor;
class Sound;
class Bundle;
-struct ScummDebugger;
+class ScummDebugger;
class Serializer;
struct FindObjectInRoom;
@@ -337,7 +338,7 @@
Dialog *_pauseDialog;
Dialog *_optionsDialog;
Dialog *_saveLoadDialog;
- Dialog *_debuggerDialog;
+ ConsoleDialog *_debuggerDialog;
int runDialog(Dialog *dialog);
void pauseDialog();
More information about the Scummvm-git-logs
mailing list