From 63e809550d9bc7385157c7aa5bef0534d298045f Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 20 Apr 2013 03:01:50 -0700 Subject: [PATCH] Implement MidiKey2Freq --- src/gba/gba-bios.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gba/gba-bios.c b/src/gba/gba-bios.c index 35be7dd02..293828e11 100644 --- a/src/gba/gba-bios.c +++ b/src/gba/gba-bios.c @@ -3,6 +3,8 @@ #include "gba.h" #include "gba-memory.h" +#include + static void _unLz77(struct GBAMemory* memory, uint32_t source, uint8_t* dest); static void _CpuSet(struct GBA* gba) { @@ -68,6 +70,11 @@ static void _FastCpuSet(struct GBA* gba) { } } +static void _MidiKey2Freq(struct GBA* gba) { + uint32_t key = GBALoad32(&gba->memory.d, gba->cpu.gprs[0] + 4); + gba->cpu.gprs[0] = key / pow(2, (180 - gba->cpu.gprs[1] - gba->cpu.gprs[2] / 256) / 12); +} + void GBASwi16(struct ARMBoard* board, int immediate) { struct GBA* gba = ((struct GBABoard*) board)->p; switch (immediate) { @@ -86,6 +93,9 @@ void GBASwi16(struct ARMBoard* board, int immediate) { case 0x12: _unLz77(&gba->memory, gba->cpu.gprs[0], &((uint8_t*) gba->video.renderer->vram)[(gba->cpu.gprs[1] & (SIZE_VRAM - 1))]); break; + case 0x1F: + _MidiKey2Freq(gba); + break; default: GBALog(GBA_LOG_STUB, "Stub software interrupt: %02x", immediate); }