From e37091595b7aac206f78ab20da9439d275593f02 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 20 Apr 2017 17:53:01 -0700 Subject: [PATCH] GBA BIOS: Fix ArcTan sign in HLE BIOS --- CHANGES | 1 + src/gba/bios.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index db314bc37..89f1629ac 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,7 @@ Bugfixes: - SDL: Fix race condition with audio thread when starting - FFmpeg: Fix overflow and general issues with audio encoding - Qt: Fix crash when changing audio settings after a game is closed + - GBA BIOS: Fix ArcTan sign in HLE BIOS Misc: - Qt: Improved HiDPI support - Feature: Support ImageMagick 7 diff --git a/src/gba/bios.c b/src/gba/bios.c index 831eee9a6..e3ad8f011 100644 --- a/src/gba/bios.c +++ b/src/gba/bios.c @@ -270,7 +270,7 @@ static void _Div(struct GBA* gba, int32_t num, int32_t denom) { } } -static int16_t _ArcTan(int16_t i) { +static int16_t _ArcTan(int32_t i) { int32_t a = -((i * i) >> 14); int32_t b = ((0xA9 * a) >> 14) + 0x390; b = ((b * a) >> 14) + 0x91C; @@ -355,7 +355,7 @@ void GBASwi16(struct ARMCore* cpu, int immediate) { cpu->gprs[0] = sqrt((uint32_t) cpu->gprs[0]); break; case 0x9: - cpu->gprs[0] = (uint16_t) _ArcTan(cpu->gprs[0]); + cpu->gprs[0] = _ArcTan(cpu->gprs[0]); break; case 0xA: cpu->gprs[0] = (uint16_t) _ArcTan2(cpu->gprs[0], cpu->gprs[1]);