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

This commit is contained in:
Sigrid Solveig Haflínudóttir 2021-12-15 23:54:44 +01:00
parent 62f740416d
commit 9bc6a83873
1 changed files with 4 additions and 4 deletions

View File

@ -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);