mirror of https://github.com/mgba-emu/mgba.git
GBA Context: Hold onto ROM directory if one is present
This commit is contained in:
parent
96bc0be963
commit
d1b12307ef
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue