From a5132a7b8f2727a33f0a1a0e4347025fb581bf67 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 16 Jun 2016 00:19:20 -0700 Subject: [PATCH] GBA BIOS: Fix ArcTan2 accuracy and boundary conditions --- CHANGES | 1 + src/gba/bios.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 91eee9769..77e3446b7 100644 --- a/CHANGES +++ b/CHANGES @@ -22,6 +22,7 @@ Bugfixes: - ARM7: Fix flags on SBC/RSC - Util: Fix realloc semantics in utf16to8 - ARM7: Fix setting spsr privilege bits when spsr is empty + - GBA BIOS: Fix ArcTan2 accuracy and boundary conditions Misc: - GBA: Slightly optimize GBAProcessEvents - Qt: Add preset for DualShock 4 diff --git a/src/gba/bios.c b/src/gba/bios.c index 5afdd73df..9895155e5 100644 --- a/src/gba/bios.c +++ b/src/gba/bios.c @@ -301,7 +301,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) { cpu->gprs[0] = sqrt((uint32_t) cpu->gprs[0]); break; case 0xA: - cpu->gprs[0] = atan2f(cpu->gprs[1] / 16384.f, cpu->gprs[0] / 16384.f) / (2 * M_PI) * 0x10000; + cpu->gprs[0] = (uint16_t) (atan2f(cpu->gprs[1] / 16384.f, cpu->gprs[0] / 16384.f) / (2 * M_PI) * 0x10001); break; case 0xB: case 0xC: