From 17a664753803d9b1606fa28cac62ef4b637a0ec9 Mon Sep 17 00:00:00 2001 From: sozud <122322823+sozud@users.noreply.github.com> Date: Sun, 26 May 2024 13:14:27 -0700 Subject: [PATCH] WRP PSP func_8018C1E0 (#1183) --- src/st/wrp_psp/st_common.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/st/wrp_psp/st_common.c b/src/st/wrp_psp/st_common.c index 8659434e3..43a95465f 100644 --- a/src/st/wrp_psp/st_common.c +++ b/src/st/wrp_psp/st_common.c @@ -61,7 +61,28 @@ u16 func_8018C160(Entity* a, Entity* b) { return ratan2(diffY, diffX); } -INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/st_common", func_8018C1E0); +u16 func_8018C1E0(u16 arg0, u16 arg1, u16 arg2) { + u16 temp_a2 = (s16)(arg2 - arg1); + u16 var_v0; + + if (temp_a2 & 0x800) { + var_v0 = (0x800 - temp_a2) & 0x7FF; + } else { + var_v0 = temp_a2; + } + + if (var_v0 > arg0) { + if (temp_a2 & 0x800) { + var_v0 = arg1 - arg0; + } else { + var_v0 = arg1 + arg0; + } + + return var_v0; + } + + return arg2; +} void SetStep(u8 step) { g_CurrentEntity->step = step;