all repos — mgba @ 20754b772e23b4aafa0c24c626c773ea2f027c03

mGBA Game Boy Advance Emulator

GBA Memory: Slightly simplify prefetch logic
Vicki Pfau vi@endrift.com
Sun, 29 Oct 2017 17:09:54 -0700
commit

20754b772e23b4aafa0c24c626c773ea2f027c03

parent

c6ce7b0bb6cb1582e0dc94fd2a732f9b356868df

1 files changed, 8 insertions(+), 9 deletions(-)

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

@@ -1531,9 +1531,11 @@

int32_t previousLoads = 0; // Don't prefetch too much if we're overlapping with a previous prefetch - uint32_t dist = (memory->lastPrefetchedPc - cpu->gprs[ARM_PC]) >> 1; - if (dist < 8) { - previousLoads = dist; + uint32_t dist = (memory->lastPrefetchedPc - cpu->gprs[ARM_PC]); + int32_t maxLoads = 8; + if (dist < 16) { + previousLoads = dist >> 1; + maxLoads -= previousLoads; } int32_t s = cpu->memory.activeSeqCycles16;

@@ -1543,12 +1545,9 @@ // Figure out how many sequential loads we can jam in

int32_t stall = s; int32_t loads = 1; - if (stall < wait) { - int32_t maxLoads = 8 - previousLoads; - while (stall < wait && loads < maxLoads) { - stall += s; - ++loads; - } + while (stall < wait && loads < maxLoads) { + stall += s; + ++loads; } if (stall > wait) { // The wait cannot take less time than the prefetch stalls