all repos — mgba @ 013e322c0b3ee8f90faa7f052b98028b7985182b

mGBA Game Boy Advance Emulator

Improved cycle counting for branches
Jeffrey Pfau jeffrey@endrift.com
Sat, 11 May 2013 14:45:31 -0700
commit

013e322c0b3ee8f90faa7f052b98028b7985182b

parent

f6592b17b88b749b86101c60ca0034f5a5f4d3f6

2 files changed, 3 insertions(+), 4 deletions(-)

jump to
M src/arm/isa-inlines.hsrc/arm/isa-inlines.h

@@ -68,14 +68,12 @@

#define ARM_WRITE_PC \ cpu->gprs[ARM_PC] = (cpu->gprs[ARM_PC] & -WORD_SIZE_ARM) + WORD_SIZE_ARM; \ cpu->memory->setActiveRegion(cpu->memory, cpu->gprs[ARM_PC]); \ - cpu->memory->loadU16(cpu->memory, cpu->gprs[ARM_PC], &cpu->cycles); \ - cpu->cycles += 2 + cpu->memory->activePrefetchCycles32; + cpu->cycles += 1 + cpu->memory->activePrefetchCycles32; #define THUMB_WRITE_PC \ cpu->gprs[ARM_PC] = (cpu->gprs[ARM_PC] & -WORD_SIZE_THUMB) + WORD_SIZE_THUMB; \ cpu->memory->setActiveRegion(cpu->memory, cpu->gprs[ARM_PC]); \ - cpu->memory->load32(cpu->memory, cpu->gprs[ARM_PC], &cpu->cycles); \ - cpu->cycles += 2 + cpu->memory->activePrefetchCycles16; + cpu->cycles += 1 + cpu->memory->activePrefetchCycles16; static inline int _ARMModeHasSPSR(enum PrivilegeMode mode) { return mode != MODE_SYSTEM && mode != MODE_USER;
M src/gba/gba-memory.csrc/gba/gba-memory.c

@@ -109,6 +109,7 @@ memory->activeRegion = 0;

memory->activeMask = 0; break; } + gbaMemory->p->cpu.cycles += 1 + (gbaMemory->p->cpu.executionMode == MODE_ARM ? gbaMemory->waitstates32[address >> BASE_OFFSET] : gbaMemory->waitstates16[address >> BASE_OFFSET]); } int32_t GBALoad32(struct ARMMemory* memory, uint32_t address, int* cycleCounter) {