all repos — mgba @ 7334b89833116c4784893eebbd373cf7eecccbfa

mGBA Game Boy Advance Emulator

Add more command line options + usage
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Apr 2014 21:32:40 -0700
commit

7334b89833116c4784893eebbd373cf7eecccbfa

parent

7c356ffd07a7fdd456748452df14bbfd4576bd40

1 files changed, 40 insertions(+), 4 deletions(-)

jump to
M src/platform/commandline.csrc/platform/commandline.c

@@ -15,6 +15,7 @@ static const char* _defaultFilename = "test.rom";

static const struct option _options[] = { { "bios", 1, 0, 'b' }, + { "debug", 1, 0, 'd' }, { "gdb", 1, 0, 'g' }, { 0, 0, 0, 0 } };

@@ -27,14 +28,18 @@ opts->width = 240;

opts->height = 160; opts->fullscreen = 0; + int multiplier = 1; int ch; - while ((ch = getopt_long(argc, argv, "b:dfg", _options, 0)) != -1) { + while ((ch = getopt_long(argc, argv, "234b:dfg", _options, 0)) != -1) { switch (ch) { case 'b': opts->biosFd = open(optarg, O_RDONLY); break; #ifdef USE_CLI_DEBUGGER case 'd': + if (opts->debuggerType != DEBUGGER_NONE) { + return 0; + } opts->debuggerType = DEBUGGER_CLI; break; #endif

@@ -43,19 +48,37 @@ opts->fullscreen = 1;

break; #ifdef USE_GDB_STUB case 'g': + if (opts->debuggerType != DEBUGGER_NONE) { + return 0; + } opts->debuggerType = DEBUGGER_GDB; break; #endif + case '2': + multiplier = 2; + break; + case '3': + multiplier = 3; + break; + case '4': + multiplier = 4; + break; + default: + return 0; } } argc -= optind; argv += optind; - if (argc) { + if (argc == 1) { opts->fname = argv[0]; - } else { + } else if (argc == 0) { opts->fname = _defaultFilename; + } else { + return 0; } opts->fd = open(opts->fname, O_RDONLY); + opts->width *= multiplier; + opts->height *= multiplier; return 1; }

@@ -81,6 +104,7 @@ #endif

#ifdef USE_GDB_STUB case DEBUGGER_GDB: GDBStubCreate(&debugger->gdb); + GDBStubListen(&debugger->gdb, 2345, 0); break; #endif case DEBUGGER_NONE:

@@ -94,5 +118,17 @@ return &debugger->d;

} void usage(const char* arg0) { - printf("%s: bad arguments\n", arg0); + printf("usage: %s [option ...] file\n", arg0); + printf("\nOptions:\n"); + printf(" -2 2x viewport\n"); + printf(" -3 3x viewport\n"); + printf(" -4 4x viewport\n"); + printf(" -b, --bios FILE GBA BIOS file to use\n"); +#ifdef USE_CLI_DEBUGGER + printf(" -d, --debug Use command-line debugger\n"); +#endif + printf(" -f Sart full-screen\n"); +#ifdef USE_GDB_STUB + printf(" -g, --gdb Start GDB session (default port 2345)\n"); +#endif }