aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorEugene Sandulenko2009-06-06 17:43:26 +0000
committerEugene Sandulenko2009-06-06 17:43:26 +0000
commited797c07090a8c41f3f2451f35aa0cc8d5aa4544 (patch)
treecad583742f34d8e3bfc372217af6f6c056d02fbe /engines/agi
parent531b96bbbeca327ac6a68edb6831d669b68fee17 (diff)
downloadscummvm-rg350-ed797c07090a8c41f3f2451f35aa0cc8d5aa4544.tar.gz
scummvm-rg350-ed797c07090a8c41f3f2451f35aa0cc8d5aa4544.tar.bz2
scummvm-rg350-ed797c07090a8c41f3f2451f35aa0cc8d5aa4544.zip
Implement debug commands "room" and "bt"
svn-id: r41249
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.h8
-rw-r--r--engines/agi/console.cpp35
-rw-r--r--engines/agi/console.h2
-rw-r--r--engines/agi/op_cmd.cpp15
4 files changed, 57 insertions, 3 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 4144304ca0..7793365c95 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -87,6 +87,8 @@ typedef signed int Err;
#define ADD_PIC 1
#define ADD_VIEW 2
+#define CMD_BSIZE 12
+
enum AgiGameID {
GID_AGIDEMO,
GID_BC,
@@ -487,6 +489,11 @@ private:
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 @@ struct AgiGame {
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 */
diff --git a/engines/agi/console.cpp b/engines/agi/console.cpp
index 09abb47525..37e9258136 100644
--- a/engines/agi/console.cpp
+++ b/engines/agi/console.cpp
@@ -52,6 +52,8 @@ Console::Console(AgiEngine *vm) : GUI::Debugger() {
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 @@ bool Console::Cmd_Cont(int argc, const char **argv) {
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;
}
diff --git a/engines/agi/console.h b/engines/agi/console.h
index c435a70188..b75abe2ccd 100644
--- a/engines/agi/console.h
+++ b/engines/agi/console.h
@@ -71,6 +71,8 @@ private:
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;
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index 5d08313b52..364a999509 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1753,8 +1753,6 @@ static void (*agiCommand[183])(uint8 *) = {
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,6 +1763,11 @@ int AgiEngine::runLogic(int n) {
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) {
@@ -1795,6 +1798,9 @@ int AgiEngine::runLogic(int n) {
}
}
+ _game.execStack.back().curIP = ip;
+ processEvents();
+
switch (op = *(code + ip++)) {
case 0xff: // if (open/close)
testIfCode(n);
@@ -1812,6 +1818,7 @@ int AgiEngine::runLogic(int n) {
}
break;
case 0x00: // return
+ _game.execStack.pop_back();
return 1;
default:
num = logicNamesCmd[op].numArgs;
@@ -1819,7 +1826,7 @@ int AgiEngine::runLogic(int n) {
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 @@ int AgiEngine::runLogic(int n) {
break;
}
+ _game.execStack.pop_back();
+
return 0; // after executing new.room()
}