From 9bc6a83873b7820173410cbfa8d239cd0fdc7f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Wed, 15 Dec 2021 23:54:44 +0100 Subject: [PATCH] emu/load: use RWops - it's more portable and allows loading roms from assets of an apk on Android --- src/uxnemu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uxnemu.c b/src/uxnemu.c index fa9b86e..b96417c 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -421,11 +421,11 @@ nil_deo(Device *d, Uint8 port) static int load(Uxn *u, char *rom) { - FILE *f; + SDL_RWops *f; int r; - if(!(f = fopen(rom, "rb"))) return 0; - r = fread(u->ram.dat + PAGE_PROGRAM, 1, sizeof(u->ram.dat) - PAGE_PROGRAM, f); - fclose(f); + if(!(f = SDL_RWFromFile(rom, "rb"))) return 0; + r = f->read(f, u->ram.dat + PAGE_PROGRAM, 1, sizeof(u->ram.dat) - PAGE_PROGRAM); + f->close(f); if(r < 1) return 0; fprintf(stderr, "Loaded %s\n", rom); SDL_SetWindowTitle(gWindow, rom);