diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/debugger.cpp | 45 | ||||
-rw-r--r-- | engines/wage/debugger.h | 1 | ||||
-rw-r--r-- | engines/wage/script.h | 4 |
3 files changed, 48 insertions, 2 deletions
diff --git a/engines/wage/debugger.cpp b/engines/wage/debugger.cpp index 2b6ec612c3..7d01b0b85e 100644 --- a/engines/wage/debugger.cpp +++ b/engines/wage/debugger.cpp @@ -24,6 +24,7 @@ #include "wage/wage.h" #include "wage/debugger.h" #include "wage/entities.h" +#include "wage/script.h" #include "wage/world.h" namespace Wage { @@ -31,15 +32,33 @@ namespace Wage { Debugger::Debugger(WageEngine *engine) : GUI::Debugger(), _engine(engine) { registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); registerCmd("scenes", WRAP_METHOD(Debugger, Cmd_ListScenes)); + registerCmd("script", WRAP_METHOD(Debugger, Cmd_Script)); } Debugger::~Debugger() { } +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + bool Debugger::Cmd_ListScenes(int argc, const char **argv) { int currentScene; - for (uint i = 0; i < _engine->_world->_orderedScenes.size(); i++) { + for (uint i = 1; i < _engine->_world->_orderedScenes.size(); i++) { // #0 is STORAGE@ if (_engine->_world->_player->_currentScene == _engine->_world->_orderedScenes[i]) currentScene = i; @@ -51,4 +70,28 @@ bool Debugger::Cmd_ListScenes(int argc, const char **argv) { return true; } +bool Debugger::Cmd_Script(int argc, const char **argv) { + Script *script = _engine->_world->_player->_currentScene->_script; + + if (argc >= 2) { + int scriptNum = strToInt(argv[1]); + + if (scriptNum) + script = _engine->_world->_orderedScenes[scriptNum]->_script; + else + script = _engine->_world->_globalScript; + } + + if (script == NULL) { + debugPrintf("There is no script for current scene\n"); + return true; + } + + for (uint i = 0; i < script->_scriptText.size(); i++) { + debugPrintf("%d [%04x]: %s\n", i, script->_scriptText[i]->offset, script->_scriptText[i]->line.c_str()); + } + + return true; +} + } // End of namespace Wage diff --git a/engines/wage/debugger.h b/engines/wage/debugger.h index 339a555468..90687760cb 100644 --- a/engines/wage/debugger.h +++ b/engines/wage/debugger.h @@ -35,6 +35,7 @@ protected: WageEngine *_engine; bool Cmd_ListScenes(int argc, const char **argv); + bool Cmd_Script(int argc, const char **argv); public: Debugger(WageEngine *engine); diff --git a/engines/wage/script.h b/engines/wage/script.h index 325733add7..de9476228c 100644 --- a/engines/wage/script.h +++ b/engines/wage/script.h @@ -150,8 +150,10 @@ private: void assign(byte operandType, int uservar, uint16 value); - Common::Array<ScriptText *> _scriptText; void convertToText(); + +public: + Common::Array<ScriptText *> _scriptText; }; } // End of namespace Wage |