From e66883d5cbae4d92264cd1c2b5784af79d30f152 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 21 Jan 2015 14:06:13 +0200 Subject: ZVISION: Add console commands to manipulate state flags and variables --- engines/zvision/core/console.cpp | 38 ++++++++++++++++++++++++++++++++++++++ engines/zvision/core/console.h | 2 ++ 2 files changed, 40 insertions(+) (limited to 'engines/zvision') diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index e54e986bd7..f5cacb582c 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -54,6 +54,8 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); registerCmd("dumpimage", WRAP_METHOD(Console, cmdDumpImage)); + registerCmd("statevalue", WRAP_METHOD(Console, cmdStateValue)); + registerCmd("stateflag", WRAP_METHOD(Console, cmdStateFlag)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -329,4 +331,40 @@ bool Console::cmdDumpImage(int argc, const char **argv) { return true; } +bool Console::cmdStateValue(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("Use %s to show the value of a state variable\n", argv[0]); + debugPrintf("Use %s to set the value of a state variable\n", argv[0]); + return true; + } + + int valueNum = atoi(argv[1]); + int newValue = (argc > 2) ? atoi(argv[2]) : -1; + + if (argc == 2) + debugPrintf("[%d] = %d\n", valueNum, _engine->getScriptManager()->getStateValue(valueNum)); + else if (argc == 3) + _engine->getScriptManager()->setStateValue(valueNum, newValue); + + return true; +} + +bool Console::cmdStateFlag(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("Use %s to show the value of a state flag\n", argv[0]); + debugPrintf("Use %s to set the value of a state flag\n", argv[0]); + return true; + } + + int valueNum = atoi(argv[1]); + int newValue = (argc > 2) ? atoi(argv[2]) : -1; + + if (argc == 2) + debugPrintf("[%d] = %d\n", valueNum, _engine->getScriptManager()->getStateFlag(valueNum)); + else if (argc == 3) + _engine->getScriptManager()->setStateFlag(valueNum, newValue); + + return true; +} + } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index ffce87869f..ac834185a0 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -48,6 +48,8 @@ private: bool cmdDumpFile(int argc, const char **argv); bool cmdDumpFiles(int argc, const char **argv); bool cmdDumpImage(int argc, const char **argv); + bool cmdStateValue(int argc, const char **argv); + bool cmdStateFlag(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3