diff --git a/include/functions.h b/include/functions.h index 086c20fd..d527df9b 100644 --- a/include/functions.h +++ b/include/functions.h @@ -44,4 +44,6 @@ void func_8002B274(s32, s32); // exception_set.s void set_watch_lohi(s32); +unsigned long long __ull_rem(unsigned long long a0, unsigned long long a1); + #endif diff --git a/include/math.h b/include/math.h index c82e6eab..7e8bc839 100644 --- a/include/math.h +++ b/include/math.h @@ -9,6 +9,15 @@ #define SHT_MAX 32767.0f #define SHT_MINV (1.0f / SHT_MAX) +extern long long __d_to_ll(double d); +extern long long __f_to_ll(float f); +extern unsigned long long __d_to_ull(double d); +extern unsigned long long __f_to_ull(float f); +extern double __ll_to_d(long long s); +extern float __ll_to_f(long long s); +extern double __ull_to_d(unsigned long long u); +extern float __ull_to_f(unsigned long long u); + typedef float MtxF_t[4][4]; typedef union { MtxF_t mf; diff --git a/include/variables.h b/include/variables.h index a0d6637c..346e6ee5 100644 --- a/include/variables.h +++ b/include/variables.h @@ -95,8 +95,6 @@ typedef struct unk_D_800A7440 { } unk_D_800A7440; // size >= 0x8 extern unk_D_800A7440 D_800A7440; - - extern struct unk_D_800AC840 D_800AC840; extern struct unk_D_800AC840 D_800AC858; extern struct unk_D_86002F58_004_000* D_8006F09C; @@ -146,5 +144,59 @@ extern s8 D_80077DE4; extern s32 D_80078E60; extern s32 D_80078E64; extern s32 D_80078E68; +extern u8 D_8007840C; +extern s32 D_80078E70; +extern s32 D_80078ECC; +extern u8 D_80078ED0; +extern u8 D_80078390[]; +extern u32 D_80078404; +extern s32 D_80078408; +extern s32 D_80078E74; +extern u8 D_80078E78; +extern u8 D_80078E7C; +extern u8 D_80078E80; +extern s32 D_80078EC8; +extern s32 D_800FC680; +extern s32 D_800FC684; +extern u32 D_800FC6DC; +extern s32 D_80078ED4; +extern s32 D_80078ED8; +extern s32 D_80078EDC; + +typedef struct unk_D_800FC6E4 { + /* 0x00 */ char pad00[0x8]; + /* 0x08 */ s32 unk_08; + /* 0x0C */ u32 unk_0C[2]; +} unk_D_800FC6E4; // size >= 0x10 + +extern unk_D_800FC6E4* D_800FC6E0; +extern unk_D_800FC6E4* D_800FC6E4; + +extern s32 D_800FC688; +extern s32 D_800FC68C; +extern s32 D_800FC6A4; +extern s32 D_800FC6A8; + +typedef struct unk_D_800FC6F4 { + /* 0x00 */ char pad00[0x14]; + /* 0x14 */ u32 unk_14; + /* 0x18 */ char pad18[0x4]; + /* 0x1C */ u32 unk_1C; + /* 0x20 */ char pad20[0x4]; + /* 0x24 */ u32 unk_24; +} unk_D_800FC6F4; /// size >= 0x28 +extern unk_D_800FC6F4* D_800FC6F4; + +typedef struct unk_D_800FC6F8 { + /* 0x00 */ u32 unk_00[2]; +} unk_D_800FC6F8; // size = 0x8 +extern unk_D_800FC6F8* D_800FC6F8; + +typedef struct unk_D_800FC798 { + /* 0x00 */ u32 unk_00; + /* 0x04 */ u32 unk_04; + /* 0x08 */ u32 unk_08; +} unk_D_800FC798; // size >= 0xC +extern unk_D_800FC798* D_800FC798; #endif diff --git a/linker_scripts/us/symbol_addrs.txt b/linker_scripts/us/symbol_addrs.txt index fa9a3567..fa54f516 100644 --- a/linker_scripts/us/symbol_addrs.txt +++ b/linker_scripts/us/symbol_addrs.txt @@ -239,3 +239,5 @@ D_87A01178 = 0x87A01178; D_87A01180 = 0x87A01180; D_87A01190 = 0x87A01190; D_87A011A4 = 0x87A011A4; +D_800A7428 = 0x800A7428; +D_80079014 = 0x80079014; diff --git a/src/2E110.c b/src/2E110.c index e8cff39f..70bfded3 100644 --- a/src/2E110.c +++ b/src/2E110.c @@ -1,4 +1,3 @@ -#include "global.h" #include "2E110.h" #pragma GLOBAL_ASM("asm/us/nonmatchings/2E110/func_8002D510.s") diff --git a/src/2E110.h b/src/2E110.h index 59c18751..7b158a23 100644 --- a/src/2E110.h +++ b/src/2E110.h @@ -3,7 +3,7 @@ #include "global.h" -char* func_8002D7C0(char*, s32, s32, s32); +char* func_8002D7C0(char* arg0, s32 arg1, s32 arg2, s32 arg3); #endif // _2E110_H_ diff --git a/src/373A0.c b/src/373A0.c index f49f8b85..5a3a7aad 100644 --- a/src/373A0.c +++ b/src/373A0.c @@ -1,4 +1,5 @@ -#include "global.h" +#include "373A0.h" +#include "4CBC0.h" #pragma GLOBAL_ASM("asm/us/nonmatchings/373A0/func_800367A0.s") diff --git a/src/373A0.h b/src/373A0.h new file mode 100644 index 00000000..16055d95 --- /dev/null +++ b/src/373A0.h @@ -0,0 +1,10 @@ +#ifndef _373A0_H_ +#define _373A0_H_ + +#include "global.h" + +void func_800367A0(s32, u8, s32); +void func_80037234(s32, s32); +void func_80037360(u32, u32, s32); + +#endif // _373A0_H_ diff --git a/src/38BB0.h b/src/38BB0.h index 0fef7548..a892bc00 100644 --- a/src/38BB0.h +++ b/src/38BB0.h @@ -4,8 +4,19 @@ #include "global.h" void func_80038E98(s32, s32); +s32 func_80038F30(s32, s32); +s32 func_80039024(s32, s32, s32, s32, u32, s32); void func_800392A8(s32, s32); +s32 func_80039354(s32); void func_800393DC(s32, s32); +void func_80039534(s32, f32); +void func_800395FC(s32, s32); +void func_8003979C(s32, s32); +void func_800397BC(s32); void func_8003986C(s32); +void func_800398F0(s32); +void func_80039940(void); +s32 func_80039A7C(s32, s32, s32); +void func_80039B88(s32, s32, s32, s32); #endif // _38BB0_H_ diff --git a/src/3D140.c b/src/3D140.c index 2f25e2c7..86d4d1c2 100644 --- a/src/3D140.c +++ b/src/3D140.c @@ -1,4 +1,111 @@ -#include "global.h" +#include "3D140.h" +#include "373A0.h" +#include "45720.h" + +extern u8 D_800783FC; +extern u8 D_80078400; +extern u16 D_80078410[1][9]; +extern u16 D_80078446[1][9]; +extern u16 D_800784EA[1][9]; +extern u16 D_80077DF0[]; +extern u16 D_80077E00[]; +extern u16 D_80077E10[]; +extern u16 D_80077E18[]; +extern u16 D_80077E20[]; +extern u16 D_80077E28[]; +extern u16 D_80077E30[]; +extern u16 D_80077E38[]; +extern u16 D_80077E40[]; +extern u16 D_80077E48[]; +extern u16 D_80077E50[]; +extern u16 D_80077E58[]; +extern u16 D_80077E60[]; +extern u16 D_80077E68[]; +extern u16 D_80077E70[]; +extern u16 D_80077E78[]; +extern u16 D_80077E88[]; +extern u16 D_80077E90[]; +extern u16 D_800780A8[]; +extern u8 D_800783BC; +extern u8 D_800783C0; +extern u8 D_800783C4; +extern s32 D_800783C8; +extern u32 D_800783CC; +extern u8 D_800783D4; +extern u8 D_800783D8; +extern u8 D_800783DC; +extern u8 D_800783E4; +extern u8 D_800783E8; +extern u8 D_800783EC; +extern f64 D_8007C7E0; +extern f64 D_8007C7E8; +extern f64 D_8007C7F0; +extern f64 D_8007C7F8; +extern u8 D_800FCD18[]; + +typedef struct unk_D_800FCB18 { + /* 0x00 */ char pad00[0xC]; + /* 0x0C */ u16 unk_0C; + /* 0x0E */ char pad0E[0xE]; + /* 0x1C */ u8 unk_1C; + /* 0x1D */ u8 unk_1D; + /* 0x1E */ char pad1E[0x8]; + /* 0x26 */ u8 unk_26; + /* 0x28 */ u16 unk_28; +} unk_D_800FCB18; // size >= 0x2C + +extern unk_D_800FCB18* D_800FCB18[2]; +extern s32 D_800FCB28; +extern s32 D_800FCB2C; + +typedef struct unk_D_800FCB48 { + /* 0x00 */ u16 unk_00[16]; + /* 0x20 */ char pad20[0x4]; + /* 0x24 */ s32 unk_24; + /* 0x28 */ char pad28[0x50]; + /* 0x78 */ s32 unk_78; + /* 0x7C */ s32 unk_7C; + /* 0x80 */ char pad80[0x4]; +} unk_D_800FCB48; // size = 0x84 +extern unk_D_800FCB48 D_800FCB48[2]; +extern s32 D_800FCCA4; +extern u8 D_800FCCAE; +extern u8 D_800FCCAF; +extern u8 D_800FCCB0; +extern u8 D_800FCCB1; +extern u8 D_800FCCB2; +extern u8 D_800FCCB3; +extern u8 D_800FCCB4; +extern u8 D_800FCCB5; +extern u8 D_800FCCB6; +extern s8 D_8007839C[]; +extern s8 D_800783E0; +extern s16 D_800783F0; +extern s16 D_800783F4; +extern s16 D_800783F8; +extern u8 D_800FCB38[2][8]; +extern s32 D_800FCC50[]; +extern s8 D_800FCCA0; +extern s8 D_800FCCA1; +extern s8 D_800FCCA2; +extern s8 D_800FCCAC; +extern s8 D_800FCCB7; +extern s8 D_800FCCB8[]; +extern s8 D_800FCCBA[]; +extern s8 D_800FCCBC[]; +extern s8 D_800FCCBE[]; +extern s8 D_800FCCC0[]; +extern s8 D_800FCCC2[]; +extern s8 D_800FCCD4[]; +extern s8 D_800FCCD6[]; +extern s8 D_800FCCD8[]; +extern s32 D_80078388; +extern u32 D_800783A4[4]; +extern s32 D_800783B8; + +void func_80041A98(void); +void func_80041C70(u32); +void func_800420C0(u16*); #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_8003C540.s") @@ -36,9 +143,496 @@ #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_8003D828.s") +#ifdef NON_MATCHING +void func_8003D918(u32 arg0, u32 arg1) { + u32 temp_v0 = arg1 == 0x10; + u8 sp1B = 0; + u16 var_a0; + + func_80041A98(); + D_80078404 = arg1; + D_80078408 = arg0; + + if (arg1 < 0x11) { + D_800783FC = 1; + D_8007840C = 1; + + if ((arg0 == 0) && (arg1 != 0x10) && (arg1 != 0xF)) { + func_80041C70(0x34); + } else if ((arg0 == 0xFF) && (arg1 != 0x10) && (arg1 != 0xF)) { + func_80041C70(0x47); + arg0 = 0; + sp1B = 1; + } + + if (arg1 < 0xC) { + if (arg0 < 9) { + var_a0 = D_80078410[arg1][arg0]; + D_800783FC = 1; + D_80078400 = 1; + } else { + return; + } + } else if (arg1 == 0xC) { + if ((arg0 < 0x21) && (arg0 != 0)) { + var_a0 = D_800784EA[(arg0 - 1) / 8][(arg0 - 1) % 8]; + D_800783FC = 1; + D_80078400 = 0; + } else { + return; + } + } else if (arg1 == 0xD) { + if (arg0 < 6) { + var_a0 = D_80078446[arg1][arg0]; + D_800783FC = 1; + D_80078400 = 0; + } else { + return; + } + } else { + if (arg1 == 0xE) { + var_a0 = 0x49; + D_800783FC = 1; + D_80078400 = 2; + } else if (arg1 == 0xF) { + var_a0 = 0; + D_800783FC = 0; + D_80078400 = 0; + arg0 = 1; + } else { + D_800783FC = 1; + if (temp_v0) { + var_a0 = 0x48; + D_80078400 = 1; + arg0 = 1; + } else { + var_a0 = 0; + D_80078400 = 1; + } + } + } + + if ((arg0 == 0) && (sp1B == 0)) { + D_80078400 = 2; + } + + if (var_a0 != 0) { + func_80041C70(var_a0); + } + } +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_8003D918.s") - +#endif + +#ifdef NON_MATCHING +void func_8003DB84(s32 arg0) { + s32 i; + s32 var_t0; + s32 var_t2; + s32 var_t4; + s32 var_t5; + s32 var_v0; + u32 var_a0; + u32 temp_v0; + + if (arg0 != 0) { + temp_v0 = osSetIntMask(1); + D_800783BC = 1; + D_800783C8 = 0; + D_800783C0 = 0; + D_800783C4 = 0; + osSetIntMask(temp_v0); + D_800783D4 = 0; + D_800783D8 = 0; + D_800783DC = 0; + D_800FCCAE = 0; + D_800FCCAF = 0; + D_800FCCB2 = 0; + D_800FCCB6 = 0; + D_800783E8 = 0; + D_800783EC = 0; + D_800FCCA4 = 0; + func_800367A0(0x5A, D_80078400, 0); + + if ((D_800FCB18[0] != NULL) && (D_800FCB18[1] != NULL)) { + if (D_800FCB18[0] != NULL) { + D_800FCB28 = D_800FCB18[0]->unk_0C; + } + + if (D_800FCB18[1] != NULL) { + D_800FCB2C = D_800FCB18[1]->unk_0C; + } + + D_800FCB48[0].unk_24++; + D_800FCB48[0].unk_00[D_800FCB48[0].unk_24 & 0xF] = D_800FCB18[0]->unk_0C; + D_800FCB48[1].unk_24++; + D_800FCB48[1].unk_00[D_800FCB48[1].unk_24 & 0xF] = D_800FCB18[1]->unk_0C; + + if (D_800783CC != 0) { + var_t0 = 1; + if (D_800FCB18[0]->unk_26 < D_800FCB18[1]->unk_26) { + var_t2 = 0; + var_t4 = 1; + } else { + var_t4 = 0; + var_t2 = 1; + } + + if (D_800FCB18[0]->unk_0C < D_800FCB18[1]->unk_0C) { + var_t0 = 0; + var_t5 = 1; + } else { + var_t5 = 0; + } + + if (D_800783CC < 2) { + if ((D_800FCB18[0]->unk_0C == 0) || (D_800FCB18[1]->unk_0C == 0)) { + temp_v0 = osSetIntMask(1); + D_800783C0 = 1; + osSetIntMask(temp_v0); + + if (D_800FCB18[0]->unk_0C == 0) { + D_800FCCB0 = 1; + } else { + D_800FCCB0 = 2; + } + + if ((D_800FCB18[0]->unk_0C == 0) && (D_800FCB18[1]->unk_0C == 0)) { + func_800420C0(D_80077E90); + return; + } + + func_800420C0(D_80077E48); + return; + } + + if ((((D_800FCB18[0]->unk_0C * 0x64u) / D_800FCB18[0]->unk_28) < 0x1E) && + (((D_800FCB18[1]->unk_0C * 0x64u) / D_800FCB18[1]->unk_28) < 0x1E)) { + func_800420C0(D_80077E88); + return; + } + + if (((((D_800FCB18[var_t4]->unk_26 - D_800FCB18[var_t2]->unk_26) * 0x64u) / + D_800FCB18[var_t2]->unk_26) >= 0x15) && + (((D_800FCB18[var_t2]->unk_0C * 0x64u) / D_800FCB18[var_t2]->unk_28) < 0x28) && + (((D_800FCB18[var_t4]->unk_0C * 0x64u) / D_800FCB18[var_t4]->unk_28) >= 0x51)) { + if (__ull_rem(osGetTime(), 3) == 0) { + var_a0 = 0x256; + goto block_53; + } + } + + if ((((D_800FCB18[0]->unk_0C * 0x64u) / D_800FCB18[0]->unk_28) >= 0x5B) && + (((D_800FCB18[1]->unk_0C * 0x64u) / D_800FCB18[1]->unk_28) >= 0x5B)) { + func_800420C0(D_80077E68); + return; + } + + if (D_80078400 == 0) { + func_800420C0(D_80077E78); + return; + } + + func_800420C0(D_80077DF0); + return; + } + + if ((D_800FCB18[0]->unk_0C == 0) || (D_800FCB18[1]->unk_0C == 0)) { + temp_v0 = osSetIntMask(1); + D_800783C0 = 1; + osSetIntMask(temp_v0); + + if (D_800FCB18[0]->unk_0C == 0) { + D_800FCCB0 = 1; + } else { + D_800FCCB0 = 2; + } + + if (D_80078390[0] >= D_80078390[1]) { + var_v0 = D_80078390[0] - D_80078390[1]; + } else { + var_v0 = D_80078390[1] - D_80078390[0]; + } + + if (var_v0 >= 2) { + func_800420C0(D_80077E70); + return; + } + + if ((D_80078390[0] == 1) && (D_80078390[1] == 1)) { + var_a0 = 0x290; + if (D_800783E4 != 0) { + D_800783E4 = 0; + } else { + if (__ull_rem(osGetTime(), 2) != 0) { + var_a0 = 0x254; + } else { + var_a0 = 0x26B; + } + } + block_53: + func_80041C70(var_a0); + return; + } + + if (D_80078390[D_800FCCB0 - 1] == 1) { + func_80041C70(0x26A); + return; + } + + func_800420C0(D_80077E00); + return; + } + + if (D_800FCCB0 != 0) { + if (((D_80078390[0] == 1) || (D_80078390[1] == 1)) && (D_80078390[0] < 4) && (D_80078390[1] < 4)) { + if (D_80078390[0] == 1) { + switch (D_80078390[1]) { + case 1: + func_80041C70(0x260); + func_80041C70(0x266); + break; + + case 2: + func_80041C70(0x261); + if (D_800FCCB0 == 1) { + func_80041C70(0x265); + } else { + func_80041C70(0x267); + } + break; + + case 3: + func_80041C70(0x262); + func_80041C70(0x264); + break; + + default: + func_80041C70(0x271); + break; + } + + D_800FCCB0 = 0; + return; + } + + switch (D_80078390[0]) { + case 2: + func_80041C70(0x25E); + if (D_800FCCB0 == 2) { + func_80041C70(0x265); + } else { + func_80041C70(0x267); + } + break; + + case 3: + func_80041C70(0x25C); + func_80041C70(0x264); + break; + + default: + func_80041C70(0x271); + break; + } + + D_800FCCB0 = 0; + return; + } + + if (D_800FCCB1 != 0) { + if (__ull_rem(osGetTime(), 2) != 0) { + D_800FCCB0 = 0; + func_800420C0(D_80077E10); + return; + } + } + + if (D_800FCB18[0]->unk_1C != D_800FCB18[1]->unk_1C) { + if (D_800FCB18[0]->unk_1C != D_800FCB18[1]->unk_1D) { + if ((D_800FCB18[0]->unk_1D != D_800FCB18[1]->unk_1C) && + (D_800FCB18[0]->unk_1D != D_800FCB18[1]->unk_1D)) { + D_800FCCB0 = 0; + func_800420C0(D_80077E18); + return; + } + } + } + + D_800FCCB0 = 0; + switch (D_80078390[0]) { + case 2: + switch (D_80078390[1]) { + case 2: + func_80041C70(0x25D); + func_80041C70(0x268); + return; + + case 3: + func_80041C70(0x25F); + func_80041C70(0x263); + return; + + default: + func_80041C70(0x271); + return; + } + break; + + case 3: + if (D_80078390[1] == 2) { + func_80041C70(0x25B); + func_80041C70(0x263); + return; + } + + func_80041C70(0x271); + return; + + default: + if (D_80078400 == 0) { + func_800420C0(D_80077E78); + return; + } + + func_800420C0(D_80077DF0); + return; + } + } else { + + if (D_800FCCB3 != 0) { + func_800420C0(D_80077E38); + D_800FCCB3 = 0; + return; + } + + if (D_800FCCB4 != 0) { + func_800420C0(D_80077E40); + D_800FCCB4 = 0; + return; + } + + if (D_800FCCB5 != 0) { + func_800420C0(D_80077E50); + D_800FCCB5 = 0; + return; + } + + if ((D_800FCB18[0]->unk_28 * 0.5f) < (D_800FCB48[0].unk_00[(D_800FCB48[0].unk_24 - 1) & 0xF] - + D_800FCB48[0].unk_00[D_800FCB48[0].unk_24 & 0xF])) { + if ((D_800FCB18[1]->unk_28 * 0.5f) < (D_800FCB48[1].unk_00[(D_800FCB48[1].unk_24 - 1) & 0xF] - + D_800FCB48[1].unk_00[(D_800FCB48[1].unk_24 & 0xF)])) { + if ((((D_800FCB18[0]->unk_0C * 0x64u) / D_800FCB18[0]->unk_28) < 0x14u) && + (((D_800FCB18[1]->unk_0C * 0x64u) / D_800FCB18[1]->unk_28) < 0x14u)) { + func_800420C0(D_80077E60); + } else { + func_800420C0(D_80077E58); + } + return; + } + } + + if (D_800FCB18[0]->unk_0C >= D_800FCB18[1]->unk_0C) { + var_v0 = D_800FCB18[0]->unk_0C - D_800FCB18[1]->unk_0C; + } else { + var_v0 = D_800FCB18[1]->unk_0C - D_800FCB18[0]->unk_0C; + } + + if ((D_800FCB18[var_t0]->unk_28 * D_8007C7E0) < var_v0) { + if ((((D_800FCB18[var_t5]->unk_0C * 0x64u) / D_800FCB18[var_t5]->unk_28) >= 0x47) && + (D_800FCB18[0]->unk_0C != D_800FCB18[0]->unk_28) && + (D_800FCB18[1]->unk_0C != D_800FCB18[1]->unk_28)) { + if ((D_800FCB18[var_t5]->unk_28 * D_8007C7E8) < D_800FCB18[var_t5]->unk_0C) { + if (D_800FCB18[var_t0]->unk_0C < (D_800FCB18[var_t0]->unk_28 * D_8007C7F0)) { + func_800420C0(D_80077E20); + return; + } + } + } + } + + if (D_800FCB18[0]->unk_0C >= D_800FCB18[1]->unk_0C) { + var_v0 = D_800FCB18[0]->unk_0C - D_800FCB18[1]->unk_0C; + } else { + var_v0 = D_800FCB18[1]->unk_0C - D_800FCB18[0]->unk_0C; + } + + if (var_v0 < 0xA) { + if ((D_800FCB18[0]->unk_28 * 0.5) < D_800FCB18[0]->unk_0C) { + if (((D_800FCB18[1]->unk_28 * 0.5) < D_800FCB18[1]->unk_0C) && + (D_800FCB18[0]->unk_0C < D_800FCB18[0]->unk_28) && + (D_800FCB18[1]->unk_0C < D_800FCB18[1]->unk_28)) { + func_800420C0(D_80077E30); + return; + } + } + } + + if (D_800FCB18[0]->unk_0C >= D_800FCB18[1]->unk_0C) { + var_v0 = D_800FCB18[0]->unk_0C - D_800FCB18[1]->unk_0C; + } else { + var_v0 = D_800FCB18[1]->unk_0C - D_800FCB18[0]->unk_0C; + } + + if (var_v0 < 0xA) { + if (D_800FCB18[0]->unk_0C < (D_800FCB18[0]->unk_28 * D_8007C7F8)) { + if (D_800FCB18[1]->unk_0C < (D_800FCB18[1]->unk_28 * D_8007C7F8)) { + func_800420C0(D_80077E28); + return; + } + } + } + + if (D_80078400 == 0) { + func_800420C0(D_80077E78); + } else { + func_800420C0(D_80077DF0); + } + return; + } + } + } + } else { + temp_v0 = osSetIntMask(1); + D_800783BC = 0; + osSetIntMask(temp_v0); + func_80037234(0x5A, 0); + func_80037234(0x5B, 0); + + if (D_800FCB18[0] != NULL) { + D_800FCB28 = D_800FCB18[0]->unk_0C; + } + + if (D_800FCB18[1] != NULL) { + D_800FCB2C = D_800FCB18[1]->unk_0C; + } + + D_800783CC++; + + for (i = 0; i < 2; i++) { + D_800FCB48[i].unk_78++; + if (D_800FCB48[i].unk_7C != 0) { + D_800FCB48[i].unk_7C++; + } + } + + D_800FCCB4 = 0; + D_800FCCB3 = 0; + D_800FCCB5 = 0; + D_800783E4 = 0; + + if ((D_800FCB18[0] != NULL) && (D_800FCB18[1] != NULL) && (D_8007840C != 0) && (D_800FCB18[0]->unk_0C != 0) && + (D_800FCB18[1]->unk_0C != 0) && (func_80044E54(1) == 0)) { + if (__ull_rem(osGetTime(), 2) == 0) { + func_800420C0(D_800780A8); + } + } + } +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_8003DB84.s") +#endif #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_8003EB40.s") @@ -60,23 +654,162 @@ #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_800416BC.s") +#ifdef NON_MATCHING +void func_80041A98(void) { + s32 i; + s32 j; + + D_800783CC = 0; + + for (i = 0; i < 2; i++) { + for (j = 0; j < 8; j++) { + D_800FCB38[i][j] = 0; + } + } + + D_8007839C[0] = 0; + D_8007839C[1] = 0; + D_800FCCA1 = 0; + D_800FCCA0 = 0; + D_800FCCA2 = 0; + D_800FCCA4 = 0; + D_800FCCAC = 0; + D_800783E0 = 0; + D_800FCCAF = 0; + D_800FCCB0 = 0; + D_800FCCB2 = 0; + D_800FCCB3 = 0; + D_800FCCB4 = 0; + D_800FCCB5 = 0; + D_800FCCB7 = 0; + D_800FCCB6 = 0; + D_800783E4 = 0; + D_800783E8 = 0; + D_800783EC = 0; + D_800783F0 = 0; + D_800783F4 = 0; + D_800783F8 = 0; + + for (i = 0; i < 21; i++) { + D_800FCCD8[i] = 0; + } + + for (i = 0; i < 80; i++) { + D_800FCC50[i] = 0; + } + + for (i = 0; i < 2; i++) { + D_800FCCB8[i] = 0; + D_800FCCBA[i] = 0; + D_800FCCBC[i] = 0; + D_800FCCBE[i] = 0; + D_800FCCC0[i] = 0; + D_800FCCC2[i] = 0; + D_800FCCD4[i] = 0; + D_800FCCD6[i] = 0; + } +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041A98.s") +#endif -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041C70.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041CEC.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041D50.s") +void func_80041C70(u32 arg0) { + u32 temp_v0; -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041D70.s") + if ((D_80078388 != 0) && (D_800783FC != 0) && (arg0 != 0)) { + temp_v0 = osSetIntMask(1); + D_800783A4[D_800783B8 & 3] = arg0; + D_800783B8++; + osSetIntMask(temp_v0); + } +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041DF4.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041E40.s") - -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041EF4.s") +#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_80041CEC.s") -#pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_800420C0.s") +void func_80041D50(u8* arg0, u8* arg1) { + u8 temp_v0 = *arg0; + u8 temp_v1 = *arg1; + + if (temp_v1 != temp_v0) { + *arg0 = temp_v1; + *arg1 = temp_v0; + } +} + +u16 func_80041D70(u16 arg0) { + s32 i; + + for (i = 0; i < 20; i++) { + if (arg0 == D_800FCC50[i]) { + return 0; + } + } + + return arg0; +} + +void func_80041DF4(u16 arg0) { + u16 i; + + for (i = 0; i < 19; i++) { + D_800FCC50[i] = D_800FCC50[i + 1]; + } + + D_800FCC50[19] = arg0; +} + +void func_80041E40(u16 arg0) { + u32 i; + + for (i = arg0; i > 0; i--) { + D_800FCC50[i] = D_800FCC50[i - 1]; + } + + D_800FCC50[0] = 0; +} + +u32 func_80041EF4(u16* arg0) { + u16 temp_v0 = *arg0; + u32 i; + u32 j; + u16 sp5A; + + for (i = 0; i < temp_v0; i++) { + D_800FCD18[i] = i + 1; + } + + for (i = 0; i < temp_v0 << 1; i++) { + func_80041D50(D_800FCD18, D_800FCD18 + __ull_rem(osGetTime(), (s32)temp_v0)); + } + + for (i = 0; i < temp_v0; i++) { + sp5A = func_80041D70(arg0[D_800FCD18[i]]); + if (sp5A != 0) { + func_80041DF4(sp5A); + return sp5A; + } + } + + for (i = 0; i < 20; i++) { + for (j = 1; j <= temp_v0; j++) { + if (D_800FCC50[i] == arg0[j]) { + func_80041E40(i); + func_80041DF4(arg0[j]); + return arg0[j]; + } + } + } + + return 0; +} + +void func_800420C0(u16* arg0) { + u32 temp_v0 = func_80041EF4(arg0); + + if (temp_v0 != 0) { + func_80041C70(temp_v0); + } +} #pragma GLOBAL_ASM("asm/us/nonmatchings/3D140/func_800420F0.s") diff --git a/src/3D140.h b/src/3D140.h new file mode 100644 index 00000000..d89cb87a --- /dev/null +++ b/src/3D140.h @@ -0,0 +1,17 @@ +#ifndef _3D140_H_ +#define _3D140_H_ + +#include "global.h" + +void func_8003D918(u32 arg0, u32 arg1); +void func_8003DB84(s32 arg0); +void func_80041A98(void); +void func_80041C70(u32 arg0); +void func_80041D50(u8* arg0, u8* arg1); +u16 func_80041D70(u16 arg0); +void func_80041DF4(u16 arg0); +void func_80041E40(u16 arg0); +u32 func_80041EF4(u16* arg0); +void func_800420C0(u16* arg0); + +#endif // _3D140_H_ diff --git a/src/3FB0.c b/src/3FB0.c index 2139293a..b329e03a 100644 --- a/src/3FB0.c +++ b/src/3FB0.c @@ -29,25 +29,25 @@ // PERSJPEG header struct UnkInputStruct80003C80 { - char filler0[0x8]; - u32 unk8; - u32 unkC; + char filler0[0x8]; + u32 unk8; + u32 unkC; }; s32 func_80003C80(s32 arg0, struct UnkInputStruct80003C80* arg1, s32 side) { - s32 addr = main_pool_alloc(arg1->unkC + 0x100, side); - - if (addr != 0) { - s32 size = func_80003680(addr, arg1->unkC + 0x100, (u32)arg1 + arg1->unk8, arg1); - if (size == 0) { - main_pool_try_free(addr); - addr = NULL; - } else if (side == 0) { - main_pool_realloc(addr, size); - } - } - main_pool_try_free(arg0); - return addr; + s32 addr = main_pool_alloc(arg1->unkC + 0x100, side); + + if (addr != 0) { + s32 size = func_80003680(addr, arg1->unkC + 0x100, (u32)arg1 + arg1->unk8, arg1); + if (size == 0) { + main_pool_try_free(addr); + addr = NULL; + } else if (side == 0) { + main_pool_realloc(addr, size); + } + } + main_pool_try_free(arg0); + return addr; } // PERS-SZP header diff --git a/src/45720.c b/src/45720.c index ccd594e7..41f99108 100644 --- a/src/45720.c +++ b/src/45720.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "45720.h" #pragma GLOBAL_ASM("asm/us/nonmatchings/45720/func_80044B20.s") diff --git a/src/45720.h b/src/45720.h new file mode 100644 index 00000000..966f96b7 --- /dev/null +++ b/src/45720.h @@ -0,0 +1,10 @@ +#ifndef _45720_H_ +#define _45720_H_ + +#include "global.h" + +void func_80044D78(s32, s32); +s32 func_80044E54(s32); +void func_80044E80(s32); + +#endif // _45720_H_ diff --git a/src/4B940.c b/src/4B940.c index ca3710dd..40d4ba65 100644 --- a/src/4B940.c +++ b/src/4B940.c @@ -1,5 +1,49 @@ -#include "global.h" +#include "4B940.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/4B940/func_8004AD40.s") +static OSMesgQueue D_800FF990; +static OSPiHandle* D_800FF9A8; +static OSMesg D_800FF9AC; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4B940/func_8004ADB0.s") +void func_8004AD40(s32 arg0) { + switch (arg0) { + case 1: + D_800FF9A8 = osDriveRomInit(); + break; + + case 2: + default: + D_800FF9A8 = osCartRomInit(); + break; + } + + osCreateMesgQueue(&D_800FF990, &D_800FF9AC, 1); +} + +void func_8004ADB0(u32 dev_addr, u32 dram_addr, u32 size) { + OSIoMesg msg; + u32 dev = dev_addr; + u32 dram = dram_addr; + s32 var_s0; + + while (size != 0) { + if (size > 0x4000) { + var_s0 = 0x4000; + } else { + var_s0 = size; + } + + msg.hdr.pri = 0; + msg.hdr.retQueue = &D_800FF990; + msg.dramAddr = dram; + msg.devAddr = dev; + msg.size = var_s0; + + osInvalDCache(msg.dramAddr, var_s0); + osEPiStartDma(D_800FF9A8, &msg, 0); + osRecvMesg(&D_800FF990, NULL, 1); + + dev += var_s0; + dram += var_s0; + size -= var_s0; + } +} diff --git a/src/4B940.h b/src/4B940.h new file mode 100644 index 00000000..3c683793 --- /dev/null +++ b/src/4B940.h @@ -0,0 +1,8 @@ +#ifndef _4B940_H_ +#define _4B940_H_ + +#include "global.h" + +void func_8004ADB0(u32 dev_addr, u32 dram_addr, u32 size); + +#endif // _4B940_H_ diff --git a/src/4BDC0.c b/src/4BDC0.c index 70e98577..e2b198ac 100644 --- a/src/4BDC0.c +++ b/src/4BDC0.c @@ -1,14 +1,600 @@ -#include "global.h" #include "4BDC0.h" +#include "src/38BB0.h" +#include "src/4BA90.h" +#include "src/4CBC0.h" +#include "src/4B940.h" +#include "src/45720.h" +#include "src/50CC0.h" +#include "src/3D140.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/4BDC0/func_8004B1C0.s") +static s32 D_800FF9B0; +static s32 D_800FF9B4; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4BDC0/func_8004B1CC.s") +void func_8004B1C0(s32 arg0) { + D_80078EC8 = arg0; +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/4BDC0/func_8004B9C4.s") +s32 func_8004B1CC(s32 arg0) { + u32 sp2C; + s32 var_a2; + UNUSED s32 pad; + s32 sp20; + s32 sp1C; + + sp20 = arg0; + sp1C = 0x80; + func_80044E80(1); + func_800398F0(1); + D_800FF9B4 = arg0; + if (arg0 == 0x50) { + D_80078E78 = 0; + D_80078E7C = 0; + if (D_80078ED0 == 1) { + func_80039B88(D_80078ECC, 0, 0x80, 0x50); + D_80078ED0 = 2; + return 0; + } + func_80039940(); + D_80078E70 = 0; + func_800392A8(D_80078ECC, 1); + D_80078ED0 = 0; + D_80078ECC = func_8004DDA4(0x01000003, 0, 0); + arg0 = 0x28; + D_80078ED0 = 2; + } else if (arg0 == 0x28) { + D_80078E78 = 0; + if (D_80078ED0 == 2) { + func_80039B88(D_80078ECC, 0x80, 0, 0x50); + D_80078ED0 = 1; + return 0; + } + func_80039940(); + D_80078E70 = 0; + func_800392A8(D_80078ECC, 1); + D_80078ED0 = 0; + D_80078ECC = func_8004DDA4(0x01000003, 0, 0); + func_800393DC(D_80078ECC, 0); + D_80078ED0 = 1; + } else { + func_80039940(); + D_80078E70 = 0; + func_800392A8(D_80078ECC, 1); + D_80078ED0 = 0; + } + + if (arg0 == 0x32) { + if ((D_80078404 < 0xC) && (D_80078390[0] > 0) && (D_80078390[1] == 0) && (D_80078408 == 8)) { + arg0 = 0x3C; + } else if ((D_80078404 == 0xD) && (D_80078390[0] > 0) && (D_80078390[1] == 0) && (D_80078408 == 5)) { + arg0 = 0x3E; + D_800FF9B4 = 0x3E; + } else if ((D_80078404 == 0xF) && (D_80078390[0] > 0) && (D_80078390[1] == 0)) { + arg0 = 0x40; + } + } + + if ((arg0 == 0x3F) && (D_80078404 == 0xD) && (D_80078408 == 5)) { + arg0 = 0x41; + } + + if ((arg0 == 0x31) && (D_80078E78 != 0)) { + arg0 = 0x46; + } + + if ((arg0 == 0x3A) && (D_80078E7C != 0)) { + arg0 = 0x48; + } + + sp2C = arg0; + switch (arg0) { + case 0x0: + D_80078E78 = 0; + D_80078E7C = 0; + D_80078E80 = 1; + sp20 = 0x98; + break; + + case 0x1: + sp20 = 0x68; + D_80078E80 = 1; + func_8003D918(0, 0xF); + break; + + case 0x9: + sp20 = 0x50; + break; + + case 0x7: + sp20 = 0x78; + break; + + case 0x8: + sp20 = 0xA0; + break; + + case 0xF: + sp20 = 0x60; + break; + + case 0xA: + sp20 = 0x60; + break; + + case 0x11: + sp20 = 0x60; + break; + + case 0x17: + sp20 = 0x60; + break; + + case 0x18: + sp20 = 0x60; + break; + + case 0x19: + sp20 = 0x58; + break; + + case 0x1C: + sp20 = 0x60; + break; + + case 0x1D: + sp20 = D_80078E74; + break; + + case 0x1E: + sp20 = 0x65; + break; + + case 0x1F: + sp20 = 0x70; + break; + + case 0x20: + sp20 = 0x70; + break; + + case 0x21: + sp20 = 0x50; + break; + + case 0x1A: + sp20 = 0x60; + func_8004B154(); + break; + + case 0x1B: + sp20 = 0x58; + func_8004B154(); + break; + + case 0x2C: + sp20 = 0x70; + break; + + case 0x13: + sp20 = 0x68; + break; + + case 0x38: + sp20 = 0x60; + break; + + case 0x15: + sp20 = 0x60; + break; + + case 0x2D: + sp20 = 0x60; + break; + + case 0x16: + sp20 = 0x60; + break; + + case 0x10: + sp20 = 0x68; + break; + + case 0x2A: + sp20 = 0x60; + break; + + case 0x27: + sp20 = 0x58; + break; + + case 0x2B: + sp20 = 0x60; + break; + + case 0x30: + D_80078E78 = 1; + sp20 = 0x64; + break; + + case 0x28: + D_80078E78 = 0; + D_80078E7C = 0; + sp20 = 0x48; + break; + + case 0x29: + D_80078E78 = 0; + D_80078E7C = 0; + sp20 = 0x78; + sp1C = 0x87; + break; + + case 0x31: + sp20 = 0x60; + break; + + case 0x33: + sp20 = 0x60; + break; + + case 0x46: + sp20 = 0x60; + break; + + case 0x32: + sp20 = 0x60; + break; + + case 0x3C: + sp20 = 0x60; + break; + + case 0x3D: + sp20 = 0x88; + break; + + case 0x3E: + sp20 = 0x60; + break; + + case 0x3F: + sp20 = 0x60; + break; + + case 0x40: + sp20 = 0x50; + break; + + case 0x41: + sp20 = 0x60; + break; + + case 0x45: + sp20 = 0x60; + break; + + case 0x44: + sp20 = 0x90; + break; + + case 0x47: + sp20 = 0x88; + D_80078E7C = 1; + break; + + case 0x5B: + sp20 = 0x78; + sp2C = 1; + break; + + case 0x3A: + sp20 = 0x68; + func_8003D918(0, 0xF); + func_8004DF94(0x01100016, 0, 0); + break; + + case 0x48: + func_8003D918(0, 0xF); + func_8004DF94(0x01100016, 0, 0); + sp20 = 0x70; + break; + + case 0x49: + sp20 = 0x68; + break; + + case 0x4A: + sp20 = 0xA8; + break; + + case 0x4B: + sp20 = 0x60; + break; + + case 0x42: + D_80078E78 = 0; + D_80078E7C = 0; + sp20 = 0x80; + break; + + case 0x43: + D_80078E78 = 0; + D_80078E7C = 0; + sp20 = 0x80; + break; + + case 0x22: + sp20 = 0x48; + break; + + case 0x24: + sp20 = 0x48; + break; + + case 0x26: + sp20 = 0x40; + break; + + case 0x23: + sp20 = 0x50; + break; + + case 0x25: + sp20 = 0x50; + break; + + case 0xE: + sp20 = 0x64; + break; + + case 0xD: + sp20 = 0x48; + break; + + case 0xB: + sp20 = 0x38; + break; + + case 0xC: + sp20 = 0x38; + break; + + case 0x12: + sp20 = 0x2E; + break; + + case 0x36: + sp20 = 0x38; + break; + + case 0x6: + sp20 = 0x38; + break; + + case 0x37: + sp20 = 0x38; + break; + + case 0x3B: + sp20 = 0x3C; + break; + + case 0x39: + sp20 = 0x38; + break; + + case 0x34: + sp20 = 0x60; + break; + + case 0x2F: + sp20 = 0x58; + break; + + case 0x2E: + sp20 = 0x54; + break; + + case 0x35: + sp20 = 0x54; + break; + + case 0x14: + sp20 = 0x58; + break; + + case 0x2: + sp20 = 0x34; + break; + + case 0x3: + sp20 = 0x44; + break; + + case 0x4: + sp20 = 0x38; + break; + + case 0x5: + sp20 = 0x34; + break; + + case 0x5A: + sp20 = 0x50; + D_80078E80 = 0; + sp2C = 2; + break; + + default: + return 0; + } + + if (sp2C < D_800FC6E4->unk_08 - 1) { + var_a2 = D_800FC6E4->unk_0C[sp2C + 1] - D_800FC6E4->unk_0C[sp2C]; + } else if (sp2C == D_800FC6E4->unk_08 - 1) { + var_a2 = D_800FC6E0->unk_08 - D_800FC6E4->unk_0C[sp2C]; + } else { + return 0; + } + + func_8004ADB0(D_800FC6E4->unk_0C[sp2C], D_800FC6DC, var_a2); + func_80050B40(D_800FC6DC, D_800FC680, 0x98D8); + + if (D_80078EC8 <= 0) { + D_80078E70 = func_80038F30(D_800FC684, D_800FC680); + } else { + D_80078E70 = func_80039A7C(D_800FC684, D_800FC680, D_80078EC8 ^ 0); + } + + D_80078EC8 = -1; + func_800393DC(D_80078E70, sp20); + + if (sp1C != 0x80) { + func_800395FC(D_80078E70, sp1C); + } + + if (arg0 == 0x1D) { + D_800FF9B0 = D_80078E70; + } + + return D_80078E70; +} + +void func_8004B9C4(s32 arg0) { + s32 i; + + if (arg0 == 0) { + arg0 = 1; + } + + func_800392A8(D_80078E70, arg0); + D_80078EC8 = -1; + func_800392A8(D_80078ECC, arg0); + D_80078ED0 = 0; + D_8007840C = 0; + func_800392A8(D_80078FA8, arg0); + func_80044E80(0); + func_8003DB84(0); + + if (D_800FF9B4 != 0x50) { + for (i = 0; i < 2; i++) { + func_80044D78(i, arg0); + } + } +} #pragma GLOBAL_ASM("asm/us/nonmatchings/4BDC0/func_8004BA88.s") -#pragma GLOBAL_ASM("asm/us/nonmatchings/4BDC0/func_8004BC84.s") +s32 func_8004BC84(s32 arg0, u32 arg1) { + s32 var_a3; + + switch (arg0) { + case 30: + switch (D_80078ED4) { + case 0: + D_80078ED4 = 1; + return func_8004B1CC(0x1E); + + case 1: + return 0; + + case 2: + return 0; + + case 3: + if (func_80039354(D_80078EDC) == 0) { + D_80078ED4 = 1; + if (arg1 == 0) { + return func_8004B1CC(0x1E); + } + return 0; + } + return 0; + } + return 0; + + case 31: + D_80078ED4 = 2; + switch (arg1) { + case 0: + var_a3 = (arg1 * 0x48) + 0xD6; + break; + + case 1: + var_a3 = (arg1 * 0x48) + 0xD6; + break; + + case 2: + var_a3 = (arg1 * 0x48) + 0xD6; + break; + + case 3: + var_a3 = (arg1 * 0x48) + 0xD6; + break; + + case 4: + var_a3 = (arg1 * 0x48) + 0xD6; + break; + + default: + var_a3 = 0xD6; + break; + } + + switch (arg1) { + case 0: + func_8004D9B0(0x9000D, 0, 0); + break; + + case 1: + func_8004D9B0(0x9000E, 0, 0); + break; + + case 2: + func_8004D9B0(0x9000F, 0, 0); + break; + + case 3: + func_8004D9B0(0x90010, 0, 0); + break; + + case 4: + func_8004D9B0(0x90011, 0, 0); + break; + } + + func_8004B1C0(var_a3); + D_80078ED8 = func_8004B1CC(0x1F); + return D_80078ED8; + + case 32: + switch (D_80078ED4) { + case 0: + return 0; + + case 1: + return 0; + + case 2: + if (func_80039354(D_80078ED8) == 0) { + if (arg1 == 0) { + D_80078ED4 = 3; + D_80078EDC = 0; + } else { + func_8004B1C0(0x46); + D_80078ED4 = 3; + D_80078EDC = func_8004B1CC(0x20); + return D_80078EDC; + } + } + return 0; + + case 3: + return 0; + } + return 0; + } +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/4BDC0/func_8004BFB0.s") +u32 func_8004BFB0(void) { + return D_80078ED4; +} diff --git a/src/4BDC0.h b/src/4BDC0.h index 7fb0c6f9..a33efe66 100644 --- a/src/4BDC0.h +++ b/src/4BDC0.h @@ -4,8 +4,8 @@ #include "global.h" void func_8004B9C4(s32); -void func_8004B1CC(s32); -void func_8004BC84(s32, u32); +s32 func_8004B1CC(s32); +s32 func_8004BC84(s32, u32); u32 func_8004BFB0(void); #endif // _4BDC0_H_ diff --git a/src/4CBC0.c b/src/4CBC0.c index 71366d49..61694f9e 100644 --- a/src/4CBC0.c +++ b/src/4CBC0.c @@ -1,57 +1,1441 @@ #include "4CBC0.h" +#include "src/38BB0.h" +#include "src/49790.h" +#include "src/4B940.h" +#include "src/4BDC0.h" +#include "src/50CC0.h" +#include "src/373A0.h" +#include "src/50860.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004BFC0.s") +static s32 D_80078EE0[4] = { + 0xFFFFFF9C, + 0xFFFFFFD8, + 0x00000028, + 0x00000064, +}; +static s32 D_80078EF0[4] = { + 0xFFFFFFFD, + 0xFFFFFFFE, + 0xFFFFFFFE, + 0xFFFFFFFE, +}; +static s32 D_80078F00[8] = { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, +}; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C16C.s") +s32 func_8004BFC0(s32 arg0, s32 arg1, s32 arg2) { + s32 sp34; + UNUSED s32 pad[3]; + f32 var_fv0; + s32 var_v0; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C17C.s") + var_fv0 = 0.0f; + var_v0 = 0x80; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C444.s") + if (arg0 == 0x2000A) { + arg0 = 0x20001; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C454.s") + switch (arg0) { + case 0x20003: + case 0x20004: + case 0x20005: + case 0x20006: + case 0x20007: + case 0x20008: + if ((arg1 <= 0) || (arg1 >= 5)) { + arg1 = 1; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C4FC.s") + switch (arg2) { + case 1: + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C6CC.s") + case 2: + var_v0 = (arg1 * 0xAF) - 0x87; + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C6DC.s") + case 3: + var_v0 = (arg1 * 0x66) - 0x4D; + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C8A4.s") + case 4: + if (1) {} + var_v0 = (arg1 * 0x4E) - 0x44; + break; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004C8B4.s") + if ((arg0 == 0x20004) || (arg0 == 0x20005) || (arg0 == 0x20006) || (arg0 == 0x20007)) { + var_fv0 = (4 - arg1) * 0.5f; + } + break; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004CA6C.s") + sp34 = func_80039024(D_800FC6A4, D_800FC6A8, arg0 & 0xFFFF, 0x80, var_v0, -1); + func_80039534(sp34, var_fv0); -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004CA7C.s") + return sp34; +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004CC10.s") +void func_8004C16C(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004CC20.s") +s32 func_8004C17C(s32 arg0, s32 arg1, s32 arg2) { + s32 sp44; + UNUSED s32 pad[2]; + u32 sp38; + f32 var_fv0; + s32 var_v0; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004CC34.s") + var_v0 = 0x7F; + sp38 = 0x80; + var_fv0 = 0.0f; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004CC94.s") + switch (arg0) { + case 0x30003: + sp38 = 0x50; + if (arg2 >= 0) { + if (func_80039354(D_80078F00[arg1]) == 0) { + var_fv0 += D_80078EF0[arg1]; + var_v0 += D_80078EE0[arg1]; + break; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004CCD8.s") + if ((arg2 >= 0) && (arg2 < 0x14)) { + var_fv0 += D_80078EF0[arg1]; + var_fv0 += 0.5f * arg2; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004D16C.s") + func_80039534(D_80078F00[arg1], var_fv0); + return 0; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004D1B0.s") + if (arg2 >= 0x14) { + var_fv0 += D_80078EF0[arg1]; + var_fv0 += (0, 0.5f) * 22.5; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004D3A0.s") + func_80039534(D_80078F00[arg1], var_fv0); + return 0; + } + } else if (func_80039354(D_80078F00[arg1]) == 0) { + return 0; + } else { + func_800392A8(D_80078F00[arg1], 0xA); + return 0; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004D3B0.s") + case 0x30004: + func_800392A8(D_80078F00[0], 0x14); + func_800392A8(D_80078F00[1], 0x14); + func_800392A8(D_80078F00[2], 0x14); + func_800392A8(D_80078F00[3], 0x14); + var_v0 += D_80078EE0[arg1]; + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004D848.s") + case 0x30001: + case 0x30002: + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004D858.s") + default: + return 0; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004D9B0.s") + sp44 = func_80039024(D_800FC6A4, D_800FC6A8, arg0 & 0xFFFF, sp38, var_v0, -1); + func_80039534(sp44, var_fv0); + if (arg0 == 0x30003) { + D_80078F00[arg1] = sp44; + } + return sp44; +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004DC8C.s") +void func_8004C444(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004DDA4.s") +s32 func_8004C454(u32 arg0, u32 arg1) { + s32 ret; -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004DF94.s") + if ((arg0 == 0) || (arg0 >= 5)) { + arg0 = 1; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/4CBC0/func_8004E304.s") + switch (arg1) { + case 1: + ret = 0x80; + break; + + case 2: + ret = (arg0 * 0xAF) - 0x87; + break; + + case 3: + ret = (arg0 * 0x66) - 0x4D; + break; + + case 4: + ret = (arg0 * 0x4E) - 0x44; + break; + + default: + ret = 0x80; + break; + } + + return ret; +} + +s32 func_8004C4FC(s32 arg0, s32 arg1, s32 arg2) { + s32 sp3C; + UNUSED s32 pad; + s32 var_v1 = 0x80; + u32 var_a3 = 0x80; + f32 var_fv0 = 0.0f; + + switch (arg0) { + case 0x00040004: + if ((arg1 <= 0) || (arg1 >= 5)) { + var_a3 = 0x80; + arg1 = 1; + } + func_800392A8(D_80078F00[arg1 + 3], 0x14); + var_v1 = func_8004C454(arg1, arg2); + var_fv0 = (4 - arg1) * 0.5f; + break; + + case 0x00040005: + case 0x00040006: + case 0x00040007: + if ((arg1 <= 0) || (arg1 >= 5)) { + arg1 = 1; + } + var_v1 = func_8004C454(arg1, arg2); + var_a3 = 0x80; + var_fv0 = (4 - arg1) * 0.5f; + break; + + case 0x00040001: + var_a3 = 0xC0; + break; + + case 0x00040003: + if ((arg1 <= 0) || (arg1 >= 5)) { + arg1 = 1; + } + var_v1 = func_8004C454(arg1, arg2); + var_a3 = 0xC0; + var_fv0 = 0.0f; + break; + + case 0x00040002: + break; + + default: + return 0; + } + + sp3C = func_80039024(D_800FC6A4, D_800FC6A8, arg0 & 0xFFFF, var_a3, var_v1, -1); + func_80039534(sp3C, var_fv0); + + if (arg0 == 0x40004) { + D_80078F00[arg1 + 3] = sp3C; + } + + return sp3C; +} + +void func_8004C6CC(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} + +s32 func_8004C6DC(s32 arg0, s32 arg1, s32 arg2) { + static s32 D_80078F20 = 0x00000000; + + s32 sp34; + UNUSED s32 pad; + u32 var_v0 = 0x80; + s32 var_a3 = 0x80; + f32 var_fv0 = 0.0f; + + switch (arg0) { + case 0x50001: + case 0x50002: + case 0x50003: + case 0x50004: + case 0x50005: + case 0x50006: + case 0x50007: + break; + + case 0x50008: + case 0x50009: + case 0x5000A: + if ((arg1 <= 0) || (arg1 >= 5)) { + arg1 = 1; + } + var_fv0 = (4 - arg1) * 0.5f; + if (arg2 >= 0x141) { + arg2 = 0x140; + } + var_v0 = arg2 * 0.796875f; + break; + + case 0x5000B: + func_800392A8(D_80078F20, 1); + var_v0 = 0x80; + var_a3 = 0x80; + var_fv0 = 0.0f; + break; + + case 0x5000C: + var_a3 = 0xA0; + break; + + default: + return 0; + } + + sp34 = func_80039024(D_800FC6A4, D_800FC6A8, arg0 & 0xFFFF, var_a3, var_v0, -1); + func_80039534(sp34, var_fv0); + D_80078F20 = sp34; + return sp34; +} + +void func_8004C8A4(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} + +s32 func_8004C8B4(s32 arg0, s32 arg1, UNUSED s32 arg2) { + static s32 D_80078F24[4] = { + 0xFFFFFF88, + 0xFFFFFFC4, + 0x0000003C, + 0x00000078, + }; + static f32 D_80078F34[4] = { + -1, + -0.5, + 0, + 0.5, + }; + static s32 D_80078F44 = 0x00000000; + static s32 D_80078F48 = 0x00000000; + + s32 sp34; + UNUSED s32 pad; + u32 var_v1; + s32 sp28; + UNUSED s32 pad2; + f32 sp20; + + sp20 = 0.0f; + var_v1 = 0x7F; + sp28 = 0x80; + + if ((arg1 >= 4) | (arg1 < 0)) { + return 0; + } + + switch (arg0) { + case 0x60003: + sp20 += D_80078F34[arg1]; + var_v1 = D_80078F24[arg1] + 0x7F; + case 0x60001: + case 0x60002: + case 0x60006: + case 0x60008: + case 0x60009: + case 0x6000A: + case 0x6000B: + break; + + case 0x60004: + var_v1 = D_80078F24[arg1] + 0x7F; + sp28 = 0x70; + break; + + case 0x60005: + if (func_80039354(D_80078F48) != 0) { + return 0; + } + var_v1 = 0x7F; + if (func_80039354(D_80078F44) != 0) { + return 0; + } + break; + + case 0x60007: + var_v1 = 0x7F; + if (func_80039354(D_80078F48) != 0) { + arg0 = 0x60008; + } + break; + + default: + return 0; + } + + sp34 = func_80039024(D_800FC6A4, D_800FC6A8, arg0 & 0xFFFF, sp28, var_v1, -1); + if (arg0 == 0x60005) { + if (func_80039354(D_80078F44) == 0) { + D_80078F44 = sp34; + } + } + D_80078F48 = sp34; + func_80039534(sp34, sp20); + return sp34; +} + +void func_8004CA6C(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} + +static u8 D_80078F4C = 0; + +s32 func_8004CA7C(s32 arg0, s32 arg1, UNUSED s32 arg2) { + s32 sp44; + s32 var_a2; + s32 var_a3; + s32 var_v0; + f32 var_fv0; + u8 var_t0; + u8 sp2C[] = { + 0x19, + 0x4E, + 0xB2, + 0xE6, + }; + + var_fv0 = 0.0f; + var_t0 = 0x80; + var_a3 = 0x80; + var_v0 = -1; + var_a2 = arg0 & 0xFFFF; + + switch (arg0) { + case 0x70004: + case 0x70005: + case 0x70006: + if ((arg1 <= 0) || (arg1 >= 5)) { + arg1 = 1; + } + var_t0 = sp2C[arg1 - 1]; + var_fv0 = ((4 - arg1) * 0.5f) + -2.0f; + break; + + case 0x70009: + break; + + case 0x70003: + if (arg1 != 0) { + var_t0 = 0x1E; + } else { + var_t0 = 0xE1; + } + break; + + case 0x70001: + switch (D_80078F4C) { + case 0: + var_a2 = 1; + break; + + case 1: + var_a2 = 7; + break; + + case 2: + var_a2 = 8; + break; + } + var_a3 = 0x70; + + D_80078F4C++; + if (D_80078F4C >= 3) { + D_80078F4C = 0; + } + var_v0 = 0x80; + break; + + case 0x70002: + D_80078F4C = 0; + var_a3 = 0x70; + var_v0 = 0x80; + break; + + default: + return 0; + } + + sp44 = func_80039024(D_800FC6A4, D_800FC6A8, var_a2, var_a3, var_t0, var_v0); + func_80039534(sp44, var_fv0); + return sp44; +} + +void func_8004CC10(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} + +static s32 D_80078F54[4] = { + 0xFFFFFF88, + 0xFFFFFFC4, + 0x0000003C, + 0x00000078, +}; + +static f32 D_80078F64[4] = { + 0.0f, + 0.1000000015f, + -0.1000000015f, + 0.200000003f, +}; + +static s32 D_80078F74[4] = { + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, +}; + +static s32 D_80078F84 = 0x00000000; + +static s32 D_80078F88 = 0x00000000; + +static s32 D_80078F8C[4] = { + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, +}; + +static s32 D_80078F9C = 0x00003039; +static u32 D_80078FA0 = 0x00001A85; + +void func_8004CC20(s32 arg0, u32 arg1) { + D_80078F9C = arg0; + D_80078FA0 = arg1; +} + +u32 func_8004CC34(void) { + D_80078F9C = (D_80078F9C * 0x41C64E6D) + 0x3039; + + if (D_80078FA0 & 1) { + D_80078FA0 ^= 0x11020; + } + + D_80078FA0 >>= 1; + + return D_80078F9C ^ D_80078FA0; +} + +f32 func_8004CC94(void) { + return (f32)func_8004CC34() / -1u; +} + +s32 func_8004CCD8(s32 arg0, s32 arg1, s32 arg2) { + static u32 D_80078FA4 = 0; + + s32 sp44; + UNUSED s32 pad; + u32 sp3C; + s32 sp38; + UNUSED s32 pad2; + f32 var_fv1; + + sp3C = 0x7F; + sp38 = 0x80; + var_fv1 = 0.0f; + + if ((arg1 >= 4) || (arg1 < 0)) { + return 0; + } + + if ((arg2 < 0) || (arg2 >= 6)) { + return 0; + } + + switch (arg0) { + case 0x80001: + sp3C += D_80078F54[arg1]; + sp38 = 0x40; + var_fv1 += D_80078F64[arg1]; + switch (arg2) { + case 0: + break; + + case 1: + return 0; + + case 2: + var_fv1 += 0.5; + func_80039534(D_80078F74[arg1], var_fv1); + return 0; + + case 3: + var_fv1 += 1.0; + func_80039534(D_80078F74[arg1], var_fv1); + return 0; + + case 4: + var_fv1 += 2.0; + func_80039534(D_80078F74[arg1], var_fv1); + func_800393DC(D_80078F74[arg1], 0x58); + return 0; + + case 5: + func_800392A8(D_80078F74[arg1], 3); + + default: + return 0; + } + break; + + case 0x80002: + if (func_80039354(D_80078F8C[arg1]) != 0) { + return 0; + } + + sp3C += D_80078F54[arg1]; + var_fv1 += D_80078F64[arg1]; + + switch (arg2) { + case 1: + return 0; + + case 2: + if (func_8004CC94() > 0.05) { + return 0; + } + break; + + case 3: + if (func_8004CC94() > 0.1) { + return 0; + } + break; + + case 4: + if (func_8004CC94() > 0.17) { + return 0; + } + break; + + default: + return 0; + } + break; + + case 0x80003: + if (func_80039354(D_80078F84) != 0) { + return 0; + } + func_8004FC60(1, 1); + break; + + case 0x80004: + func_8004FC60(1, 1); + break; + + case 0x80005: + var_fv1 += (f32)D_80078FA4 * 2.0; + if (D_80078FA4 < 2) { + D_80078FA4 += 1; + } else if (D_80078FA4 >= 2) { + D_80078FA4 = 0; + } + break; + + case 0x80006: + func_8004FC60(1, 2); + break; + + case 0x80007: + case 0x80008: + break; + + default: + return 0; + } + + sp44 = func_80039024(D_800FC6A4, D_800FC6A8, arg0 & 0xFFFF, sp38, sp3C, -1); + + switch (arg0) { + case 0x80001: + D_80078F74[arg1] = sp44; + break; + + case 0x80002: + D_80078F8C[arg1] = sp44; + break; + + case 0x80003: + D_80078F84 = sp44; + + case 0x80004: + D_80078F88 = sp44; + break; + } + + func_80039534(sp44, var_fv1); + return sp44; +} + +void func_8004D16C(s32 arg0, s32 arg1, UNUSED s32 arg2) { + if (arg0 == 0x80001) { + func_800392A8(D_80078F74[arg1], 0xA); + } +} + +s32 D_80078FA8 = 0; + +s32 func_8004D1B0(s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { + static s32 D_80078FAC = 0; + + s32 sp3C; + s32 sp38; + UNUSED s32 pad; + s32 sp30; + f32 var_fv1; + UNUSED s32 pad2; + + sp30 = 0x80; + var_fv1 = 0.0f; + sp38 = arg0 & 0xFFFF; + + switch (arg0) { + case 0x90001: + if (D_80078FAC == 0) { + D_80078ED4 = 0; + D_80078ED8 = 0; + D_80078EDC = 0; + sp38 = 2; + D_80078FAC++; + func_8004BC84(0x1E, 0); + } else if (D_80078FAC == 1) { + D_80078FAC++; + var_fv1 -= 4.0f; + } else if (D_80078FAC == 2) { + D_80078FAC++; + var_fv1 -= 2.0f; + } else if (D_80078FAC == 3) { + D_80078FAC = 0; + var_fv1 -= 9.0f; + } + break; + + case 0x90002: + case 0x90003: + case 0x90004: + case 0x90005: + case 0x90006: + case 0x90007: + case 0x90008: + case 0x90009: + break; + + case 0x9000A: + func_8004B1CC(0x1A); + break; + + case 0x9000B: + func_8004B1CC(0x1B); + break; + + case 0x9000C: + return 0; + + case 0x9000D: + case 0x9000E: + case 0x9000F: + case 0x90010: + case 0x90011: + sp38 = sp38 - 1; + sp30 = 0x60; + break; + + default: + return 0; + } + + sp3C = func_80039024(D_800FC6A4, D_800FC6A8, sp38, sp30, 0x7F, -1); + func_80039534(sp3C, var_fv1); + + switch (arg0) { + case 0x9000D: + case 0x9000E: + case 0x9000F: + case 0x90010: + case 0x90011: + D_80078FA8 = sp3C; + break; + } + + return sp3C; +} + +void func_8004D3A0(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} + +s32 func_8004D3B0(s32 arg0, s32 arg1, s32 arg2) { + static s32 D_80078FB0[4] = { + 0xFFFFFF88, + 0xFFFFFFD8, + 0x00000028, + 0x00000078, + }; + static s32 D_80078FC0[3] = { + 0xFFFFFF8D, + 0x00000000, + 0x00000073, + }; + static f32 D_80078FCC[3] = { + 1.0f, + 0.8000000119f, + 0.6000000238f, + }; + static f32 D_80078FD8[4] = { + -0.6000000238f, + 1.0f, + -1.0f, + 0.6000000238f, + }; + static f32 D_80078FE8[4] = { + 0.0f, + 0.0f, + 2.0f, + 2.0f, + }; + static f32 D_80078FF8[4] = { + 0.0f, + 4.0f, + 8.0f, + 12.0f, + }; + + s32 sp34; + s32 sp30; + u32 var_t0; + u32 var_a3; + f32 var_fv0; + UNUSED s32 pad; + + var_t0 = 0x7F; + var_a3 = 0x80; + sp30 = arg0 & 0xFFFF; + var_fv0 = 0.0f; + + switch (arg0) { + case 0xA0003: + if (arg1 < 0) { + return 0; + } + + if (arg1 >= 4) { + return 0; + } + + switch (arg2) { + case 0: + break; + + case 1: + sp30 = 4; + break; + + case 2: + sp30 = 5; + break; + + case 3: + sp30 = 6; + break; + } + + var_fv0 += D_80078FD8[arg1]; + var_fv0 += D_80078FE8[arg2]; + var_t0 = D_80078FB0[arg1] + 0x7F; + var_a3 = 240.0f; + var_a3 += D_80078FF8[arg2]; + + if (var_t0 >= 0x100) { + var_t0 = 0xFF; + } + + if (var_t0 == 0) { + var_t0 = 1; + } + break; + + case 0xA0001: + case 0xA0002: + case 0xA0009: + case 0xA000C: + case 0xA000D: + case 0xA0010: + case 0xA0012: + case 0xA0013: + break; + + case 0xA0007: + if (arg1 < 0) { + return 0; + } + + if (arg1 >= 4) { + return 0; + } + + if (arg2 < -0x7D) { + arg2 = -0x7D; + } else if (arg2 >= 0x7E) { + arg2 = 0x7D; + } + + var_t0 = arg2 + 0x7F; + var_fv0 += D_80078FD8[arg1]; + break; + + case 0xA0008: + if (arg1 == 1) { + sp30 = 9; + } else if (arg1 != 0) { + return 0; + } + + if ((arg2 < 0) || (arg2 >= 0xB) || (arg2 == 3) || (arg2 == 7)) { + return 0; + } + + var_t0 = (s32)(D_80078FCC[(arg2 & 0xC) >> 2] * (f32)D_80078FC0[arg2 & 3]) + 0x7F; + break; + + case 0xA000A: + var_t0 = (s32)((0.8 * (f32)D_80078FC0[arg2 & 3]) * D_80078FCC[(arg2 & 0xC) >> 2]) + (0, 0x7F); + break; + + case 0xA000B: + if (arg1 == 1) { + sp30 = 0xC; + } else if (arg1 != 0) { + return 0; + } + var_t0 = (s32)(0.8 * (f32)D_80078FC0[arg2 & 3] * D_80078FCC[(arg2 & 0xC) >> 2]) + (0, 0x7F); + break; + + case 0xA000E: + func_8004FC60(1, 5); + var_a3 = 0x80; + var_t0 = 0x7F; + var_fv0 = 0.0f; + break; + + case 0xA000F: + return 0; + + case 0xA0011: + if (arg1 == 1) { + sp30 = 0x10; + } else if (arg1 != 0) { + return 0; + } + var_t0 = (s32)(0.8 * (f32)D_80078FC0[arg2 & 3] * D_80078FCC[(arg2 & 0xC) >> 2]) + (0, 0x7F); + break; + + default: + return 0; + } + + if (var_t0 == 0) { + var_t0 = 1; + } else if (var_t0 >= 0x100) { + var_t0 = 0xFF; + } + + sp34 = func_80039024(D_800FC6A4, D_800FC6A8, sp30, var_a3, var_t0, -1); + func_80039534(sp34, var_fv0); + return sp34; +} + +void func_8004D848(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { +} + +s32 func_8004D858(s32 arg0, s32 arg1) { + static s32 D_80079008 = 0x00000000; + static s32 D_8007900C = 0x00000000; + static s32 D_80079010 = 0x00000000; + + s32 temp_v0; + + switch (arg0) { + case 19: + func_800392A8(D_80079008, 1); + break; + + case 18: + case 20: + break; + + case 21: + switch (arg1) { + case 0: + if (func_80039354(D_80079010) != 0) { + return 0; + } + break; + + case 1: + func_800392A8(D_8007900C, 0x19); + break; + } + break; + + default: + return 0; + } + + if (arg0 == 0x15) { + func_800392A8(D_80079010, 0xA); + } + + temp_v0 = func_80039024(D_800FC68C, D_800FC688, arg0, 0x80, 0x80, -1); + switch (arg0) { + case 18: + D_80079008 = temp_v0; + break; + + case 20: + D_8007900C = temp_v0; + break; + + case 21: + D_80079010 = temp_v0; + break; + } + + return temp_v0; +} + +u32 D_80079014 = 0xFFFFFFFF; +static s32 D_80079018 = 0x00000000; + +s32 func_8004D9B0(s32 arg0, s32 arg1, s32 arg2) { + UNUSED s32 pad[5]; + s32 var_v0; + u32 sp24; + u32 temp_v1; + + temp_v1 = arg0 & 0xFFFF0000; + + switch (temp_v1) { + case 0x20000: + case 0x30000: + case 0x40000: + case 0x50000: + case 0x60000: + case 0x70000: + case 0x80000: + case 0x90000: + case 0xA0000: + break; + + default: + return 0; + } + + if (temp_v1 != D_80079014) { + sp24 = D_800FC6F8[temp_v1 >> 0x10].unk_00[-3]; + + func_8004ADB0(sp24, (u32)D_800FC798, 0xC); + func_80037360((u32)D_800FC798, sp24, 3); + func_8004ADB0(D_800FC798->unk_00, D_800FC6DC, D_800FC798->unk_04 - D_800FC798->unk_00); + func_80050B40(D_800FC6DC, D_800FC6A8, 0xBB8); + func_800397BC(D_800FC6A8); + func_8004ADB0(D_800FC798->unk_04, D_800FC6DC, D_800FC798->unk_08 - D_800FC798->unk_04); + func_80050B40(D_800FC6DC, D_800FC6A4, 0x1388); + func_8003979C(D_800FC6A4, D_800FC798->unk_08); + } + + D_80079014 = temp_v1; + + switch (temp_v1) { + case 0x20000: + var_v0 = func_8004BFC0(arg0, arg1, arg2); + break; + + case 0x30000: + var_v0 = func_8004C17C(arg0, arg1, arg2); + break; + + case 0x40000: + var_v0 = func_8004C4FC(arg0, arg1, arg2); + break; + + case 0x50000: + var_v0 = func_8004C6DC(arg0, arg1, arg2); + break; + + case 0x60000: + var_v0 = func_8004C8B4(arg0, arg1, arg2); + break; + + case 0x70000: + var_v0 = func_8004CA7C(arg0, arg1, arg2); + break; + + case 0x80000: + var_v0 = func_8004CCD8(arg0, arg1, arg2); + break; + + case 0x90000: + var_v0 = func_8004D1B0(arg0, arg1, arg2); + break; + + case 0xA0000: + var_v0 = func_8004D3B0(arg0, arg1, arg2); + break; + + default: + return 0; + } + + D_80079018 = var_v0; +} + +void func_8004DC8C(s32 arg0, s32 arg1, s32 arg2) { + switch (arg0 & 0xFFFF0000) { + case 0x20000: + func_8004C16C(arg0, arg1, arg2); + break; + + case 0x30000: + func_8004C444(arg0, arg1, arg2); + break; + + case 0x40000: + func_8004C6CC(arg0, arg1, arg2); + break; + + case 0x50000: + func_8004C8A4(arg0, arg1, arg2); + break; + + case 0x60000: + func_8004CA6C(arg0, arg1, arg2); + break; + + case 0x70000: + func_8004CC10(arg0, arg1, arg2); + break; + + case 0x80000: + func_8004D16C(arg0, arg1, arg2); + break; + + case 0x90000: + func_8004D3A0(arg0, arg1, arg2); + break; + + case 0xA0000: + func_8004D848(arg0, arg1, arg2); + break; + } +} + +s32 func_8004DDA4(s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { + UNUSED s32 pad[4]; + s32 var_v0; + s32 sp2C; + u32 sp34; + u32 sp28; + + sp28 = arg0 & 0xFFFF0000; + sp2C = arg0 & 0xFFFF; + + if (sp28 != D_80079014) { + sp34 = D_800FC6F4->unk_14; + + func_8004ADB0(sp34, (u32)D_800FC798, 0xC); + func_80037360((u32)D_800FC798, sp34, 3); + sp34 = D_800FC798->unk_04 - D_800FC798->unk_00; + func_8004ADB0(D_800FC798->unk_00, D_800FC6DC, sp34); + func_80050B40(D_800FC6DC, D_800FC6A8, 0xBB8); + func_800397BC(D_800FC6A8); + sp34 = D_800FC798->unk_08 - D_800FC798->unk_04; + func_8004ADB0(D_800FC798->unk_04, D_800FC6DC, sp34); + func_80050B40(D_800FC6DC, D_800FC6A4, 0x1388); + func_8003979C(D_800FC6A4, D_800FC798->unk_08); + } + + D_80079014 = sp28; + + switch (arg0) { + case 0x1000001: + var_v0 = func_80039024(D_800FC6A4, D_800FC6A8, sp2C, 0x80, 0x80, -1); + break; + + case 0x1000002: + var_v0 = func_80039024(D_800FC6A4, D_800FC6A8, sp2C, 0xA0, 0x80, -1); + break; + + case 0x1000003: + var_v0 = func_80039024(D_800FC684, D_800FC6A8, sp2C, 0xA0, 0x80, -1); + break; + + default: + return 0; + } + + D_80079018 = var_v0; +} + +s32 func_8004DF94(s32 arg0, s32 arg1, s32 arg2) { + static s32 D_8007901C = 0x00000000; + static s32 D_80079020 = 0x00000000; + static s32 D_80079024 = 0x00000000; + static s32 D_80079028 = 0; + static u8 D_8007902C[] = { + 0x60, 0xA0, 0xE0, 0x20, 0x60, 0xA0, + }; + static u8 D_80079034[] = { + 0x60, 0xA0, 0xE0, 0x60, 0xA0, 0xE0, 0x20, 0x60, 0xA0, 0x20, 0x60, 0xA0, + }; + static u8 D_80079040[] = { + 0x20, 0x60, 0xA0, 0xE0, 0x20, 0x60, 0xA0, 0xE0, 0x20, 0x60, 0xA0, 0xE0, + }; + + UNUSED s32 pad; + s32 sp40; + s32 temp_v0_2; + u32 sp38; + s32 sp34; + UNUSED s32 pad2; + u32 sp2C; + u32 sp20; + + sp20 = arg0 & 0xFFFF0000; + sp38 = 0x80; + sp34 = 0x80; + + if (sp20 != D_80079014) { + sp2C = D_800FC6F4->unk_1C; + func_8004ADB0(sp2C, (u32)D_800FC798, 0xC); + func_80037360((u32)D_800FC798, sp2C, 3); + func_8004ADB0(D_800FC798->unk_00, D_800FC6DC, D_800FC798->unk_04 - D_800FC798->unk_00); + func_80050B40(D_800FC6DC, D_800FC6A8, 0xBB8); + func_800397BC(D_800FC6A8); + func_8004ADB0(D_800FC798->unk_04, D_800FC6DC, D_800FC798->unk_08 - D_800FC798->unk_04); + func_80050B40(D_800FC6DC, D_800FC6A4, 0x1388); + func_8003979C(D_800FC6A4, D_800FC798->unk_08); + } + + D_80079014 = sp20; + + sp40 = arg0 & 0xFFFF; + switch (arg0) { + case 0x1100007: + return 0; + + case 0x1100015: + case 0x1100016: + case 0x1100017: + sp40--; + break; + + case 0x1100001: + case 0x1100002: + case 0x1100003: + case 0x1100005: + case 0x1100006: + case 0x1100009: + case 0x110000A: + case 0x110000C: + case 0x110000D: + case 0x110000F: + case 0x1100010: + case 0x1100011: + break; + + case 0x1100013: + sp34 = 0xF0; + break; + + case 0x1100012: + func_80048B90(0x1B); + break; + + case 0x1100004: + func_800392A8(D_8007901C, 5); + break; + + case 0x1100008: + func_800392A8(D_80079020, 5); + func_800392A8(D_80079024, 5); + break; + + case 0x110000B: + if (arg2 == 0) { + if ((arg1 <= 0) || (arg1 >= 7)) { + return 0; + } + sp38 = D_8007902C[arg1 - 1]; + } else { + if ((arg1 <= 0) || (arg1 >= 0xD)) { + return 0; + } + sp38 = D_80079034[arg1 - 1]; + } + func_800392A8(D_80079028, 0xA); + break; + + case 0x1100014: + sp40 = 0xB; + if (arg2 == 1) { + sp38 = 0x7F; + } else { + sp38 = D_80079040[(arg1 - 1) % 4]; + } + break; + + case 0x110000E: + if ((arg1 < 0) || (arg1 >= 9)) { + return 0; + } + sp38 = D_80079040[3 + arg1]; + break; + + default: + return 0; + } + + temp_v0_2 = func_80039024(D_800FC6A4, D_800FC6A8, sp40, sp34, sp38, -1); + switch (arg0) { + case 0x1100003: + D_8007901C = temp_v0_2; + break; + + case 0x1100006: + D_80079020 = temp_v0_2; + break; + + case 0x1100007: + D_80079024 = temp_v0_2; + break; + + case 0x110000B: + D_80079028 = temp_v0_2; + break; + } + D_80079018 = temp_v0_2; +} + +s32 func_8004E304(s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2) { + static s32 D_8007904C = 0x00000000; + static s32 D_80079050 = 0x00000000; + static s32 D_80079054 = 0x00000000; + static s32 D_80079058 = 0x00000000; + static s32 D_8007905C = 0x00000000; + static u8 D_80079060 = 0; + static u8 D_80079064 = 0; + + UNUSED s32 pad[2]; + s32 sp4C; + UNUSED s32 pad2[2]; + f32 var_fv1; + u32 sp3C; + u32 sp24; + + sp24 = arg0 & 0xFFFF0000; + if (sp24 != D_80079014) { + sp3C = D_800FC6F4->unk_24; + + func_8004ADB0(sp3C, (u32)D_800FC798, 0xC); + func_80037360((u32)D_800FC798, sp3C, 3); + func_8004ADB0(D_800FC798->unk_00, D_800FC6DC, D_800FC798->unk_04 - D_800FC798->unk_00); + func_80050B40(D_800FC6DC, D_800FC6A8, 0xBB8); + func_800397BC(D_800FC6A8); + func_8004ADB0(D_800FC798->unk_04, D_800FC6DC, D_800FC798->unk_08 - D_800FC798->unk_04); + func_80050B40(D_800FC6DC, D_800FC6A4, 0x1388); + func_8003979C(D_800FC6A4, D_800FC798->unk_08); + } + + D_80079014 = sp24; + + switch (arg0) { + case 0x1200001: + func_800392A8(D_8007904C, 1); + var_fv1 = __ull_to_f(__ull_rem(osGetTime(), 8)) - 4.0f; + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 7, 0x80, 0x80, -1); + func_80039534(sp4C, var_fv1); + D_8007904C = sp4C; + break; + + case 0x1200002: + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 1, 0x80, 0x80, -1); + D_80079050 = sp4C; + D_80079064 = 0; + break; + + case 0x1200003: + func_800392A8(D_80079050, 0x3C); + func_800392A8(D_80079054, 0x3C); + D_80079060 = 0; + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 3, 0x80, 0x80, -1); + break; + + case 0x1200004: + if (D_80079060 == 0) { + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 2, 0x80, 0x80, -1); + D_80079054 = sp4C; + var_fv1 = 2.0f; + D_80079060 = 1; + } else { + var_fv1 = 4.0f; + } + func_80039534(D_80079054, var_fv1); + break; + + case 0x1200005: + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 4, 0x80, 0x80, -1); + D_80079058 = sp4C; + break; + + case 0x1200006: + func_800392A8(D_80079054, 0x5A); + func_800392A8(D_80079058, 1); + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 5, 0x80, 0x80, -1); + break; + + case 0x1200007: + D_8007905C = sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 6, 0x80, 0x80, -1); + func_8004B9C4(0x78); + D_80079064 = 1; + break; + + case 0x1200008: + func_800392A8(D_8007905C, 6); + func_8004B1CC(0x13); + D_80079064 = 1; + break; + + case 0x1200009: + if (D_80079064 != 0) { + func_8004B1CC(0x10); + } + func_80048B90(2); + D_80079064 = 0; + break; + + case 0x120000C: + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 8, 0x80, 0x80, -1); + break; + + case 0x120000D: + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 9, 0x80, 0x80, -1); + break; + + case 0x120000E: + func_800392A8(D_8007904C, 1); + sp4C = func_80039024(D_800FC6A4, D_800FC6A8, 7, 0x80, 0x80, -1); + func_80039534(sp4C, -5.0f); + D_8007904C = sp4C; + break; + + default: + return 0; + } + + D_80079018 = sp4C; +} diff --git a/src/4CBC0.h b/src/4CBC0.h index 5a5b6ecb..cceb3188 100644 --- a/src/4CBC0.h +++ b/src/4CBC0.h @@ -3,6 +3,11 @@ #include "global.h" +extern s32 D_80078FA8; +extern u32 D_80079014; + s32 func_8004D9B0(s32 arg0, s32 arg1, s32 arg2); +s32 func_8004DDA4(s32, s32, s32); +s32 func_8004DF94(s32, s32, s32); #endif // _4CBC0_H_ diff --git a/src/50860.c b/src/50860.c index b4185a61..ef5f0f25 100644 --- a/src/50860.c +++ b/src/50860.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "50860.h" #pragma GLOBAL_ASM("asm/us/nonmatchings/50860/func_8004FC60.s") diff --git a/src/50860.h b/src/50860.h new file mode 100644 index 00000000..f2531efb --- /dev/null +++ b/src/50860.h @@ -0,0 +1,8 @@ +#ifndef _50860_H_ +#define _50860_H_ + +#include "global.h" + +void func_8004FC60(s32, s32); + +#endif // _50860_H_ diff --git a/src/50CC0.c b/src/50CC0.c index a3fa8feb..7c5f3629 100644 --- a/src/50CC0.c +++ b/src/50CC0.c @@ -1,4 +1,4 @@ -#include "global.h" +#include "50CC0.h" #pragma GLOBAL_ASM("asm/us/nonmatchings/50CC0/func_800500C0.s") diff --git a/src/50CC0.h b/src/50CC0.h new file mode 100644 index 00000000..31f8a97b --- /dev/null +++ b/src/50CC0.h @@ -0,0 +1,8 @@ +#ifndef _50CC0_H_ +#define _50CC0_H_ + +#include "global.h" + +void func_80050B40(s32, s32, s32); + +#endif // _50CC0_H_ diff --git a/yamls/us/rom.yaml b/yamls/us/rom.yaml index e873dcb5..d1974488 100644 --- a/yamls/us/rom.yaml +++ b/yamls/us/rom.yaml @@ -98,10 +98,10 @@ - [0x49DC0, c] - [0x4A360, c] - [0x4A3E0, c] - - [0x4B940, c] + - [0x4B940, c, 4B940] - [0x4BA90, c, 4BA90] - - [0x4BDC0, c] - - [0x4CBC0, c] + - [0x4BDC0, c, 4BDC0] + - [0x4CBC0, c, 4CBC0] - [0x4F410, c] - [0x4F7F0, c] - [0x4F870, c] @@ -331,6 +331,8 @@ - [0x6A3E0, data, rom_data_6A3E0] - [0x6A3F0, .data, math_util] - [0x6FC00, data, rom_data_6FC00] + - [0x79AE0, .data, 4CBC0] + - [0x79C70, data, rom_data_79C70] # libleo - [0x7A180, .data, libleo/driverominit] @@ -396,8 +398,8 @@ - [0x7DFD0, rodata, rom_rodata_7DFD0] - [0x7E0D0, rodata, rom_rodata_7E0D0] - [0x7E0E0, .rodata, 4BA90] - - [0x7E110, rodata, rom_rodata_7E110] - - [0x7E2F0, rodata, rom_rodata_7E2F0] + - [0x7E110, .rodata, 4BDC0] + - [0x7E2F0, .rodata, 4CBC0] - [0x7E560, rodata, rom_rodata_7E560] - [0x7E5D0, rodata, rom_rodata_7E5D0] - [0x7E600, rodata, rom_rodata_7E600] @@ -446,6 +448,9 @@ - {vram: 0x800A74C0, type: .bss, name: crash_screen} - {vram: 0x800A7EA0, type: .bss, name: profiler} - {vram: 0x800A8100, type: bss, name: unk_bss_2} + - {vram: 0x800FF990, type: .bss, name: 4B940} + - {vram: 0x800FF9B0, type: .bss, name: 4BDC0} + - {vram: 0x800FF9C0, type: bss, name: unk_bss_10} # libleo - {vram: 0x80100740, type: .bss, name: libleo/driverominit}