GBA Memory: Fix stalling behavior a bit
Jeffrey Pfau jeffrey@endrift.com
Mon, 01 Aug 2016 02:24:00 -0700
3 files changed,
1 insertions(+),
4 deletions(-)
M
src/gba/gba.c
→
src/gba/gba.c
@@ -537,7 +537,7 @@ void GBATimerUpdateRegister(struct GBA* gba, int timer) {
struct GBATimer* currentTimer = &gba->timers[timer]; if (GBATimerFlagsIsEnable(currentTimer->flags) && !GBATimerFlagsIsCountUp(currentTimer->flags)) { int32_t prefetchSkew = 0; - if (gba->memory.lastPrefetchedPc - gba->memory.lastPrefetchedLoads * WORD_SIZE_THUMB >= (uint32_t) gba->cpu->gprs[ARM_PC]) { + if (gba->memory.lastPrefetchedPc >= (uint32_t) gba->cpu->gprs[ARM_PC]) { prefetchSkew = (gba->memory.lastPrefetchedPc - gba->cpu->gprs[ARM_PC]) * (gba->cpu->memory.activeSeqCycles16 + 1) / WORD_SIZE_THUMB; } // Reading this takes two cycles (1N+1I), so let's remove them preemptively
M
src/gba/memory.c
→
src/gba/memory.c
@@ -244,7 +244,6 @@ }
gba->lastJump = address; memory->lastPrefetchedPc = 0; - memory->lastPrefetchedLoads = 0; if (newRegion == memory->activeRegion) { if (newRegion < REGION_CART0 || (address & (SIZE_CART0 - 1)) < memory->romSize) { return;@@ -1779,7 +1778,6 @@ // This instruction used to have an N, convert it to an S.
wait -= n2s; // TODO: Invalidate prefetch on branch - memory->lastPrefetchedLoads = loads; memory->lastPrefetchedPc = cpu->gprs[ARM_PC] + WORD_SIZE_THUMB * loads; // The next |loads|S waitstates disappear entirely, so long as they're all in a row
M
src/gba/memory.h
→
src/gba/memory.h
@@ -136,7 +136,6 @@ char waitstatesPrefetchNonseq16[16];
int activeRegion; bool prefetch; uint32_t lastPrefetchedPc; - uint32_t lastPrefetchedLoads; uint32_t biosPrefetch; struct GBADMA dma[4];