diff options
author | James Brown | 2002-04-11 17:19:16 +0000 |
---|---|---|
committer | James Brown | 2002-04-11 17:19:16 +0000 |
commit | 7696081c54a6cac8152a227bd9d0bcc41999f261 (patch) | |
tree | 70859cf2d6be5ad77d7e7c41ed01c20837a0b2d0 /debug.cpp | |
parent | 34747b792a42e8129af60371541e9b7321d4d55f (diff) | |
download | scummvm-rg350-7696081c54a6cac8152a227bd9d0bcc41999f261.tar.gz scummvm-rg350-7696081c54a6cac8152a227bd9d0bcc41999f261.tar.bz2 scummvm-rg350-7696081c54a6cac8152a227bd9d0bcc41999f261.zip |
Large pointless reindentation of all the code. Also fixed a few mistakes
in the object flags code cleanup.
Flags used:
indent *.cpp -br -bap -nbc -lp -ce -cdw -brs -nbad -nbc -npsl -nip
-ts2 -ncs -nbs -npcs -nbap -Tbyte -Tuint32 -Tuint8 -Tuint16 -TArrayHeader
-TMemBlkHeader -TVerbSlot -TObjectData -Tvoid -TImageHeader -TRoomHeader
-TCodeHeader -TResHdr -TBompHeader -TMidiChannelAdl -TGui -TScumm
-TSoundEngine -TPart -TPlayer
svn-id: r3908
Diffstat (limited to 'debug.cpp')
-rw-r--r-- | debug.cpp | 197 |
1 files changed, 110 insertions, 87 deletions
@@ -41,13 +41,14 @@ enum { CMD_ACTOR, CMD_SCRIPTS, CMD_LOAD_ROOM, - CMD_DUMPBOX, - CMD_VAR, + CMD_DUMPBOX, + CMD_VAR, CMD_WATCH, CMD_EXIT }; -void ScummDebugger::attach(Scumm *s) { +void ScummDebugger::attach(Scumm *s) +{ if (_s) detach(); @@ -62,22 +63,21 @@ void ScummDebugger::attach(Scumm *s) { } void BoxTest(int num); -bool ScummDebugger::do_command() { - switch(get_command()) { +bool ScummDebugger::do_command() +{ + switch (get_command()) { case CMD_HELP: - printf( - "Debugger commands:\n" - "(h)elp -> display this help text\n" - "(q)uit -> quit the debugger\n" - "(g)o [numframes] -> increase frame\n" - "(a)ctor [actornum] -> show actor information\n" - "(r)oom roomnum -> load room\n" - "(s)cripts -> show running scripts\n" - "(b)oxes -> list and draw boxen\n" - "(v)ariable -> set or show a variable value\n" - "(w)atch [varnum] -> set a variable watch. 0 means all variables.\n" - "(e)xit -> exit game\n" - ); + printf("Debugger commands:\n" + "(h)elp -> display this help text\n" + "(q)uit -> quit the debugger\n" + "(g)o [numframes] -> increase frame\n" + "(a)ctor [actornum] -> show actor information\n" + "(r)oom roomnum -> load room\n" + "(s)cripts -> show running scripts\n" + "(b)oxes -> list and draw boxen\n" + "(v)ariable -> set or show a variable value\n" + "(w)atch [varnum] -> set a variable watch. 0 means all variables.\n" + "(e)xit -> exit game\n"); return true; case CMD_QUIT: @@ -102,9 +102,9 @@ bool ScummDebugger::do_command() { case CMD_LOAD_ROOM: if (!_parameters[0]) { printf("Enter a room number...\n"); - } else { - int room=atoi(_parameters); - _s->actor[_s->_vars[_s->VAR_EGO]].room=room; + } else { + int room = atoi(_parameters); + _s->actor[_s->_vars[_s->VAR_EGO]].room = room; _s->startScene(room, 0, 0); _s->_fullRedraw = 1; } @@ -112,43 +112,43 @@ bool ScummDebugger::do_command() { case CMD_DUMPBOX: { int num, i = 0; - BoxCoords box; + BoxCoords box; byte *boxm = _s->getBoxMatrixBaseAddr(); - num = _s->getNumBoxes(); + num = _s->getNumBoxes(); printf("Walk matrix:\n"); - for (i=0;i<num;i++) - { - while(*boxm != 0xFF) { - printf ("[%d] ",*boxm); + for (i = 0; i < num; i++) { + while (*boxm != 0xFF) { + printf("[%d] ", *boxm); boxm++; } boxm++; printf("\n"); } - - printf("\nWalk boxes:\n"); - for (i=0; i<num; i++) { + + printf("\nWalk boxes:\n"); + for (i = 0; i < num; i++) { BoxTest(i); _s->getBoxCoordinates(i, &box); - printf("%d: [%d x %d] [%d x %d] [%d x %d] [%d x %d]\n", i, - box.ul.x, box.ul.y, box.ll.x, box.ll.y, - box.ur.x, box.ur.y, box.lr.x, box.lr.y); + printf("%d: [%d x %d] [%d x %d] [%d x %d] [%d x %d]\n", i, + box.ul.x, box.ul.y, box.ll.x, box.ll.y, + box.ur.x, box.ur.y, box.lr.x, box.lr.y); } } return true; case CMD_VAR: if (!_parameters[0]) { - printf("v 123 will show the value of 123, v 123 456 will set the value of 123 to 456.\n"); - } else { + printf + ("v 123 will show the value of 123, v 123 456 will set the value of 123 to 456.\n"); + } else { char *tok = strtok(_parameters, " "); int var = atoi(tok); tok = strtok(NULL, ""); - if (tok) - _s->writeVar(var, atoi(tok)); + if (tok) + _s->writeVar(var, atoi(tok)); printf("Var[%d] = %d\n", var, _s->readVar(var)); - } + } return true; case CMD_WATCH: if (!_parameters[0]) { @@ -156,7 +156,7 @@ bool ScummDebugger::do_command() { _s->_varwatch = -1; } else { _s->_varwatch = atoi(_parameters); - if (_s->_varwatch == 0) + if (_s->_varwatch == 0) printf("Watching all variables\n"); else printf("Watching vars[%d]\n", _s->_varwatch); @@ -165,31 +165,36 @@ bool ScummDebugger::do_command() { case CMD_EXIT: exit(1); - default: /* this line is never reached */ - error("Unknown debug command"); + default: /* this line is never reached */ + error("Unknown debug command"); return true; } } -void ScummDebugger::enter() { +void ScummDebugger::enter() +{ if (_welcome) { _welcome = false; - printf("Debugging Mode entered!, please switch to this console for input.\n" - "Enter h to list all the debug commands\n"); + printf + ("Debugging Mode entered!, please switch to this console for input.\n" + "Enter h to list all the debug commands\n"); + } + while (do_command()) { } - while(do_command()) {} } -void ScummDebugger::on_frame() { - if (_go_amount==0) +void ScummDebugger::on_frame() +{ + if (_go_amount == 0) return; if (!--_go_amount) enter(); } -void ScummDebugger::detach() { +void ScummDebugger::detach() +{ _s->_debugger = NULL; _s = NULL; } @@ -201,20 +206,21 @@ struct DebuggerCommands { }; static const DebuggerCommands debugger_commands[] = { - { "h", 1, CMD_HELP }, - { "q", 1, CMD_QUIT }, - { "g", 1, CMD_GO }, - { "a", 1, CMD_ACTOR }, - { "s", 1, CMD_SCRIPTS }, - { "r", 1, CMD_LOAD_ROOM }, - { "b", 1, CMD_DUMPBOX}, - { "v", 1, CMD_VAR}, - { "w", 1, CMD_WATCH}, - { "e", 1, CMD_EXIT }, - { "" , 0, 0 } + {"h", 1, CMD_HELP}, + {"q", 1, CMD_QUIT}, + {"g", 1, CMD_GO}, + {"a", 1, CMD_ACTOR}, + {"s", 1, CMD_SCRIPTS}, + {"r", 1, CMD_LOAD_ROOM}, + {"b", 1, CMD_DUMPBOX}, + {"v", 1, CMD_VAR}, + {"w", 1, CMD_WATCH}, + {"e", 1, CMD_EXIT}, + {"", 0, 0} }; -int ScummDebugger::get_command() { +int ScummDebugger::get_command() +{ const DebuggerCommands *dc; char *s; int i; @@ -228,22 +234,22 @@ int ScummDebugger::get_command() { return CMD_QUIT; i = strlen(_cmd_buffer); - while (i>0 && _cmd_buffer[i-1]==10) + while (i > 0 && _cmd_buffer[i - 1] == 10) _cmd_buffer[--i] = 0; - if (i==0) + if (i == 0) continue; - -#else // yes we do have readline - if(buf) { - free(buf); + +#else // yes we do have readline + if (buf) { + free(buf); } buf = readline("debug> "); - if(!buf) { - printf("\n"); - return CMD_QUIT; + if (!buf) { + printf("\n"); + return CMD_QUIT; } - if(strlen(buf) == 0) { + if (strlen(buf) == 0) { continue; } add_history(buf); @@ -252,50 +258,67 @@ int ScummDebugger::get_command() { dc = debugger_commands; do { if (!strncmp(buf, dc->text, dc->len)) { - for(s=buf;*s;s++) { - if (*s==32) { s++; break; } + for (s = buf; *s; s++) { + if (*s == 32) { + s++; + break; + } } _parameters = s; return _command = dc->id; } } while ((++dc)->text[0]); - - for(s=buf;*s;s++) - if (*s==32) { *s=0; break; } - printf("Invalid command '%s'. Type 'help' for a list of available commands.\n", buf); + + for (s = buf; *s; s++) + if (*s == 32) { + *s = 0; + break; + } + printf + ("Invalid command '%s'. Type 'help' for a list of available commands.\n", + buf); } while (1); } -void ScummDebugger::printActors(int act) { +void ScummDebugger::printActors(int act) +{ int i; Actor *a; - printf("+--------------------------------------------------------------+\n"); - printf("|# |room| x y |elev|cos|width|box|mov|zp|frame|scale|spd|dir|\n"); - printf("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+\n"); - for(i=1; i<_s->NUM_ACTORS; i++) { - if (act==-1 || act==i) { + printf + ("+--------------------------------------------------------------+\n"); + printf + ("|# |room| x y |elev|cos|width|box|mov|zp|frame|scale|spd|dir|\n"); + printf + ("+--+----+--------+----+---+-----+---+---+--+-----+-----+---+---+\n"); + for (i = 1; i < _s->NUM_ACTORS; i++) { + if (act == -1 || act == i) { a = &_s->actor[i]; if (a->visible) printf("|%2d|%4d|%3d %3d|%4d|%3d|%5d|%3d|%3d|%2d|%5d|%5d|%3d|%3d|\n", - i,a->room,a->x,a->y,a->elevation,a->costume,a->width,a->walkbox,a->moving,a->forceClip,a->frame,a->scalex,a->speedx,a->facing); + i, a->room, a->x, a->y, a->elevation, a->costume, a->width, + a->walkbox, a->moving, a->forceClip, a->frame, a->scalex, + a->speedx, a->facing); } } - printf("+--------------------------------------------------------------+\n"); + printf + ("+--------------------------------------------------------------+\n"); } -void ScummDebugger::printScripts() { +void ScummDebugger::printScripts() +{ int i; ScriptSlot *ss; printf("+---------------------------------+\n"); printf("|# |num|sta|typ|un1|un2|fc|cut|un5|\n"); printf("+--+---+---+---+---+---+--+---+---+\n"); - for(i=0; i<25; i++) { + for (i = 0; i < 25; i++) { ss = &_s->vm.slot[i]; if (ss->number) { printf("|%2d|%3d|%3d|%3d|%3d|%3d|%2d|%3d|%3d|\n", - i, ss->number, ss->status, ss->where, ss->unk1, ss->unk2, ss->freezeCount, ss->cutsceneOverride, ss->unk5); + i, ss->number, ss->status, ss->where, ss->unk1, ss->unk2, + ss->freezeCount, ss->cutsceneOverride, ss->unk5); } } printf("+---------------------------------+\n"); |