Added new debug command to dump scripts execution status.

svn-id: r30840
This commit is contained in:
Nicola Mettifogo 2008-02-09 22:07:51 +00:00
parent bc257fc378
commit cf724e889c
6 changed files with 35 additions and 0 deletions

View File

@ -46,6 +46,7 @@ Debugger::Debugger(Parallaction *vm)
DCmd_Register("locations", WRAP_METHOD(Debugger, Cmd_Locations));
DCmd_Register("gfxobjects", WRAP_METHOD(Debugger, Cmd_GfxObjects));
DCmd_Register("set", WRAP_METHOD(Debugger, Cmd_Set));
DCmd_Register("programs", WRAP_METHOD(Debugger, Cmd_Programs));
}
@ -216,4 +217,25 @@ bool Debugger::Cmd_Set(int argc, const char** argv) {
return true;
}
bool Debugger::Cmd_Programs(int argc, const char** argv) {
ProgramList::iterator b = _vm->_programs.begin();
ProgramList::iterator e = _vm->_programs.end();
const char *status[] = { "idle", "running", "completed" };
int i = 1;
DebugPrintf("+---+--------------------+----------+\n"
"| # | bound animation | status |\n"
"+---+--------------------+----------+\n");
for ( ; b != e; b++, i++) {
Program *p = *b;
DebugPrintf("|%3i|%-20s|%-10s|\n", i, p->_anim->_name, status[p->_status] );
}
DebugPrintf("+---+--------------------+---------+\n");
return true;
}
} // namespace Parallaction

View File

@ -30,6 +30,7 @@ protected:
bool Cmd_GfxObjects(int argc, const char **argv);
bool Cmd_GfxFeature(int argc, const char** argv);
bool Cmd_Set(int argc, const char** argv);
bool Cmd_Programs(int argc, const char** argv);
};
} // End of namespace Parallaction

View File

@ -489,6 +489,7 @@ DECLARE_INSTRUCTION_OPCODE(endscript) {
if ((_instRunCtxt.anim->_flags & kFlagsLooping) == 0) {
_instRunCtxt.anim->_flags &= ~kFlagsActing;
runCommands(_instRunCtxt.anim->_commands, _instRunCtxt.anim);
_instRunCtxt.program->_status = kProgramDone;
}
_instRunCtxt.program->_ip = _instRunCtxt.program->_instructions.begin();

View File

@ -180,6 +180,7 @@ DECLARE_INSTRUCTION_OPCODE(endscript) {
if ((_instRunCtxt.anim->_flags & kFlagsLooping) == 0) {
_instRunCtxt.anim->_flags &= ~kFlagsActing;
runCommands(_instRunCtxt.anim->_commands, _instRunCtxt.anim);
_instRunCtxt.program->_status = kProgramDone;
}
_instRunCtxt.program->_ip = _instRunCtxt.program->_instructions.begin();
@ -386,6 +387,8 @@ void Parallaction_ns::runScripts() {
InstructionList::iterator inst = (*it)->_ip;
while (((*inst)->_index != INST_SHOW) && (a->_flags & kFlagsActing)) {
(*it)->_status = kProgramRunning;
debugC(9, kDebugExec, "Animation: %s, instruction: %s", a->_name, _instructionNamesRes[(*inst)->_index - 1]);
_instRunCtxt.inst = inst;

View File

@ -85,6 +85,7 @@ Program::Program() {
_loopCounter = 0;
_locals = new LocalVariable[NUM_LOCALS];
_numLocals = 0;
_status = kProgramIdle;
}
Program::~Program() {

View File

@ -363,6 +363,11 @@ struct Instruction {
};
enum {
kProgramIdle, // awaiting execution
kProgramRunning, // running
kProgramDone // execution completed
};
struct Program {
Animation *_anim;
@ -377,6 +382,8 @@ struct Program {
InstructionList::iterator _loopStart;
InstructionList _instructions;
uint32 _status;
Program();
~Program();