all repos — mgba @ a53b01be00e8fc65c1abc28c8d9d3ab59f76c209

mGBA Game Boy Advance Emulator

ARM: Fix Addressing mode 1 shifter on rs == pc (fixes #1926)
Vicki Pfau vi@endrift.com
Sun, 01 Nov 2020 02:22:09 -0800
commit

a53b01be00e8fc65c1abc28c8d9d3ab59f76c209

parent

791818e9a8df1c6ad86864ae8c1f2450ef8f039a

2 files changed, 5 insertions(+), 20 deletions(-)

jump to
M CHANGESCHANGES

@@ -15,6 +15,7 @@ - Individual window types can now be toggled in GBA debugging views

Emulation fixes: - ARM: Fix ALU reading PC after shifting - ARM: Fix STR storing PC after address calculation + - ARM: Fix Addressing mode 1 shifter on rs == pc (fixes mgba.io/i/1926) - GB: Partially fix timing for skipped BIOS - GB Audio: Fix serializing sweep time - GB MBC: Fix MBC1 mode changing behavior
M src/arm/isa-arm.csrc/arm/isa-arm.c

@@ -19,15 +19,11 @@ int rm = opcode & 0x0000000F;

if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; int32_t shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; if (!shift) { cpu->shifterOperand = shiftVal; cpu->shifterCarryOut = cpu->cpsr.c;

@@ -58,15 +54,11 @@ int rm = opcode & 0x0000000F;

if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; uint32_t shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; if (!shift) { cpu->shifterOperand = shiftVal; cpu->shifterCarryOut = cpu->cpsr.c;

@@ -97,15 +89,11 @@ int rm = opcode & 0x0000000F;

if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; int shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; if (!shift) { cpu->shifterOperand = shiftVal; cpu->shifterCarryOut = cpu->cpsr.c;

@@ -136,15 +124,11 @@ int rm = opcode & 0x0000000F;

if (opcode & 0x00000010) { int rs = (opcode >> 8) & 0x0000000F; ++cpu->cycles; - int shift = cpu->gprs[rs]; - if (rs == ARM_PC) { - shift += 4; - } - shift &= 0xFF; int shiftVal = cpu->gprs[rm]; if (rm == ARM_PC) { shiftVal += 4; } + int shift = cpu->gprs[rs] & 0xFF; int rotate = shift & 0x1F; if (!shift) { cpu->shifterOperand = shiftVal;