GBA Context: Hold onto ROM directory if one is present

This commit is contained in:
Jeffrey Pfau 2015-12-29 04:44:28 -05:00
parent 96bc0be963
commit d1b12307ef
2 changed files with 11 additions and 1 deletions

View File

@ -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 @@ bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autolo
}
vf->close(vf);
}
if (!context->rom) {
dir->close(dir);
} else {
context->romDir = dir;
}
} else {
context->rom = VFileOpen(path, O_RDONLY);
}
@ -119,6 +124,10 @@ void GBAContextUnloadROM(struct GBAContext* context) {
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);
context->save = 0;

View File

@ -17,6 +17,7 @@ struct GBAContext {
struct ARMCore* cpu;
struct GBAVideoRenderer* renderer;
struct VFile* rom;
struct VDir* romDir;
const char* fname;
struct VFile* save;
struct VFile* bios;