From eb26b3c387400d6a5d4bcc2d3e4ab5b2541980fb Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 28 Apr 2023 22:45:39 -0700 Subject: [PATCH] GBA BIOS: Fix clobbering registers with word-sized CpuSet --- CHANGES | 1 + src/gba/hle-bios.c | 8 ++++---- src/gba/hle-bios.s | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index ae611c1cf..9496d97a1 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,7 @@ Emulation fixes: - GB Audio: Fix channels 1/2 staying muted if restarted after long silence - GB Serialize: Add missing Pocket Cam state to savestates - GB Video: Implement DMG-style sprite ordering + - GBA BIOS: Fix clobbering registers with word-sized CpuSet - GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722) Other fixes: - Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560) diff --git a/src/gba/hle-bios.c b/src/gba/hle-bios.c index 84737afd4..f82d01f64 100644 --- a/src/gba/hle-bios.c +++ b/src/gba/hle-bios.c @@ -50,13 +50,13 @@ const uint8_t hleBios[GBA_SIZE_BIOS] = { 0x0c, 0x80, 0xbd, 0xe8, 0x30, 0x40, 0x2d, 0xe9, 0x02, 0x46, 0xa0, 0xe1, 0x00, 0xc0, 0xa0, 0xe1, 0x01, 0x50, 0xa0, 0xe1, 0x01, 0x04, 0x12, 0xe3, 0x0f, 0x00, 0x00, 0x0a, 0x01, 0x03, 0x12, 0xe3, 0x05, 0x00, 0x00, 0x0a, - 0x24, 0x45, 0x85, 0xe0, 0x08, 0x00, 0xbc, 0xe8, 0x04, 0x00, 0x55, 0xe1, - 0x08, 0x00, 0xa5, 0xb8, 0xfc, 0xff, 0xff, 0xba, 0x14, 0x00, 0x00, 0xea, + 0x24, 0x45, 0x85, 0xe0, 0x08, 0x00, 0xb0, 0xe8, 0x04, 0x00, 0x51, 0xe1, + 0x08, 0x00, 0xa1, 0xb8, 0xfc, 0xff, 0xff, 0xba, 0x14, 0x00, 0x00, 0xea, 0x01, 0xc0, 0xcc, 0xe3, 0x01, 0x50, 0xc5, 0xe3, 0xa4, 0x45, 0x85, 0xe0, 0xb0, 0x30, 0xdc, 0xe1, 0x04, 0x00, 0x55, 0xe1, 0xb2, 0x30, 0xc5, 0xb0, 0xfc, 0xff, 0xff, 0xba, 0x0c, 0x00, 0x00, 0xea, 0x01, 0x03, 0x12, 0xe3, - 0x05, 0x00, 0x00, 0x0a, 0x24, 0x45, 0x85, 0xe0, 0x04, 0x00, 0x55, 0xe1, - 0x08, 0x00, 0xbc, 0xb8, 0x08, 0x00, 0xa5, 0xb8, 0xfb, 0xff, 0xff, 0xba, + 0x05, 0x00, 0x00, 0x0a, 0x24, 0x45, 0x85, 0xe0, 0x04, 0x00, 0x51, 0xe1, + 0x08, 0x00, 0xb0, 0xb8, 0x08, 0x00, 0xa1, 0xb8, 0xfb, 0xff, 0xff, 0xba, 0x04, 0x00, 0x00, 0xea, 0xa4, 0x45, 0x85, 0xe0, 0x04, 0x00, 0x55, 0xe1, 0xb2, 0x30, 0xdc, 0xb0, 0xb2, 0x30, 0xc5, 0xb0, 0xfb, 0xff, 0xff, 0xba, 0x17, 0x3e, 0xa0, 0xe3, 0x30, 0x80, 0xbd, 0xe8, 0xf0, 0x47, 0x2d, 0xe9, diff --git a/src/gba/hle-bios.s b/src/gba/hle-bios.s index c891479a5..36e18790b 100644 --- a/src/gba/hle-bios.s +++ b/src/gba/hle-bios.s @@ -209,10 +209,10 @@ tst r2, #0x04000000 beq 1f @ Word add r4, r5, r4, lsr #10 -ldmia r12!, {r3} +ldmia r0!, {r3} 2: -cmp r5, r4 -stmltia r5!, {r3} +cmp r1, r4 +stmltia r1!, {r3} blt 2b b 3f @ Halfword @@ -233,9 +233,9 @@ beq 1f @ Word add r4, r5, r4, lsr #10 2: -cmp r5, r4 -ldmltia r12!, {r3} -stmltia r5!, {r3} +cmp r1, r4 +ldmltia r0!, {r3} +stmltia r1!, {r3} blt 2b b 3f @ Halfword