mirror of https://github.com/mgba-emu/mgba.git
GBA Memory: Fix stalling behavior a bit
This commit is contained in:
parent
5b740518cf
commit
2d94f202a6
|
@ -537,7 +537,7 @@ void GBATimerUpdateRegister(struct GBA* gba, int timer) {
|
||||||
struct GBATimer* currentTimer = &gba->timers[timer];
|
struct GBATimer* currentTimer = &gba->timers[timer];
|
||||||
if (GBATimerFlagsIsEnable(currentTimer->flags) && !GBATimerFlagsIsCountUp(currentTimer->flags)) {
|
if (GBATimerFlagsIsEnable(currentTimer->flags) && !GBATimerFlagsIsCountUp(currentTimer->flags)) {
|
||||||
int32_t prefetchSkew = 0;
|
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;
|
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
|
// Reading this takes two cycles (1N+1I), so let's remove them preemptively
|
||||||
|
|
|
@ -244,7 +244,6 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) {
|
||||||
|
|
||||||
gba->lastJump = address;
|
gba->lastJump = address;
|
||||||
memory->lastPrefetchedPc = 0;
|
memory->lastPrefetchedPc = 0;
|
||||||
memory->lastPrefetchedLoads = 0;
|
|
||||||
if (newRegion == memory->activeRegion) {
|
if (newRegion == memory->activeRegion) {
|
||||||
if (newRegion < REGION_CART0 || (address & (SIZE_CART0 - 1)) < memory->romSize) {
|
if (newRegion < REGION_CART0 || (address & (SIZE_CART0 - 1)) < memory->romSize) {
|
||||||
return;
|
return;
|
||||||
|
@ -1779,7 +1778,6 @@ int32_t GBAMemoryStall(struct ARMCore* cpu, int32_t wait) {
|
||||||
wait -= n2s;
|
wait -= n2s;
|
||||||
|
|
||||||
// TODO: Invalidate prefetch on branch
|
// TODO: Invalidate prefetch on branch
|
||||||
memory->lastPrefetchedLoads = loads;
|
|
||||||
memory->lastPrefetchedPc = cpu->gprs[ARM_PC] + WORD_SIZE_THUMB * 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
|
// The next |loads|S waitstates disappear entirely, so long as they're all in a row
|
||||||
|
|
|
@ -136,7 +136,6 @@ struct GBAMemory {
|
||||||
int activeRegion;
|
int activeRegion;
|
||||||
bool prefetch;
|
bool prefetch;
|
||||||
uint32_t lastPrefetchedPc;
|
uint32_t lastPrefetchedPc;
|
||||||
uint32_t lastPrefetchedLoads;
|
|
||||||
uint32_t biosPrefetch;
|
uint32_t biosPrefetch;
|
||||||
|
|
||||||
struct GBADMA dma[4];
|
struct GBADMA dma[4];
|
||||||
|
|
Loading…
Reference in New Issue