all repos — mgba @ d1b12307ef40c08d09364f25716c76b8eec5c098

mGBA Game Boy Advance Emulator

GBA Context: Hold onto ROM directory if one is present
Jeffrey Pfau jeffrey@endrift.com
Tue, 29 Dec 2015 04:44:28 -0500
commit

d1b12307ef40c08d09364f25716c76b8eec5c098

parent

96bc0be96357db792fd5d9aa47604865d72343d6

2 files changed, 11 insertions(+), 1 deletions(-)

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

@@ -17,6 +17,7 @@ bool GBAContextInit(struct GBAContext* context, const char* port) {

context->gba = anonymousMemoryMap(sizeof(struct GBA)); context->cpu = anonymousMemoryMap(sizeof(struct ARMCore)); context->rom = 0; + context->romDir = 0; context->bios = 0; context->fname = 0; context->save = 0;

@@ -87,7 +88,11 @@ break;

} vf->close(vf); } - dir->close(dir); + if (!context->rom) { + dir->close(dir); + } else { + context->romDir = dir; + } } else { context->rom = VFileOpen(path, O_RDONLY); }

@@ -118,6 +123,10 @@ }

if (context->rom) { context->rom->close(context->rom); context->rom = 0; + } + if (context->romDir) { + context->romDir->close(context->romDir); + context->romDir = 0; } if (context->save) { context->save->close(context->save);
M src/gba/context/context.hsrc/gba/context/context.h

@@ -17,6 +17,7 @@ struct GBA* gba;

struct ARMCore* cpu; struct GBAVideoRenderer* renderer; struct VFile* rom; + struct VDir* romDir; const char* fname; struct VFile* save; struct VFile* bios;