From e263e05f4a8e369869ac6ff65ce25019ce0ea808 Mon Sep 17 00:00:00 2001 From: Maide Date: Tue, 1 Oct 2024 09:13:11 +0100 Subject: [PATCH] 14A030 --- include/global.h | 8 +- include/macros.h | 2 + include/variables.h | 26 +- linker_scripts/us/symbol_addrs.txt | 24 + src/18480.c | 4 +- src/18480.h | 2 +- src/fragments/14/fragment14.h | 183 +++ src/fragments/14/fragment14_144300.c | 761 ++++++++++- src/fragments/14/fragment14_1462A0.c | 1770 +++++++++++++++++++++++++- src/fragments/14/fragment14_14A030.c | 566 +++++++- src/fragments/2/fragment2.c | 2 +- src/fragments/2/fragment2.h | 2 +- src/fragments/8/fragment8.c | 2 +- tools/permuter_settings.toml | 6 + yamls/us/rom.yaml | 16 +- 15 files changed, 3289 insertions(+), 85 deletions(-) create mode 100644 src/fragments/14/fragment14.h diff --git a/include/global.h b/include/global.h index 9778a37d..4fa71cb3 100644 --- a/include/global.h +++ b/include/global.h @@ -142,7 +142,9 @@ typedef struct unk_D_86002F58_004_000 { /* 0x0DC */ Vec3f unk_0DC; /* 0x0E0 */ char pad0E0[0x4]; /* 0x0EC */ Vec3f unk_0EC; - /* 0x0F8 */ char pad0F8[0x70]; + /* 0x0F8 */ char pad0F8[0x4]; + /* 0x0FC */ Vec3f unk_0FC; + /* 0x108 */ char pad108[0x60]; } unk_D_86002F58_004_000; // size = 0x168 typedef struct unk_D_86002F34_000_014_004 { @@ -166,10 +168,10 @@ typedef struct unk_D_86002F34_000 { /* 0x04 */ char pad04[0x2]; /* 0x06 */ s16 unk_06; /* 0x08 */ struct unk_D_86002F34_000* unk_08; - /* 0x0C */ struct unk_D_86002F34_000* unk_0C; + /* 0x0C */ struct unk_D_86002F34_00C* unk_0C; /* 0x10 */ s32 (*unk_10)(s32, struct unk_D_86002F34_000*); /* 0x14 */ unk_D_86002F34_000_014* unk_14; -} unk_D_86002F34_000; // size >= 0x18 +} unk_D_86002F34_000; // size = 0x18 typedef struct unk_D_86002F34_00C_018 { /* 0x00 */ Vp* vp; diff --git a/include/macros.h b/include/macros.h index 374b8593..c9f7a4e3 100644 --- a/include/macros.h +++ b/include/macros.h @@ -51,6 +51,8 @@ #define ABS(x) ((x) < 0 ? -(x) : (x)) #define ABS_ALT(x) ((x) >= 0 ? (x) : -(x)) +#define ABS_NORMALIZED(x) ((ABS_ALT((x)) < (0.000001f)) ? 0.0f : (x)) + #define FRAGMENT_ID(fragment) ((((u32)fragment##_TEXT_START & 0x0FF00000) >> 0x14) - 0x10) #define ASSET_ID(asset) (((u32)asset & 0x0F000000) >> 0x18) diff --git a/include/variables.h b/include/variables.h index 1234101f..4afe63b5 100644 --- a/include/variables.h +++ b/include/variables.h @@ -62,7 +62,7 @@ extern Gfx D_1002508[]; extern Gfx D_1002590[]; extern u8 D_2000000[]; extern u8 D_3000000[]; -extern u8 D_4000000[]; +extern u8 D_04000000[]; extern u8 D_4000008[]; extern u8 D_4000810[]; extern u8 D_4001018[]; @@ -78,6 +78,29 @@ extern u8 D_2028A20[]; extern u8 D_2028A60[]; extern u8 D_2028AA0[]; extern u32 D_B0000D10; +extern u8 D_400C800[]; +extern u8 D_400CA00[]; +extern u8 D_400CC00[]; +extern u8 D_400CE00[]; +extern u8 D_400CF00[]; +extern u8 D_400D100[]; +extern u8 D_400D200[]; +extern u8 D_04000000[]; +extern u8 D_04000800[]; +extern u8 D_04001000[]; +extern u8 D_04001800[]; +extern u8 D_04002000[]; +extern u8 D_04002800[]; +extern u8 D_04003000[]; +extern u8 D_04003800[]; +extern u8 D_04004000[]; +extern u8 D_04005000[]; +extern u8 D_04006000[]; +extern u8 D_04007000[]; +extern u8 D_04008000[]; +extern u8 D_04009000[]; +extern u8 D_0400A000[]; +extern u8 D_0400B000[]; extern u8 D_800818E0[0x20]; @@ -94,6 +117,7 @@ extern u8 D_86200000; extern u8 D_86800000; extern u8 D_86C00000; extern u8 D_87A00000; +extern u8 D_87000000[]; typedef struct unk_D_800A7440 { /* 0x00 */ s16 x1; diff --git a/linker_scripts/us/symbol_addrs.txt b/linker_scripts/us/symbol_addrs.txt index 315d8b6a..184d60f1 100644 --- a/linker_scripts/us/symbol_addrs.txt +++ b/linker_scripts/us/symbol_addrs.txt @@ -308,3 +308,27 @@ D_879060E0 = 0x879060E0; // size:0xC D_87906100 = 0x87906100; // size:0xC D_87906110 = 0x87906110; // size:0xC D_8140E628 = 0x8140E628; // size:0x90 +D_400C800 = 0x400C800; +D_400CA00 = 0x400CA00; +D_400CC00 = 0x400CC00; +D_400CE00 = 0x400CE00; +D_400CF00 = 0x400CF00; +D_400D100 = 0x400D100; +D_400D200 = 0x400D200; +D_86808498 = 0x86808498; // size:0x38 +D_04000000 = 0x04000000; +D_04000800 = 0x04000800; +D_04001000 = 0x04001000; +D_04001800 = 0x04001800; +D_04002000 = 0x04002000; +D_04002800 = 0x04002800; +D_04003000 = 0x04003000; +D_04003800 = 0x04003800; +D_04004000 = 0x04004000; +D_04005000 = 0x04005000; +D_04006000 = 0x04006000; +D_04007000 = 0x04007000; +D_04008000 = 0x04008000; +D_04009000 = 0x04009000; +D_0400A000 = 0x0400A000; +D_0400B000 = 0x0400B000; diff --git a/src/18480.c b/src/18480.c index 24535ad6..13f907b5 100644 --- a/src/18480.c +++ b/src/18480.c @@ -94,7 +94,7 @@ extern u8* D_800ABE00; #pragma GLOBAL_ASM("asm/us/nonmatchings/18480/func_80018AD0.s") -unk_D_86002F34* func_80018B70(MemoryBlock* arg0, void* arg1) { +void* func_80018B70(MemoryBlock* arg0, void* arg1) { extern func_D_8006F2B0 D_8006F2B0[]; D_800ABD34 = NULL; @@ -107,7 +107,7 @@ unk_D_86002F34* func_80018B70(MemoryBlock* arg0, void* arg1) { D_800ABD38[0] = 0; D_800ABD38[1] = 0; - while (D_800ABE00 != 0) { + while (D_800ABE00 != NULL) { D_8006F2B0[*D_800ABE00](); } diff --git a/src/18480.h b/src/18480.h index eb61e6f7..484f5422 100644 --- a/src/18480.h +++ b/src/18480.h @@ -4,7 +4,7 @@ #include "global.h" #include "src/memory.h" -unk_D_86002F34* func_80018B70(MemoryBlock*, void*); +void* func_80018B70(MemoryBlock*, void*); #endif // _18480_H_ diff --git a/src/fragments/14/fragment14.h b/src/fragments/14/fragment14.h new file mode 100644 index 00000000..362ce3e0 --- /dev/null +++ b/src/fragments/14/fragment14.h @@ -0,0 +1,183 @@ +#ifndef _FRAGMENT14_H_ +#define _FRAGMENT14_H_ + +#include "global.h" +#include "src/controller.h" + +typedef struct unk_D_868084D8_038 { + /* 0x000 */ s16 unk_000; + /* 0x002 */ s16 unk_002; + /* 0x004 */ char unk004[0x2]; + /* 0x006 */ s16 unk_006; + /* 0x008 */ struct unk_D_868084D8_038* unk_008; + /* 0x00C */ Vec3f unk_00C; + /* 0x018 */ char unk018[0x1B8]; + /* 0x1D0 */ Vec3f unk_1D0; +} unk_D_868084D8_038; // size >= 0x1DC + +typedef struct unk_D_868084D8_040 { + /* 0x00 */char unk00[0x1]; + /* 0x01 */u8 unk_01; + /* 0x02 */char unk02[0x1]; + /* 0x03 */u8 unk_03; +} unk_D_868084D8_040; // size >= 0x2 + +typedef struct unk_D_868084D8 { + /* 0x00 */ u16 unk_00; + /* 0x02 */ u16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x06 */ s16 unk_06; + /* 0x08 */ Color_RGBA8_u32 unk_08; + /* 0x0C */ s32 unk_0C; + /* 0x10 */ s32 unk_10; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ f32 unk_2C; + /* 0x30 */ f32 unk_30; + /* 0x34 */ f32 unk_34; + /* 0x38 */ unk_D_868084D8_038* unk_38; + /* 0x3C */ Gfx* unk_3C; + /* 0x40 */ unk_D_86002F34_alt9* unk_40; +} unk_D_868084D8; // size = 0x44 + +typedef struct unk_D_86807558_040 { + /* 0x00 */ s16 unk_00; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 unk_04; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ f32 unk_10; + /* 0x14 */ f32 unk_14; + /* 0x18 */ s16 unk_18; +} unk_D_86807558_040; // size >= 0x1C + +typedef struct unk_D_86807558_098 { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; +} unk_D_86807558_098; // size = 0x24 + +typedef struct unk_D_86807558 { + /* 0x000 */ s16 unk_000; + /* 0x002 */ u16 unk_002; + /* 0x004 */ s16 unk_004; + /* 0x004 */ s16 unk_006; + /* 0x008 */ s32 unk_008; + /* 0x00C */ s16 unk_00C; + /* 0x010 */ unk_D_868084D8* unk_010; + /* 0x014 */ s16 unk_014; + /* 0x016 */ u16 unk_016; + /* 0x018 */ s32 unk_018; + /* 0x01C */ s32 unk_01C; + /* 0x020 */ s32 unk_020; + /* 0x024 */ s32 unk_024; + /* 0x028 */ s16 unk_028; + /* 0x02A */ s16 unk_02A; + /* 0x02C */ s16 unk_02C[9]; + /* 0x03E */ s16 unk_03E; + /* 0x040 */ unk_D_86807558_040 unk_040; + /* 0x05C */ s32 unk_05C; + /* 0x060 */ s32 unk_060; + /* 0x064 */ Controller* unk_064; + /* 0x068 */ Vec3f unk_068; + /* 0x074 */ Vec3f unk_074; + /* 0x080 */ Vec3f unk_080; + /* 0x08C */ Vec3f unk_08C; + /* 0x098 */ unk_D_86807558_098 unk_098; + /* 0x0BC */ s16 unk_0BC; + /* 0x0BE */ s16 unk_0BE; + /* 0x0C0 */ s32 unk_0C0; + /* 0x0C4 */ s32 unk_0C4; + /* 0x0C8 */ f32 unk_0C8; + /* 0x0CC */ s16 unk_0CC; + /* 0x0D0 */ Color_RGBA8_u32 unk_0D0; + /* 0x0D4 */ s16 unk_0D4; + /* 0x0D8 */ f32 unk_0D8; + /* 0x0DC */ unk_D_868084D8* unk_0DC; + /* 0x0E0 */ s16 unk_0E0; + /* 0x0E2 */ s16 unk_0E2; + /* 0x0E4 */ unk_D_86002F58_004_000 unk_0E4; + /* 0x24C */ unk_D_86002F58_004_000 unk_24C; + /* 0x3B4 */ u32* unk_3B4; +} unk_D_86807558; // size = 0x3B8 + +typedef struct unk_D_86808498 { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ s16 unk_18; + /* 0x1A */ s16 unk_1A; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; +} unk_D_86808498; // size >= 0x38 + +typedef struct unk_D_86808808_018 { + /* 0x000 */ unk_D_86002F58_004_000_000 unk_000; + /* 0x018 */ char unk018[0xC]; + /* 0x024 */ Vec3f unk_024; + /* 0x030 */ Vec3f unk_030; +} unk_D_86808808_018; // size >= 0x3C + +typedef struct unk_D_86808808 { + /* 0x000 */ s16 unk_000; + /* 0x002 */ s16 unk_002; + /* 0x004 */ u16 unk_004; + /* 0x006 */ s16 unk_006; + /* 0x008 */ s32 unk_008; + /* 0x00C */ Vec3f unk_00C; + /* 0x018 */ unk_D_86808808_018 unk_018; + /* 0x054 */ char unk054[0x12C]; +} unk_D_86808808; // size = 0x180 + +typedef struct unk_D_86807180 { + /* 0x00 */ s32 unk_00; + /* 0x04 */ u8* unk_04; + /* 0x08 */ u8* unk_08; + /* 0x10 */ char* unk_0C; + /* 0x10 */ s16 unk_10; + /* 0x12 */ s16 unk_12; + /* 0x14 */ s32 unk_14; + /* 0x18 */ s16 unk_18; +} unk_D_86807180; // size = 0x1C + +extern s32 D_86807160[]; +extern unk_D_86807180 D_86807180[]; + +extern unk_D_86002F34* D_86807500; +extern s32 D_86807510; +extern unk_D_86807558 D_86807558[4]; + +extern unk_D_868084D8 D_868084D8[12]; + +void func_86800020(s32 arg0); +void func_86800070(void); +Gfx* func_868001A8(Gfx* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +void func_868004F4(void); +void func_868005A8(Color_RGB8* arg0, Color_RGB8* arg1, s32 arg2, s32 arg3, s32 arg4); +void func_8680091C(s32 arg0, s16 arg1, s16 arg2, f32 arg3); +void func_86800B38(void); +void func_86801644(void); +void func_86801700(void); +s32 func_86801840(void); +s32 func_86801884(void); +void func_86801CA8(void); +void func_86801D48(void); +void func_86801E2C(s32 arg0, UNUSED s32 arg1); + + +void func_86805108(u16, s32); +s32 func_868055D4(void); +void func_86805858(s32); +void func_86805974(void); +void func_86805BD4(void); +void func_86805CB4(void); + +f32 func_86805E94(unk_D_868084D8*, Vec3f*, Vec3f*); +void func_86806868(unk_D_868084D8*, s32, unk_D_86807558*); +s32 func_86806930(unk_D_868084D8*); +s16 func_86806950(s32); +void func_86806964(s32); +void func_86806A50(void); +void func_86806BF0(void); + +#endif // _FRAGMENT14_H_ diff --git a/src/fragments/14/fragment14_144300.c b/src/fragments/14/fragment14_144300.c index 7263a3e7..6d31db12 100644 --- a/src/fragments/14/fragment14_144300.c +++ b/src/fragments/14/fragment14_144300.c @@ -1,29 +1,766 @@ -#include "global.h" +#include "fragment14.h" +#include "src/12D80.h" +#include "src/18480.h" +#include "src/19840.h" +#include "src/1C720.h" +#include "src/1CF30.h" +#include "src/20330.h" +#include "src/20470.h" +#include "src/2E110.h" +#include "src/3FB0.h" +#include "src/490A0.h" +#include "src/49790.h" +#include "src/4BA90.h" +#include "src/4BDC0.h" +#include "src/4CBC0.h" +#include "src/50860.h" +#include "src/6A40.h" +#include "src/6BC0.h" +#include "src/controller.h" +#include "src/fragments/2/fragment2.h" +#include "src/fragments/3/fragment3.h" +#include "src/memory.h" +#include "src/stage_loader.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86800020.s") +typedef struct unk_D_86806E20 { + /* 0x00 */ u8* texture; + /* 0x02 */ s16 width; + /* 0x04 */ s16 height; +} unk_D_86806E20; // size = 0x8 -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86800070.s") +static u32 D_86806CD0[] = { + 0x0C00FFFF, 0x05000000, 0x0B00001E, 0x00000000, 0x014000F0, 0x0000000F, 0x00000000, 0x00000000, + 0x05000000, 0x0D000000, 0x05000000, 0x14000000, 0x002B0012, 0xFFFFFF32, 0x16FFFFFF, 0x0F000003, + 0x05000000, 0x1F00FFFF, 0x00000000, 0x00000000, 0xFFFF0000, 0x00640064, 0x00640000, 0x05000000, + 0x00000000, 0x87006D00, 0x06000000, 0x06000000, 0x05000000, 0x0A000000, 0x800AC840, 0x06000000, + 0x06000000, 0x06000000, 0x03000000, 0x87806398, 0x06000000, 0x01000000, +}; +static Controller** D_86806D68 = &gPlayer1Controller; +static Controller** D_86806D6C = &gPlayer2Controller; +static Controller** D_86806D70 = &gPlayer3Controller; +static Controller** D_86806D74 = &gPlayer4Controller; + +static s16 D_86806D78[] = { 0x1E, 0x1E, 0x108, 0x108 }; +static s16 D_86806D80[] = { 0xCC, 0x10, 0x10, 0xCC }; + +static unk_D_86806E20 D_86806D88 = { 0x400C800, 32, 8 }; +static unk_D_86806E20 D_86806D90 = { 0x400CA00, 32, 8 }; +static unk_D_86806E20 D_86806D98 = { 0x400CC00, 32, 8 }; +static unk_D_86806E20 D_86806DA0 = { 0x400CE00, 32, 4 }; +static unk_D_86806E20 D_86806DA8 = { 0x400CF00, 32, 8 }; +static unk_D_86806E20 D_86806DB0 = { 0x400D100, 32, 4 }; +static unk_D_86806E20 D_86806DB8 = { 0x400D200, 32, 4 }; +static unk_D_86806E20* D_86806DC0[] = { &D_86806D90, &D_86806D88, NULL }; +static unk_D_86806E20* D_86806DCC[] = { &D_86806DA0, &D_86806D98, &D_86806D88, NULL }; +static unk_D_86806E20* D_86806DDC[] = { &D_86806DA0, &D_86806DB0, &D_86806DA8, &D_86806D88, NULL }; +static unk_D_86806E20* D_86806DF0[] = { &D_86806DA0, &D_86806DB0, &D_86806DB8, &D_86806DA8, &D_86806D88, NULL }; +static unk_D_86806E20* D_86806E08[] = { + &D_86806DA0, &D_86806DB0, &D_86806DB8, &D_86806DB8, &D_86806DA8, &D_86806D88, +}; +static unk_D_86806E20** D_86806E20[] = { NULL, D_86806DC0, D_86806DCC, D_86806DDC, D_86806DF0, D_86806E08 }; +static unk_func_87801684 D_86806E38[] = { + { 0x0303ED80, 0xE }, { 0x0303F180, 2 }, { 0x0303F580, 6 }, { 0x0303F180, 2 }, { NULL, 0 }, +}; +static unk_func_87801684 D_86806E60[] = { + { 0x03040580, 0x12 }, { 0x03040980, 2 }, { 0x03040D80, 8 }, { 0x03040980, 2 }, { NULL, 0 }, +}; +static unk_func_87801684 D_86806E88[] = { + { 0x030397C0, 0xE }, { 0x03034E40, 2 }, { 0x03035A80, 2 }, { 0x03034E40, 2 }, { 0x030397C0, 2 }, { 0x0303D500, 2 }, + { 0x0303E140, 2 }, { 0x03038B80, 2 }, { 0x03037300, 2 }, { 0x03037F40, 2 }, { 0x03035A80, 2 }, { 0x0303BC80, 2 }, + { 0x0303B040, 2 }, { 0x0303A400, 2 }, { 0x030397C0, 2 }, { 0x030366C0, 2 }, { 0x03037300, 2 }, { 0x030366C0, 2 }, + { 0x030397C0, 2 }, { 0x0303A400, 2 }, { 0x0303B040, 2 }, { 0x0303A400, 2 }, { NULL, 0 }, +}; +static Color_RGB8 D_86806F40 = { 255, 255, 255 }; +static Color_RGB8 D_86806F44[] = { + { 0, 0, 0xFF }, + { 0, 0xFF, 0 }, + { 0xFF, 0, 0 }, + { 0xFF, 0xFF, 0 }, +}; +static Color_RGB8 D_86806F50[] = { + { 255, 0, 0 }, + { 0, 255, 0 }, + { 255, 255, 100 }, +}; +static Color_RGB8 D_86806F5C[] = { + { 0, 255, 0 }, + { 255, 255, 100 }, + { 255, 0, 0 }, +}; +static Color_RGB8 D_86806F68[] = { + { 0, 0, 255 }, + { 255, 0, 0 }, + { 255, 255, 100 }, + { 0, 0, 0 }, +}; +static s32 D_86806F74[] = { 0x50002, 0x50002, 0x50001, 0x50002, 0, 0, 0 }; + +unk_D_86002F34* D_86807500; +static unk_D_800AC870* D_86807504; +static u32 D_86807508; +static s32 D_8680750C; +s32 D_86807510; +static Controller D_86807518; +static u16 D_8680753C; +static s16 D_8680753E; +static s16 D_86807540; + +void func_86800020(s32 arg0) { + if (D_8680753E == 0) { + func_8004FC60(1, arg0); + func_8004FC60(2, arg0); + } else { + func_8004B094(arg0); + } +} + +void func_86800070(void) { + Controller* temp_v0; + + Cont_StartReadInputs(); + Cont_ReadInputs(); + func_8001F730(); + + bzero(&D_86807518, sizeof(Controller)); + + temp_v0 = *D_86806D68; + D_86807518.buttonDown |= temp_v0->buttonDown; + D_86807518.buttonPressed |= temp_v0->buttonPressed; + D_86807518.unkA |= temp_v0->unkA; + + temp_v0 = *D_86806D6C; + D_86807518.buttonDown |= temp_v0->buttonDown; + D_86807518.buttonPressed |= temp_v0->buttonPressed; + D_86807518.unkA |= temp_v0->unkA; + + temp_v0 = *D_86806D70; + D_86807518.buttonDown |= temp_v0->buttonDown; + D_86807518.buttonPressed |= temp_v0->buttonPressed; + D_86807518.unkA |= temp_v0->unkA; + + temp_v0 = *D_86806D74; + D_86807518.buttonDown |= temp_v0->buttonDown; + D_86807518.buttonPressed |= temp_v0->buttonPressed; + D_86807518.unkA |= temp_v0->unkA; + + if (1) {} +} + +#ifdef NON_MATCHING +Gfx* func_868001A8(Gfx* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + s32 sp34; + unk_D_86806E20** var_a3; + unk_D_86806E20* ptr; + s32 var_s0; + s32 var_v0; + s32 var_v1; + + var_s0 = (arg1 != 0) ? arg2 + 6 : arg2; + var_v1 = arg3 + 24; + + while (arg4 > 0) { + sp34 = var_v1; + + if (arg4 < 5) { + var_a3 = D_86806E20[arg4]; + arg4 = 0; + } else { + var_a3 = &D_86806E08[0]; + arg4 -= 5; + } + + var_v0 = var_s0; + while (*var_a3 != NULL) { + ptr = *var_a3; + sp34 -= (ptr->height * 3) / 4; + + gDPLoadTextureBlock(arg0++, ptr->texture, G_IM_FMT_RGBA, G_IM_SIZ_16b, ptr->width, ptr->height, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + gSPTextureRectangle(arg0++, var_v0 << 2, sp34 << 2, (((ptr->width * 9) / 16) + var_v0) << 2, + (sp34 + ((ptr->height * 3) / 4)) << 2, G_TX_RENDERTILE, 0, 0, 0x071C, 0x0555); + var_a3++; + } + + if (arg1 == 0) { + var_s0 += 20; + } else { + var_s0 -= 20; + } + } + + return arg0; +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_868001A8.s") +#endif + +void func_868004F4(void) { + s32 i; + Gfx* var_s4 = gDisplayListHead; + unk_D_86807558* ptr; + + for (i = 0, ptr = D_86807558; i < 4; i++, ptr++) { + var_s4 = func_868001A8(var_s4, i / 2, D_86806D78[i], D_86806D80[i], ptr->unk_02A); + } + + gDisplayListHead = var_s4; +} + +void func_868005A8(Color_RGB8* arg0, Color_RGB8* arg1, s32 arg2, s32 arg3, s32 arg4) { + Color_RGB8* var_v0; + Color_RGB8* var_v1; + f32 temp_fv0; + f32 var_ft5; + s32 temp_a0; + s32 tmp; + + if (arg2 >= 2) { + tmp = D_86807508 % arg3; + temp_fv0 = tmp; + temp_fv0 /= arg3; + + temp_a0 = (D_86807508 % (arg3 * arg2)) / arg3; + + if (arg4 == 0) { + var_v0 = &arg1[temp_a0]; + var_v1 = &arg1[(temp_a0 + 1) % arg2]; + } else { + temp_a0 = (arg2 - temp_a0); + temp_a0--; + + var_v0 = &arg1[temp_a0]; + temp_a0--; + + if (temp_a0 < 0) { + temp_a0 += arg2; + } + var_v1 = &arg1[temp_a0]; + } + + arg0->r = var_v0->r + ((var_v1->r - var_v0->r) * temp_fv0); + arg0->g = var_v0->g + ((var_v1->g - var_v0->g) * temp_fv0); + arg0->b = var_v0->b + ((var_v1->b - var_v0->b) * temp_fv0); + } +} + +void func_8680091C(s32 arg0, s16 arg1, s16 arg2, f32 arg3) { + s16 sp36; + s16 sp34; + s16 sp32; + + if ((arg0 > 0) && (arg0 < 9) && (arg3 != 0.0f)) { + sp36 = ROUND_MAX(1024.0f / arg3); + sp34 = ROUND_MAX(32.0f * arg3); + sp32 = ROUND_MAX(32.0f * arg3); + + gDPLoadTextureBlock(gDisplayListHead++, D_86807180[arg0].unk_08, G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, + G_TX_NOLOD, G_TX_NOLOD); + + func_8001C330(arg1, arg2, sp34, sp32, 0, 0, sp36, sp36, 0); + } +} + +#ifdef NON_MATCHING +void func_86800B38(void) { + s32 pad1; + s32 pad2; + s32 i; + Color_RGB8 spD8[4]; + Color_RGB8 spD0[2]; + Color_RGB8 spC4[4]; + Color_RGB8 spB8[4]; + Color_RGB8 spB4 = D_86806F40; + s32 var_v0; + + gSPDisplayList(gDisplayListHead++, D_8006F518); + + if (D_8680753C & 2) { + func_868004F4(); + for (i = 0; i < 4; i++) { + if ((i == 0) || (i == 3)) { + var_v0 = -0x18; + } else { + var_v0 = 0x1C; + } + + if (!(D_86807558[i].unk_002 & 4)) { + func_87801644(i, D_86806D78[i], D_86806D80[i] + var_v0, 0.75f); + } else { + func_87801644(-1 - i, D_86806D78[i], D_86806D80[i] + var_v0, 0.75f); + } + } + } + + if (D_8680753E != 0) { + func_878021B4(0x1E, 0x17); + } + + gSPDisplayList(gDisplayListHead++, D_8006F630); + + if (D_8680753C & 1) { + func_80020460(0x18, 0x16, 0x110, 0x90, 0x15); + func_80020460(0x18, 0xA5, 0x110, 0x36, 0x14B); + func_8780118C(0x17, 0x16, 2, 0x90); + func_8780118C(0x127, 0x16, 2, 0x90); + } + + func_8001F3F4(); + func_8001F470(); + + if (D_8680753C & 1) { + s32 spA4; + s32 spA0; + s32 sp9C; + s32 sp98; + s32 sp94; + + func_8001EBE0(2, 0); + func_8001F324(0xFF, 0xFF, 0xFF, 0xFF); + func_8001F36C(0xF9, 0xF4, 0, 0xFF); + func_8001F1E8(0xA0 - (func_878013D4(D_86807504, func_8002D7C0(NULL, 0, D_87806330, 0xC)) / 2), 0x20, + func_8002D7C0(NULL, 0, D_87806330, 0xC)); + func_8001F324(0xFF, 0xFF, 0xFF, 0xFF); + func_8001F36C(0xFF, 0xFF, 0xFF, 0xFF); + func_8001F3B4(0xC); + func_8001F1E8(0x28, 0x34, func_8002D7C0(NULL, 0, D_87806330, 0x32)); + func_8001F1E8(0x28, 0x4C, func_8002D7C0(NULL, 0, D_87806330, 0x33)); + func_8001F1E8(0x78, 0xB2, func_8002D7C0(NULL, 0, D_87806330, 0x5C)); + func_8001F1E8(0xDA, 0xB2, func_8002D7C0(NULL, 0, D_87806330, 0x5C)); + func_8001F1E8(0x86, 0xC8, func_8002D7C0(NULL, 0, D_87806330, 0x5C)); + func_8001F324(0xE6, 0xD2, 0xFF, 0xFF); + func_8001F36C(0x82, 0x50, 0xD2, 0xFF); + func_8001F1E8(0x8C, 0xB2, func_8002D7C0(NULL, 0, D_87806330, 0x34)); + func_8001F324(0xC8, 0xC8, 0xFF, 0xFF); + func_8001F36C(0x50, 0x50, 0xFF, 0xFF); + func_8001F1E8(0xEE, 0xB2, func_8002D7C0(NULL, 0, D_87806330, 0x35)); + func_8001F324(0xFF, 0xFF, 0xFF, 0xFF); + func_8001F36C(0xFF, 0x80, 0x80, 0xFF); + func_8001F1E8(0x9A, 0xC8, func_8002D7C0(NULL, 0, D_87806330, 0x14)); + func_87801290(&spA4, &spA0, func_8002D7C0(NULL, 0, D_87806330, 0x32), func_8002D7C0(NULL, 0, D_87806330, 0x5F), + 0xC); + func_8001F324(0xC8, 0xC8, 0xFF, 0xFF); + func_8001F36C(0x50, 0x50, 0xFF, 0xFF); + func_8001F1E8(spA4 + 0x28, spA0 + 0x34, func_8002D7C0(NULL, 0, D_87806330, 0x5F)); + func_8001EBE0(1, 0); + func_8001F324(0xFF, 0xFF, 0xFF, 0xFF); + func_8001F36C(0xFF, 0xFF, 0xFF, 0xFF); + + for (i = 0; i < 8; i++) { + pad1 = i % 4; + if (pad1) {} + + sp9C = func_8001F5B0(0, 0, func_8002D7C0(NULL, 0, D_87806330, 0x36)); + sp98 = func_8001F5B0(0, 0, func_8002D7C0(NULL, 0, D_87806330, i + 0x36)); + + func_8001F1E8((((pad1 * 60) + sp9C) - sp98) + 0x46, ((i / 4) << 5) + 0x72, + func_8002D7C0(NULL, 0, D_87806330, i + 0x36)); + } + } + + switch (D_8680750C) { + s32 var_s4; + s32 var_s7; + + case 4: + break; + + case 2: + case 3: + if (D_8680753E == 0) { + func_8001EBE0(4, 0); + for (i = 0; i < 4; i++) { + f32 v; + + if ((D_86807558[i].unk_040.unk_00 != 0) && (D_86807558[i].unk_040.unk_00 != 1)) { + if ((i / 2) != 0) { + var_s7 = -0x14; + } else { + var_s7 = 0x1E; + } + + if ((i == 0) || (i == 3)) { + var_s4 = -0x16; + } else { + var_s4 = 0x1E; + } + + if (D_86807558[i].unk_03E < 5) { + func_8001F324(0xFF, 0xFF, 0xFF, D_86807558[i].unk_040.unk_18); + func_8001F36C(D_86806F44[i].r, D_86806F44[i].g, D_86806F44[i].b, + D_86807558[i].unk_040.unk_18); + } else { + func_868005A8(spD8, D_86806F68, 4, 4, 0); + func_8001F324(spD8[0].r, spD8[0].g, spD8[0].b, D_86807558[i].unk_040.unk_18); + func_8001F36C(spD8[0].r, spD8[0].g, spD8[0].b, D_86807558[i].unk_040.unk_18); + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_868004F4.s") + v = D_86807558[i].unk_040.unk_08; + func_8001F1E8(D_86806D78[i] + var_s7 + (s16)v, + (D_86806D80[i] + var_s4) - (s16)D_86807558[i].unk_040.unk_0C, "x%d", + D_86807558[i].unk_03E); + } + } + } + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_868005A8.s") + case 5: + case 6: + func_8001EBE0(4, 0); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_8680091C.s") + for (i = 0; i < 4; i++) { + char sp78[16]; + spD0[0] = spB4; + spD0[1] = D_86806F44[i]; + + func_868005A8(&spB8[i], spD0, 2, 0x1E, 0); + func_868005A8(&spC4[i], spD0, 2, 0x1E, 1); + + if ((i / 2) != 0) { + var_s7 = -0x32; + } else { + var_s7 = 0x1C; + } + + if ((i == 0) || (i == 3)) { + var_s4 = -0x16; + } else { + var_s4 = 0x1E; + } + + if ((D_86807558[i].unk_028 == 1) && (D_86807558[i].unk_01C == D_86807558[i].unk_018) && + (D_86807558[i].unk_018 > 0)) { + func_868005A8(&spD8, &D_86806F50, 3, 4, 0); + func_8001F324(spD8[0].r, spD8[0].g, spD8[0].b, 0xFF); + func_868005A8(&spD8, &D_86806F5C, 3, 4, 0); + func_8001F36C(spD8[0].r, spD8[0].g, spD8[0].b, 0xFF); + } else { + func_8001F324(spB8[i].r, spB8[i].g, spB8[i].b, 0xFF); + func_8001F36C(spB8[i + 4].r, spB8[i + 4].g, spB8[i + 4].b, 0xFF); + } + + func_8002D600(6, D_86807558[i].unk_01C); + func_8001F1E8(D_86806D78[i] + var_s7, D_86806D80[i] + var_s4, + func_8002D7C0(&sp78, 0x20, D_87806330, 0x5E)); + } + break; + } + + func_8001F4C4(); + func_8001F444(); + + if (D_8680753C & 1) { + gSPDisplayList(gDisplayListHead++, D_8006F518); + + for (i = 0; i < 8; i++) { + if ((i % 4) >= 2) { + var_v0 = 0x3C; + } else { + var_v0 = 0x40; + } + + pad1 = i % 4; + func_8680091C(D_86807160[i], (var_v0 * pad1) + 0x28, ((i / 4) << 5) + 0x68, 0.75f); + } + + func_87801D5C(0, 0x5A, 0xA8, D_86806E88); + func_87801684(0xC8, 0xB0, D_86806E38); + func_87801824(0x74, 0xC6, D_86806E60); + func_87801F48(0, 0x19, 0xA6); + } +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86800B38.s") +#endif + +void func_86801644(void) { + func_800079C4(); + func_800067E4(&gDisplayListHead, 0, 0, 0x140, 0xF0); + + if (D_8780FC94 == 0) { + func_80015348(); + } + + func_80015094(D_86807500); + func_87901C98(); + + if (D_8780FC98 == 0) { + func_86800B38(); + } + + if (D_8680753E == 0) { + func_87804FD4(); + } + + if (D_8680753E != 0) { + func_8780005C(); + } + + func_80007778(); +} + +void func_86801700(void) { + func_878001E8(0x80); + + if (func_80007604() == 0) { + if (D_8680753E != 0) { + D_8680750C = 1; + D_86807510 = 0x1C2; + D_86807540 = 0xF; + } else if (gPlayer1Controller->buttonPressed & 0x1000) { + D_8680750C = 1; + D_8680753C &= ~1; + D_8680753C |= 2; + D_86807510 = 0x708; + D_86807540 = 0xF; + func_8004B9C4(0x3C); + func_86805108(0xF, 1); + } else if ((D_8780FA2A == 0) && (gPlayer1Controller->buttonPressed & 0x4000)) { + func_80048B90(3); + D_8680750C = 7; + D_86807540 = 0x1E; + func_80006CB4(D_86807540); + func_86800020(D_86807540 / 2); + func_87802EB8(2); + } + } +} + +s32 func_86801840(void) { + s32 var_v1 = 0; + + if (D_8680753E == 0) { + if (D_86807510 <= 0) { + var_v1 = 1; + } + } else if (D_86807510 <= 0) { + var_v1 = 1; + } + return var_v1; +} + +#ifdef NON_MATCHING +s32 func_86801884(void) { + s32 sp1C; + s32 sp18; + unk_D_86807558* ptr; + s32 i; + s32 temp_v0; + s32 var_a0; + + sp1C = 0; + + sp18 = 0; + if ((D_8680753E != 0) && (gPlayer1Controller->buttonPressed != 0)) { + if (func_80007604() == 0) { + sp18 = 1; + } + } + + if (((D_8780FC92 != 0) || (sp18 != 0)) && (D_8680750C != 7)) { + D_8680750C = 7; + D_86807540 = 0x1E; + func_80006CB4(D_86807540); + func_86800020(D_86807540 / 2); + } + + switch (D_8680750C) { + case 0: + func_86801700(); + break; + + case 1: + D_86807540 -= 1; + if (D_86807540 <= 0) { + D_8680750C = 2; + func_8780295C(1); + } + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86801644.s") + case 2: + temp_v0 = func_87802974(); + if ((temp_v0 >= 0) && (temp_v0 < 4)) { + func_8004D9B0(D_86806F74[temp_v0], 0, 0); + } else if (temp_v0 == -2) { + D_8680750C = 3; + func_86805108(0xF, 3); + func_86806964(1); + } + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86801700.s") + case 3: + if (D_8780FC94 == 0) { + D_86807510--; + if (((D_86807510 % 30) == 0) && (D_8680753E == 0)) { + if (((D_86807510 / 30) > 0) && ((D_86807510 / 30) < 6)) { + func_8004D9B0(0x50002, 0, 0); + } + } + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86801840.s") + if (func_86801840() != 0) { + if (D_8680753E == 0) { + D_8680750C = 4; + D_86807540 = 0x1E; + func_86805108(0xF, 2); + func_86806964(2); + func_8004B9C4(0xA); + func_8004D9B0(0x50004, 0, 0); + } else { + D_8680750C = 7; + D_86807540 = 0x1E; + func_80006CB4(D_86807540); + func_86800020(D_86807540 / 2); + func_87802EB8(2); + } + } + break; + case 4: + if (func_868055D4() != 0) { + D_86807540--; + } + + if (D_86807540 <= 0) { + D_8680750C = 5; + func_86805108(0xF, 4); + } + break; + + case 5: + var_a0 = 1; + ptr = &D_86807558[0]; + + for (i = 0; i < 4; i++, ptr++) { + if (ptr->unk_018 != ptr->unk_01C) { + var_a0 = 0; + } + } + + if ((var_a0 != 0) && (D_8780FC94 == 0)) { + D_8680750C = 6; + func_86805108(0xF, 5); + func_87802EB8(1); + } + break; + + case 6: + if (D_8780FC96 != 0) { + D_8680750C = 7; + D_86807540 = 0x1E; + func_80006CB4(D_86807540); + func_86800020(D_86807540 / 2); + } + break; + + case 7: + if (D_86807540 > 0) { + D_86807540--; + } + + if ((D_86807540 <= 0) && (func_800484E0() == 0)) { + sp1C = 1; + func_8004B154(); + } + break; + } + + return sp1C; +} +#else #pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86801884.s") +#endif + +void func_86801CA8(void) { + s32 var_s0; + + func_800077B4(5); + func_80006C6C(0x10); + D_86807508 = 0; + + var_s0 = 1; + while (var_s0 != 0) { + func_86800070(); + func_878025D0(); + func_86805CB4(); + func_86806BF0(); + func_86805974(); + func_87901C20(); + func_86801644(); + + if (func_86801884() != 0) { + var_s0 = 0; + } + + D_86807508++; + } +} + +void func_86801D48(void) { + UNUSED s32 pad; + MemoryBlock* sp18; + + sp18 = func_80002D10(main_pool_get_available(), 0); + D_86807500 = (unk_D_86002F34_000*)func_80018B70(sp18, &D_86806CD0); + + func_80002D60(sp18); + func_8001BB20(); + func_8001987C(); + func_87802528(); + func_86806A50(); + + if (D_8680753E != 0) { + func_86805858(1); + } else { + func_86805858(0); + } + + func_86805BD4(); + func_87901620(); + func_878029C0(); + + D_8680750C = 0; + if (D_8680753E == 0) { + D_8680753C |= 1; + } + + func_86805108(0xF, 2); +} + +void func_86801E2C(s32 arg0, UNUSED s32 arg1) { + unk_func_80007444* sp24; + + if (arg0 == 1) { + D_8680753E = 1; + func_878010C8(9); + } else { + D_8680753E = 0; + } + + main_pool_push_state('MINI'); + + func_80005E40(0x18000, 0); + sp24 = func_80007444(0, 1, 3, 1, 2, 1); + D_86807504 = func_8001E94C(0x17, 0); + + ASSET_LOAD(D_1000000, common_menu1_ui, 0); + ASSET_LOAD(D_04000000, sushi_go_round_sprites, 0); + + FRAGMENT_LOAD(fragment31); + func_80004454((((u32)D_87000000 & 0x0FF00000) >> 0x14) - 0x10, sushi_go_round_ROM_START, order_select_ui_ROM_START); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86801CA8.s") + func_86801D48(); + func_80007678(sp24); + func_86801CA8(); + func_800076C0(); + func_8001E9CC(); + func_80005EAC(); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86801D48.s") + main_pool_pop_state('MINI'); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_144300/func_86801E2C.s") + func_87803118(); +} diff --git a/src/fragments/14/fragment14_1462A0.c b/src/fragments/14/fragment14_1462A0.c index 8b3a128f..0e65dc01 100644 --- a/src/fragments/14/fragment14_1462A0.c +++ b/src/fragments/14/fragment14_1462A0.c @@ -1,83 +1,1773 @@ -#include "global.h" +#include "fragment14.h" +#include "src/12D80.h" +#include "src/17300.h" +#include "src/18480.h" +#include "src/19840.h" +#include "src/1C720.h" +#include "src/4CBC0.h" +#include "src/F420.h" +#include "src/fragments/2/fragment2.h" +#include "src/fragments/3/fragment3.h" +#include "src/fragments/34/fragment34.h" +#include "src/memmap.h" +#include "src/memory.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86801FC0.s") +static f32 D_86806F90[] = { 10.0f, 30.0f, 10.0f }; +static f32 D_86806F9C = 0.8f; +static f32 D_86806FA0 = 0.2f; +static f32 D_86806FA4 = 0.2f; +static f32 D_86806FA8 = -5.0f; +static f32 D_86806FAC = 0.9f; +static f32 D_86806FB0 = 20.0f; +static f32 D_86806FB4 = 20.0f; +static f32 D_86806FB8 = 130.0f; +static f32 D_86806FBC = 30.0f; +static f32 D_86806FC0 = 20.0f; +static f32 D_86806FC4 = 14681.355f; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802084.s") +static char D_86806FC8[] = " Mie"; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802204.s") +static Vtx D_86806FD0[] = { + VTX(-18, 26, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(-18, 0, 0, 0, 832, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(18, 0, 0, 1152, 832, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(18, 26, 0, 1152, 0, 0xFF, 0xFF, 0xFF, 0xFF), +}; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_8680262C.s") +static Gfx D_86807010[] = { + gsSPSetGeometryMode(G_CULL_BACK), + gsDPSetCombineLERP(TEXEL0, 0, ENVIRONMENT, 0, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED), + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsSPVertex(D_86806FD0, 4, 0), + gsDPLoadTextureBlock(0x0F000000, G_IM_FMT_RGBA, G_IM_SIZ_32b, 36, 26, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD), + gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0), + gsSPEndDisplayList(), +}; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868026B8.s") +static u32 D_86807078[] = { + 0x17000000, 0x00000000, 0x00000000, 0x00000000, 0x86806FD0, 0x05000000, 0x22040000, + 0x00000000, 0x08000000, 0x86802084, 0x00000000, 0x06000000, 0x01000000, +}; +static Controller** D_868070AC[] = { + &gPlayer1Controller, + &gPlayer2Controller, + &gPlayer3Controller, + &gPlayer4Controller, +}; +static s32 D_868070BC[4][4] = { + { + 0x00000002, + 0x00000001, + 0x00000001, + 0x00000002, + }, + { + 0x00000003, + 0x00000002, + 0x00000001, + 0x00000002, + }, + { + 0x00000003, + 0x00000002, + 0x00000002, + 0x00000003, + }, + { + 0x00000003, + 0x00000003, + 0x00000002, + 0x00000003, + }, +}; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868026E0.s") +static unk_D_86002F30* D_86807550; +unk_D_86807558 D_86807558[4]; +s32 D_86808438[4]; +static s32 D_86808448; +static Controller D_86808450; +static unk_D_86002F58_004_000_004* D_86808474; +static s16 D_86808478; +static s16 D_8680847A; +static s16 D_8680847C; +static s16 D_8680847E; +static s16 D_86808480; +static s32 pad_D_86808488[2]; +static unk_D_86002F34_00C* D_86808490; +unk_D_86808498 D_86808498; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802728.s") +void func_86801FC0(unk_D_86807558* arg0) { + unk_D_86002F58_004_000* ptr = &arg0->unk_24C; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802750.s") + if (arg0->unk_0DC != 0) { + ptr->unk_030.x = (SINS(arg0->unk_0E2 + 0x0000) * 0.3f) + 1.0f; + ptr->unk_030.y = (SINS(arg0->unk_0E2 + 0x3200) * 0.3f) + 1.0f; + } else { + ptr->unk_030.y = 1.0f; + ptr->unk_030.x = 1.0f; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802BE4.s") + ptr->unk_024 = arg0->unk_0E4.unk_0FC; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802C6C.s") + if (D_8780FC94 == 0) { + arg0->unk_0E2 += 0x1800; + } +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802D28.s") +void func_86802084(s32 arg0, UNUSED s32 arg1) { + UNUSED s32 pad; + s32 idx; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802E18.s") + switch (arg0) { + case 2: + idx = D_8006F09C->unk_000.unk_14; + func_86801FC0(&D_86807558[idx]); + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86802FB0.s") + case 5: + idx = D_8006F09C->unk_000.unk_14; + gSPSegment(gDisplayListHead++, 0x0F, Memmap_GetSegmentVaddr(D_86807558[idx].unk_3B4)); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86803038.s") + gDPPipeSync(gDisplayListHead++); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86803078.s") + gDPSetRenderMode(gDisplayListHead++, + AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL | G_RM_PASS, + AA_EN | Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | CVG_X_ALPHA | ALPHA_CVG_SEL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)); + gDPSetEnvColor(gDisplayListHead++, D_8006F09C->unk_03C.r, D_8006F09C->unk_03C.g, D_8006F09C->unk_03C.b, + D_8006F09C->unk_01D); + gSPDisplayList(gDisplayListHead++, D_86807010); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868031A8.s") + func_8001554C(); + func_80015684(); + break; + } +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86803374.s") +s32 func_86802204(unk_D_86807558_098* arg0) { + f32 temp_fs0; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868035FC.s") + arg0->unk_00.x = ABS_NORMALIZED(arg0->unk_00.x); + arg0->unk_00.y = ABS_NORMALIZED(arg0->unk_00.y); + arg0->unk_00.z = ABS_NORMALIZED(arg0->unk_00.z); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86803760.s") + arg0->unk_0C.x = ABS_NORMALIZED(arg0->unk_0C.x); + arg0->unk_0C.y = ABS_NORMALIZED(arg0->unk_0C.y); + arg0->unk_0C.z = ABS_NORMALIZED(arg0->unk_0C.z); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868038A8.s") + temp_fs0 = SQ(arg0->unk_00.x) + SQ(arg0->unk_00.y) + SQ(arg0->unk_00.z); + if (temp_fs0 == 0.0f) { + return -1; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86803BC4.s") + temp_fs0 = 1.0f / sqrtf(temp_fs0); + arg0->unk_00.x *= temp_fs0; + arg0->unk_00.y *= temp_fs0; + arg0->unk_00.z *= temp_fs0; + arg0->unk_18.x = (arg0->unk_0C.y * arg0->unk_00.z) - (arg0->unk_0C.z * arg0->unk_00.y); + arg0->unk_18.y = (arg0->unk_0C.z * arg0->unk_00.x) - (arg0->unk_0C.x * arg0->unk_00.z); + arg0->unk_18.z = (arg0->unk_0C.x * arg0->unk_00.y) - (arg0->unk_0C.y * arg0->unk_00.x); + + temp_fs0 = SQ(arg0->unk_18.x) + SQ(arg0->unk_18.y) + SQ(arg0->unk_18.z); + if (temp_fs0 == 0.0f) { + return -1; + } + + temp_fs0 = 1.0f / sqrtf(temp_fs0); + arg0->unk_18.x *= temp_fs0; + arg0->unk_18.y *= temp_fs0; + arg0->unk_18.z *= temp_fs0; + + arg0->unk_18.x = ABS_NORMALIZED(arg0->unk_18.x); + arg0->unk_18.y = ABS_NORMALIZED(arg0->unk_18.y); + arg0->unk_18.z = ABS_NORMALIZED(arg0->unk_18.z); + + arg0->unk_0C.x = (arg0->unk_00.y * arg0->unk_18.z) - (arg0->unk_00.z * arg0->unk_18.y); + arg0->unk_0C.y = (arg0->unk_00.z * arg0->unk_18.x) - (arg0->unk_00.x * arg0->unk_18.z); + arg0->unk_0C.z = (arg0->unk_00.x * arg0->unk_18.y) - (arg0->unk_00.y * arg0->unk_18.x); + + return 0; +} + +s16 func_8680262C(unk_D_86002F58_004_000* arg0, s16 arg1) { + s32 i; + s16 sp2A; + + if (func_80017514(arg0) != 0) { + return arg1; + } + + sp2A = -1; + + for (i = 0; i < arg1; i++) { + if (func_80017484(arg0, i) != 0) { + sp2A = i; + break; + } + } + + return sp2A; +} + +s16 func_868026B8(s16 arg0) { + s16 ret; + + if (arg0 < 0x32) { + ret = 2; + } else { + ret = 1; + } + return ret; +} + +f32 func_868026E0(s16 arg0) { + f32 var_fv1 = (2.0f * arg0) / 100.0f; + + if (var_fv1 < 0.5f) { + var_fv1 = 0.5f; + } + return var_fv1; +} + +void func_86802728(unk_D_86807558_040* arg0) { + arg0->unk_00 = 0; + arg0->unk_02 = 0; + arg0->unk_18 = 0xFF; + arg0->unk_0C = 0.0f; + arg0->unk_08 = 0.0f; + arg0->unk_14 = 0.0f; + arg0->unk_10 = 0.0f; +} + +void func_86802750(unk_D_86807558* arg0, s32 arg1, s32 arg2) { + s32 i; + unk_D_86002F58_004_000* sp24; + s16 angle; + f32 sqrt; + + arg0->unk_000 = arg1; + arg0->unk_002 = 0; + + if (D_8780FA30[arg0->unk_000] == 1) { + arg0->unk_002 |= 4; + } + + if (arg2 != 0) { + arg0->unk_002 |= 0x10; + } + + arg0->unk_004 = 0x32; + arg0->unk_006 = 0; + + if (arg0->unk_002 & 4) { + arg0->unk_008 = D_868070BC[D_8780FA38][(D_8680847C + D_8680847A) % D_8680847E]; + arg0->unk_00C = D_8680847A; + if (arg0->unk_00C == 0) { + D_86808478 = arg0->unk_000; + } + + D_8680847A++; + + if ((arg2 != 0) && (func_878001E8(4) == 0) && (D_86808480 <= 0)) { + arg0->unk_008 = 4; + D_86808480++; + } + } else { + arg0->unk_008 = 0; + arg0->unk_00C = 0x64; + } + + arg0->unk_010 = 0; + arg0->unk_014 = 0; + arg0->unk_016 = 0; + + if (arg0->unk_002 & 4) { + arg0->unk_016 |= 1; + if ((arg0->unk_008 == 4) || (D_8780FA38 == 0)) { + arg0->unk_016 &= ~1; + } + + if (D_8780FA38 >= 2) { + arg0->unk_016 |= 2; + } + } + + arg0->unk_018 = 0; + arg0->unk_01C = 0; + arg0->unk_020 = 0; + arg0->unk_024 = 0; + arg0->unk_028 = 0; + arg0->unk_02A = 0; + + for (i = 0; i < 9; i++) { + arg0->unk_02C[i] = 0; + } + + arg0->unk_05C = 0; + arg0->unk_03E = 1; + + func_86802728(&arg0->unk_040); + arg0->unk_060 = 0; + arg0->unk_064 = *D_868070AC[arg0->unk_000]; + + angle = 0xE000 - (arg0->unk_000 << 0xE); + + arg0->unk_068.x = SINS(angle) * D_86806FB8; + arg0->unk_068.y = 0.0f; + arg0->unk_068.z = COSS(angle) * D_86806FB8; + + arg0->unk_074.x = 0.0f; + arg0->unk_074.y = 0.0f; + arg0->unk_074.z = 0.0f; + + arg0->unk_080.x = 0.0f; + arg0->unk_080.y = 0.0f; + arg0->unk_080.z = 0.0f; + + arg0->unk_08C.x = 0.0f; + arg0->unk_08C.y = 0.0f; + arg0->unk_08C.z = 0.0f; + + arg0->unk_098.unk_00.x = arg0->unk_068.x; + arg0->unk_098.unk_00.y = 0.0f; + arg0->unk_098.unk_00.z = arg0->unk_068.z; + + sqrt = sqrtf(SQ(arg0->unk_098.unk_00.x) + SQ(arg0->unk_098.unk_00.z)); + arg0->unk_098.unk_00.x *= 1.0f / sqrt; + arg0->unk_098.unk_00.z *= 1.0f / sqrt; + arg0->unk_098.unk_0C.x = 0.0f; + arg0->unk_098.unk_0C.y = 1.0f; + arg0->unk_098.unk_0C.z = 0.0f; + + func_86802204(&arg0->unk_098); + + arg0->unk_0BC = 0; + arg0->unk_0BE = func_878001E8(0x5B) + 0x1E; + arg0->unk_0C0 = 0; + arg0->unk_0C4 = 0; + arg0->unk_0CC = 0; + arg0->unk_0D0.rgba = -0x100; + arg0->unk_0C8 = 1.0f; + arg0->unk_0D4 = func_868026B8(arg0->unk_004); + arg0->unk_0D8 = func_868026E0(arg0->unk_004); + arg0->unk_0DC = 0; + arg0->unk_0E0 = 0; + arg0->unk_0E2 = 0; + + sp24 = &arg0->unk_0E4; + func_8001BB58(sp24); + func_8001BB58(&arg0->unk_24C); + + arg0->unk_24C.unk_000.unk_14 = arg0->unk_000; + + func_8001BC34(sp24, 0, 0xA0, D_86807550->unk_08->unk_00[0]); + func_8001BD04(sp24, arg0->unk_0C0); + + sp24->unk_040.unk_08 = func_878001E8(0x1E) << 0x10; + + func_8001BC34(&arg0->unk_24C, 0, 0, D_86808474); + + arg0->unk_24C.unk_000.unk_01 |= 1; + arg0->unk_24C.unk_000.unk_02 |= 8; + + if (arg2 != 0) { + arg0->unk_3B4 = D_8780633C[arg0->unk_000]; + } else if (arg0->unk_002 & 4) { + arg0->unk_3B4 = D_8780634C[arg0->unk_000]; + } else { + arg0->unk_3B4 = D_8780633C[arg0->unk_000]; + } +} + +f32 func_86802BE4(s16 arg0) { + f32 temp_fv0; + s16 var_v1; + s32 var_v0 = 0; + + if (arg0 < 0) { + var_v0 = 1; + arg0 *= -1; + } + + if (arg0 < 0xA) { + var_v1 = 0xA; + } else { + var_v1 = arg0; + } + + if (var_v1 > 0x4A) { + var_v1 = 0x4A; + } + + var_v1 -= 10; + temp_fv0 = var_v1; + temp_fv0 /= 64; + + if (var_v0 != 0) { + temp_fv0 = 0.0f - temp_fv0; + } + return temp_fv0; +} + +s32 func_86802C6C(unk_D_86807558* arg0) { + s32 sp1C = 0; + f32 temp_fa0 = SQ(arg0->unk_068.x) + SQ(arg0->unk_068.z); + + if (SQ(D_86806FB8) < temp_fa0) { + temp_fa0 = D_86806FB8 / sqrtf(temp_fa0); + + arg0->unk_074.x = 0.0f; + arg0->unk_074.z = 0.0f; + + arg0->unk_068.x *= temp_fa0; + arg0->unk_068.z *= temp_fa0; + } + + if (arg0->unk_068.y <= 0.0f) { + arg0->unk_068.y = 0.0f; + arg0->unk_074.y = 0.0f; + sp1C = 1; + } + + return sp1C; +} + +s32 func_86802D28(unk_D_86807558* arg0) { + f32 var_fv0 = arg0->unk_068.x - D_86808498.unk_0C.x; + s32 var_v1; + + if (var_fv0 < 0.0f) { + if (!(var_fv0 > -280.0f)) { + var_fv0 = -280.0f; + } + } else { + if (!(var_fv0 < 280.0f)) { + var_fv0 = 280.0f; + } + } + + var_fv0 = ((var_fv0 + 280.0f) * 320.0f) / 560.0f; + var_v1 = ROUND_MAX(var_fv0); + + if (var_v1 < 0) { + var_v1 = 0; + } else if (var_v1 > 0x140) { + var_v1 = 0x140; + } + return var_v1; +} + +void func_86802E18(unk_D_86807558* arg0, u32 arg1) { + arg0->unk_060 = arg1; + + switch (arg1) { + case 0: + arg0->unk_006 = 0; + arg0->unk_0D0.rgba = -0x100; + arg0->unk_0DC = 0; + arg0->unk_0C0 = 0; + arg0->unk_0C8 = 1.0f; + break; + + case 1: + arg0->unk_006 = 0x1E; + arg0->unk_074.z = 0.0f; + arg0->unk_074.x = 0.0f; + func_8004D9B0(0x50008, arg0->unk_000 + 1, func_86802D28(arg0)); + arg0->unk_0C0 = 2; + arg0->unk_0C8 = 1.0f; + break; + + case 2: + arg0->unk_006 = 0x3C; + arg0->unk_0C0 = 7; + arg0->unk_0DC = 0; + arg0->unk_0C8 = 1.0f; + func_8004D9B0(0x50009, arg0->unk_000 + 1, func_86802D28(arg0)); + break; + + case 3: + arg0->unk_006 = 0x3C; + arg0->unk_0C0 = 7; + arg0->unk_0DC = 0; + arg0->unk_0C8 = 1.0f; + func_8004D9B0(0x5000A, arg0->unk_000 + 1, func_86802D28(arg0)); + break; + + case 4: + arg0->unk_006 = 0; + arg0->unk_0D0.rgba = -0x100; + if ((arg0->unk_028 != 1) || (arg0->unk_018 == 0)) { + arg0->unk_0C0 = 9; + arg0->unk_24C.unk_000.unk_01 &= ~1; + } + arg0->unk_074.x = arg0->unk_074.z = 0.0f; + arg0->unk_0C8 = 1.0f; + break; + } +} + +s32 func_86802FB0(unk_D_868084D8* arg0, s32 arg1, s32 arg2) { + if (arg0 == NULL) { + return 1; + } + + if (arg0->unk_0C == 0) { + return 0; + } + + if ((arg1 != 0) && (arg0->unk_0C == 1)) { + return 0; + } + + if (arg2 != 0) { + if ((arg0->unk_10 != 1) && (arg0->unk_10 != 2)) { + return 0; + } + } else if (arg0->unk_10 != 2) { + return 0; + } + + return 1; +} + +unk_D_86807558* func_86803038(unk_D_86807558* arg0, unk_D_868084D8* arg1) { + s32 i; + unk_D_86807558* ret = NULL; + unk_D_86807558* ptr; + + for (i = 0, ptr = D_86807558; i < 4; i++, ptr++) { + if ((ptr != arg0) && (arg1 == ptr->unk_010)) { + ret = ptr; + break; + } + } + + return ret; +} + +unk_D_868084D8* func_86803078(unk_D_86807558* arg0) { + s32 i; + f32 temp_fa0; + f32 var_fs0; + s32 var_s4; + s32 var_s6; + unk_D_86807558* temp_v0_2; + unk_D_868084D8* var_s0; + unk_D_868084D8* var_s5; + + var_s5 = NULL; + + if (!(arg0->unk_016 & 1)) { + var_s6 = 0; + } else { + var_s6 = 1; + } + if (arg0->unk_016 & 2) { + var_s4 = 1; + } else { + var_s4 = 0; + } + var_fs0 = 1e9f; + + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + if (func_86802FB0(var_s0, var_s6, var_s4) == 0) { + continue; + } + + temp_v0_2 = func_86803038(arg0, var_s0); + if (temp_v0_2 != NULL) { + if (temp_v0_2->unk_00C >= arg0->unk_00C) { + temp_v0_2->unk_010 = 0; + } else { + continue; + } + } + + temp_fa0 = SQ(var_s0->unk_14.x - arg0->unk_068.x) + SQ(var_s0->unk_14.z - arg0->unk_068.z); + if (temp_fa0 < var_fs0) { + var_s5 = var_s0; + var_fs0 = temp_fa0; + } + } + + return var_s5; +} + +unk_D_868084D8* func_868031A8(unk_D_86807558* arg0) { + s32 i; + f32 temp_fa0; + f32 var_fs0; + s16 var_a0; + s32 var_s2; + s32 var_s5; + s32 var_s7; + s32 var_v1; + unk_D_86807558* temp_v0_2; + unk_D_868084D8* var_s0; + unk_D_868084D8* var_s4; + + if (!(arg0->unk_016 & 1)) { + var_s7 = 0; + } else { + var_s7 = 1; + } + + if (arg0->unk_016 & 2) { + var_s5 = 1; + } else { + var_s5 = 0; + } + + var_s2 = 0; + var_fs0 = 1e9f; + var_s4 = NULL; + + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + if (func_86802FB0(var_s0, var_s7, var_s5) == 0) { + continue; + } + + temp_v0_2 = func_86803038(arg0, var_s0); + if (temp_v0_2 != NULL) { + if (temp_v0_2->unk_00C >= arg0->unk_00C) { + temp_v0_2->unk_010 = NULL; + } else { + continue; + } + } + + var_v1 = func_86806930(var_s0); + if (var_s0->unk_0C == arg0->unk_05C) { + var_a0 = arg0->unk_03E; + if (var_a0 < 5) { + var_a0++; + } + var_v1 *= var_a0; + } + + if (var_s2 < var_v1) { + var_s4 = var_s0; + var_s2 = var_v1; + var_fs0 = SQ(var_s0->unk_14.x - arg0->unk_068.x) + SQ(var_s0->unk_14.z - arg0->unk_068.z); + } else if (var_v1 == var_s2) { + temp_fa0 = SQ(var_s0->unk_14.x - arg0->unk_068.x) + SQ(var_s0->unk_14.z - arg0->unk_068.z); + if (temp_fa0 < var_fs0) { + var_s4 = var_s0; + var_fs0 = temp_fa0; + } + } + } + + return var_s4; +} + +unk_D_868084D8* func_86803374(unk_D_86807558* arg0) { + s32 i; + s16 sp4A; + f32 temp_fa0; + f32 var_fs0; + s32 var_s4; + s32 var_s6; + s32 var_s7; + unk_D_86807558* temp_v0_2; + unk_D_868084D8* var_s0; + unk_D_868084D8* var_s0_2; + unk_D_868084D8* var_s5; + + if (!(arg0->unk_016 & 1)) { + var_s6 = 0; + } else { + var_s6 = 1; + } + + if (arg0->unk_016 & 2) { + var_s7 = 1; + } else { + var_s7 = 0; + } + + var_s5 = NULL; + var_fs0 = 1e9f; + + if (arg0->unk_05C != 0) { + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + if ((func_86802FB0(var_s0, var_s6, var_s7) == 0) || (arg0->unk_05C != var_s0->unk_0C)) { + continue; + } + + temp_v0_2 = func_86803038(arg0, var_s0); + if (temp_v0_2 != NULL) { + if (temp_v0_2->unk_00C >= arg0->unk_00C) { + temp_v0_2->unk_010 = NULL; + } else { + continue; + } + } + + temp_fa0 = SQ(var_s0->unk_14.x - arg0->unk_068.x) + SQ(var_s0->unk_14.z - arg0->unk_068.z); + if (temp_fa0 < var_fs0) { + var_s5 = var_s0; + var_fs0 = temp_fa0; + } + } + } + + if (var_s5 == NULL) { + sp4A = 0; + var_s4 = 0; + + for (i = 0; i < 8; i++) { + s32 v = D_86807160[i]; + if (v != 1) { + if (sp4A < func_86806950(v)) { + var_s4 = v; + sp4A = func_86806950(v); + } + } + } + + if (var_s4 != 0) { + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + if ((func_86802FB0(var_s0, var_s6, var_s7) == 0) || (var_s4 != var_s0->unk_0C)) { + continue; + } + + temp_v0_2 = func_86803038(arg0, var_s0); + if (temp_v0_2 != NULL) { + if (temp_v0_2->unk_00C >= arg0->unk_00C) { + temp_v0_2->unk_010 = NULL; + } else { + continue; + } + } + + temp_fa0 = SQ(var_s0->unk_14.x - arg0->unk_068.x) + SQ(var_s0->unk_14.z - arg0->unk_068.z); + if (temp_fa0 < var_fs0) { + if (1) {} + var_s5 = var_s0; + var_fs0 = temp_fa0; + } + } + } + + if (var_s5 == NULL) { + var_s5 = func_868031A8(arg0); + } + } + + return var_s5; +} + +unk_D_868084D8* func_868035FC(unk_D_86807558* arg0) { + s32 i; + f32 temp_fa0; + f32 var_fs0; + unk_D_868084D8* var_s0; + unk_D_868084D8* var_s3; + + var_fs0 = 1e9f; + var_s3 = NULL; + + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + if ((func_86802FB0(var_s0, 0, 1) == 0) || (var_s0->unk_0C != 1)) { + continue; + } + + temp_fa0 = SQ(var_s0->unk_14.x - arg0->unk_068.x) + SQ(var_s0->unk_14.z - arg0->unk_068.z); + if (temp_fa0 < var_fs0) { + var_s3 = var_s0; + var_fs0 = temp_fa0; + } + } + + if (var_s3 != NULL) { + return var_s3; + } + + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + if ((func_86802FB0(var_s0, 0, 1) == 0) || !(var_s0->unk_02 & 2)) { + continue; + } + + temp_fa0 = SQ(var_s0->unk_14.x - arg0->unk_068.x) + SQ(var_s0->unk_14.z - arg0->unk_068.z); + if (temp_fa0 < var_fs0) { + if (1) {} + var_s3 = var_s0; + var_fs0 = temp_fa0; + } + } + + return var_s3; +} + +void func_86803760(Vec3f* arg0, f32 arg1, s16* arg2, s16* arg3, f32 arg4) { + unk_D_86808498* ptr = &D_86808498; + f32 tmp1; + f32 tmp2; + + arg1 = ABS_NORMALIZED(arg1); + + if (arg1 == 0.0f) { + *arg2 = 0; + *arg3 = 0; + return; + } + + arg1 = 1.0f / sqrtf(arg1); + arg0->x *= arg1; + arg0->z *= arg1; + + tmp1 = (0.0f - (arg0->x * ptr->unk_2C.x)) + (arg0->z * ptr->unk_2C.z); + tmp2 = (arg0->x * ptr->unk_20.x) + (arg0->z * ptr->unk_20.z); + + *arg2 = 74.0f * tmp1 * arg4; + *arg3 = 74.0f * tmp2 * arg4; +} + +void func_868038A8(unk_D_86807558* arg0, Controller* arg1) { + s16 var_a1; + s16 var_a2; + f32 sp60; + Vec3f sp54; + s32 sp50; + f32 tmp; + f32 temp_fv0; + s16 sp40[] = { 0x002D, 0x0014, 0x000F, 0x0000 }; // D_868070FC + f32 sp30[] = { 0.8f, 0.9f, 0.9f, 1.0f }; // D_86807104 + + bzero(arg1, sizeof(Controller)); + sp50 = 0; + + if (!(arg0->unk_016 & 1)) { + var_a1 = 0; + } else { + var_a1 = 1; + } + + if (arg0->unk_016 & 2) { + var_a2 = 1; + } else { + var_a2 = 0; + } + + arg0->unk_014--; + if (arg0->unk_014 <= 0) { + sp50 = 1; + arg0->unk_014 = sp40[D_8780FA38]; + arg0->unk_010 = NULL; + } else { + if (func_86802FB0(arg0->unk_010, var_a1, var_a2) == 0) { + arg0->unk_010 = NULL; + } + } + + if (sp50 != 0) { + switch (arg0->unk_008) { + case 1: + arg0->unk_010 = func_86803078(arg0); + break; + + case 2: + arg0->unk_010 = func_86803374(arg0); + break; + + case 3: + arg0->unk_010 = func_868031A8(arg0); + break; + + case 4: + arg0->unk_010 = func_868035FC(arg0); + break; + } + } + + if (arg0->unk_010 == NULL) { + if (arg0->unk_008 == 4) { + sp54.x = 0.0f - arg0->unk_068.x; + sp54.y = 0.0f; + sp54.z = 0.0f - arg0->unk_068.z; + + temp_fv0 = SQ(sp54.x) + SQ(sp54.z); + if (temp_fv0 > 30.0f) { + func_86803760(&sp54, temp_fv0, &arg1->rawStickX, &arg1->rawStickY, 0.5f); + } + } + } else { + sp54.y = 0.0f; + sp60 = func_86805E94(arg0->unk_010, &arg0->unk_068, &sp54); + + if ((sp60 <= 13225.0f) && (sp60 != 0.0f)) { + tmp = (((sp54.x * arg0->unk_098.unk_00.x) + (sp54.y * arg0->unk_098.unk_00.y) + + (sp54.z * arg0->unk_098.unk_00.z)) / + sqrtf(sp60)); + if (tmp >= 0.8f) { + arg1->buttonPressed |= 0x8000; + } else { + func_86803760(&sp54, sp60, &arg1->rawStickX, &arg1->rawStickY, sp30[D_8780FA38]); + } + } else { + func_86803760(&sp54, sp60, &arg1->rawStickX, &arg1->rawStickY, sp30[D_8780FA38]); + } + } +} + +f32 func_86803BC4(s16 arg0, s32 arg1) { + static s16 D_86807114[] = { + 0x003C, + 0x000A, + 0x0028, + 0x0014, + }; + static s16 D_8680711C[] = { + 0x003C, + 0x000A, + 0x0028, + 0x0014, + }; + static s16* D_86807124[] = { D_86807114, D_8680711C }; + + s16* temp_v0 = D_86807124[arg1]; + f32 ret; + + arg0 = temp_v0[0] - arg0; + + if (arg0 < temp_v0[1]) { + ret = arg0 / (f32)temp_v0[1]; + } else if (temp_v0[2] < arg0) { + ret = 1.0f - ((arg0 - temp_v0[2]) / (f32)temp_v0[3]); + } else { + ret = 1.0f; + } + + return ret; +} + +#ifdef NON_MATCHING +void func_86803C6C(unk_D_86807558* arg0) { + s32 pad; + s32 pad1; + unk_D_86808498* ptr = &D_86808498; + f32 spB8; + f32 temp_fa0; + f32 var_fv1; + f32 spAC; + f32 spA8; + Controller* spA4; + Controller sp80; + f32 tmp; + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + + if (arg0->unk_002 & 2) { + if (!(arg0->unk_002 & 4)) { + spA4 = arg0->unk_064; + } else { + func_868038A8(arg0, &sp80); + spA4 = &sp80; + } + } else { + spA4 = &D_86808450; + } + + switch (arg0->unk_060) { + case 0: + if (spA4->buttonPressed & 0x8000) { + func_86802E18(arg0, 1); + return; + } + + spAC = func_86802BE4(spA4->rawStickX); + spA8 = func_86802BE4(spA4->rawStickY); + break; + + case 2: + case 3: + arg0->unk_006--; + if (arg0->unk_060 == 2) { + spB8 = func_86803BC4(arg0->unk_006, 0); + } else { + spB8 = func_86803BC4(arg0->unk_006, 1); + } + + if (arg0->unk_006 <= 0) { + arg0->unk_006 = 0; + func_86802E18(arg0, 0); + return; + } + + if (!(arg0->unk_006 & 0xF)) { + arg0->unk_0E0 = func_878001E8(0x10000); + } + + spAC = COSS(arg0->unk_0E0) * spB8; + spA8 = SINS(arg0->unk_0E0) * spB8; + spB8 = 1.0f - spB8; + + if (arg0->unk_060 == 2) { + arg0->unk_0D0.g = arg0->unk_0D0.b = 255.0f * spB8; + if (!(arg0->unk_006 & 0xF)) { + func_81407D48(1.0f, arg0->unk_0E4.unk_0FC, D_8006F05C, func_879023EC, &D_87903E10, 4); + } + } else { + arg0->unk_0D0.r = arg0->unk_0D0.b = 255.0f * spB8; + } + break; + } + + temp_fa0 = SQ(spAC) + SQ(spA8); + if (temp_fa0 > 1.0f) { + temp_fa0 = 1.0f / sqrtf(temp_fa0); + spAC *= temp_fa0; + spA8 *= temp_fa0; + } + + sp70 = arg0->unk_068; + sp64 = arg0->unk_074; + + sp58.y = D_86806FA8; + + var_fv1 = -D_86806F90[0] * spAC; + temp_fa0 = D_86806F90[0] * spA8; + + var_fv1 = ABS_NORMALIZED(var_fv1); + temp_fa0 = ABS_NORMALIZED(temp_fa0); + + sp4C.x = (ptr->unk_2C.x * var_fv1) + (temp_fa0 * ptr->unk_20.x); + sp4C.z = (ptr->unk_2C.z * var_fv1) + (temp_fa0 * ptr->unk_20.z); + + sp4C.x = ABS_NORMALIZED(sp4C.x); + sp4C.z = ABS_NORMALIZED(sp4C.z); + + sp58.x = sp4C.x - sp64.x; + sp58.z = sp4C.z - sp64.z; + + sp58.x = ABS_NORMALIZED(sp58.x); + sp58.z = ABS_NORMALIZED(sp58.z); + + if ((SQ(sp58.x) + SQ(sp58.z)) <= 0.000001f) { + sp58.x = sp58.z = 0.0f; + } else { + if (((sp64.x * sp58.x) + (sp64.z * sp58.z)) >= 0.0f) { + if (sp70.y > 0.0f) { + var_fv1 = D_86806FA0; + } else { + var_fv1 = D_86806F9C; + } + } else { + var_fv1 = D_86806FA4; + } + sp58.x *= var_fv1; + sp58.z *= var_fv1; + } + + arg0->unk_074.x = sp64.x + sp58.x; + arg0->unk_074.y = sp64.y + sp58.y; + arg0->unk_074.z = sp64.z + sp58.z; + + arg0->unk_074.x = ABS_NORMALIZED(arg0->unk_074.x); + arg0->unk_074.y = ABS_NORMALIZED(arg0->unk_074.y); + arg0->unk_074.z = ABS_NORMALIZED(arg0->unk_074.z); + + if (arg0->unk_060 == 0) { + if ((SQ(arg0->unk_074.x) + SQ(arg0->unk_074.z)) < 0.25f) { + if (arg0->unk_0C0 == 1) { + arg0->unk_0C0 = 0; + arg0->unk_0C8 = 1.0f; + } + } else { + arg0->unk_0C0 = 1; + arg0->unk_0C8 = 1.0f; + } + } + + arg0->unk_068.x = arg0->unk_074.x + sp70.x; + arg0->unk_068.y = arg0->unk_074.y + sp70.y; + arg0->unk_068.z = arg0->unk_074.z + sp70.z; + + func_86802C6C(arg0); + + temp_fa0 = SQ(sp4C.x) + SQ(sp4C.z); + if (temp_fa0 > 0.0001f) { + temp_fa0 = 1.0f / sqrtf(temp_fa0); + sp4C.x *= temp_fa0; + sp4C.z *= temp_fa0; + + if (((arg0->unk_098.unk_00.x * sp4C.x) + (sp4C.z * arg0->unk_098.unk_00.z)) < -0.95f) { + var_fv1 = 0.3f; + } else { + var_fv1 = 0.0f; + } + + arg0->unk_098.unk_00.x += (sp4C.x * D_86806FAC) + (var_fv1 * arg0->unk_098.unk_18.x); + arg0->unk_098.unk_00.y = 0.0f; + arg0->unk_098.unk_00.z += (sp4C.z * D_86806FAC) + (var_fv1 * arg0->unk_098.unk_18.z); + + arg0->unk_098.unk_00.x = ABS_NORMALIZED(arg0->unk_098.unk_00.x); + arg0->unk_098.unk_00.z = ABS_NORMALIZED(arg0->unk_098.unk_00.z); + } + + arg0->unk_0BE--; + if (arg0->unk_0BE == 0) { + if (arg0->unk_0BC == 0) { + arg0->unk_0BC = func_878001E8(3) + 1; + arg0->unk_0BE = 0xF; + } else { + arg0->unk_0BC--; + if (arg0->unk_0BC == 0) { + arg0->unk_0BE = func_878001E8(0x5B) + 0x1E; + } else { + arg0->unk_0BE = 0xF; + } + } + } +} +#else +void func_86803C6C(unk_D_86807558* arg0); #pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86803C6C.s") +#endif + +#ifdef NON_MATCHING +unk_D_868084D8* func_86804634(unk_D_86807558* arg0) { + s32 i; + Vec3f sp14; + unk_D_868084D8* var_v1; + f32 sq; + Vec3f* tmp; + sp14 = arg0->unk_0E4.unk_0EC; + + for (i = 0, var_v1 = D_868084D8; i < 12; i++, var_v1++) { + if (((var_v1->unk_02 & 1) != 0) && (var_v1->unk_10 == 2)) { + if (SQ(D_86806FBC) >= + SQ(var_v1->unk_14.x - sp14.x) + SQ(var_v1->unk_14.y - sp14.y) + SQ(var_v1->unk_14.z - sp14.z)) { + break; + } + } + } + + if (i == 0xC) { + var_v1 = NULL; + } + + return var_v1; +} +#else +unk_D_868084D8* func_86804634(unk_D_86807558* arg0); #pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86804634.s") +#endif + +s32 func_86804700(unk_D_86807558* arg0) { + UNUSED s32 pad; + s32 i; + Vec3f sp2C; + f32 temp_fa0; + f32 temp_fv0; + f32 temp_fv1; + unk_D_86807558* var_v0; + + if (arg0->unk_0DC != 0) { + return 1; + } + + if (func_80017514(&arg0->unk_0E4) != 0) { + return 2; + } + + sp2C = arg0->unk_0E4.unk_0EC; + + for (i = 0, var_v0 = D_86807558; i < 4; i++, var_v0++) { + if (arg0 == var_v0) { + continue; + } + + temp_fv0 = var_v0->unk_068.x - sp2C.x; + temp_fv1 = (var_v0->unk_068.y + D_86806FB4) - sp2C.y; + temp_fa0 = var_v0->unk_068.z - sp2C.z; + + if ((SQ(temp_fv0) + SQ(temp_fv1) + SQ(temp_fa0)) <= SQ(D_86806FC0 + D_86806FB0)) { + return 3; + } + } + + return 0; +} + +void func_86804884(unk_D_86807558* arg0) { + s32 sp24; + s32 sp20; + + if (arg0->unk_0DC->unk_02 & 2) { + sp24 = 1; + } else { + sp24 = 0; + } + + sp20 = arg0->unk_0DC->unk_0C; + if (sp20 == arg0->unk_05C) { + if (arg0->unk_03E < 5) { + arg0->unk_03E++; + } + arg0->unk_040.unk_00 = 1; + } else { + arg0->unk_03E = 1; + } + arg0->unk_05C = sp20; + + arg0->unk_018 += func_86806930(arg0->unk_0DC) * arg0->unk_03E; + arg0->unk_02A++; + arg0->unk_02C[sp20]++; + + func_86806868(arg0->unk_0DC, 0, NULL); + + if (sp20 == 1) { + func_86802E18(arg0, 2); + } else if ((sp24 != 0) && (arg0->unk_002 & 2)) { + func_86802E18(arg0, 3); + } else { + func_86802E18(arg0, 0); + } +} + +void func_868049C0(unk_D_86807558* arg0) { + switch (arg0->unk_0C0) { + case 2: + if (func_80017514(&arg0->unk_0E4) != 0) { + arg0->unk_0C0 = 3; + } + break; + + case 3: + if (arg0->unk_0DC == NULL) { + arg0->unk_0DC = func_86804634(arg0); + if (arg0->unk_0DC != NULL) { + arg0->unk_0CC = func_8680262C(&arg0->unk_0E4, 0xD); + func_86806868(arg0->unk_0DC, 3, arg0); + } + } + + if (arg0->unk_0C8 >= 0.0f) { + switch (func_86804700(arg0)) { + case 1: + case 2: + arg0->unk_0C8 = -1.0f; + break; + + case 3: + if (func_8680262C(&arg0->unk_0E4, 0xD) < 3) { + arg0->unk_0C0 = 4; + } else { + arg0->unk_0C8 = -1.0f; + } + break; + } + } else if (func_80017484(&arg0->unk_0E4, 0) != 0) { + if (arg0->unk_0DC == NULL) { + arg0->unk_0C0 = 4; + } else if (arg0->unk_0DC->unk_0C != 1) { + arg0->unk_0C0 = 5; + arg0->unk_006 = arg0->unk_0D4; + } else { + func_86804884(arg0); + } + arg0->unk_0C8 = 1.0f; + } + break; + + case 4: + if (func_80017514(&arg0->unk_0E4) != 0) { + func_86802E18(arg0, 0); + } + break; + + case 5: + if (func_80017514(&arg0->unk_0E4) != 0) { + arg0->unk_006--; + if (arg0->unk_006 <= 0) { + arg0->unk_0C0 = 6; + arg0->unk_0C8 = arg0->unk_0D8; + } else { + func_80017464(&arg0->unk_0E4, 0); + } + } + break; + + case 6: + if (func_80017514(&arg0->unk_0E4) != 0) { + func_86804884(arg0); + } + break; + } +} + +void func_86804BD0(unk_D_86807558* arg0) { + UNUSED s32 pad; + Vec3f sp30; + f32 temp_fa0; + f32 tmp; + + if ((arg0->unk_028 != 1) || (arg0->unk_018 == 0)) { + if (func_80017514(&arg0->unk_0E4) != 0) { + func_80017464(&arg0->unk_0E4, 0x3D); + } + } else if (arg0->unk_0C0 == 8) { + if (func_80017514(&arg0->unk_0E4) != 0) { + func_86802E18(arg0, 0); + } + } else { + sp30.x = D_86808498.unk_0C.x - arg0->unk_068.x; + sp30.y = 0.0f; + sp30.z = D_86808498.unk_0C.z - arg0->unk_068.z; + + temp_fa0 = 1.0f / sqrtf(SQ(sp30.x) + SQ(sp30.z)); + sp30.x *= temp_fa0; + sp30.z *= temp_fa0; + + arg0->unk_098.unk_00.x += sp30.x * 0.3f; + arg0->unk_098.unk_00.z += sp30.z * 0.3f; + + func_86802204(&arg0->unk_098); + + tmp = (sp30.x * arg0->unk_098.unk_00.x) + sp30.y + (sp30.z * arg0->unk_098.unk_00.z); + + if (tmp >= 0.95f) { + arg0->unk_0C0 = 8; + } + } +} + +void func_86804D38(unk_D_86807558* arg0) { + s32 i; + f32 sp68; + f32 temp_fa0; + f32 sp60; + f32 temp_fs1; + f32 temp_fs2; + f32 temp_fs3; + f32 temp_fs4; + f32 temp_fs5; + f32 temp_fv0_3; + f32 var_fs0; + unk_D_86807558* var_s1; + + for (i = 0, var_s1 = D_86807558; i < 4; i++, var_s1++) { + if (arg0 == var_s1) { + continue; + } + + temp_fs4 = var_s1->unk_068.x - arg0->unk_068.x; + temp_fs5 = var_s1->unk_068.y - arg0->unk_068.y; + sp60 = var_s1->unk_068.z - arg0->unk_068.z; + + temp_fa0 = SQ(temp_fs4) + SQ(temp_fs5) + SQ(sp60); + if (temp_fa0 < (4.0f * D_86806FB0 * D_86806FB0)) { + sp68 = sqrtf(temp_fa0); + if (sp68 < 0.01f) { + var_fs0 = 0.0f; + } else { + var_fs0 = 1.0f / sp68; + } + + temp_fs1 = temp_fs4 * var_fs0; + temp_fs2 = temp_fs5 * var_fs0; + temp_fs3 = sp60 * var_fs0; + + temp_fv0_3 = sqrtf(SQ(var_s1->unk_074.x) + SQ(var_s1->unk_074.y) + SQ(var_s1->unk_074.z)); + arg0->unk_002 |= 1; + + arg0->unk_080.x -= temp_fs1 * temp_fv0_3; + arg0->unk_080.y -= temp_fs2 * temp_fv0_3; + arg0->unk_080.z -= temp_fs3 * temp_fv0_3; + + var_fs0 = (2.0f * D_86806FB0) - sp68; + arg0->unk_08C.x -= temp_fs1 * var_fs0; + arg0->unk_08C.y -= temp_fs2 * var_fs0; + arg0->unk_08C.z -= temp_fs3 * var_fs0; + } + } +} + +void func_86804F2C(unk_D_86807558* arg0) { + if (arg0->unk_002 & 1) { + arg0->unk_068.x += arg0->unk_080.x + arg0->unk_08C.x; + arg0->unk_068.y += arg0->unk_080.y + arg0->unk_08C.y; + arg0->unk_068.z += arg0->unk_080.z + arg0->unk_08C.z; + + arg0->unk_074 = arg0->unk_080; + + func_86802C6C(arg0); + + arg0->unk_002 &= ~1; + arg0->unk_080.x = arg0->unk_080.y = arg0->unk_080.z = 0.0f; + + arg0->unk_08C = arg0->unk_080; + } +} + +void func_86805000(unk_D_86807558* arg0) { + UNUSED s32 pad[3]; + f32 var_fv0; + unk_D_86002F58_004_000* ptr = &arg0->unk_0E4; + + ptr->unk_024 = arg0->unk_068; + + func_86802204(&arg0->unk_098); + + var_fv0 = 1.0f - arg0->unk_098.unk_00.z; + var_fv0 = var_fv0 * 32768.0f * 0.5f; + if (arg0->unk_098.unk_00.x < 0.0f) { + var_fv0 = 0.0f - var_fv0; + } + ptr->unk_01E.y = (s32)var_fv0 & 0xFFFF; + + ptr->unk_03C.rgba = arg0->unk_0D0.rgba; + + if (arg0->unk_0C4 != arg0->unk_0C0) { + func_8001BD04(&arg0->unk_0E4, arg0->unk_0C0); + } + + ptr->unk_040.unk_0C = (s32)(arg0->unk_0C8 * 65536.0f); + if (arg0->unk_002 & 0x10) { + ptr->unk_01D = 0xFF; + } else { + ptr->unk_01D = 0; + } +} + +void func_86805108(u16 arg0, s32 arg1) { + static u16 D_8680712C[] = { 1, 2, 4, 8 }; + + s32 i; + + for (i = 0; i < 4; i++) { + if (!(D_8680712C[i] & arg0)) { + return; + } + + D_86808438[i] = arg1; + if ((D_86808438[i] < 0) || (D_86808438[i] >= 6)) { + D_86808438[i] = 0; + } + } +} + +void func_868051E0(void) { + unk_D_86807558* ptr2; + s32 tmp; + s32 i; + s32 j; + s32 var_v1; + s32 sp3C[4]; + unk_D_86807558* ptr; + s32 var_a2; + + if (D_86808438[0] != 4) { + return; + } + + for (i = 0; i < 4; i++) { + sp3C[i] = i; + } + + for (i = 0; i < 3; i++) { + for (j = i + 1; j < 4; j++) { + ptr = &D_86807558[sp3C[i]]; + ptr2 = &D_86807558[sp3C[j]]; + if (ptr->unk_018 < ptr2->unk_018) { + tmp = sp3C[i]; + sp3C[i] = sp3C[j]; + sp3C[j] = tmp; + } + } + } + + var_a2 = -1; + var_v1 = 0; + for (i = 0; i < 4; i++) { + if (D_86808448 == -1) { + D_86808448 = sp3C[i]; + } + + ptr = &D_86807558[sp3C[i]]; + if (var_a2 != ptr->unk_018) { + var_v1++; + var_a2 = ptr->unk_018; + } + + ptr->unk_028 = var_v1; + } + + for (i = 0, ptr = D_86807558; i < 4; i++, ptr++) { + ptr->unk_002 |= 8; + if ((ptr->unk_028 == 1) && (ptr->unk_018 > 0)) { + func_87802F00(i); + } + } +} + +void func_86805428(unk_D_86807558* arg0) { + switch (D_86808438[arg0->unk_000]) { + case 0: + case 4: + break; + + case 2: + arg0->unk_002 &= ~2; + break; + + case 1: + arg0->unk_002 |= 0x10; + break; + + case 3: + arg0->unk_002 |= 2; + break; + + case 5: + arg0->unk_002 &= ~2; + func_86802E18(arg0, 4); + break; + } + + D_86808438[arg0->unk_000] = 0; +} + +void func_86805518(unk_D_86807558* arg0) { + arg0->unk_020++; + arg0->unk_01C += arg0->unk_020; + if (arg0->unk_01C >= arg0->unk_018) { + arg0->unk_01C = arg0->unk_018; + arg0->unk_024 = arg0->unk_018; + arg0->unk_020 = 0; + arg0->unk_002 &= ~8; + if (D_86808448 == arg0->unk_000) { + func_8004D9B0(0x5000C, 0, 0); + } + } else if ((arg0->unk_01C - arg0->unk_024) >= 0xA) { + arg0->unk_024 = arg0->unk_01C; + if (D_86808448 == arg0->unk_000) { + func_8004D9B0(0x5000B, 0, 0); + } + } +} + +s32 func_868055D4(void) { + s32 var_v1 = 0; + s32 i; + unk_D_86807558* var_a0; + + for (i = 0, var_a0 = D_86807558; i < 4; i++, var_a0++) { + if ((var_a0->unk_060 != 0) || (var_a0->unk_0DC != 0)) { + break; + } + } + + if (i == 4) { + var_v1 = 1; + } + + return var_v1; +} + +void func_86805620(UNUSED unk_D_86807558* arg0, unk_D_86807558_040* arg1) { + s32 i; + + switch (arg1->unk_00) { + case 0: + break; + + case 1: + arg1->unk_00 = 2; + arg1->unk_02 = 0xA; + arg1->unk_04 = 0; + arg1->unk_10 = 0.0f; + arg1->unk_08 = arg1->unk_08; + arg1->unk_0C += 5.0f; + arg1->unk_14 = 5.0f; + arg1->unk_18 = 0; + break; + + case 2: + if (arg1->unk_02 > 0) { + arg1->unk_02--; + } + + arg1->unk_18 = ((0xA - arg1->unk_02) * 0xFF) / 10; + arg1->unk_14 += -1.0f; + + if (arg1->unk_0C <= 0.0f) { + arg1->unk_0C = 0.0f; + arg1->unk_14 = 0.0f; + arg1->unk_04++; + if (arg1->unk_04 < 3) { + arg1->unk_14 = 5.0f; + for (i = 0; i < arg1->unk_04; i++) { + arg1->unk_14 *= 0.5f; + } + } else { + arg1->unk_00 = 3; + arg1->unk_02 = 0x1E; + arg1->unk_18 = 0xFF; + } + } + arg1->unk_08 += arg1->unk_10; + arg1->unk_0C += arg1->unk_14; + break; + + case 3: + arg1->unk_02--; + if (arg1->unk_02 <= 0) { + arg1->unk_00 = 4; + arg1->unk_02 = 0xF; + } + break; + + case 4: + arg1->unk_02--; + arg1->unk_18 = (arg1->unk_02 * 0xFF) / 15; + if (arg1->unk_02 <= 0) { + func_86802728(arg1); + } + break; + } +} + +void func_86805858(s32 arg0) { + s32 i; + MemoryBlock* temp_v0; + + for (i = 0; i < 4; i++) { + D_86808438[i] = 0; + } + + bzero(&D_86808450, sizeof(Controller)); + + D_86808448 = -1; + D_86807550 = func_80019D18(0xA0); + + temp_v0 = func_80002D10(main_pool_get_available(), 0); + D_86808474 = (unk_D_86002F58_004_000_004*)func_80018B70(temp_v0, &D_86807078); + func_80002D60(temp_v0); + D_8680847A = 0; + D_8680847E = 4 - D_8780FA2C; + D_8680847C = func_878001E8(D_8680847E); + D_86808480 = 0; + + for (i = 0; i < 4; i++) { + func_86802750(&D_86807558[i], i, arg0); + } +} + +void func_86805974(void) { + s32 i; + unk_D_86807558* var_s0; + + if ((D_8780FC94 == 0) && (D_86808438[0] != 0)) { + func_868051E0(); + } + + var_s0 = D_86807558; + for (i = 0; i < 4; i++, var_s0++) { + if (D_8780FC94 != 0) { + continue; + } + + var_s0->unk_0C4 = var_s0->unk_0C0; + if (D_86808438[i] != 0) { + func_86805428(var_s0); + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86804700.s") + switch (var_s0->unk_060) { + case 0: + case 2: + case 3: + func_86803C6C(var_s0); + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86804884.s") + case 1: + func_868049C0(var_s0); + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868049C0.s") + case 4: + func_86804BD0(var_s0); + break; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86804BD0.s") + if (var_s0->unk_002 & 8) { + func_86805518(var_s0); + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86804D38.s") + func_86805620(var_s0, &var_s0->unk_040); + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86804F2C.s") + var_s0 = D_86807558; + for (i = 0; i < 4; i++, var_s0++) { + if (D_8780FC94 == 0) { + func_86804D38(var_s0); + } + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805000.s") + var_s0 = D_86807558; + for (i = 0; i < 4; i++, var_s0++) { + if (D_8780FC94 == 0) { + func_86804F2C(var_s0); + } + func_86805000(var_s0); + } +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805108.s") +void func_86805AF0(unk_D_86808498* arg0) { + f32 temp_fa0; + Vec3f sp20; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868051E0.s") + arg0->unk_20.x = D_86808490->unk_60.at.x - D_86808490->unk_60.eye.x; + arg0->unk_20.y = 0.0f; + arg0->unk_20.z = D_86808490->unk_60.at.z - D_86808490->unk_60.eye.z; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805428.s") + temp_fa0 = SQ(arg0->unk_20.x) + SQ(arg0->unk_20.z); + if (temp_fa0 != 0.0f) { + temp_fa0 = 1.0f / sqrtf(temp_fa0); + arg0->unk_20.x *= temp_fa0; + arg0->unk_20.y = 0.0f; + arg0->unk_20.z *= temp_fa0; + } else { + arg0->unk_20.x = 0.0f; + arg0->unk_20.z = 1.0f; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805518.s") + sp20.x = 0.0f; + sp20.y = 1.0f; + sp20.z = 0.0f; + func_8000EA84(&arg0->unk_2C, &sp20, &arg0->unk_20); +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_868055D4.s") +void func_86805BD4(void) { + D_87906054 = D_86808490 = D_86807500->unk_00.unk_0C; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805620.s") + D_86808498.unk_00.x = 0.0f; + D_86808498.unk_00.y = 0.0f; + D_86808498.unk_00.z = -7.8f; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805858.s") + D_86808498.unk_0C = D_8006F050; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805974.s") + D_86808498.unk_18 = 0; + D_86808498.unk_1A = 0x16A8; + D_86808498.unk_1C = 880.0f; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805AF0.s") + func_80010354(&D_86808498.unk_00, &D_86808498.unk_0C, D_86808498.unk_1C, D_86808498.unk_1A, D_86808498.unk_18); + func_86805AF0(&D_86808498); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805BD4.s") + D_86808490->unk_24.near = 50.0f; + D_86808490->unk_24.far = 6400.0f; +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_1462A0/func_86805CB4.s") +void func_86805CB4(void) { + func_80010354(&D_86808498.unk_00, &D_86808498.unk_0C, D_86808498.unk_1C, D_86808498.unk_1A, D_86808498.unk_18); + func_86805AF0(&D_86808498); + D_86808490->unk_60.eye = D_86808498.unk_0C; + D_86808490->unk_60.at = D_86808498.unk_00; +} diff --git a/src/fragments/14/fragment14_14A030.c b/src/fragments/14/fragment14_14A030.c index 6577b2fb..6a6aaf6d 100644 --- a/src/fragments/14/fragment14_14A030.c +++ b/src/fragments/14/fragment14_14A030.c @@ -1,33 +1,565 @@ -#include "global.h" +#include "fragment14.h" +#include "src/11BA0.h" +#include "src/1C720.h" +#include "src/4BDC0.h" +#include "src/4CBC0.h" +#include "src/6A40.h" +#include "src/F420.h" +#include "src/fragments/2/fragment2.h" +#include "src/memory.h" -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86805D50.s") +static const u32 D_868074B0[] = { 0xA4A2A4AC, 0xA4EA0000 }; // "あがり" +static const u32 D_868074B8[] = { 0xA4A8A4D3, 0x00000000 }; // "えび" +static const u32 D_868074C0[] = { 0xA4A4A4AF, 0xA4E90000 }; // "いくら" +static const u32 D_868074C8[] = { 0xA4ABA4C3, 0xA4D10000 }; // "かっぱ" +static const u32 D_868074D0[] = { 0xA4C8A4ED, 0x00000000 }; // "とろ" +static const u32 D_868074D8[] = { 0xA4C6A4C3, 0xA4AB0000 }; // "てっか" +static const u32 D_868074E0[] = { 0xA4BFA4DE, 0xA4B40000 }; // "たまご" +static const u32 D_868074E8[] = { 0xA4A6A4CB, 0x00000000 }; // "うに" -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86805E94.s") +static f32 D_86807140 = 230.0f; +static Vec3f D_86807144 = { 0.0f, 35.0f, 0.0f }; +static Vec3f D_86807150 = { 3.0f, 0.0f, 17.0f }; +static f32 D_8680715C = 10.0f; +s32 D_86807160[] = { + 8, 5, 2, 3, 6, 7, 4, 1, +}; +unk_D_86807180 D_86807180[9] = { + { + 0x00000000, + NULL, + NULL, + NULL, + 0x0000, + 0x0000, + 0x00000000, + 0x0000, + }, + { + 0x00000014, + 0x04000000, + 0x04004000, + D_868074B0, + 0x0000, + 0x0014, + 0x00000000, + 0x0000, + }, + { + 0x0000015E, + 0x04000800, + 0x04005000, + D_868074B8, + 0x0014, + 0x000A, + 0x00050005, + 0x0001, + }, + { + 0x000000FA, + 0x04001000, + 0x04006000, + D_868074C0, + 0x0000, + 0x000C, + 0x00000000, + 0x0000, + }, + { + 0x00000032, + 0x04001800, + 0x04007000, + D_868074C8, + 0x0000, + 0x0014, + 0x00000000, + 0x0000, + }, + { + 0x00000258, + 0x04002000, + 0x04008000, + D_868074D0, + 0x0019, + 0x0005, + 0x00050006, + 0x0001, + }, + { + 0x000000C8, + 0x04002800, + 0x04009000, + D_868074D8, + 0x0000, + 0x000D, + 0x00000000, + 0x0000, + }, + { + 0x00000096, + 0x04003000, + 0x0400A000, + D_868074E0, + 0x0000, + 0x0011, + 0x00000000, + 0x0000, + }, + { + 0x000003E8, + 0x04003800, + 0x0400B000, + D_868074E8, + 0x001E, + 0x0003, + 0x00050007, + 0x0001, + }, +}; +static Vtx D_86807280[] = { + VTX(-16, 0, -16, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(15, 0, -16, 992, 0, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(-16, 0, 15, 0, 992, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(15, 0, 15, 992, 992, 0xFF, 0xFF, 0xFF, 0xFF), +}; +static Gfx D_868072C0[] = { + gsDPPipeSync(), + gsDPSetTextureLUT(G_TT_NONE), + gsSPClearGeometryMode(G_LIGHTING), + gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_PASS2), + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsSPVertex(D_86807280, 4, 0), + gsDPLoadTextureBlock(0x0400C000, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, G_TX_NOMIRROR | G_TX_CLAMP, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD), + gsSP2Triangles(0, 3, 1, 0, 0, 2, 3, 0), + gsSPEndDisplayList(), +}; +static Gfx D_86807338[] = { + gsSPEndDisplayList(), +}; +static Vtx D_86807340[] = { + VTX(-16, 31, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(15, 31, 0, 992, 0, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(-16, 0, 0, 0, 992, 0xFF, 0xFF, 0xFF, 0xFF), + VTX(15, 0, 0, 992, 992, 0xFF, 0xFF, 0xFF, 0xFF), +}; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86805F94.s") +static s32 D_868084D0; +static f32 D_868084D4; +unk_D_868084D8 D_868084D8[12]; +static unk_D_86808808 D_86808808[12]; +static s32 D_86809A08; +static s16 D_86809A0C; +static s16 D_86809A10[9]; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86805FFC.s") +void func_86805D50(s16 arg0, Vec3f* arg1) { + f32 var_fv0 = D_868084D4 + (arg0 * 30.0f); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806100.s") + if (var_fv0 >= 360.0f) { + var_fv0 -= 360.0f; + } + var_fv0 = (var_fv0 * 65536.0f) / 360.0f; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_868061E8.s") + arg1->x = D_86807144.x + (SINS(var_fv0) * D_86807140); + arg1->y = D_86807144.y; + arg1->z = D_86807144.z + (COSS(var_fv0) * D_86807140); +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806388.s") +f32 func_86805E94(unk_D_868084D8* arg0, Vec3f* arg1, Vec3f* arg2) { + f32 var_fv1; + unk_D_868084D8_038* ptr = arg0->unk_38; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_868063C4.s") + var_fv1 = (0.5f * D_8680715C) + D_868084D4 + (30.0f * ptr->unk_000); + if (var_fv1 >= 360.0f) { + var_fv1 -= 360.0f; + } -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_868064BC.s") + arg2->x = ((SINS(((s32)var_fv1 << 0xF) / 180) * D_86807140) + D_86807144.x) - arg1->x; + arg2->y = 0.0f; + arg2->z = ((COSS(((s32)var_fv1 << 0xF) / 180) * D_86807140) + D_86807144.z) - arg1->z; + return SQ(arg2->x) + SQ(arg2->z); +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806868.s") +void func_86805F94(unk_D_86808808* arg0, s32 arg1) { + unk_D_86808808_018* sp1C = &arg0->unk_018; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806930.s") + arg0->unk_000 = arg1; + arg0->unk_002 = 0; + arg0->unk_004 = 0; + arg0->unk_006 = 0; + arg0->unk_008 = 0; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806950.s") + func_86805D50(arg0->unk_000, &arg0->unk_00C); + func_8001BB58(&sp1C->unk_000); -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806964.s") + sp1C->unk_030.x = sp1C->unk_030.y = sp1C->unk_030.z = 2.0f; +} -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806980.s") +void func_86805FFC(unk_D_868084D8* arg0) { + unk_D_868084D8_038* ptr; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806A50.s") + switch (arg0->unk_10) { + case 0: + arg0->unk_14 = D_8006F050; + arg0->unk_20 = arg0->unk_14; + break; -#pragma GLOBAL_ASM("asm/us/nonmatchings/fragments/14/fragment14_14A030/func_86806BF0.s") + case 1: + case 2: + arg0->unk_14.x = arg0->unk_38->unk_00C.x; + arg0->unk_14.y = arg0->unk_38->unk_00C.y; + arg0->unk_14.z = arg0->unk_38->unk_00C.z; + + arg0->unk_20.x = arg0->unk_14.x + D_86807150.x; + arg0->unk_20.y = arg0->unk_14.y + D_86807150.y; + arg0->unk_20.z = arg0->unk_14.z + D_86807150.z; + break; + + case 3: + ptr = arg0->unk_38; + arg0->unk_14 = ptr->unk_1D0; + arg0->unk_20 = arg0->unk_14; + break; + } +} + +s32 func_86806100(void) { + UNUSED s32 pad[4]; + s32 i; + s32 sp20; + s32 sp1C = 1; + s16 var_v0; + s32 temp_a0; + s32 var_a1; + s32 temp_v0; + + if (D_86809A10[1] < 3) { + sp20 = 0; + var_v0 = D_86809A0C; + } else { + sp20 = 1; + var_v0 = D_86809A0C - D_86807180[1].unk_12; + } + + temp_v0 = func_878001E8(var_v0); + var_a1 = 0; + + for (i = 0; i < 9; i++) { + if ((sp20 != 0) && (i == 1)) { + continue; + } + + temp_a0 = D_86807180[i].unk_12 + var_a1; + if ((temp_v0 >= var_a1) && (temp_v0 < temp_a0)) { + sp1C = i; + break; + } + + var_a1 = temp_a0; + } + + return sp1C; +} + +void func_868061E8(s32 arg0, unk_D_868084D8* arg1, s32 arg2, unk_D_868084D8_038* arg3) { + if (arg0 == 0) { + if (arg2 != -1) { + arg1->unk_00 = arg2; + } + arg1->unk_02 = 0; + arg1->unk_04 = 0; + arg1->unk_06 = 0; + arg1->unk_08.rgba = -1; + arg1->unk_0C = 0; + arg1->unk_10 = 0; + arg1->unk_38 = NULL; + arg1->unk_2C = 0.0f; + arg1->unk_40->unk_00.unk_01 &= ~1; + } else { + arg3->unk_008 = arg1; + arg1->unk_02 = 0; + arg1->unk_04 = 0; + arg1->unk_06 = 0; + arg1->unk_08.rgba = 0xFFFFFF80; + arg1->unk_0C = func_86806100(); + + D_86809A10[arg1->unk_0C]++; + + arg1->unk_10 = 1; + arg1->unk_2C = 0.0f; + arg1->unk_38 = arg3; + + if ((s16)func_878001E8(100) < D_86807180[arg1->unk_0C].unk_10) { + arg1->unk_02 |= 2; + } + + arg1->unk_40->unk_00.unk_01 |= 1; + + if (arg3->unk_006 >= 2) { + if ((D_86807180[arg1->unk_0C].unk_18 != 0) && (D_86807510 >= 0x3D)) { + func_8004D9B0(D_86807180[arg1->unk_0C].unk_14, 0, 0); + } + } + } + + arg1->unk_30 = 1.0f; + arg1->unk_34 = 0.0f; + + func_86805FFC(arg1); + + arg1->unk_3C = &D_86807338; +} + +unk_D_868084D8* func_86806388(void) { + s32 i; + unk_D_868084D8* var_v1 = D_868084D8; + + for (i = 0; i < 12; i++, var_v1++) { + if (var_v1->unk_0C == 0) { + break; + } + } + + if (i == 0xC) { + var_v1 = NULL; + } + return var_v1; +} + +void func_868063C4(unk_D_86808808* arg0) { + unk_D_868084D8* sp24; + + func_86805D50(arg0->unk_000, &arg0->unk_00C); + + if ((D_8780FC94 == 0) && (arg0->unk_008 == 0) && (arg0->unk_004 & 1)) { + arg0->unk_002 -= 1; + if (arg0->unk_002 <= 0) { + arg0->unk_002 = 0; + sp24 = func_86806388(); + if (sp24 != NULL) { + arg0->unk_006++; + if (D_868084D0 == 0) { + D_868084D0 = 1; + func_8004D9B0(0x50003, 0, 0); + func_8004B1CC(0x17); + } + func_868061E8(1, sp24, -1, arg0); + } + } + } + + arg0->unk_018.unk_024 = arg0->unk_00C; +} + +void func_868064BC(unk_D_868084D8* arg0) { + Gfx* gfx; + f32 var_fv0; + s32 var_v0; + + if (D_8780FC94 == 0) { + switch (arg0->unk_10) { + case 1: + if (arg0->unk_30 >= 0.0f) { + arg0->unk_34 -= 0.05f; + } else { + arg0->unk_34 += 0.05f; + } + + var_v0 = 0; + var_fv0 = arg0->unk_30; + arg0->unk_30 += arg0->unk_34; + if ((arg0->unk_30 * var_fv0) < 0.0f) { + if (arg0->unk_34 < 0.0f) { + var_fv0 = arg0->unk_34; + var_fv0 = 0.0f - var_fv0; + } else { + var_fv0 = arg0->unk_34; + } + + if (var_fv0 < 0.1f) { + var_v0 = 1; + arg0->unk_2C = 1.5f; + } + } + + if (var_v0 == 0) { + arg0->unk_34 *= 0.8f; + arg0->unk_2C = (arg0->unk_30 * -1.5f) + 1.5f; + } else { + func_86806868(arg0, 2, NULL); + } + break; + + case 3: + if (arg0->unk_04 > 0) { + arg0->unk_04--; + if (arg0->unk_04 > 0) { + var_fv0 = 1.0f - ((f32)(arg0->unk_06 - arg0->unk_04) / arg0->unk_06); + arg0->unk_2C = 1.5f * var_fv0; + } else { + arg0->unk_2C = 0.0f; + arg0->unk_40->unk_00.unk_01 &= ~1; + } + } + break; + } + } + + func_86805FFC(arg0); + gfx = func_80005F5C(sizeof(Gfx) * 16); + arg0->unk_3C = gfx; + + gSPVertex(gfx++, D_86807340, 4, 0); + + if (arg0->unk_08.a != 0xFF) { + gDPPipeSync(gfx++); + + gDPSetCombineMode(gfx++, G_CC_MODULATEIA_PRIM, G_CC_PASS2); + gDPSetPrimColor(gfx++, 0, 0, arg0->unk_08.r, arg0->unk_08.g, arg0->unk_08.b, arg0->unk_08.a); + } + + gDPLoadTextureBlock(gfx++, D_86807180[arg0->unk_0C].unk_04, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32, 0, + G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + gSP2Triangles(gfx++, 0, 3, 1, 0, 0, 2, 3, 0); + gSPEndDisplayList(gfx++); + + if (arg0->unk_08.a != 0xFF) { + arg0->unk_40->unk_00.unk_03 = 5; + } else { + arg0->unk_40->unk_00.unk_03 = 4; + } + + arg0->unk_40->unk_18 = arg0->unk_3C; + arg0->unk_40->unk_1C = arg0->unk_20; + arg0->unk_40->unk_28 = arg0->unk_2C; +} + +void func_86806860(void) { +} + +void func_86806868(unk_D_868084D8* arg0, s32 arg1, unk_D_86807558* arg2) { + unk_D_868084D8_038* temp_v0; + + arg0->unk_10 = arg1; + + switch (arg1) { + case 2: + arg0->unk_02 |= 1; + arg0->unk_04 = 0; + arg0->unk_08.a = 0xFF; + arg0->unk_2C = 1.5f; + break; + + case 3: + temp_v0 = arg0->unk_38; + temp_v0->unk_008 = 0; + temp_v0->unk_002 = 0x78; + arg0->unk_38 = arg2; + arg0->unk_04 = arg0->unk_06 = arg2->unk_0CC; + break; + + case 0: + D_86809A10[arg0->unk_0C]--; + func_868061E8(0, arg0, -1, NULL); + break; + } +} + +s32 func_86806930(unk_D_868084D8* arg0) { + return D_86807180[arg0->unk_0C].unk_00; +} + +s16 func_86806950(s32 arg0) { + return D_86809A10[arg0]; +} + +void func_86806964(s32 arg0) { + if ((arg0 >= 0) && (arg0 < 3)) { + D_86809A08 = arg0; + } +} + +void func_86806980(void) { + s32 i; + unk_D_86808808* var_v1; + + switch (D_86809A08) { + case 1: + for (i = 0, var_v1 = D_86808808; i < 12; i++, var_v1++) { + var_v1->unk_004 |= 1; + } + break; + + case 2: + for (i = 0, var_v1 = D_86808808; i < 12; i++, var_v1++) { + var_v1->unk_004 &= ~1; + } + break; + } + + D_86809A08 = 0; +} + +void func_86806A50(void) { + s32 i; + MainPoolState* temp_s2; + unk_D_868084D8* var_s0; + unk_func_80011B94* temp_a1; + unk_D_86808808* ptr; + Gfx* temp = D_86807338; + + D_868084D4 = 0.0f; + D_86809A08 = 0; + D_86809A0C = 0; + + for (i = 0; i < 9; i++) { + D_86809A0C += D_86807180[i].unk_12; + D_86809A10[i] = 0; + } + + D_868084D0 = 0; + temp_s2 = func_80002D10(main_pool_get_available(), 0); + + for (i = 0, ptr = D_86808808; i < 12; i++, ptr++) { + func_86805F94(ptr, i); + temp_a1 = func_80011B94(temp_s2, NULL, 4, D_868072C0); + ptr->unk_018.unk_000.unk_01 |= 1; + func_80012094(&ptr->unk_018, &temp_a1->unk_00); + } + + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + var_s0->unk_40 = func_80011B10(temp_s2, 0, 5, temp, &D_8006F050, var_s0->unk_2C); + func_868061E8(0, var_s0, i, NULL); + func_80012094(&D_800AC840, var_s0->unk_40); + } + + func_80002D60(temp_s2); +} + +void func_86806BF0(void) { + unk_D_86808808* ptr; + unk_D_868084D8* var_s0; + s32 i; + + if (D_86809A08 != 0) { + func_86806980(); + } + + if (D_8780FC94 == 0) { + D_868084D4 += 0.5f; + if (D_868084D4 >= 360.0f) { + D_868084D4 -= 360.0f; + } + } + + for (i = 0, ptr = D_86808808; i < 12; i++, ptr++) { + func_868063C4(ptr); + } + + for (i = 0, var_s0 = D_868084D8; i < 12; i++, var_s0++) { + if (var_s0->unk_0C != 0) { + func_868064BC(var_s0); + } + } +} diff --git a/src/fragments/2/fragment2.c b/src/fragments/2/fragment2.c index 6ece5996..4805d4c9 100644 --- a/src/fragments/2/fragment2.c +++ b/src/fragments/2/fragment2.c @@ -79,7 +79,7 @@ void func_878001D0(void) { D_8780FA20++; } -u32 func_878001E8(s32 arg0) { +u32 func_878001E8(u32 arg0) { u32 temp_a0 = guRandom() + D_8780FA20; u32 var_v1; diff --git a/src/fragments/2/fragment2.h b/src/fragments/2/fragment2.h index a501fd7d..ac1738a7 100644 --- a/src/fragments/2/fragment2.h +++ b/src/fragments/2/fragment2.h @@ -32,7 +32,7 @@ extern u16 D_8780FC98; void func_87800020(void); void func_8780005C(void); void func_878001D0(void); -u32 func_878001E8(s32 arg0); +u32 func_878001E8(u32 arg0); void func_8780024C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); void func_878009BC(s32 arg0, s32 arg1, s32 arg2, s32 arg3); void func_878010C8(s16 arg0); diff --git a/src/fragments/8/fragment8.c b/src/fragments/8/fragment8.c index 653e9664..bf8570ac 100644 --- a/src/fragments/8/fragment8.c +++ b/src/fragments/8/fragment8.c @@ -1404,7 +1404,7 @@ void func_8620369C(s32 arg0, UNUSED s32 arg1) { D_86204714 = func_8001E94C(0x16, 0); ASSET_LOAD(D_1000000, common_menu1_ui, 0); - ASSET_LOAD(D_4000000, run_rattata_run_flag_gfx, 0); + ASSET_LOAD(D_04000000, run_rattata_run_flag_gfx, 0); FRAGMENT_LOAD(fragment31); func_80004454((((u32)&D_8D000000 & 0x0FF00000) >> 0x14) - 0x10, _5C7A70_ROM_START, _5C7A70_ROM_END); diff --git a/tools/permuter_settings.toml b/tools/permuter_settings.toml index 3964bdb8..941ea7b8 100644 --- a/tools/permuter_settings.toml +++ b/tools/permuter_settings.toml @@ -17,6 +17,12 @@ POLY_XLU_DISP = "int" UNK_2B0_DISP = "int" UNK_2C0_DISP = "int" LIGHT_DISP = "int" +SQ = "float" +ABS = "float" +ABS_ALT = "float" +ABS_NORMALIZED = "float" +COSS = "float" +SINS = "float" [decompme.compilers] "tools/ido/linux/7.1/cc" = "ido7.1" diff --git a/yamls/us/rom.yaml b/yamls/us/rom.yaml index 909ac8e5..f6ab6a4b 100644 --- a/yamls/us/rom.yaml +++ b/yamls/us/rom.yaml @@ -898,12 +898,16 @@ - [0x144300, c, fragments/14/fragment14_144300] - [0x1462A0, c, fragments/14/fragment14_1462A0] - [0x14A030, c, fragments/14/fragment14_14A030] - - [0x14AFB0, data, fragments/14/fragment14_data] - - [0x14B660, rodata, fragments/14/fragment14_rodata_14B660] - - [0x14B6A0, rodata, fragments/14/fragment14_rodata_14B6A0] - - [0x14B790, rodata, fragments/14/fragment14_rodata_14B790] - - - {vram: 0x86807500, type: bss, name: fragments/14/fragment14_bss} + - [0x14AFB0, .data, fragments/14/fragment14_144300] + - [0x14B270, .data, fragments/14/fragment14_1462A0] + - [0x14B420, .data, fragments/14/fragment14_14A030] + - [0x14B660, .rodata, fragments/14/fragment14_144300] + - [0x14B6A0, .rodata, fragments/14/fragment14_1462A0] + - [0x14B790, .rodata, fragments/14/fragment14_14A030] + + - {vram: 0x86807500, type: .bss, name: fragments/14/fragment14_144300} + - {vram: 0x86807550, type: .bss, name: fragments/14/fragment14_1462A0} + - {vram: 0x868084D0, type: .bss, name: fragments/14/fragment14_14A030} - name: fragment14_relocs type: code