GB, GBA: Automatic BIOS detection

This commit is contained in:
Jeffrey Pfau 2016-09-09 16:30:48 -07:00
parent 38e3858852
commit 1bc8dfe42b
4 changed files with 54 additions and 19 deletions

View File

@ -12,6 +12,7 @@ Features:
- 3DS: Adjustable screen darkening
- Ability to temporarily load a savegame
- Load specific files out of archives
- Automatic BIOS detection
Bugfixes:
- SDL: Fix axes being mapped wrong
- GBA Memory: Fix mirror on non-overdumped Classic NES games

View File

@ -104,13 +104,6 @@ static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* conf
gb->video.frameskip = core->opts.frameskip;
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
struct VFile* bios = 0;
if (core->opts.useBios && core->opts.bios) {
bios = VFileOpen(core->opts.bios, O_RDONLY);
}
if (bios) {
GBLoadBIOS(gb, bios);
}
struct GBCore* gbcore = (struct GBCore*) core;
gbcore->overrides = mCoreConfigGetOverridesConst(config);
#endif
@ -216,6 +209,35 @@ static void _GBCoreReset(struct mCore* core) {
}
}
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
struct VFile* bios = 0;
if (core->opts.useBios) {
if (!core->opts.bios) {
char path[PATH_MAX];
GBDetectModel(gb);
mCoreConfigDirectory(path, PATH_MAX);
switch (gb->model) {
case GB_MODEL_DMG:
case GB_MODEL_SGB: // TODO
strncat(path, PATH_SEP "gb_bios.bin", PATH_MAX - strlen(path));
break;
case GB_MODEL_CGB:
case GB_MODEL_AGB:
strncat(path, PATH_SEP "gbc_bios.bin", PATH_MAX - strlen(path));
break;
default:
break;
};
bios = VFileOpen(path, O_RDONLY);
} else {
bios = VFileOpen(core->opts.bios, O_RDONLY);
}
}
if (bios) {
GBLoadBIOS(gb, bios);
}
#endif
LR35902Reset(core->cpu);
}

View File

@ -59,6 +59,8 @@ static void GBInit(void* cpu, struct mCPUComponent* component) {
gb->timer.p = gb;
gb->model = GB_MODEL_AUTODETECT;
gb->biosVf = 0;
gb->romVf = 0;
gb->sramVf = 0;

View File

@ -118,14 +118,6 @@ static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* con
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
struct GBACore* gbacore = (struct GBACore*) core;
gbacore->overrides = mCoreConfigGetOverridesConst(config);
struct VFile* bios = 0;
if (core->opts.useBios && core->opts.bios) {
bios = VFileOpen(core->opts.bios, O_RDONLY);
}
if (bios) {
GBALoadBIOS(gba, bios);
}
#endif
const char* idleOptimization = mCoreConfigGetValue(config, "idleOptimization");
@ -247,10 +239,6 @@ static void _GBACoreReset(struct mCore* core) {
#endif
GBAVideoAssociateRenderer(&gba->video, renderer);
}
ARMReset(core->cpu);
if (core->opts.skipBios && gba->pristineRom) {
GBASkipBIOS(core->board);
}
struct GBACartridgeOverride override;
const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom;
@ -260,6 +248,28 @@ static void _GBACoreReset(struct mCore* core) {
GBAOverrideApply(gba, &override);
}
}
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
struct VFile* bios = 0;
if (core->opts.useBios) {
if (!core->opts.bios) {
char path[PATH_MAX];
mCoreConfigDirectory(path, PATH_MAX);
strncat(path, PATH_SEP "gba_bios.bin", PATH_MAX - strlen(path));
bios = VFileOpen(path, O_RDONLY);
} else {
bios = VFileOpen(core->opts.bios, O_RDONLY);
}
}
if (bios) {
GBALoadBIOS(gba, bios);
}
#endif
ARMReset(core->cpu);
if (core->opts.skipBios && gba->pristineRom) {
GBASkipBIOS(core->board);
}
}
static void _GBACoreRunFrame(struct mCore* core) {