mirror of https://github.com/mgba-emu/mgba.git
GBA Context: Make slightly better sense of ROM loading
This commit is contained in:
parent
04d542e241
commit
8e5df9473d
|
@ -74,7 +74,13 @@ void GBAContextDeinit(struct GBAContext* context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autoloadSave) {
|
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) {
|
if (dir) {
|
||||||
struct VDirEntry* de;
|
struct VDirEntry* de;
|
||||||
while ((de = dir->listNext(dir))) {
|
while ((de = dir->listNext(dir))) {
|
||||||
|
@ -94,19 +100,12 @@ bool GBAContextLoadROM(struct GBAContext* context, const char* path, bool autolo
|
||||||
context->romDir = dir;
|
context->romDir = dir;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
context->rom = VFileOpen(path, O_RDONLY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!context->rom) {
|
if (!context->rom) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GBAIsROM(context->rom)) {
|
|
||||||
context->rom->close(context->rom);
|
|
||||||
context->rom = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
context->fname = path;
|
context->fname = path;
|
||||||
if (autoloadSave) {
|
if (autoloadSave) {
|
||||||
context->save = VDirOptionalOpenFile(0, path, 0, ".sav", O_RDWR | O_CREAT);
|
context->save = VDirOptionalOpenFile(0, path, 0, ".sav", O_RDWR | O_CREAT);
|
||||||
|
|
Loading…
Reference in New Issue