GBA: Detect hardware for Pokémon FireRed ROM hacks

This commit is contained in:
Vicki Pfau 2017-09-09 11:22:14 -07:00
parent bd4dd8de5c
commit ca4d53f014
4 changed files with 16 additions and 14 deletions

View File

@ -46,6 +46,7 @@ Misc:
- Test: Restructure test suite into multiple executables - Test: Restructure test suite into multiple executables
- Python: Integrate tests from cinema test suite - Python: Integrate tests from cinema test suite
- Util: Don't build crc32 if the function already exists - 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) 0.6.0: (2017-07-16)
Features: Features:

View File

@ -28,7 +28,7 @@ void GBAOverrideSave(struct Configuration*, const struct GBACartridgeOverride* o
struct GBA; struct GBA;
void GBAOverrideApply(struct GBA*, const struct GBACartridgeOverride*); void GBAOverrideApply(struct GBA*, const struct GBACartridgeOverride*);
void GBAOverrideApplyDefaults(struct GBA*); void GBAOverrideApplyDefaults(struct GBA*, const struct Configuration*);
CXX_GUARD_END CXX_GUARD_END

View File

@ -395,14 +395,7 @@ static void _GBACoreReset(struct mCore* core) {
GBAVideoAssociateRenderer(&gba->video, renderer); GBAVideoAssociateRenderer(&gba->video, renderer);
} }
struct GBACartridgeOverride override; GBAOverrideApplyDefaults(gba, gbacore->overrides);
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);
}
}
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
if (!gba->biosVf && core->opts.useBios) { if (!gba->biosVf && core->opts.useBios) {

View File

@ -338,11 +338,19 @@ void GBAOverrideApply(struct GBA* gba, const struct GBACartridgeOverride* overri
} }
} }
void GBAOverrideApplyDefaults(struct GBA* gba) { void GBAOverrideApplyDefaults(struct GBA* gba, const struct Configuration* overrides) {
struct GBACartridgeOverride override; struct GBACartridgeOverride override = { .idleLoop = IDLE_LOOP_NONE };
const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom; const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom;
memcpy(override.id, &cart->id, sizeof(override.id)); if (cart) {
if (GBAOverrideFind(0, &override)) { memcpy(override.id, &cart->id, sizeof(override.id));
GBAOverrideApply(gba, &override);
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);
}
} }
} }