diff --git a/cli.c b/cli.c index 7328a09..09bfbcc 100644 --- a/cli.c +++ b/cli.c @@ -2,10 +2,15 @@ #include int parseCLIArgs(int argc, char **argv, CLIArgs *args) { - if (argc != 2) { - fprintf(stderr, "usage: %s /path/to/rom.vb\n", argv[0]); - return 1; + int arg; + + args->filename = NULL; + for (arg = 1; arg < argc; ++arg) { + if (args->filename) { + fprintf(stderr, "usage: %s /path/to/rom.vb\n", argv[0]); + return 1; + } + args->filename = argv[arg]; } - args->filename = argv[1]; return 0; } \ No newline at end of file diff --git a/main.c b/main.c index d09d7d6..98687b7 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,6 @@ #include "cli.h" #include +#include #include #include "ui.h" @@ -7,6 +8,7 @@ int main(int argc, char **argv) { CLIArgs args; UIContext *ui; int status; + bool running = false; if (parseCLIArgs(argc, argv, &args)) { return 1; @@ -25,10 +27,13 @@ int main(int argc, char **argv) { } if (args.filename) { - uiLoadGame(ui, args.filename); + if (uiLoadGame(ui, args.filename)) { + return 1; + } + running = true; } - status = uiRun(ui); + status = uiRun(ui, running); uiDestroy(ui); SDL_Quit(); return status; diff --git a/ui.c b/ui.c index 18d914b..c863718 100644 --- a/ui.c +++ b/ui.c @@ -105,10 +105,10 @@ typedef enum status_t { status_running } status_t; -int uiRun(UIContext *ui) { +int uiRun(UIContext *ui, bool running) { static uint8_t leftEye[384*224]; static uint8_t rightEye[384*224]; - status_t status = status_running; + status_t status = running ? status_running : status_paused; while (1) { struct nk_context *ctx; diff --git a/ui.h b/ui.h index 145f630..05bdbb2 100644 --- a/ui.h +++ b/ui.h @@ -1,11 +1,13 @@ #ifndef SHROOMS_VB_NATIVE_UI_ #define SHROOMS_VB_NATIVE_UI_ +#include + typedef struct UIContext UIContext; UIContext *uiInit(); void uiDestroy(UIContext *ui); int uiLoadGame(UIContext *ui, const char *path); -int uiRun(UIContext *ui); +int uiRun(UIContext *ui, bool running); #endif