diff options
author | Sven Hesse | 2010-10-16 17:25:08 +0000 |
---|---|---|
committer | Sven Hesse | 2010-10-16 17:25:08 +0000 |
commit | c9f9c75a838719921003287af6c44625ee71352c (patch) | |
tree | 8d93f676d24836d758dcfdb64f580964a994c9de /engines/gob | |
parent | 49fc73e3be33163b63d7a3114bdc27032f5ffdde (diff) | |
download | scummvm-rg350-c9f9c75a838719921003287af6c44625ee71352c.tar.gz scummvm-rg350-c9f9c75a838719921003287af6c44625ee71352c.tar.bz2 scummvm-rg350-c9f9c75a838719921003287af6c44625ee71352c.zip |
GOB: Extend debug console variable command a bit
...So that it's actually useful
svn-id: r53544
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/console.cpp | 94 | ||||
-rw-r--r-- | engines/gob/console.h | 6 |
2 files changed, 94 insertions, 6 deletions
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 <var> (<value>)\n"); + DebugPrintf("Usage: var8 <var offset> (<value>)\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 <var offset> (<value>)\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 <var offset> (<value>)\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 <var offset> (<value>)\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 |