From 1a99793ab1041fe0788ba515f4e6b136a9812046 Mon Sep 17 00:00:00 2001 From: angie Date: Sun, 3 Apr 2022 21:06:21 -0400 Subject: [PATCH] func_8017FB1C --- src/code/sys_math3d.c | 50 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index f52440dc5..d9e8ed812 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -2270,7 +2270,55 @@ s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z) { return false; } -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_math3d/func_8017FB1C.s") +s32 func_8017FB1C(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32* arg7, f32* arg8, f32* arg9, f32* argA) { + f32 temp_fa0; + f32 temp_fa1; + f32 temp_fs0; + f32 temp_fv0; + f32 temp_ft5; + f32 temp_fv1; + f32 temp_ft2; + s32 phi_a1; + + temp_fa1 = SQ(arg5) + SQ(arg6); + temp_fv1 = arg3 - arg0; + temp_fa0 = arg4 - arg1; + + if ((IS_ZERO(arg5) && IS_ZERO(arg6)) || IS_ZERO(temp_fa1)) { + *arg7 = 0.0f; + *arg8 = 0.0f; + *arg9 = 0.0f; + *argA = 0.0f; + return 0; + } + + temp_fs0 = 2.0f * ((arg5 * temp_fv1) + (arg6 * temp_fa0)); + temp_ft5 = SQ(temp_fs0) - (4.0f * temp_fa1 * ((SQ(temp_fv1) + SQ(temp_fa0)) - SQ(arg2))); + phi_a1 = 0; + + if (IS_ZERO(temp_ft5)) { + temp_fv0 = (-temp_fs0 / (2.0f * temp_fa1)); + *arg7 = (arg5 * temp_fv0) + arg3; + *arg8 = (arg6 * temp_fv0) + arg4; + *arg9 = 0.0f; + *argA = 0.0f; + } + + if (temp_ft5 > 0.0f) { + temp_fv0 = ((-temp_fs0 - sqrtf(temp_ft5)) / (2.0f * temp_fa1)); + temp_ft2 = ((sqrtf(temp_ft5) + -temp_fs0) / (2.0f * temp_fa1)); + *arg7 = (arg5 * temp_fv0) + arg3; + *arg8 = (arg6 * temp_fv0) + arg4; + *arg9 = (arg5 * temp_ft2) + arg3; + *argA = (arg6 * temp_ft2) + arg4; + phi_a1 = 2; + } else { + *arg7 = 0.0f; + *arg8 = 0.0f; + } + + return phi_a1; +} void func_8017FD44(Vec3f* arg0, Vec3f* arg1, Vec3f* dst, f32 arg3) { Vec3f sp2C;