mirror of https://github.com/mgba-emu/mgba.git
GBA Memory: Slightly simplify prefetch logic
This commit is contained in:
parent
7b5a9b4f65
commit
1a71b8b11a
|
@ -1499,9 +1499,11 @@ int32_t GBAMemoryStall(struct ARMCore* cpu, int32_t wait) {
|
||||||
int32_t previousLoads = 0;
|
int32_t previousLoads = 0;
|
||||||
|
|
||||||
// Don't prefetch too much if we're overlapping with a previous prefetch
|
// Don't prefetch too much if we're overlapping with a previous prefetch
|
||||||
uint32_t dist = (memory->lastPrefetchedPc - cpu->gprs[ARM_PC]) >> 1;
|
uint32_t dist = (memory->lastPrefetchedPc - cpu->gprs[ARM_PC]);
|
||||||
if (dist < 8) {
|
int32_t maxLoads = 8;
|
||||||
previousLoads = dist;
|
if (dist < 16) {
|
||||||
|
previousLoads = dist >> 1;
|
||||||
|
maxLoads -= previousLoads;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t s = cpu->memory.activeSeqCycles16;
|
int32_t s = cpu->memory.activeSeqCycles16;
|
||||||
|
@ -1511,12 +1513,9 @@ int32_t GBAMemoryStall(struct ARMCore* cpu, int32_t wait) {
|
||||||
int32_t stall = s;
|
int32_t stall = s;
|
||||||
int32_t loads = 1;
|
int32_t loads = 1;
|
||||||
|
|
||||||
if (stall < wait) {
|
while (stall < wait && loads < maxLoads) {
|
||||||
int32_t maxLoads = 8 - previousLoads;
|
stall += s;
|
||||||
while (stall < wait && loads < maxLoads) {
|
++loads;
|
||||||
stall += s;
|
|
||||||
++loads;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (stall > wait) {
|
if (stall > wait) {
|
||||||
// The wait cannot take less time than the prefetch stalls
|
// The wait cannot take less time than the prefetch stalls
|
||||||
|
|
Loading…
Reference in New Issue