diff --git a/ref/uxn.c b/ref/uxn.c index 813ce74..9a3071f 100644 --- a/ref/uxn.c +++ b/ref/uxn.c @@ -23,16 +23,6 @@ typedef struct Uxn { int uxn_eval(Uxn *u, Uint16 pc); -int -system_load(Uxn *u, char *filename) -{ - FILE *f = fopen(filename, "rb"); - if(!f) return 0; - fread(&u->ram[0x0100], 0xff00, 1, f); - fclose(f); - return 1; -} - int console_input(Uxn *u, char c, int type) { @@ -161,14 +151,18 @@ main(int argc, char **argv) { int i = 1; Uxn u = {0}; + FILE *f; if(i == argc) { fprintf(stdout, "usage: %s file.rom [args..]\n", argv[0]); return 0; } - if(!system_load(&u, argv[i++])) { + f = fopen(argv[i++], "rb"); + if(!f) { fprintf(stderr, "Failed to initialize %s\n", argv[1]); return 0; } + fread(&u.ram[0x0100], 0xff00, 1, f); + fclose(f); /* eval */ u.dev[0x17] = argc - i; if(uxn_eval(&u, 0x0100)) {