From: Justin Wind Date: Fri, 13 Apr 2012 22:01:43 +0000 (-0700) Subject: cleaned up verbosity in vm-dcpu16.c X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=f31ad321a9be61f23e33ba631b962c51fc8650c0;p=dcpu16 cleaned up verbosity in vm-dcpu16.c --- diff --git a/vm-dcpu16.c b/vm-dcpu16.c index df86455..b59c253 100644 --- a/vm-dcpu16.c +++ b/vm-dcpu16.c @@ -61,7 +61,7 @@ void usage_(char *prog, unsigned int full) { if (full) { fprintf(f, "\nOptions:\n" "\t [file] -- ram image to load initially\n" - "\t -v -- verbose execution tracing\n" + "\t -v -- displays slightly more information\n" "\t -h -- this screen\n"); fprintf(f, "\n%78s\n", src_id_); @@ -190,7 +190,7 @@ struct command_ { COMMAND_IMPL(quit) { (void)vm, (void)arg_count, (void)arg_vector; - VERBOSE_PRINTF("done\n"); + return -1; } COMMAND_HELP(quit) { @@ -331,12 +331,11 @@ COMMAND_IMPL(step) { } while (count--) { - VERBOSE_PRINTF("executing next cycle, instruction: "); - dcpu16_disassemble_print(vm, vm->pc), printf("\n"); - + dcpu16_disassemble_print(vm, vm->pc); + printf("\n"); dcpu16_step(vm); - if (opt_.verbose) + if (count > 1 && opt_.verbose) dcpu16_state_print(vm); } @@ -364,8 +363,12 @@ COMMAND_IMPL(run) { while(running_) { dcpu16_step(vm); - if (opt_.verbose) + if (opt_.verbose > 1) dcpu16_state_print(vm); + else if (opt_.verbose) { + dcpu16_disassemble_print(vm, vm->pc); + printf("\n"); + } } /* restore the old interrupt signal handler */ @@ -374,7 +377,7 @@ COMMAND_IMPL(run) { return -1; } - VERBOSE_PRINTF("interrupted...\n"); + printf("interrupted...\n"); return 0; } @@ -382,7 +385,8 @@ COMMAND_HELP(run) { fprintf(f, "\trun\n"); if (summary) return; - fprintf(f, "Begins executing continuously.\n"); + fprintf(f, "Begins executing continuously.\n" + "May be interrupted with SIGINT.\n"); } /* gather all these together into a searchable table */ @@ -428,7 +432,7 @@ COMMAND_HELP(help) { fprintf(f, "\thelp [command]\n"); if (summary) return; - fprintf(f, "Displays a list of available commands, or help on a specific command.\n"); + fprintf(f, "Displays a list of available commands, or detailed help on a specific command.\n"); } @@ -466,7 +470,7 @@ int main(int argc, char **argv) { argv += optind; if ((vm = dcpu16_new()) == NULL) { - fprintf(stderr, "could not allocate new dcpu instance\n"); + fprintf(stderr, "could not allocate new dcpu16 instance\n"); exit(EX_UNAVAILABLE); }