From ee610db141499fb7d8ebae3901838a7e893adcd2 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 28 Dec 2021 17:12:22 -0800 Subject: [PATCH] GBA BIOS: Work around IRQ handling hiccup in Mario & Luigi (fixes #1059) --- CHANGES | 1 + src/gba/hle-bios.c | 12 ++++++------ src/gba/hle-bios.s | 14 +++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index 398df1445..62f6daa64 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ Emulation fixes: - ARM7: Fix unsigned multiply timing - GB Memory: Add cursory cartridge open bus emulation (fixes mgba.io/i/2032) - GBA: Improve timing when not booting from BIOS + - GBA BIOS: Work around IRQ handling hiccup in Mario & Luigi (fixes mgba.io/i/1059) - GBA I/O: Redo internal key input, enabling edge-based key IRQs - GBA Memory: Fix misaligned 32-bit I/O loads (fixes mgba.io/i/2307) Other fixes: diff --git a/src/gba/hle-bios.c b/src/gba/hle-bios.c index 05223b937..9ee6dd5b1 100644 --- a/src/gba/hle-bios.c +++ b/src/gba/hle-bios.c @@ -9,17 +9,17 @@ const uint8_t hleBios[SIZE_BIOS] = { 0x03, 0x10, 0xd0, 0xe5, 0xea, 0x00, 0x51, 0xe3, 0x4c, 0x01, 0x9f, 0x15, 0x10, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x29, 0xe1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xe3, 0x01, 0xd3, 0xa0, 0x03, - 0x20, 0xd0, 0x4d, 0x02, 0x00, 0x58, 0x2d, 0xe9, 0x02, 0xb0, 0x5e, 0xe5, - 0xd4, 0xc0, 0xa0, 0xe3, 0x0b, 0xb1, 0x9c, 0xe7, 0xd2, 0xcf, 0xa0, 0xe3, - 0x0b, 0x00, 0x5c, 0xe1, 0x00, 0xc0, 0x4f, 0xe1, 0x00, 0x10, 0x2d, 0xe9, + 0x20, 0xd0, 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x01, 0x00, 0x00, 0xb0, 0x01, 0x00, 0x00, 0xcc, 0x01, 0x00, 0x00, 0xc4, 0x01, 0x00, 0x00, 0x48, 0x03, 0x00, 0x00, diff --git a/src/gba/hle-bios.s b/src/gba/hle-bios.s index 8234b9e45..be0d81703 100644 --- a/src/gba/hle-bios.s +++ b/src/gba/hle-bios.s @@ -31,12 +31,12 @@ swiBase: cmp sp, #0 moveq sp, #0x04000000 subeq sp, #0x20 -stmfd sp!, {r11-r12, lr} -ldrb r11, [lr, #-2] +stmfd sp!, {r4, r12, lr} +ldrb r4, [lr, #-2] mov r12, #swiTable -ldr r11, [r12, r11, lsl #2] +ldr r4, [r12, r4, lsl #2] mov r12, #StallCall -cmp r12, r11 +cmp r12, r4 mrs r12, spsr stmfd sp!, {r12} and r12, #0x80 @@ -44,7 +44,7 @@ orr r12, #0x1F msr cpsr_c, r12 swieq 0xF00000 @ Special mGBA-internal call to load the stall count into r12 stmfd sp!, {r2, lr} -cmp r11, #0 +cmp r4, #0 nop nop nop @@ -52,7 +52,7 @@ nop nop nop mov lr, pc -bxne r11 +bxne r4 nop nop nop @@ -60,7 +60,7 @@ ldmfd sp!, {r2, lr} msr cpsr, #0x93 ldmfd sp!, {r12} msr spsr, r12 -ldmfd sp!, {r11-r12, lr} +ldmfd sp!, {r4, r12, lr} movs pc, lr .word 0 .word 0xE3A02004