mirror of https://github.com/mgba-emu/mgba.git
Merge branch 'optimization/idle-loops'
This commit is contained in:
commit
24b0e78360
|
@ -87,6 +87,7 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
|
|||
gba->idleOptimization = IDLE_LOOP_REMOVE;
|
||||
gba->idleLoop = IDLE_LOOP_NONE;
|
||||
gba->lastJump = 0;
|
||||
gba->haltPending = false;
|
||||
gba->idleDetectionStep = 0;
|
||||
gba->idleDetectionFailures = 0;
|
||||
|
||||
|
|
|
@ -157,6 +157,7 @@ struct GBA {
|
|||
enum GBAIdleLoopOptimization idleOptimization;
|
||||
uint32_t idleLoop;
|
||||
uint32_t lastJump;
|
||||
bool haltPending;
|
||||
int idleDetectionStep;
|
||||
int idleDetectionFailures;
|
||||
int32_t cachedRegisters[16];
|
||||
|
|
|
@ -567,7 +567,7 @@ void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -197,8 +197,13 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
|||
|
||||
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) {
|
||||
|
|
|
@ -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 @@ static const struct GBACartridgeOverride _overrides[] = {
|
|||
// 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 @@ static const struct GBACartridgeOverride _overrides[] = {
|
|||
{ "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 @@ static const struct GBACartridgeOverride _overrides[] = {
|
|||
{ "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 },
|
||||
|
|
Loading…
Reference in New Issue