GB, GBA: Automatic BIOS detection
Jeffrey Pfau jeffrey@endrift.com
Fri, 09 Sep 2016 16:30:48 -0700
4 files changed,
54 insertions(+),
19 deletions(-)
M
CHANGES
→
CHANGES
@@ -12,6 +12,7 @@ - Wii: 240p support
- 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
M
src/gb/core.c
→
src/gb/core.c
@@ -104,13 +104,6 @@ }
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@@ -215,6 +208,35 @@ if (GBOverrideFind(gbcore->overrides, &override)) {
GBOverrideApply(gb, &override); } } + +#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); }
M
src/gb/gb.c
→
src/gb/gb.c
@@ -59,6 +59,8 @@ GBSIOInit(&gb->sio);
gb->timer.p = gb; + gb->model = GB_MODEL_AUTODETECT; + gb->biosVf = 0; gb->romVf = 0; gb->sramVf = 0;
M
src/gba/core.c
→
src/gba/core.c
@@ -118,14 +118,6 @@
#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 @@ }
#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;@@ -259,6 +247,28 @@ memcpy(override.id, &cart->id, sizeof(override.id));
if (GBAOverrideFind(gbacore->overrides, &override)) { 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); } }