From 76eb52ab5277ad69cd0908f8492483ef5881ee75 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Wed, 18 Mar 2020 01:09:21 +0100 Subject: Various fixes/matches - Matched all remaining functions in `__osMalloc.c`, 2 functions in `code_8007BF90.c`, 1 in `code_800A9F30.c`, 2 in `fault.c`, 1 in `fault_drawer.c`, 1 in `gfxprint.c`, 2 in `z_camera.c` - Improved most other remaining non matchings to ensure they are actually equivalent and to get them closer to matching - Added a `alloc.h` header file in the process of working on `fault.c` non matchings - Decompiled `padmgr.c` data/bss in order to improve padmgr non matchings - Removed unused `z_en_wallmas.c` data files - Moved functions confirmed to be in `z_cheap_proc.c` to their own file with that name --- src/code/code_8007BF90.c | 71 ++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'src/code/code_8007BF90.c') diff --git a/src/code/code_8007BF90.c b/src/code/code_8007BF90.c index 8c5347971..a7e1cca5b 100644 --- a/src/code/code_8007BF90.c +++ b/src/code/code_8007BF90.c @@ -1,7 +1,7 @@ #include #include -void func_8007C1AC(Vec3f* dest, struct_80045714* arg1); +Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1); f32 func_8007BF90(Vec3f* a, Vec3f* b) { @@ -33,49 +33,48 @@ f32 func_8007C058(f32 arg0, f32 arg1) #pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C0A8.s") -#ifdef NON_MATCHING -void func_8007C0F8(Vec3f* dest, Vec3f* a, Vec3f* b) +Vec3f* func_8007C0F8(Vec3f* dest, Vec3f* a, Vec3f* b) { - f32 fVar1; - Vec3f v; + Vec3f v1; + Vec3f v2; + f32 temp; + + v1.x = b->x - a->x; + v1.y = b->y - a->y; + v1.z = b->z - a->z; + + temp = func_8007C058(sqrtf(SQ(v1.x) + SQ(v1.y) + SQ(v1.z)), 0.01f); - v.x = b->x - a->x; - v.y = b->y - a->y; - v.z = b->z - a->z; + v2.x = v1.x / temp; + v2.y = v1.y / temp; + v2.z = v1.z / temp; - fVar1 = func_8007C058(sqrtf(v.x * v.x + v.y * v.y + v.z * v.z), D_8013CB80); + *dest = v2; - dest->x = v.x / fVar1; - dest->y = v.y / fVar1; - dest->z = v.z / fVar1; + return dest; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C0F8.s") -#endif -#ifdef NON_MATCHING -void func_8007C1AC(Vec3f* dest, struct_80045714* arg1) +Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1) { - f32 fVar1; - f32 fVar2; - f32 fVar3; - f32 fVar4; - f32 fVar5; - f32 fVar6; - - fVar1 = Math_Coss(arg1->unk_04); - fVar2 = Math_Coss(arg1->unk_06); - fVar3 = Math_Coss(arg1->unk_04); - fVar4 = Math_Coss(arg1->unk_06); - fVar6 = arg1->unk_00; - fVar5 = arg1->unk_00; - dest->x = arg1->unk_00 * fVar3 * fVar4; - dest->y = fVar6 * fVar1; - dest->z = fVar5 * fVar3 * fVar2; + Vec3f v; + f32 sin4; + f32 cos4; + f32 sin6; + f32 cos6; + + cos4 = Math_Coss(arg1->unk_04); + cos6 = Math_Coss(arg1->unk_06); + sin4 = Math_Sins(arg1->unk_04); + sin6 = Math_Sins(arg1->unk_06); + + v.x = arg1->unk_00 * sin4 * sin6; + v.y = arg1->unk_00 * cos4; + v.z = arg1->unk_00 * sin4 * cos6; + + *dest = v; + + return dest; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C1AC.s") -#endif void func_8007C3F4(struct_80045714* arg0, Vec3f* arg1); -- cgit v1.2.3 From 0cf75356a557e94f7919521ff9ad53e4b733ac20 Mon Sep 17 00:00:00 2001 From: glank Date: Sat, 21 Mar 2020 03:09:42 +0100 Subject: code_800FCE80 OK --- src/code/code_8007BF90.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/code/code_8007BF90.c') diff --git a/src/code/code_8007BF90.c b/src/code/code_8007BF90.c index a7e1cca5b..f947e042b 100644 --- a/src/code/code_8007BF90.c +++ b/src/code/code_8007BF90.c @@ -121,8 +121,8 @@ Vec3f* func_8007C4E0(Vec3f* dest, Vec3f* a, Vec3f* b) { Vec3f var; - var.x = func_800FD250(b->z - a->z, b->y - a->y); - var.y = func_800FD250(b->x - a->x, b->z - a->z); + var.x = Math_atan2f(b->z - a->z, b->y - a->y); + var.y = Math_atan2f(b->x - a->x, b->z - a->z); var.z = 0; *dest = var; -- cgit v1.2.3 From 8cfe7cce9f8d8abea794e67510879e751d373a87 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Sun, 22 Mar 2020 22:19:43 +0100 Subject: Format all src C files --- src/code/code_8007BF90.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'src/code/code_8007BF90.c') diff --git a/src/code/code_8007BF90.c b/src/code/code_8007BF90.c index f947e042b..c51b222f9 100644 --- a/src/code/code_8007BF90.c +++ b/src/code/code_8007BF90.c @@ -3,8 +3,7 @@ Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1); -f32 func_8007BF90(Vec3f* a, Vec3f* b) -{ +f32 func_8007BF90(Vec3f* a, Vec3f* b) { f32 dx = a->x - b->x; f32 dy = a->y - b->y; f32 dz = a->z - b->z; @@ -12,8 +11,7 @@ f32 func_8007BF90(Vec3f* a, Vec3f* b) return sqrtf(SQ(dx) + SQ(dy) + SQ(dz)); } -f32 func_8007BFD0(Vec3f* a, Vec3f* b, Vec3f* dest) -{ +f32 func_8007BFD0(Vec3f* a, Vec3f* b, Vec3f* dest) { dest->x = a->x - b->x; dest->y = a->y - b->y; dest->z = a->z - b->z; @@ -21,20 +19,17 @@ f32 func_8007BFD0(Vec3f* a, Vec3f* b, Vec3f* dest) return sqrtf(SQ(dest->x) + SQ(dest->y) + SQ(dest->z)); } -f32 func_8007C028(Vec3f* a, Vec3f* b) -{ +f32 func_8007C028(Vec3f* a, Vec3f* b) { return sqrtf(SQ(a->x - b->x) + SQ(a->z - b->z)); } -f32 func_8007C058(f32 arg0, f32 arg1) -{ +f32 func_8007C058(f32 arg0, f32 arg1) { return (arg1 <= fabsf(arg0)) ? arg0 : ((arg0 >= 0) ? arg1 : -arg1); } #pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C0A8.s") -Vec3f* func_8007C0F8(Vec3f* dest, Vec3f* a, Vec3f* b) -{ +Vec3f* func_8007C0F8(Vec3f* dest, Vec3f* a, Vec3f* b) { Vec3f v1; Vec3f v2; f32 temp; @@ -54,8 +49,7 @@ Vec3f* func_8007C0F8(Vec3f* dest, Vec3f* a, Vec3f* b) return dest; } -Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1) -{ +Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1) { Vec3f v; f32 sin4; f32 cos4; @@ -78,8 +72,7 @@ Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1) void func_8007C3F4(struct_80045714* arg0, Vec3f* arg1); -void func_8007C25C(Vec3f* dest, struct_80045714* arg1) -{ +void func_8007C25C(Vec3f* dest, struct_80045714* arg1) { struct_80045714 var; var.unk_00 = arg1->unk_00; @@ -95,8 +88,7 @@ void func_8007C25C(Vec3f* dest, struct_80045714* arg1) void func_8007C29C(struct_80045714* arg0, Vec3f* arg1); -void func_8007C440(struct_80045714* arg0, Vec3f* a, Vec3f* b) -{ +void func_8007C440(struct_80045714* arg0, Vec3f* a, Vec3f* b) { Vec3f var; var.x = b->x - a->x; @@ -106,8 +98,7 @@ void func_8007C440(struct_80045714* arg0, Vec3f* a, Vec3f* b) func_8007C29C(arg0, &var); } -void func_8007C490(struct_80045714* arg0, Vec3f* a, Vec3f* b) -{ +void func_8007C490(struct_80045714* arg0, Vec3f* a, Vec3f* b) { Vec3f var; var.x = b->x - a->x; @@ -117,8 +108,7 @@ void func_8007C490(struct_80045714* arg0, Vec3f* a, Vec3f* b) func_8007C3F4(arg0, &var); } -Vec3f* func_8007C4E0(Vec3f* dest, Vec3f* a, Vec3f* b) -{ +Vec3f* func_8007C4E0(Vec3f* dest, Vec3f* a, Vec3f* b) { Vec3f var; var.x = Math_atan2f(b->z - a->z, b->y - a->y); @@ -133,4 +123,3 @@ Vec3f* func_8007C4E0(Vec3f* dest, Vec3f* a, Vec3f* b) #pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C574.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C5E0.s") - -- cgit v1.2.3