From 6d8dc724c2765c10b4e6f3f3e53855aa5175e6b7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 11 Oct 2016 22:01:13 -0700 Subject: [PATCH] GBA BIOS: Fix MidiKey2Freq BIOS reads --- CHANGES | 1 + src/gba/bios.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index 2789e1f3e..eecd7ed76 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 0.5.2: (Future) Bugfixes: - GBA Memory: Fix misaligned BIOS reads + - GBA BIOS: Fix MidiKey2Freq BIOS reads 0.5.1: (2016-10-05) Bugfixes: diff --git a/src/gba/bios.c b/src/gba/bios.c index 13a96cfc8..f0fd4b451 100644 --- a/src/gba/bios.c +++ b/src/gba/bios.c @@ -244,7 +244,12 @@ static void _ObjAffineSet(struct GBA* gba) { static void _MidiKey2Freq(struct GBA* gba) { struct ARMCore* cpu = gba->cpu; + + int oldRegion = gba->memory.activeRegion; + gba->memory.activeRegion = REGION_BIOS; uint32_t key = cpu->memory.load32(cpu, cpu->gprs[0] + 4, 0); + gba->memory.activeRegion = oldRegion; + cpu->gprs[0] = key / powf(2, (180.f - cpu->gprs[1] - cpu->gprs[2] / 256.f) / 12.f); }