Only update active region if necessary

This commit is contained in:
Jeffrey Pfau 2013-10-27 03:44:38 -07:00
parent 775f9db546
commit 7cb183a8be
1 changed files with 6 additions and 2 deletions

View File

@ -62,7 +62,7 @@ void GBAMemoryInit(struct GBAMemory* memory) {
memory->waitstatesPrefetch32[i] = 0; memory->waitstatesPrefetch32[i] = 0;
} }
memory->activeRegion = 0; memory->activeRegion = -1;
memory->d.activeRegion = 0; memory->d.activeRegion = 0;
memory->d.activeMask = 0; memory->d.activeMask = 0;
memory->d.setActiveRegion = GBASetActiveRegion; memory->d.setActiveRegion = GBASetActiveRegion;
@ -81,10 +81,14 @@ void GBAMemoryDeinit(struct GBAMemory* memory) {
static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t address) { static void GBASetActiveRegion(struct ARMMemory* memory, uint32_t address) {
struct GBAMemory* gbaMemory = (struct GBAMemory*) memory; struct GBAMemory* gbaMemory = (struct GBAMemory*) memory;
int newRegion = address >> BASE_OFFSET;
if (newRegion == gbaMemory->activeRegion) {
return;
}
if (gbaMemory->activeRegion == REGION_BIOS) { if (gbaMemory->activeRegion == REGION_BIOS) {
gbaMemory->biosPrefetch = memory->load32(memory, gbaMemory->p->cpu.currentPC + WORD_SIZE_ARM * 2, 0); gbaMemory->biosPrefetch = memory->load32(memory, gbaMemory->p->cpu.currentPC + WORD_SIZE_ARM * 2, 0);
} }
gbaMemory->activeRegion = address >> BASE_OFFSET; gbaMemory->activeRegion = newRegion;
memory->activePrefetchCycles32 = gbaMemory->waitstatesPrefetch32[gbaMemory->activeRegion]; memory->activePrefetchCycles32 = gbaMemory->waitstatesPrefetch32[gbaMemory->activeRegion];
memory->activePrefetchCycles16 = gbaMemory->waitstatesPrefetch16[gbaMemory->activeRegion]; memory->activePrefetchCycles16 = gbaMemory->waitstatesPrefetch16[gbaMemory->activeRegion];
memory->activeNonseqCycles32 = gbaMemory->waitstates32[gbaMemory->activeRegion]; memory->activeNonseqCycles32 = gbaMemory->waitstates32[gbaMemory->activeRegion];