all repos — mgba @ 24b0e78360fcf4e2251d014b6eb51f7bbfe1b582

mGBA Game Boy Advance Emulator

Merge branch 'optimization/idle-loops'
Jeffrey Pfau jeffrey@endrift.com
Tue, 31 Mar 2015 21:48:26 -0700
commit

24b0e78360fcf4e2251d014b6eb51f7bbfe1b582

parent

bed6a0c1302d49ae673b6df31cdbb4410abba4f5

5 files changed, 30 insertions(+), 12 deletions(-)

jump to
M src/gba/gba.csrc/gba/gba.c

@@ -87,6 +87,7 @@

gba->idleOptimization = IDLE_LOOP_REMOVE; gba->idleLoop = IDLE_LOOP_NONE; gba->lastJump = 0; + gba->haltPending = false; gba->idleDetectionStep = 0; gba->idleDetectionFailures = 0;
M src/gba/gba.hsrc/gba/gba.h

@@ -157,6 +157,7 @@

enum GBAIdleLoopOptimization idleOptimization; uint32_t idleLoop; uint32_t lastJump; + bool haltPending; int idleDetectionStep; int idleDetectionFailures; int32_t cachedRegisters[16];
M src/gba/io.csrc/gba/io.c

@@ -567,7 +567,7 @@ gba->memory.io[(address >> 1) + 1] = value >> 16;

} uint16_t GBAIORead(struct GBA* gba, uint32_t address) { - gba->lastJump = -1; // IO reads need to invalidate detected idle loops + gba->haltPending = false; // IO reads need to invalidate detected idle loops switch (address) { case REG_TM0CNT_LO: GBATimerUpdateRegister(gba, 0);
M src/gba/memory.csrc/gba/memory.c

@@ -197,8 +197,13 @@ struct GBAMemory* memory = &gba->memory;

int newRegion = address >> BASE_OFFSET; if (gba->idleOptimization >= IDLE_LOOP_REMOVE && memory->activeRegion != REGION_BIOS) { - if (address == gba->lastJump && address == gba->idleLoop) { - GBAHalt(gba); + if (address == gba->idleLoop) { + if (gba->haltPending) { + gba->haltPending = false; + GBAHalt(gba); + } else { + gba->haltPending = true; + } } else if (gba->idleOptimization >= IDLE_LOOP_DETECT && newRegion == memory->activeRegion) { if (address == gba->lastJump) { switch (gba->idleDetectionStep) {
M src/gba/supervisor/overrides.csrc/gba/supervisor/overrides.c

@@ -11,6 +11,10 @@

#include "util/configuration.h" static const struct GBACartridgeOverride _overrides[] = { + // Advance Wars + { "AWRE", SAVEDATA_FLASH512, HW_NONE, 0x8038810 }, + { "AWRP", SAVEDATA_FLASH512, HW_NONE, 0x8038810 }, + // Boktai: The Sun is in Your Hand { "U3IJ", SAVEDATA_EEPROM, HW_RTC | HW_LIGHT_SENSOR, IDLE_LOOP_NONE }, { "U3IE", SAVEDATA_EEPROM, HW_RTC | HW_LIGHT_SENSOR, IDLE_LOOP_NONE },

@@ -47,6 +51,9 @@

// Mega Man Battle Network { "AREE", SAVEDATA_SRAM, HW_NONE, 0x800032E }, + // Mega Man Zero + { "AZCE", SAVEDATA_SRAM, HW_NONE, 0x80004E8 }, + // Metal Slug Advance { "BSME", SAVEDATA_EEPROM, HW_NONE, 0x8000290 },

@@ -69,13 +76,13 @@ { "AXPD", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE },

{ "AXPF", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE }, // Pokemon Emerald - { "BPEJ", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE }, + { "BPEJ", SAVEDATA_FLASH1M, HW_RTC, 0x80008C6 }, { "BPEE", SAVEDATA_FLASH1M, HW_RTC, 0x80008C6 }, - { "BPEP", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE }, - { "BPEI", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE }, - { "BPES", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE }, - { "BPED", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE }, - { "BPEF", SAVEDATA_FLASH1M, HW_RTC, IDLE_LOOP_NONE }, + { "BPEP", SAVEDATA_FLASH1M, HW_RTC, 0x80008C6 }, + { "BPEI", SAVEDATA_FLASH1M, HW_RTC, 0x80008C6 }, + { "BPES", SAVEDATA_FLASH1M, HW_RTC, 0x80008C6 }, + { "BPED", SAVEDATA_FLASH1M, HW_RTC, 0x80008C6 }, + { "BPEF", SAVEDATA_FLASH1M, HW_RTC, 0x80008C6 }, // Pokemon Mystery Dungeon { "B24J", SAVEDATA_FLASH1M, HW_NONE, IDLE_LOOP_NONE },

@@ -115,15 +122,19 @@ // Shin Bokura no Taiyou: Gyakushuu no Sabata

{ "U33J", SAVEDATA_EEPROM, HW_RTC | HW_LIGHT_SENSOR, IDLE_LOOP_NONE }, // Super Mario Advance 2 + { "AA2J", SAVEDATA_EEPROM, HW_NONE, 0x800052E }, { "AA2E", SAVEDATA_EEPROM, HW_NONE, 0x800052E }, + { "AA2P", SAVEDATA_EEPROM, HW_NONE, 0x800052E }, // Super Mario Advance 3 + { "A3AJ", SAVEDATA_EEPROM, HW_NONE, 0x8002B9C }, { "A3AE", SAVEDATA_EEPROM, HW_NONE, 0x8002B9C }, + { "A3AP", SAVEDATA_EEPROM, HW_NONE, 0x8002B9C }, // Super Mario Advance 4 - { "AX4J", SAVEDATA_FLASH1M, HW_NONE, IDLE_LOOP_NONE }, - { "AX4E", SAVEDATA_FLASH1M, HW_NONE, IDLE_LOOP_NONE }, - { "AX4P", SAVEDATA_FLASH1M, HW_NONE, IDLE_LOOP_NONE }, + { "AX4J", SAVEDATA_FLASH1M, HW_NONE, 0x800072A }, + { "AX4E", SAVEDATA_FLASH1M, HW_NONE, 0x800072A }, + { "AX4P", SAVEDATA_FLASH1M, HW_NONE, 0x800072A }, // Top Gun - Combat Zones { "A2YE", SAVEDATA_FORCE_NONE, HW_NONE, IDLE_LOOP_NONE },