Skip to content

Commit

Permalink
ZVISION: Add console commands to manipulate state flags and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
bluegr committed Jan 21, 2015
1 parent 46fe6b6 commit e66883d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
38 changes: 38 additions & 0 deletions engines/zvision/core/console.cpp
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 <valuenum> to show the value of a state variable\n", argv[0]);
debugPrintf("Use %s <valuenum> <newvalue> 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 <flagnum> to show the value of a state flag\n", argv[0]);
debugPrintf("Use %s <flagnum> <newvalue> 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
2 changes: 2 additions & 0 deletions engines/zvision/core/console.h
Expand Up @@ -48,6 +48,8 @@ class Console : public GUI::Debugger {
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
Expand Down

0 comments on commit e66883d

Please sign in to comment.