From 72fb8eb8629171e5cda6deb3584c7c6158b6f22d Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Mon, 31 Oct 2022 17:03:58 -0500 Subject: [PATCH] core1/code_13990.c progress --- README.md | 2 +- progress/progress_core1.svg | 6 +- progress/progress_total.svg | 4 +- src/MMM/crc.c | 6 ++ src/core1/code_10A00.c | 4 +- src/core1/code_13990.c | 178 +++++++++++++++++++++++++++++------- subyaml/MMM.us.v10.yaml | 3 +- 7 files changed, 161 insertions(+), 42 deletions(-) create mode 100644 src/MMM/crc.c diff --git a/README.md b/README.md index 04d023b2..d00b2752 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# banjo (92.3375%) +# banjo (92.4511%) diff --git a/progress/progress_core1.svg b/progress/progress_core1.svg index 9826281b..9f5d30a6 100644 --- a/progress/progress_core1.svg +++ b/progress/progress_core1.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ core1 - 85.1429% - 85.1429% + 85.9260% + 85.9260% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index a686c7b8..3c905765 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 92.3375% - 92.3375% + 92.4511% + 92.4511% \ No newline at end of file diff --git a/src/MMM/crc.c b/src/MMM/crc.c new file mode 100644 index 00000000..bec39d98 --- /dev/null +++ b/src/MMM/crc.c @@ -0,0 +1,6 @@ +#include + +u32 D_8038C300 = 0x00146061; +u32 D_8038C304 = 0xEC79D7B4; +u32 D_8038C308 = 0x0001B98D; +u32 D_8038C30C = 0x0; \ No newline at end of file diff --git a/src/core1/code_10A00.c b/src/core1/code_10A00.c index e147ec0d..c0984d18 100644 --- a/src/core1/code_10A00.c +++ b/src/core1/code_10A00.c @@ -7,7 +7,7 @@ #define CORE2_DATA_CRC2 0 #endif -extern s32 D_803727F4 = CORE2_DATA_CRC2; +extern s32 D_803727F4; extern struct { u8 pad0[4]; @@ -36,7 +36,7 @@ typedef struct { /* .data */ extern s32 D_80275D38; -extern s32 D_80276574; +extern s32 D_80276574; // = CORE2_DATA_CRC2 /* .bss */ diff --git a/src/core1/code_13990.c b/src/core1/code_13990.c index af196dc9..f270805e 100644 --- a/src/core1/code_13990.c +++ b/src/core1/code_13990.c @@ -5,10 +5,17 @@ #include "ml/mtx.h" - +void func_8024632C(Mtx*, f32, f32, f32, f32); f32 func_80263FF0(f32); f32 cosf(f32); + +extern f32 D_80276578; +extern f32 D_8027657C; + + extern f64 D_80278220; +extern f64 D_80278228; +extern f64 D_80278230; /*.bss*/ Mtx_t D_80282810; @@ -124,47 +131,129 @@ void func_80251B5C(f32 arg0, f32 arg1, f32 arg2){ *(var_v0++) = arg0; *(var_v0++) = arg1; *(var_v0++) = arg2; *(var_v0++) = 1.0f; } +void func_80245DCC(Mtx *,Mtx *, Mtx *); #pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/func_80251BCC.s") -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/func_80251C20.s") +void func_80251C20(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + func_8024632C(D_80282FD0 + 1, arg0, arg1, arg2, arg3); + func_80245DCC(D_80282FD0 + 1, D_80282FD0, D_80282FD0); +} -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/mlMtxRotPitch.s") - -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/mlMtxRotYaw.s") -/*void mlMtxRotYaw(f32 yaw) { - f32 sin; +void mlMtxRotPitch(f32 arg0) { f32 cos; - f32 phi_f12; - f32 phi_f10; - f32 phi_f8; - f32 phi_f4; - f32 *phi_v0; - s32 phi_v1; + f32 sin; + f32 var_f10; + f32 var_f18; - if (yaw == 0.0f) - return; + if (arg0 != 0.0f) { + arg0 *= D_80276578; + sin = sinf(arg0); + cos = cosf(arg0); + var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][0]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][0]); + reinterpret_cast(f32, D_80282FD0->m[1][0]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[2][0]) = var_f18*-sin + var_f10*cos; - sin = sinf(yaw*0.0174533); - cos = cosf(yaw*0.0174533); - phi_v0 = D_80282FD0; - for(phi_v1 = 0; phi_v1 < 0xC; phi_v1 += 4){ - phi_v0 = (u32)D_80282FD0 + phi_v1; - phi_f12 = phi_v0[0] * cos; - phi_f10 = phi_v0[8] * sin; - phi_f8 = phi_v0[0] * sin; - phi_f4 = phi_v0[8] * cos; - phi_v0[0] = phi_f12 - phi_f10; - phi_v0 = (u32)D_80282FD0 + phi_v1; - phi_v0[8] = phi_f8 + phi_f4; + var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][1]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][1]); + reinterpret_cast(f32, D_80282FD0->m[1][1]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[2][1]) = var_f18*-sin + var_f10*cos; + + var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][2]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][2]); + reinterpret_cast(f32, D_80282FD0->m[1][2]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[2][2]) = var_f18*-sin + var_f10*cos; } +} -}//*/ +void mlMtxRotYaw(f32 arg0) { + f32 cos; + f32 sin; + f32 var_f10; + f32 var_f18; + s32 i; -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/mlMtxRotRoll.s") + if (arg0 != 0.0f) { + arg0 *= D_80278220; + sin = sinf(arg0); + cos = cosf(arg0); + for(i = 0; i < 3; i++){ + var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][i]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][i]); + reinterpret_cast(f32, D_80282FD0->m[0][i]) = var_f18*cos - var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[2][i]) = var_f18*sin + var_f10*cos; + } + } +} -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/func_80251F8C.s") +void mlMtxRotRoll(f32 arg0) { + f32 cos; + f32 sin; + f32 var_f10; + f32 var_f18; + + if (arg0 != 0.0f) { + arg0 *= D_8027657C; + sin = sinf(arg0); + cos = cosf(arg0); + var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][0]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[1][0]); + reinterpret_cast(f32, D_80282FD0->m[0][0]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[1][0]) = var_f18*-sin + var_f10*cos; + + var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][1]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[1][1]); + reinterpret_cast(f32, D_80282FD0->m[0][1]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[1][1]) = var_f18*-sin + var_f10*cos; + + var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][2]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[1][2]); + reinterpret_cast(f32, D_80282FD0->m[0][2]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[1][2]) = var_f18*-sin + var_f10*cos; + } +} + + +void func_80251F8C(f32 arg0) { + f32 cos; + f32 sin; + f32 var_f10; + f32 var_f18; + s32 i; + + if (arg0 != 0.0f) { + arg0 *= D_80278228; + sin = sinf(arg0); + cos = cosf(arg0); + for(i = 0; i < 3; i++){ + var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][i]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][i]); + reinterpret_cast(f32, D_80282FD0->m[1][i]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[2][i]) = var_f18*-sin +var_f10*cos; + } + } +} + +void func_8025208C(f32 arg0) { + f32 cos; + f32 sin; + f32 var_f10; + f32 var_f18; + s32 i; + + if (arg0 != 0.0f) { + arg0 *= D_80278230; + sin = sinf(arg0); + cos = cosf(arg0); + for(i = 0; i < 3; i++){ + var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][i]); + var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][i]); + reinterpret_cast(f32, D_80282FD0->m[0][i]) = var_f18*cos - var_f10*sin; + reinterpret_cast(f32, D_80282FD0->m[2][i]) = var_f18*sin + var_f10*cos; + } + } +} -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/func_8025208C.s") void mlMtxRotate(f32 pitch, f32 yaw, f32 roll){ mlMtxRotYaw(yaw); @@ -196,9 +285,32 @@ void func_80252330(f32 x, f32 y, f32 z){ reinterpret_cast(f32, D_80282FD0->m[3][2]) = z; } -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/func_8025235C.s") +void func_8025235C(f32 arg0[3], f32 arg1[3]) { + s32 i; + f32 sp0[3]; -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13990/func_80252434.s") + sp0[0] = arg1[0]; + sp0[1] = arg1[1]; + sp0[2] = arg1[2]; + + for(i = 0; i < 3; i++){ + arg0[i] = sp0[0]*reinterpret_cast(f32, D_80282FD0->m[0][i]) + + sp0[1]*reinterpret_cast(f32, D_80282FD0->m[1][i]) + + sp0[2]*reinterpret_cast(f32, D_80282FD0->m[2][i]) + + reinterpret_cast(f32, D_80282FD0->m[3][i]); + } +} + +void func_80252434(f32 arg0[3], f32 arg1[3]) { + s32 i; + + for(i = 0; i < 3; i++){ + arg0[i] = arg1[0]*reinterpret_cast(f32, D_80282FD0->m[0][i]) + + arg1[1]*reinterpret_cast(f32, D_80282FD0->m[1][i]) + + arg1[2]*reinterpret_cast(f32, D_80282FD0->m[2][i]) + + reinterpret_cast(f32, D_80282FD0->m[3][i]); + } +} void func_802524F0(f32 dst[3], f32 x, f32 y, f32 z) { dst[0] = x*((f32 (*)[4])D_80282FD0)[0][0] + y*((f32 (*)[4])D_80282FD0)[1][0] + z*((f32 (*)[4])D_80282FD0)[2][0] + ((f32 (*)[4])D_80282FD0)[3][0]; diff --git a/subyaml/MMM.us.v10.yaml b/subyaml/MMM.us.v10.yaml index 5d0d0a5d..05f2228a 100644 --- a/subyaml/MMM.us.v10.yaml +++ b/subyaml/MMM.us.v10.yaml @@ -37,6 +37,7 @@ segments: - [0x2F60, c, code_2F60] #DONE - [0x3120, c, code_3120] #DONE - [0x3420, c, code_3420] #DONE + - [0x3420, c, crc] #DONE - [0x3D50, c, code_3D50] #DONE - [0x47D0, c, code_47D0] #DONE - [0x5000, c, code_5000] #DONE @@ -49,7 +50,7 @@ segments: - [0x00005A40, .data, code_2F60] - [0x00005B30, .data, code_3420] - [0x00005E00, .data, code_3D50] - - [0x00005F10, bin, data_5F10] + - [0x00005F10, .data, crc] - [0x00005F20, .data, code_5000] - [0x00005F50, .rodata, ch/loggo] - [0x00005F80, .rodata, ch/napper]