GBA: Detect hardware for Pokémon FireRed ROM hacks
Vicki Pfau vi@endrift.com
Sat, 09 Sep 2017 11:22:14 -0700
4 files changed,
16 insertions(+),
14 deletions(-)
M
CHANGES
→
CHANGES
@@ -46,6 +46,7 @@ - SDL: Fix 2.0.5 build on macOS under some circumstances
- Test: Restructure test suite into multiple executables - Python: Integrate tests from cinema test suite - Util: Don't build crc32 if the function already exists + - GBA: Detect hardware for Pokémon FireRed ROM hacks 0.6.0: (2017-07-16) Features:
M
include/mgba/internal/gba/overrides.h
→
include/mgba/internal/gba/overrides.h
@@ -28,7 +28,7 @@ void GBAOverrideSave(struct Configuration*, const struct GBACartridgeOverride* override);
struct GBA; void GBAOverrideApply(struct GBA*, const struct GBACartridgeOverride*); -void GBAOverrideApplyDefaults(struct GBA*); +void GBAOverrideApplyDefaults(struct GBA*, const struct Configuration*); CXX_GUARD_END
M
src/gba/core.c
→
src/gba/core.c
@@ -395,14 +395,7 @@ #endif
GBAVideoAssociateRenderer(&gba->video, renderer); } - struct GBACartridgeOverride override; - const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom; - if (cart) { - memcpy(override.id, &cart->id, sizeof(override.id)); - if (GBAOverrideFind(gbacore->overrides, &override)) { - GBAOverrideApply(gba, &override); - } - } + GBAOverrideApplyDefaults(gba, gbacore->overrides); #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 if (!gba->biosVf && core->opts.useBios) {
M
src/gba/overrides.c
→
src/gba/overrides.c
@@ -338,11 +338,19 @@ gba->memory.mirroring = true;
} } -void GBAOverrideApplyDefaults(struct GBA* gba) { - struct GBACartridgeOverride override; +void GBAOverrideApplyDefaults(struct GBA* gba, const struct Configuration* overrides) { + struct GBACartridgeOverride override = { .idleLoop = IDLE_LOOP_NONE }; const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom; - memcpy(override.id, &cart->id, sizeof(override.id)); - if (GBAOverrideFind(0, &override)) { - GBAOverrideApply(gba, &override); + if (cart) { + memcpy(override.id, &cart->id, sizeof(override.id)); + + if (!strncmp("pokemon red version", &((const char*) gba->memory.rom)[0x108], 20) && gba->romCrc32 != 0xDD88761C) { + // Enable FLASH1M and RTC on Pokémon FireRed ROM hacks + override.savetype = SAVEDATA_FLASH1M; + override.hardware = HW_RTC; + GBAOverrideApply(gba, &override); + } else if (GBAOverrideFind(overrides, &override)) { + GBAOverrideApply(gba, &override); + } } }