From 0ac8284fb26ddafcff799fa1011d8b3a7bdeb558 Mon Sep 17 00:00:00 2001 From: Matthew <25674682+spazzylemons@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:03:41 -0500 Subject: [PATCH] Match func_802B5B14 (#581) * Match func_802B5B14 --- .../racing/math_util/func_802B5B14.s | 103 ------------------ src/racing/math_util.c | 83 +++++--------- src/racing/math_util.h | 1 + 3 files changed, 31 insertions(+), 156 deletions(-) delete mode 100644 asm/non_matchings/racing/math_util/func_802B5B14.s diff --git a/asm/non_matchings/racing/math_util/func_802B5B14.s b/asm/non_matchings/racing/math_util/func_802B5B14.s deleted file mode 100644 index 1346869d1..000000000 --- a/asm/non_matchings/racing/math_util/func_802B5B14.s +++ /dev/null @@ -1,103 +0,0 @@ -glabel func_802B5B14 -/* 11F124 802B5B14 27BDFF78 */ addiu $sp, $sp, -0x88 -/* 11F128 802B5B18 AFB10020 */ sw $s1, 0x20($sp) -/* 11F12C 802B5B1C 00808825 */ move $s1, $a0 -/* 11F130 802B5B20 AFBF0024 */ sw $ra, 0x24($sp) -/* 11F134 802B5B24 AFB0001C */ sw $s0, 0x1c($sp) -/* 11F138 802B5B28 F7B40010 */ sdc1 $f20, 0x10($sp) -/* 11F13C 802B5B2C 00A08025 */ move $s0, $a1 -/* 11F140 802B5B30 0C0AE006 */ jal sins -/* 11F144 802B5B34 94A40000 */ lhu $a0, ($a1) -/* 11F148 802B5B38 E7A00038 */ swc1 $f0, 0x38($sp) -/* 11F14C 802B5B3C 0C0AE00E */ jal coss -/* 11F150 802B5B40 96040000 */ lhu $a0, ($s0) -/* 11F154 802B5B44 46000506 */ mov.s $f20, $f0 -/* 11F158 802B5B48 0C0AE006 */ jal sins -/* 11F15C 802B5B4C 96040002 */ lhu $a0, 2($s0) -/* 11F160 802B5B50 96040002 */ lhu $a0, 2($s0) -/* 11F164 802B5B54 0C0AE00E */ jal coss -/* 11F168 802B5B58 E7A00030 */ swc1 $f0, 0x30($sp) -/* 11F16C 802B5B5C 96040004 */ lhu $a0, 4($s0) -/* 11F170 802B5B60 0C0AE006 */ jal sins -/* 11F174 802B5B64 E7A0002C */ swc1 $f0, 0x2c($sp) -/* 11F178 802B5B68 96040004 */ lhu $a0, 4($s0) -/* 11F17C 802B5B6C 0C0AE00E */ jal coss -/* 11F180 802B5B70 E7A00028 */ swc1 $f0, 0x28($sp) -/* 11F184 802B5B74 C7AE0030 */ lwc1 $f14, 0x30($sp) -/* 11F188 802B5B78 C7A80038 */ lwc1 $f8, 0x38($sp) -/* 11F18C 802B5B7C C7B0002C */ lwc1 $f16, 0x2c($sp) -/* 11F190 802B5B80 C6240000 */ lwc1 $f4, ($s1) -/* 11F194 802B5B84 460E4302 */ mul.s $f12, $f8, $f14 -/* 11F198 802B5B88 C7A20028 */ lwc1 $f2, 0x28($sp) -/* 11F19C 802B5B8C E7A4003C */ swc1 $f4, 0x3c($sp) -/* 11F1A0 802B5B90 46008282 */ mul.s $f10, $f16, $f0 -/* 11F1A4 802B5B94 C6260004 */ lwc1 $f6, 4($s1) -/* 11F1A8 802B5B98 46026102 */ mul.s $f4, $f12, $f2 -/* 11F1AC 802B5B9C E7A60040 */ swc1 $f6, 0x40($sp) -/* 11F1B0 802B5BA0 46045180 */ add.s $f6, $f10, $f4 -/* 11F1B4 802B5BA4 46008287 */ neg.s $f10, $f16 -/* 11F1B8 802B5BA8 E7A60048 */ swc1 $f6, 0x48($sp) -/* 11F1BC 802B5BAC 46025102 */ mul.s $f4, $f10, $f2 -/* 11F1C0 802B5BB0 00000000 */ nop -/* 11F1C4 802B5BB4 46006282 */ mul.s $f10, $f12, $f0 -/* 11F1C8 802B5BB8 460A2100 */ add.s $f4, $f4, $f10 -/* 11F1CC 802B5BBC 460EA282 */ mul.s $f10, $f20, $f14 -/* 11F1D0 802B5BC0 E7A40058 */ swc1 $f4, 0x58($sp) -/* 11F1D4 802B5BC4 4602A102 */ mul.s $f4, $f20, $f2 -/* 11F1D8 802B5BC8 E7AA0068 */ swc1 $f10, 0x68($sp) -/* 11F1DC 802B5BCC 4600A282 */ mul.s $f10, $f20, $f0 -/* 11F1E0 802B5BD0 E7A4004C */ swc1 $f4, 0x4c($sp) -/* 11F1E4 802B5BD4 46104482 */ mul.s $f18, $f8, $f16 -/* 11F1E8 802B5BD8 46004107 */ neg.s $f4, $f8 -/* 11F1EC 802B5BDC E7AA005C */ swc1 $f10, 0x5c($sp) -/* 11F1F0 802B5BE0 46007287 */ neg.s $f10, $f14 -/* 11F1F4 802B5BE4 E7A4006C */ swc1 $f4, 0x6c($sp) -/* 11F1F8 802B5BE8 46005102 */ mul.s $f4, $f10, $f0 -/* 11F1FC 802B5BEC 00000000 */ nop -/* 11F200 802B5BF0 46029202 */ mul.s $f8, $f18, $f2 -/* 11F204 802B5BF4 46082280 */ add.s $f10, $f4, $f8 -/* 11F208 802B5BF8 46027102 */ mul.s $f4, $f14, $f2 -/* 11F20C 802B5BFC 00000000 */ nop -/* 11F210 802B5C00 46009202 */ mul.s $f8, $f18, $f0 -/* 11F214 802B5C04 E7AA0050 */ swc1 $f10, 0x50($sp) -/* 11F218 802B5C08 46082100 */ add.s $f4, $f4, $f8 -/* 11F21C 802B5C0C 4610A202 */ mul.s $f8, $f20, $f16 -/* 11F220 802B5C10 E7A40060 */ swc1 $f4, 0x60($sp) -/* 11F224 802B5C14 C7A4003C */ lwc1 $f4, 0x3c($sp) -/* 11F228 802B5C18 E7A80070 */ swc1 $f8, 0x70($sp) -/* 11F22C 802B5C1C 46062202 */ mul.s $f8, $f4, $f6 -/* 11F230 802B5C20 C7A6004C */ lwc1 $f6, 0x4c($sp) -/* 11F234 802B5C24 C7A40040 */ lwc1 $f4, 0x40($sp) -/* 11F238 802B5C28 46062182 */ mul.s $f6, $f4, $f6 -/* 11F23C 802B5C2C 46064200 */ add.s $f8, $f8, $f6 -/* 11F240 802B5C30 46045182 */ mul.s $f6, $f10, $f4 -/* 11F244 802B5C34 46083280 */ add.s $f10, $f6, $f8 -/* 11F248 802B5C38 E62A0000 */ swc1 $f10, ($s1) -/* 11F24C 802B5C3C C7A4003C */ lwc1 $f4, 0x3c($sp) -/* 11F250 802B5C40 C7A60058 */ lwc1 $f6, 0x58($sp) -/* 11F254 802B5C44 C7AA0040 */ lwc1 $f10, 0x40($sp) -/* 11F258 802B5C48 46062202 */ mul.s $f8, $f4, $f6 -/* 11F25C 802B5C4C C7A4005C */ lwc1 $f4, 0x5c($sp) -/* 11F260 802B5C50 46045182 */ mul.s $f6, $f10, $f4 -/* 11F264 802B5C54 46064100 */ add.s $f4, $f8, $f6 -/* 11F268 802B5C58 C7A80060 */ lwc1 $f8, 0x60($sp) -/* 11F26C 802B5C5C 460A4182 */ mul.s $f6, $f8, $f10 -/* 11F270 802B5C60 46043200 */ add.s $f8, $f6, $f4 -/* 11F274 802B5C64 E6280004 */ swc1 $f8, 4($s1) -/* 11F278 802B5C68 C7A60068 */ lwc1 $f6, 0x68($sp) -/* 11F27C 802B5C6C C7AA003C */ lwc1 $f10, 0x3c($sp) -/* 11F280 802B5C70 C7A80040 */ lwc1 $f8, 0x40($sp) -/* 11F284 802B5C74 46065102 */ mul.s $f4, $f10, $f6 -/* 11F288 802B5C78 C7AA006C */ lwc1 $f10, 0x6c($sp) -/* 11F28C 802B5C7C 460A4182 */ mul.s $f6, $f8, $f10 -/* 11F290 802B5C80 46062280 */ add.s $f10, $f4, $f6 -/* 11F294 802B5C84 C7A40070 */ lwc1 $f4, 0x70($sp) -/* 11F298 802B5C88 46082182 */ mul.s $f6, $f4, $f8 -/* 11F29C 802B5C8C 460A3100 */ add.s $f4, $f6, $f10 -/* 11F2A0 802B5C90 E6240008 */ swc1 $f4, 8($s1) -/* 11F2A4 802B5C94 8FBF0024 */ lw $ra, 0x24($sp) -/* 11F2A8 802B5C98 8FB10020 */ lw $s1, 0x20($sp) -/* 11F2AC 802B5C9C 8FB0001C */ lw $s0, 0x1c($sp) -/* 11F2B0 802B5CA0 D7B40010 */ ldc1 $f20, 0x10($sp) -/* 11F2B4 802B5CA4 03E00008 */ jr $ra -/* 11F2B8 802B5CA8 27BD0088 */ addiu $sp, $sp, 0x88 diff --git a/src/racing/math_util.c b/src/racing/math_util.c index c4b6e3169..aef024671 100644 --- a/src/racing/math_util.c +++ b/src/racing/math_util.c @@ -372,61 +372,38 @@ void mtxf_s16_rotate_z(Mat4 mat, s16 angle) { */ } -#ifdef MIPS_TO_C -//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-29-2023 -void func_802B5B14(f32 *arg0, s16 *arg1) { - f32 sp70; - f32 sp6C; - f32 sp68; - f32 sp60; - f32 sp5C; - f32 sp58; - f32 sp50; - f32 sp4C; - f32 sp48; - f32 sp40; - f32 sp3C; - f32 sp38; - f32 sp30; - f32 sp2C; - f32 sp28; - f32 temp_f0; - f32 temp_f10; - f32 temp_f12; - f32 temp_f18; - f32 temp_f20; - f32 temp_f4; - f32 temp_f6; +void func_802B5B14(Vec3f b, Vec3s rotate) { + Mat4 mtx; + Vec3f copy; - sp38 = sins((u16) arg1->unk0); - temp_f20 = coss((u16) arg1->unk0); - sp30 = sins(arg1->unk2); - sp2C = coss(arg1->unk2); - sp28 = sins(arg1->unk4); - temp_f0 = coss(arg1->unk4); - temp_f4 = arg0->unk0; - temp_f12 = sp38 * sp30; - sp3C = temp_f4; - sp40 = arg0->unk4; - temp_f6 = (sp2C * temp_f0) + (temp_f12 * sp28); - sp48 = temp_f6; - sp58 = (-sp2C * sp28) + (temp_f12 * temp_f0); - sp68 = temp_f20 * sp30; - sp4C = temp_f20 * sp28; - temp_f18 = sp38 * sp2C; - sp5C = temp_f20 * temp_f0; - sp6C = -sp38; - temp_f10 = (-sp30 * temp_f0) + (temp_f18 * sp28); - sp50 = temp_f10; - sp60 = (sp30 * sp28) + (temp_f18 * temp_f0); - sp70 = temp_f20 * sp2C; - arg0->unk0 = (temp_f10 * sp40) + ((temp_f4 * temp_f6) + (sp40 * sp4C)); - arg0->unk4 = (f32) ((sp60 * sp40) + ((temp_f4 * sp58) + (sp40 * sp5C))); - arg0->unk8 = (f32) ((sp70 * sp40) + ((sp3C * sp68) + (sp40 * sp6C))); + f32 sx = sins(rotate[0]); + f32 cx = coss(rotate[0]); + + f32 sy = sins(rotate[1]); + f32 cy = coss(rotate[1]); + + f32 sz = sins(rotate[2]); + f32 cz = coss(rotate[2]); + + copy[0] = b[0]; + copy[1] = b[1]; + + mtx[0][0] = cy * cz + sx * sy * sz; + mtx[1][0] = -cy * sz + sx * sy * cz; + mtx[2][0] = cx * sy; + + mtx[0][1] = cx * sz; + mtx[1][1] = cx * cz; + mtx[2][1] = -sx; + + mtx[0][2] = -sy * cz + sx * cy * sz; + mtx[1][2] = sy * sz + sx * cy * cz; + mtx[2][2] = cx * cy; + + b[0] = copy[0] * mtx[0][0] + copy[1] * mtx[0][1] + copy[1] * mtx[0][2]; + b[1] = copy[0] * mtx[1][0] + copy[1] * mtx[1][1] + copy[1] * mtx[1][2]; + b[2] = copy[0] * mtx[2][0] + copy[1] * mtx[2][1] + copy[1] * mtx[2][2]; } -#else -GLOBAL_ASM("asm/non_matchings/racing/math_util/func_802B5B14.s") -#endif void func_802B5CAC(s16 arg0, s16 arg1, Vec3f arg2) { f32 sp2C = sins(arg1); diff --git a/src/racing/math_util.h b/src/racing/math_util.h index 06f76fc7d..794028219 100644 --- a/src/racing/math_util.h +++ b/src/racing/math_util.h @@ -36,6 +36,7 @@ void func_802B5564(Mat4, u16*, f32, f32, f32, f32, f32); void mtxf_rotate_x(Mat4, s16); void mtxf_rotate_y(Mat4, s16); void mtxf_s16_rotate_z(Mat4, s16); +void func_802B5B14(Vec3f b, Vec3s rotate); // unused void func_802B5CAC(s16, s16, Vec3f); void func_802B5D30(s16, s16, s32); void func_802B5D64(uintptr_t, s16, s16, s32);