mirror of https://github.com/mgba-emu/mgba.git
DS: Improve step stability
This commit is contained in:
parent
7389176033
commit
1039569b01
|
@ -303,10 +303,12 @@ void ARMHalt(struct ARMCore* cpu) {
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void ARM ## VERSION ## Run(struct ARMCore* cpu) { \
|
void ARM ## VERSION ## Run(struct ARMCore* cpu) { \
|
||||||
if (cpu->executionMode == MODE_THUMB) { \
|
if (cpu->cycles < cpu->nextEvent) { \
|
||||||
Thumb ## VERSION ## Step(cpu); \
|
if (cpu->executionMode == MODE_THUMB) { \
|
||||||
} else { \
|
Thumb ## VERSION ## Step(cpu); \
|
||||||
ARM ## VERSION ## Step(cpu); \
|
} else { \
|
||||||
|
ARM ## VERSION ## Step(cpu); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
if (cpu->cycles >= cpu->nextEvent) { \
|
if (cpu->cycles >= cpu->nextEvent) { \
|
||||||
cpu->irqh.processEvents(cpu); \
|
cpu->irqh.processEvents(cpu); \
|
||||||
|
|
28
src/ds/ds.c
28
src/ds/ds.c
|
@ -359,7 +359,7 @@ static void DSProcessEvents(struct DSCommon* dscore) {
|
||||||
int32_t cycles = cpu->cycles;
|
int32_t cycles = cpu->cycles;
|
||||||
|
|
||||||
cpu->cycles = 0;
|
cpu->cycles = 0;
|
||||||
cpu->nextEvent = INT_MAX;
|
cpu->nextEvent = 0;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (cycles < 0) {
|
if (cycles < 0) {
|
||||||
|
@ -371,12 +371,12 @@ static void DSProcessEvents(struct DSCommon* dscore) {
|
||||||
nextEvent = mTimingTick(&dscore->timing, nextEvent);
|
nextEvent = mTimingTick(&dscore->timing, nextEvent);
|
||||||
} while (ds->cpuBlocked);
|
} while (ds->cpuBlocked);
|
||||||
|
|
||||||
cpu->nextEvent = nextEvent;
|
|
||||||
|
|
||||||
if (ds->earlyExit) {
|
if (ds->earlyExit) {
|
||||||
ds->earlyExit = false;
|
ds->earlyExit = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpu->nextEvent = nextEvent;
|
||||||
if (cpu->halted) {
|
if (cpu->halted) {
|
||||||
cpu->cycles = nextEvent;
|
cpu->cycles = nextEvent;
|
||||||
}
|
}
|
||||||
|
@ -397,17 +397,23 @@ void DSRunLoop(struct DS* ds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DS7Step(struct DS* ds) {
|
void DS7Step(struct DS* ds) {
|
||||||
while (ds->activeCpu == ds->ds9.cpu) {
|
int32_t pc = ds->ds7.cpu->gprs[ARM_PC];
|
||||||
ARMv5RunLoop(ds->ds9.cpu);
|
do {
|
||||||
}
|
while (ds->activeCpu == ds->ds9.cpu) {
|
||||||
ARMv4Run(ds->ds7.cpu);
|
ARMv5RunLoop(ds->ds9.cpu);
|
||||||
|
}
|
||||||
|
ARMv4Run(ds->ds7.cpu);
|
||||||
|
} while (ds->ds7.cpu->halted || ds->ds7.cpu->gprs[ARM_PC] == pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DS9Step(struct DS* ds) {
|
void DS9Step(struct DS* ds) {
|
||||||
while (ds->activeCpu == ds->ds7.cpu) {
|
int32_t pc = ds->ds9.cpu->gprs[ARM_PC];
|
||||||
ARMv4RunLoop(ds->ds7.cpu);
|
do {
|
||||||
}
|
while (ds->activeCpu == ds->ds7.cpu) {
|
||||||
ARMv5Run(ds->ds9.cpu);
|
ARMv4RunLoop(ds->ds7.cpu);
|
||||||
|
}
|
||||||
|
ARMv5Run(ds->ds9.cpu);
|
||||||
|
} while (ds->ds9.cpu->halted || ds->ds9.cpu->gprs[ARM_PC] == pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSAttachDebugger(struct DS* ds, struct mDebugger* debugger) {
|
void DSAttachDebugger(struct DS* ds, struct mDebugger* debugger) {
|
||||||
|
|
Loading…
Reference in New Issue