all repos — mgba @ 8e5df9473d5f26057c9f37c9bf76362036f80795

mGBA Game Boy Advance Emulator

GBA Context: Make slightly better sense of ROM loading
Jeffrey Pfau jeffrey@endrift.com
Tue, 29 Dec 2015 07:25:28 -0500
commit

8e5df9473d5f26057c9f37c9bf76362036f80795

parent

04d542e241fe2d2e3e5c5ba07038e868e7483457

1 files changed, 7 insertions(+), 8 deletions(-)

jump to
M src/gba/context/context.csrc/gba/context/context.c

@@ -74,7 +74,13 @@ GBAConfigDeinit(&context->config);

} bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autoloadSave) { - struct VDir* dir = VDirOpenArchive(path); + context->rom = VFileOpen(path, O_RDONLY); + struct VDir* dir = 0; + if (!GBAIsROM(context->rom)) { + context->rom->close(context->rom); + context->rom = 0; + dir = VDirOpenArchive(path); + } if (dir) { struct VDirEntry* de; while ((de = dir->listNext(dir))) {

@@ -94,16 +100,9 @@ } else {

context->romDir = dir; } } else { - context->rom = VFileOpen(path, O_RDONLY); } if (!context->rom) { - return false; - } - - if (!GBAIsROM(context->rom)) { - context->rom->close(context->rom); - context->rom = 0; return false; }