From c9f9c75a838719921003287af6c44625ee71352c Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sat, 16 Oct 2010 17:25:08 +0000 Subject: GOB: Extend debug console variable command a bit ...So that it's actually useful svn-id: r53544 --- engines/gob/console.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++--- engines/gob/console.h | 6 +++- 2 files changed, 94 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/gob/console.cpp b/engines/gob/console.cpp index 1909d1fcf5..247911402f 100644 --- a/engines/gob/console.cpp +++ b/engines/gob/console.cpp @@ -30,7 +30,11 @@ namespace Gob { GobConsole::GobConsole(GobEngine *vm) : GUI::Debugger(), _vm(vm) { - DCmd_Register("var", WRAP_METHOD(GobConsole, Cmd_Var)); + DCmd_Register("varSize", WRAP_METHOD(GobConsole, cmd_varSize)); + DCmd_Register("var8", WRAP_METHOD(GobConsole, cmd_var8)); + DCmd_Register("var16", WRAP_METHOD(GobConsole, cmd_var16)); + DCmd_Register("var32", WRAP_METHOD(GobConsole, cmd_var32)); + DCmd_Register("varString", WRAP_METHOD(GobConsole, cmd_varString)); } GobConsole::~GobConsole() { @@ -42,20 +46,100 @@ void GobConsole::preEnter() { void GobConsole::postEnter() { } -bool GobConsole::Cmd_Var(int argc, const char **argv) { +bool GobConsole::cmd_varSize(int argc, const char **argv) { + DebugPrintf("Size of the variable space: %d bytes\n", _vm->_inter->_variables->getSize()); + return true; +} + +bool GobConsole::cmd_var8(int argc, const char **argv) { if (argc == 1) { - DebugPrintf("Usage: var ()\n"); + DebugPrintf("Usage: var8 ()\n"); return true; } uint32 varNum = atoi(argv[1]); + if (varNum >= _vm->_inter->_variables->getSize()) { + DebugPrintf("Variable offset out of range\n"); + return true; + } + if (argc > 2) { uint32 varVal = atoi(argv[2]); - _vm->_inter->_variables->writeVar32(varNum, varVal); + _vm->_inter->_variables->writeOff8(varNum, varVal); + } + + DebugPrintf("var8_%d = %d\n", varNum, _vm->_inter->_variables->readOff8(varNum)); + + return true; +} + +bool GobConsole::cmd_var16(int argc, const char **argv) { + if (argc == 1) { + DebugPrintf("Usage: var16 ()\n"); + return true; + } + + uint32 varNum = atoi(argv[1]); + + if ((varNum + 1) >= _vm->_inter->_variables->getSize()) { + DebugPrintf("Variable offset out of range\n"); + return true; + } + + if (argc > 2) { + uint32 varVal = atoi(argv[2]); + _vm->_inter->_variables->writeOff16(varNum, varVal); + } + + DebugPrintf("var16_%d = %d\n", varNum, _vm->_inter->_variables->readOff16(varNum)); + + return true; +} + +bool GobConsole::cmd_var32(int argc, const char **argv) { + if (argc == 1) { + DebugPrintf("Usage: var32 ()\n"); + return true; + } + + uint32 varNum = atoi(argv[1]); + + if ((varNum + 3) >= _vm->_inter->_variables->getSize()) { + DebugPrintf("Variable offset out of range\n"); + return true; + } + + if (argc > 2) { + uint32 varVal = atoi(argv[2]); + _vm->_inter->_variables->writeOff32(varNum, varVal); + } + + DebugPrintf("var8_%d = %d\n", varNum, _vm->_inter->_variables->readOff32(varNum)); + + return true; +} + +bool GobConsole::cmd_varString(int argc, const char **argv) { + if (argc == 1) { + DebugPrintf("Usage: varString ()\n"); + return true; + } + + uint32 varNum = atoi(argv[1]); + + if (varNum >= _vm->_inter->_variables->getSize()) { + DebugPrintf("Variable offset out of range\n"); + return true; + } + + if (argc > 2) { + uint32 maxLength = _vm->_inter->_variables->getSize() - varNum; + + Common::strlcpy(_vm->_inter->_variables->getAddressOffString(varNum), argv[2], maxLength); } - DebugPrintf("%d = %d\n", varNum, _vm->_inter->_variables->readVar32(varNum)); + DebugPrintf("varString_%d = \"%s\"\n", varNum, _vm->_inter->_variables->getAddressOffString(varNum)); return true; } diff --git a/engines/gob/console.h b/engines/gob/console.h index 25b2ac471e..5dc6096062 100644 --- a/engines/gob/console.h +++ b/engines/gob/console.h @@ -44,7 +44,11 @@ protected: private: GobEngine *_vm; - bool Cmd_Var(int argc, const char **argv); + bool cmd_varSize(int argc, const char **argv); + bool cmd_var8(int argc, const char **argv); + bool cmd_var16(int argc, const char **argv); + bool cmd_var32(int argc, const char **argv); + bool cmd_varString(int argc, const char **argv); }; } // End of namespace Mohawk -- cgit v1.2.3