mirror of https://github.com/mgba-emu/mgba.git
GBA: Ensure idle loops are not removed on the first iteration
This commit is contained in:
parent
475954aff1
commit
64cbdf8aa0
|
@ -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;
|
||||
gba->performingDMA = false;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -198,7 +198,12 @@ 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->idleLoop) {
|
||||
GBAHalt(gba);
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue