diff options
Diffstat (limited to 'emux64/src/main.c')
-rw-r--r-- | emux64/src/main.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/emux64/src/main.c b/emux64/src/main.c index cacd6b3..4396eb5 100644 --- a/emux64/src/main.c +++ b/emux64/src/main.c @@ -29,13 +29,55 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include <cpu/cpu.h> +#include <string.h> + +static char *rom_file = NULL; + +static void +help(void) +{ + printf( + "- OSMX64 emulator -\n" + "[-h] Show this help menu\n" + "[-r] <rom_file>\n" + ); +} + +static void +cleanup(void) +{ + if (rom_file != NULL) { + free(rom_file); + rom_file = NULL; + } +} int -main(void) +main(int argc, char **argv) { struct osmx_core core; int error; + int c; + + atexit(cleanup); + while ((c = getopt(argc, argv, "hr:")) != -1) { + switch (c) { + case 'h': + help(); + return 0; + case 'r': + rom_file = strdup(optarg); + break; + } + } + + if (rom_file == NULL) { + printf("** please select a ROM file\n"); + help(); + return -1; + } if ((error = cpu_reset(&core)) < 0) { printf("error: failed to power up vcore\n"); |