GBA Context: Hold onto ROM directory if one is present
Jeffrey Pfau jeffrey@endrift.com
Tue, 29 Dec 2015 04:44:28 -0500
2 files changed,
11 insertions(+),
1 deletions(-)
M
src/gba/context/context.c
→
src/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.h
→
src/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;