[Scummvm-cvs-logs] SF.net SVN: scummvm:[41249] scummvm/trunk/engines/agi
sev at users.sourceforge.net
sev at users.sourceforge.net
Sat Jun 6 19:43:26 CEST 2009
Revision: 41249
http://scummvm.svn.sourceforge.net/scummvm/?rev=41249&view=rev
Author: sev
Date: 2009-06-06 17:43:26 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
Implement debug commands "room" and "bt"
Modified Paths:
--------------
scummvm/trunk/engines/agi/agi.h
scummvm/trunk/engines/agi/console.cpp
scummvm/trunk/engines/agi/console.h
scummvm/trunk/engines/agi/op_cmd.cpp
Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h 2009-06-06 17:43:04 UTC (rev 41248)
+++ scummvm/trunk/engines/agi/agi.h 2009-06-06 17:43:26 UTC (rev 41249)
@@ -87,6 +87,8 @@
#define ADD_PIC 1
#define ADD_VIEW 2
+#define CMD_BSIZE 12
+
enum AgiGameID {
GID_AGIDEMO,
GID_BC,
@@ -487,6 +489,11 @@
bool _authenticAmiga; ///< Don't use border around buttons in Amiga-style mode.
};
+struct ScriptPos {
+ int script;
+ int curIP;
+};
+
#define EGO_VIEW_TABLE 0
#define HORIZON 36
#define _WIDTH 160
@@ -532,6 +539,7 @@
int inputMode; /**< keyboard input mode */
int inputEnabled; /**< keyboard input enabled */
int lognum; /**< current logic number */
+ Common::Array<ScriptPos> execStack;
// internal flags
int playerControl; /**< player is in control */
Modified: scummvm/trunk/engines/agi/console.cpp
===================================================================
--- scummvm/trunk/engines/agi/console.cpp 2009-06-06 17:43:04 UTC (rev 41248)
+++ scummvm/trunk/engines/agi/console.cpp 2009-06-06 17:43:26 UTC (rev 41249)
@@ -52,6 +52,8 @@
DCmd_Register("setvar", WRAP_METHOD(Console, Cmd_SetVar));
DCmd_Register("setflag", WRAP_METHOD(Console, Cmd_SetFlag));
DCmd_Register("setobj", WRAP_METHOD(Console, Cmd_SetObj));
+ DCmd_Register("room", WRAP_METHOD(Console, Cmd_Room));
+ DCmd_Register("bt", WRAP_METHOD(Console, Cmd_BT));
}
Console::~Console() {
@@ -243,6 +245,39 @@
return true;
}
+bool Console::Cmd_Room(int argc, const char **argv) {
+ DebugPrintf("Current room: %d\n", _vm->getvar(0));
+
+ return true;
+}
+
+bool Console::Cmd_BT(int argc, const char **argv) {
+ DebugPrintf("Current script: %d\nStack depth: %d\n", _vm->_game.lognum, _vm->_game.execStack.size());
+
+ uint8 *code = NULL;
+ uint8 op = 0;
+ uint8 p[CMD_BSIZE] = { 0 };
+ int num;
+ Common::Array<ScriptPos>::iterator it;
+
+ for (it = _vm->_game.execStack.begin(); it != _vm->_game.execStack.end(); it++) {
+ code = _vm->_game.logics[it->script].data;
+ op = code[it->curIP];
+ num = logicNamesCmd[op].numArgs;
+ memmove(p, &code[it->curIP], num);
+ memset(p + num, 0, CMD_BSIZE - num);
+
+ DebugPrintf("%d(%d): %s(", it->script, it->curIP, logicNamesCmd[op].name);
+
+ for (int i = 0; i < num; i++)
+ DebugPrintf("%d, ", p[i]);
+
+ DebugPrintf(")\n");
+ }
+
+ return true;
+}
+
PreAGI_Console::PreAGI_Console(PreAgiEngine *vm) {
_vm = vm;
}
Modified: scummvm/trunk/engines/agi/console.h
===================================================================
--- scummvm/trunk/engines/agi/console.h 2009-06-06 17:43:04 UTC (rev 41248)
+++ scummvm/trunk/engines/agi/console.h 2009-06-06 17:43:26 UTC (rev 41249)
@@ -71,6 +71,8 @@
bool Cmd_Step(int argc, const char **argv);
bool Cmd_Debug(int argc, const char **argv);
bool Cmd_Cont(int argc, const char **argv);
+ bool Cmd_Room(int argc, const char **argv);
+ bool Cmd_BT(int argc, const char **argv);
private:
AgiEngine *_vm;
Modified: scummvm/trunk/engines/agi/op_cmd.cpp
===================================================================
--- scummvm/trunk/engines/agi/op_cmd.cpp 2009-06-06 17:43:04 UTC (rev 41248)
+++ scummvm/trunk/engines/agi/op_cmd.cpp 2009-06-06 17:43:26 UTC (rev 41249)
@@ -1753,8 +1753,6 @@
cmd_adj_ego_move_to_x_y
};
-#define CMD_BSIZE 12
-
/**
* Execute a logic script
* @param n Number of the logic resource to execute
@@ -1765,7 +1763,12 @@
uint8 *code = NULL;
g_agi = this;
int num = 0;
+ ScriptPos sp;
+ sp.script = n;
+ sp.curIP = 0;
+ _game.execStack.push_back(sp);
+
// If logic not loaded, load it
if (~_game.dirLogic[n].flags & RES_LOADED) {
debugC(4, kDebugLevelScripts, "logic %d not loaded!", n);
@@ -1795,6 +1798,9 @@
}
}
+ _game.execStack.back().curIP = ip;
+ processEvents();
+
switch (op = *(code + ip++)) {
case 0xff: // if (open/close)
testIfCode(n);
@@ -1812,6 +1818,7 @@
}
break;
case 0x00: // return
+ _game.execStack.pop_back();
return 1;
default:
num = logicNamesCmd[op].numArgs;
@@ -1819,7 +1826,7 @@
memset(p + num, 0, CMD_BSIZE - num);
debugC(2, kDebugLevelScripts, "%s(%d %d %d)", logicNamesCmd[op].name, p[0], p[1], p[2]);
- agiCommand[op] (p);
+ agiCommand[op](p);
ip += num;
}
@@ -1827,6 +1834,8 @@
break;
}
+ _game.execStack.pop_back();
+
return 0; // after executing new.room()
}
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