Don't require a game on startup
This commit is contained in:
parent
3cb5606382
commit
f6ed4d6f27
9
cli.c
9
cli.c
|
@ -2,10 +2,15 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int parseCLIArgs(int argc, char **argv, CLIArgs *args) {
|
||||
if (argc != 2) {
|
||||
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[1];
|
||||
args->filename = argv[arg];
|
||||
}
|
||||
return 0;
|
||||
}
|
9
main.c
9
main.c
|
@ -1,5 +1,6 @@
|
|||
#include "cli.h"
|
||||
#include <SDL2/SDL.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
|
|
4
ui.c
4
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;
|
||||
|
|
4
ui.h
4
ui.h
|
@ -1,11 +1,13 @@
|
|||
#ifndef SHROOMS_VB_NATIVE_UI_
|
||||
#define SHROOMS_VB_NATIVE_UI_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue