Imported funcs from sm64 to code_80004740.c and trig_tables.inc.c (#68)

* fixed float issue brought over from zeldaret

* Import trig_tables.inc.c

* Delete game_data_802BA370.s

* Import two funcs from sm64 into code_80004740.c
This commit is contained in:
CoderStig
2021-11-28 15:42:03 -07:00
committed by GitHub
parent 7387724509
commit 632512ada9
132 changed files with 2469 additions and 6154 deletions
+101 -107
View File
@@ -3,10 +3,18 @@
#include <types.h>
#include <common_structs.h>
// Location based from sm64.
// This may need to be moved before framebuffers.c
// If math_util has data that does not line-up with trig_tables.
#include "trig_tables.inc.c"
f32 func_802B4F60(s32 arg0, f32 arg2, f32 arg3); // static
f32 func_802B6434(f32, f32, f32 *, f32 *); // static
s16 func_802B7830(f32 y, f32 x);
extern f32 gSineTable[];
extern f32 gCosineTable[];
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
? func_802B4F60(s32 arg0, ? arg2, ? arg3) {
@@ -485,8 +493,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B5794.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
? func_802B53C8(void *); /* extern */
f32 func_802B8018(s32); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32); /* extern */
f32 coss(s32); /* extern */
void func_802B59DC(void *arg0, s32 arg1) {
f32 sp2C;
@@ -497,9 +505,9 @@ void func_802B59DC(void *arg0, s32 arg1) {
temp_a0 = arg1 & 0xFFFF;
sp24 = temp_a0;
temp_f0 = func_802B8018(temp_a0);
temp_f0 = sins(temp_a0);
sp2C = temp_f0;
sp28 = func_802B8038(temp_a0);
sp28 = coss(temp_a0);
func_802B53C8(arg0);
arg0->unk18 = temp_f0;
arg0->unk24 = -temp_f0;
@@ -515,8 +523,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B59DC.s")
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
? func_802B53C8(void *); /* extern */
f32 func_802B8018(s32); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32); /* extern */
f32 coss(s32); /* extern */
void func_802B5A44(void *arg0, s32 arg1) {
f32 sp2C;
@@ -527,9 +535,9 @@ void func_802B5A44(void *arg0, s32 arg1) {
temp_a0 = arg1 & 0xFFFF;
sp24 = temp_a0;
temp_f0 = func_802B8018(temp_a0);
temp_f0 = sins(temp_a0);
sp2C = temp_f0;
sp28 = func_802B8038(temp_a0);
sp28 = coss(temp_a0);
func_802B53C8(arg0);
arg0->unk20 = temp_f0;
arg0->unk8 = -temp_f0;
@@ -545,8 +553,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B5A44.s")
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
? func_802B53C8(void *); /* extern */
f32 func_802B8018(s32); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32); /* extern */
f32 coss(s32); /* extern */
void func_802B5AAC(void *arg0, s32 arg1) {
f32 sp2C;
@@ -557,9 +565,9 @@ void func_802B5AAC(void *arg0, s32 arg1) {
temp_a0 = arg1 & 0xFFFF;
sp24 = temp_a0;
temp_f0 = func_802B8018(temp_a0);
temp_f0 = sins(temp_a0);
sp2C = temp_f0;
sp28 = func_802B8038(temp_a0);
sp28 = coss(temp_a0);
func_802B53C8(arg0);
arg0->unk4 = temp_f0;
arg0->unk10 = -temp_f0;
@@ -572,8 +580,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B5AAC.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
f32 func_802B8018(u16); /* extern */
f32 func_802B8038(u16); /* extern */
f32 sins(u16); /* extern */
f32 coss(u16); /* extern */
void func_802B5B14(void *arg0, void *arg1) {
f32 sp70;
@@ -599,12 +607,12 @@ void func_802B5B14(void *arg0, void *arg1) {
f32 temp_f4;
f32 temp_f6;
sp38 = func_802B8018(arg1->unk0);
temp_f20 = func_802B8038(arg1->unk0);
sp30 = func_802B8018(arg1->unk2);
sp2C = func_802B8038(arg1->unk2);
sp28 = func_802B8018(arg1->unk4);
temp_f0 = func_802B8038(arg1->unk4);
sp38 = sins(arg1->unk0);
temp_f20 = coss(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;
@@ -631,8 +639,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B5B14.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
f32 func_802B8018(s32); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32); /* extern */
f32 coss(s32); /* extern */
void func_802B5CAC(u16 arg0, s32 arg1, void *arg2) {
f32 sp2C;
@@ -644,11 +652,11 @@ void func_802B5CAC(u16 arg0, s32 arg1, void *arg2) {
temp_a0 = arg1 & 0xFFFF;
sp1C = temp_a0;
sp2C = func_802B8018(temp_a0);
sp28 = func_802B8038(temp_a0);
sp2C = sins(temp_a0);
sp28 = coss(temp_a0);
sp1C = arg0;
sp24 = func_802B8018(arg0);
temp_f10 = sp28 * func_802B8038(arg0);
sp24 = sins(arg0);
temp_f10 = sp28 * coss(arg0);
arg2->unk0 = sp28 * sp24;
arg2->unk4 = sp2C;
arg2->unk8 = -temp_f10;
@@ -672,8 +680,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B5D30.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
f32 func_802B8018(s32); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32); /* extern */
f32 coss(s32); /* extern */
extern ? gSegmentTable;
void func_802B5D64(u32 arg0, u16 arg1, s32 arg2, s32 arg3) {
@@ -700,12 +708,12 @@ void func_802B5D64(u32 arg0, u16 arg1, s32 arg2, s32 arg3) {
temp_a0 = arg2 & 0xFFFF;
temp_s0 = *(&gSegmentTable + ((arg0 >> 0x18) * 4)) + (arg0 & 0xFFFFFF) + 0x80000000;
sp20 = temp_a0;
sp48 = func_802B8018(temp_a0);
sp44 = func_802B8038(temp_a0);
sp48 = sins(temp_a0);
sp44 = coss(temp_a0);
sp20 = arg1;
sp40 = func_802B8018(arg1);
sp40 = sins(arg1);
temp_a0_2 = arg3 & 3;
temp_f10 = sp44 * func_802B8038(arg1) * -120.0f;
temp_f10 = sp44 * coss(arg1) * -120.0f;
sp2C = sp44 * sp40 * 120.0f;
sp2D = 120.0f * sp48;
sp2E = temp_f10;
@@ -775,8 +783,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B5F00.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
f32 func_802B8018(u16); /* extern */
f32 func_802B8038(u16); /* extern */
f32 sins(u16); /* extern */
f32 coss(u16); /* extern */
void func_802B5F74(void *arg0, void *arg1, void *arg2) {
f32 sp3C;
@@ -789,12 +797,12 @@ void func_802B5F74(void *arg0, void *arg1, void *arg2) {
f32 temp_f20;
f32 temp_f6;
sp3C = func_802B8018(arg2->unk0);
temp_f20 = func_802B8038(arg2->unk0);
sp34 = func_802B8018(arg2->unk2);
sp30 = func_802B8038(arg2->unk2);
sp2C = func_802B8018(arg2->unk4);
temp_f0 = func_802B8038(arg2->unk4);
sp3C = sins(arg2->unk0);
temp_f20 = coss(arg2->unk0);
sp34 = sins(arg2->unk2);
sp30 = coss(arg2->unk2);
sp2C = sins(arg2->unk4);
temp_f0 = coss(arg2->unk4);
temp_f12 = sp3C * sp34;
temp_f6 = temp_f12 * temp_f0;
arg0->unk0 = (sp30 * temp_f0) + (temp_f12 * sp2C);
@@ -823,8 +831,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B5F74.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
f32 func_802B8018(u16); /* extern */
f32 func_802B8038(u16); /* extern */
f32 sins(u16); /* extern */
f32 coss(u16); /* extern */
void func_802B60B4(void *arg0, void *arg1, void *arg2) {
f32 sp3C;
@@ -837,12 +845,12 @@ void func_802B60B4(void *arg0, void *arg1, void *arg2) {
f32 temp_f20;
f32 temp_f6;
sp3C = func_802B8018(arg2->unk0);
temp_f20 = func_802B8038(arg2->unk0);
sp34 = func_802B8018(arg2->unk2);
sp30 = func_802B8038(arg2->unk2);
sp2C = func_802B8018(arg2->unk4);
temp_f0 = func_802B8038(arg2->unk4);
sp3C = sins(arg2->unk0);
temp_f20 = coss(arg2->unk0);
sp34 = sins(arg2->unk2);
sp30 = coss(arg2->unk2);
sp2C = sins(arg2->unk4);
temp_f0 = coss(arg2->unk4);
temp_f12 = sp3C * sp34;
temp_f6 = temp_f12 * temp_f0;
arg0->unk0 = (sp30 * temp_f0) + (temp_f12 * sp2C);
@@ -871,8 +879,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B60B4.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
f32 func_802B8018(u16); /* extern */
f32 func_802B8038(u16); /* extern */
f32 sins(u16); /* extern */
f32 coss(u16); /* extern */
void func_802B6214(void *arg0, void *arg1, void *arg2) {
f32 sp3C;
@@ -885,12 +893,12 @@ void func_802B6214(void *arg0, void *arg1, void *arg2) {
f32 temp_f20;
f32 temp_f6;
sp3C = func_802B8018(arg2->unk0);
temp_f20 = func_802B8038(arg2->unk0);
sp34 = func_802B8018(arg2->unk2);
sp30 = func_802B8038(arg2->unk2);
sp2C = func_802B8018(arg2->unk4);
temp_f0 = func_802B8038(arg2->unk4);
sp3C = sins(arg2->unk0);
temp_f20 = coss(arg2->unk0);
sp34 = sins(arg2->unk2);
sp30 = coss(arg2->unk2);
sp2C = sins(arg2->unk4);
temp_f0 = coss(arg2->unk4);
temp_f12 = sp3C * sp34;
temp_f6 = temp_f12 * temp_f0;
arg0->unk0 = (sp30 * temp_f0) + (temp_f12 * sp2C);
@@ -996,8 +1004,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B64B0.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
f32 func_802B8018(s32, void *); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32, void *); /* extern */
f32 coss(s32); /* extern */
void func_802B64C4(void *arg0, s32 arg1) {
f32 sp2C;
@@ -1014,8 +1022,8 @@ void func_802B64C4(void *arg0, s32 arg1) {
temp_a0 = arg1 & 0xFFFF;
sp18 = temp_a0;
arg0 = temp_a2;
sp2C = func_802B8018(temp_a0, temp_a2);
temp_f0 = func_802B8038(temp_a0);
sp2C = sins(temp_a0, temp_a2);
temp_f0 = coss(temp_a0);
temp_f2 = arg0->unk0;
temp_f12 = arg0->unk8;
temp_f4 = temp_f0 * temp_f2;
@@ -1032,8 +1040,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B64C4.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
? func_802B6A84(f32, ?, f32 *, s16, f32, ?, f32); /* extern */
f32 func_802B7CE8(f32, f32, s32); /* extern */
f32 func_802B8018(u16); /* extern */
f32 func_802B8038(u16); /* extern */
f32 sins(u16); /* extern */
f32 coss(u16); /* extern */
static f64 D_802B9FB8 = 3.141592653589793;
static f64 D_802B9FC0 = 360.0;
@@ -1067,8 +1075,8 @@ void func_802B6540(void *arg0, f32 arg1, f32 arg2, f32 arg3, u16 arg4) {
f32 *phi_a3_2;
sp38 = arg4;
sp40 = func_802B8018(arg4);
temp_f0 = func_802B8038(arg4);
sp40 = sins(arg4);
temp_f0 = coss(arg4);
sp8C = temp_f0;
spAC = temp_f0;
sp94 = -sp40;
@@ -1228,8 +1236,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B68F8.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
f32 func_802B8018(s32, void *); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32, void *); /* extern */
f32 coss(s32); /* extern */
void func_802B6A84(void *arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4) {
f32 sp54;
@@ -1253,8 +1261,8 @@ void func_802B6A84(void *arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4) {
temp_a0 = arg1 & 0xFFFF;
sp34 = temp_a0;
arg0 = temp_a2;
sp54 = func_802B8018(temp_a0, temp_a2);
temp_f0 = func_802B8038(temp_a0);
sp54 = sins(temp_a0, temp_a2);
temp_f0 = coss(temp_a0);
temp_f12 = arg2 * arg2;
temp_f6 = 1.0f - temp_f0;
arg0->unk0 = ((1.0f - temp_f12) * temp_f0) + temp_f12;
@@ -1285,8 +1293,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B6A84.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
f32 func_802B8018(f32, s32, void *); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(f32, s32, void *); /* extern */
f32 coss(s32); /* extern */
void func_802B6BC0(void *arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4) {
f32 sp3C;
@@ -1308,8 +1316,8 @@ void func_802B6BC0(void *arg0, s32 arg1, f32 arg2, f32 arg3, f32 arg4) {
sp2C = temp_a0;
arg0 = temp_a2;
arg2 = temp_f14;
sp3C = func_802B8018(temp_f14, temp_a0, temp_a2);
temp_f18 = func_802B8038(temp_a0);
sp3C = sins(temp_f14, temp_a0, temp_a2);
temp_f18 = coss(temp_a0);
temp_f0 = sqrtf((arg2 * arg2) + (arg4 * arg4));
if (temp_f0 != 0.0f) {
temp_f12 = 1.0f / temp_f0;
@@ -1351,8 +1359,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B6BC0.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
f32 func_802B8018(s32); /* extern */
f32 func_802B8038(s32); /* extern */
f32 sins(s32); /* extern */
f32 coss(s32); /* extern */
void func_802B6D58(void *arg0, void *arg1, void *arg2) {
f32 sp3C;
@@ -1368,15 +1376,15 @@ void func_802B6D58(void *arg0, void *arg1, void *arg2) {
f32 temp_f20;
f32 temp_f6;
sp3C = func_802B8018(arg2->unk0 & 0xFFFF);
temp_f20 = func_802B8038(arg2->unk0 & 0xFFFF);
temp_f0 = func_802B8018(arg2->unk4 & 0xFFFF);
sp3C = sins(arg2->unk0 & 0xFFFF);
temp_f20 = coss(arg2->unk0 & 0xFFFF);
temp_f0 = sins(arg2->unk4 & 0xFFFF);
sp34 = temp_f0;
temp_f0_2 = func_802B8038(arg2->unk4 & 0xFFFF);
temp_f0_2 = coss(arg2->unk4 & 0xFFFF);
sp30 = temp_f0_2;
temp_f0_3 = func_802B8018(arg2->unk8 & 0xFFFF);
temp_f0_3 = sins(arg2->unk8 & 0xFFFF);
sp2C = temp_f0_3;
temp_f0_4 = func_802B8038(arg2->unk8 & 0xFFFF);
temp_f0_4 = coss(arg2->unk8 & 0xFFFF);
temp_f12 = sp3C * temp_f0;
temp_f6 = temp_f12 * temp_f0_4;
arg0->unk0 = (temp_f0_2 * temp_f0_4) + (temp_f12 * temp_f0_3);
@@ -1534,14 +1542,14 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B75F8.s")
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
extern u16 D_802BF370;
extern u16 gArctanTable;
static f32 D_802B9FD8 = 1000000.0f;
u16 func_802B7790(f32 arg0, f32 arg1) {
f32 temp_f0;
if (arg1 == 0.0f) {
return D_802BF370;
return gArctanTable;
}
temp_f0 = arg0 / arg1;
if (D_802B9FD8 < temp_f0) {
@@ -1550,7 +1558,7 @@ u16 func_802B7790(f32 arg0, f32 arg1) {
}
return 0xC000;
}
return (&D_802BF370)[(temp_f0 * 1024.0f) + 0.5f];
return (&gArctanTable)[(temp_f0 * 1024.0f) + 0.5f];
}
#else
GLOBAL_ASM("asm/non_matchings/math_util/func_802B7790.s")
@@ -1861,27 +1869,13 @@ void func_802B7F7C(void *arg0, void *arg1, void *arg2) {
GLOBAL_ASM("asm/non_matchings/math_util/func_802B7F7C.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
extern ? D_802BA370;
f32 func_802B8018(s32 arg0) {
return *(&D_802BA370 + (((arg0 & 0xFFFF) >> 4) * 4));
f32 sins(u16 arg0) {
return gSineTable[arg0 >> 4];
}
#else
GLOBAL_ASM("asm/non_matchings/math_util/func_802B8018.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
extern ? D_802BB370;
f32 func_802B8038(s32 arg0) {
return *(&D_802BB370 + (((arg0 & 0xFFFF) >> 4) * 4));
f32 coss(u16 arg0) {
return gCosineTable[arg0 >> 4];
}
#else
GLOBAL_ASM("asm/non_matchings/math_util/func_802B8038.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
@@ -1996,8 +1990,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B80D0.s")
//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909
//This function did not have a glabel in the original assembly, as such it may
//be unused/unnamed
? func_802B8018(s32); /* extern */
? func_802B8038(s32); /* extern */
? sins(s32); /* extern */
? coss(s32); /* extern */
extern ? gSegmentTable;
void func_802B8414(u32 arg0, void *arg1, u16 arg2, s32 arg3, s32 arg4) {
@@ -2023,11 +2017,11 @@ void func_802B8414(u32 arg0, void *arg1, u16 arg2, s32 arg3, s32 arg4) {
temp_a0 = arg3 & 0xFFFF;
temp_s0 = *(&gSegmentTable + ((arg0 >> 0x18) * 4)) + (arg0 & 0xFFFFFF) + 0x80000000;
sp20 = temp_a0;
func_802B8018(temp_a0);
func_802B8038(temp_a0);
sins(temp_a0);
coss(temp_a0);
sp20 = arg2;
func_802B8018(arg2);
func_802B8038(arg2);
sins(arg2);
coss(arg2);
sp40 = 0.0f;
sp44 = 0.0f;
sp48 = 1.0f;