uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 9bc6a83873b7820173410cbfa8d239cd0fdc7f72
parent 62f740416d36171ce7836c9948afb7c748a49f98
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Wed, 15 Dec 2021 23:54:44 +0100

emu/load: use RWops - it's more portable and allows loading roms from assets of an apk on Android

Diffstat:
Msrc/uxnemu.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 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);