mirror of https://github.com/mgba-emu/mgba.git
Add more command line options + usage
This commit is contained in:
parent
7c356ffd07
commit
7334b89833
|
@ -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 @@ int parseCommandArgs(struct StartupOptions* opts, int argc, char* const* argv) {
|
|||
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 @@ int parseCommandArgs(struct StartupOptions* opts, int argc, char* const* argv) {
|
|||
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 @@ struct ARMDebugger* createDebugger(struct StartupOptions* opts) {
|
|||
#ifdef USE_GDB_STUB
|
||||
case DEBUGGER_GDB:
|
||||
GDBStubCreate(&debugger->gdb);
|
||||
GDBStubListen(&debugger->gdb, 2345, 0);
|
||||
break;
|
||||
#endif
|
||||
case DEBUGGER_NONE:
|
||||
|
@ -94,5 +118,17 @@ struct ARMDebugger* createDebugger(struct StartupOptions* opts) {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue