From 5b9a825cad7f7101a5619c4552e25142de32afec Mon Sep 17 00:00:00 2001 From: Maide <34639600+Kelebek1@users.noreply.github.com> Date: Tue, 21 Sep 2021 23:08:09 +0100 Subject: [PATCH] Bg_Hakugin_Post (#258) * Bg_Hakugin_Post * PR * a * PR * a --- include/functions.h | 1 + spec | 4 +- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c | 1031 ++++++++++++++++- .../ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h | 62 +- undefined_syms.txt | 5 + 5 files changed, 1045 insertions(+), 58 deletions(-) diff --git a/include/functions.h b/include/functions.h index 2b92417a83..bd61a60c45 100644 --- a/include/functions.h +++ b/include/functions.h @@ -834,6 +834,7 @@ void func_800B8E58(Actor* actor, u16 sfxId); void Audio_PlayActorSound2(Actor* actor, u16 sfxId); // void func_800B8FC0(void); void func_800B8F98(Actor* actor, u16 sfxId); +void func_800B8FE8(Actor* actor, u16 sfxId); void func_800B9010(Actor* actor, u16 sfxId); // void func_800B9038(void); // void func_800B9084(void); diff --git a/spec b/spec index a42617d9aa..da9ea49997 100644 --- a/spec +++ b/spec @@ -3295,9 +3295,7 @@ beginseg name "ovl_Bg_Hakugin_Post" compress include "build/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.o" - include "build/data/ovl_Bg_Hakugin_Post/ovl_Bg_Hakugin_Post.data.o" - include "build/data/ovl_Bg_Hakugin_Post/ovl_Bg_Hakugin_Post.bss.o" - include "build/data/ovl_Bg_Hakugin_Post/ovl_Bg_Hakugin_Post.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Hakugin_Post/ovl_Bg_Hakugin_Post_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index c0f5ecba1e..7df92fc577 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -1,3 +1,9 @@ +/* + * File: z_bg_hakugin_post.c + * Overlay: ovl_Bg_Hakugin_Post + * Description: Snowhead Temple Central Pillar + */ + #include "z_bg_hakugin_post.h" #define FLAGS 0x00000030 @@ -8,7 +14,34 @@ void BgHakuginPost_Init(Actor* thisx, GlobalContext* globalCtx); void BgHakuginPost_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakuginPost_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A9CA94(BgHakuginPost* this); +void func_80A9CAA8(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9CC84(BgHakuginPost* this); +void func_80A9CCA0(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9CD00(BgHakuginPost* this); +void func_80A9CD14(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9CE00(BgHakuginPost* this); +void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D0A0(BgHakuginPost* this); +void func_80A9D0B4(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4); +void func_80A9D260(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4); +void func_80A9D360(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D3E4(BgHakuginPost* this); +void func_80A9D434(BgHakuginPost* this, GlobalContext* globalCtx); +void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx); + +extern Gfx D_0600C1A8[]; +extern Gfx D_0600C568[]; +extern Gfx D_0600CA38[]; +extern Gfx D_0600CEC8[]; +extern Gfx D_0600D098[]; +extern CollisionHeader D_0600D3B0; + +BgHakuginPostColliders D_80A9DDC0; +BgHakuginPostUnkStruct D_80A9E028; + const ActorInit Bg_Hakugin_Post_InitVars = { ACTOR_BG_HAKUGIN_POST, ACTORCAT_BG, @@ -21,103 +54,997 @@ const ActorInit Bg_Hakugin_Post_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80A9D8B8 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_NONE, OC2_NONE, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000100, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_NONE, }, +typedef struct { + f32 unk_00; + u8 unk_04; +} BgHakuginPostUnkStruct3; + +static BgHakuginPostUnkStruct3 D_80A9D880[] = { + { 1200.0f, false }, { 600.0f, false }, { 900.0f, false }, { 870.0f, false }, + { 120.0f, false }, { 120.0f, true }, { 200.0f, true }, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE, + OC2_NONE, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000100, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, { 276, 0, 20, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A9D8F8[] = { +static Color_RGBA8 D_80A9D8E4 = { 250, 250, 250, 255 }; +static Color_RGBA8 D_80A9D8E8 = { 180, 180, 180, 255 }; +static Vec3f D_80A9D8EC = { 0.0f, 0.3f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void func_80A9ACD0(BgHakuginPostUnkStruct* arg0) { + bzero((void*)arg0, sizeof(BgHakuginPostUnkStruct)); +} -extern ColliderCylinderInit D_80A9D8B8; -extern InitChainEntry D_80A9D8F8[]; +void func_80A9ACF0(void) { + bzero(&D_80A9DDC0, sizeof(BgHakuginPostColliders)); +} -extern UNK_TYPE D_0600D3B0; +void func_80A9AD18(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9ACD0.s") + for (i = 0; i < unkStruct->count; i++) { + BgHakuginPostUnkStruct3* unkStruct3 = &D_80A9D880[unkStruct->unk_0000[i].unk_00]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9ACF0.s") + if ((unkStruct3->unk_04) && (D_80A9DDC0.count < 8)) { + ColliderCylinder* collider = &D_80A9DDC0.colliders[D_80A9DDC0.count]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9AD18.s") + Collider_InitCylinder(globalCtx, collider); + Collider_SetCylinder(globalCtx, collider, &this->dyna.actor, &sCylinderInit); + collider->dim.height = (s32)unkStruct3->unk_00 - 40; + unkStruct->unk_0000[i].collider = collider; + D_80A9DDC0.count++; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9AE3C.s") +void func_80A9AE3C(BgHakuginPost* this, GlobalContext* globalCtx) { + while (D_80A9DDC0.count != 0) { + D_80A9DDC0.count--; + Collider_DestroyCylinder(globalCtx, &D_80A9DDC0.colliders[D_80A9DDC0.count]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9AEB8.s") +void func_80A9AEB8(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9AFB4.s") + for (i = 0; i < unkStruct->count; i++) { + ColliderCylinder* collider = unkStruct->unk_0000[i].collider; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B160.s") + if ((collider != NULL) && (unkStruct->unk_0000[i].unk_34 == 1)) { + collider->dim.pos.x = unkStruct->unk_0000[i].unk_14.x + this->dyna.actor.home.pos.x; + collider->dim.pos.y = unkStruct->unk_0000[i].unk_14.y + this->unk_16C; + collider->dim.pos.z = unkStruct->unk_0000[i].unk_14.z + this->dyna.actor.home.pos.z; + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &collider->base); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B244.s") +void func_80A9AFB4(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { + s32 i; + s32 j; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B2B8.s") + if (unkStruct->count < ARRAY_COUNT(unkStruct->unk_0000)) { + for (i = 0; i < unkStruct->count; i++) { + if ((unkStruct->unk_0000[i].unk_34 == 0) || + (this->dyna.actor.world.pos.y < unkStruct->unk_0000[i].unk_08.y)) { + for (j = 10; j >= i; j--) { + bcopy(&unkStruct->unk_0000[j], &unkStruct->unk_0000[j + 1], 0x38); + } + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B32C.s") + unkStruct->unk_0000[i].unk_00 = BGHAKUGINPOST_GET_7(&this->dyna.actor); + Math_Vec3f_Copy(&unkStruct->unk_0000[i].unk_08, &this->dyna.actor.world.pos); + Math_Vec3f_Copy(&unkStruct->unk_0000[i].unk_14, &this->dyna.actor.world.pos); + unkStruct->unk_0000[i].unk_2E = BGHAKUGINPOST_GET_7F00(&this->dyna.actor); + if (D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_04) { + if (Flags_GetSwitch(globalCtx, unkStruct->unk_0000[i].unk_2E)) { + unkStruct->unk_0000[i].unk_34 = 5; + } else { + unkStruct->unk_0000[i].unk_34 = 1; + } + unkStruct->unk_0000[i].unk_2A = this->dyna.actor.cutscene; + unkStruct->unk_0000[i].unk_2C = ActorCutscene_GetAdditionalCutscene(unkStruct->unk_0000[i].unk_2A); + } else { + unkStruct->unk_0000[i].unk_34 = 1; + unkStruct->unk_0000[i].unk_2A = -1; + unkStruct->unk_0000[i].unk_2C = -1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B384.s") + unkStruct->unk_0000[i].unk_2F = 1; + unkStruct->count++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B3BC.s") +void func_80A9B160(BgHakuginPostUnkStruct* unkStruct, GlobalContext* globalCtx) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B46C.s") + for (i = 0; i < unkStruct->count; i++) { + Math_Vec3f_Copy(&unkStruct->unk_0000[i].unk_14, &unkStruct->unk_0000[i].unk_08); + unkStruct->unk_0000[i].unk_20 = 0.0f; + unkStruct->unk_0000[i].unk_24 = 0.0f; + unkStruct->unk_0000[i].unk_34 = 1; + if (D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_04 != 0) { + Actor_UnsetSwitchFlag(globalCtx, unkStruct->unk_0000[i].unk_2E); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9B554.s") +f32 func_80A9B244(BgHakuginPostUnkStruct* unkStruct) { + s32 i; + f32 ret = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9BC0C.s") + for (i = 0; i < unkStruct->count; i++) { + ret += D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_00; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9BD24.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9C058.s") +f32 func_80A9B2B8(BgHakuginPostUnkStruct* unkStruct) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9C18C.s") + for (i = unkStruct->count - 1; i >= 0; i--) { + if ((unkStruct->unk_0000[i].unk_34 == 1) || (unkStruct->unk_0000[i].unk_34 == 2)) { + return unkStruct->unk_0000[i].unk_14.y + D_80A9D880[unkStruct->unk_0000[i].unk_00].unk_00; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9C228.s") + return 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9C634.s") +BgHakuginPostUnkStruct1* func_80A9B32C(BgHakuginPostUnkStruct* unkStruct, BgHakuginPostUnkStruct1* unkStruct1) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9C854.s") + for (i = 0; i < unkStruct->count; i++) { + if (unkStruct1 == &unkStruct->unk_0000[i]) { + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/BgHakuginPost_Init.s") + i++; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/BgHakuginPost_Destroy.s") + if (i < unkStruct->count) { + return &unkStruct->unk_0000[i]; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CA94.s") + return NULL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CAA8.s") +void func_80A9B384(Vec3f* arg0) { + MtxF* matrix = SysMatrix_GetCurrentState(); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CC84.s") + matrix->mf[3][0] = arg0->x; + matrix->mf[3][1] = arg0->y; + matrix->mf[3][2] = arg0->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CCA0.s") +void func_80A9B3BC(BgHakuginPost* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = BGHAKUGINPOST_GET_7F00(&this->dyna.actor); + s32 sp24 = BGHAKUGINPOST_GET_7F00(&this->dyna.actor) + 1; + s32 sp20; + s32 sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CD00.s") + if (Flags_GetSwitch(globalCtx, sp28)) { + sp20 = true; + } else { + sp20 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CD14.s") + if (Flags_GetSwitch(globalCtx, sp24)) { + sp1C = true; + } else { + sp1C = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CE00.s") + if (!(sp20 | sp1C)) { + Actor_SetSwitchFlag(globalCtx, sp28); + this->unk_170 = true; + } else { + this->unk_170 = sp20; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9CE1C.s") + this->unk_174 = sp1C; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D0A0.s") +void func_80A9B46C(BgHakuginPost* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30 = BGHAKUGINPOST_GET_7F00(&this->dyna.actor); + s32 sp2C = BGHAKUGINPOST_GET_7F00(&this->dyna.actor) + 1; + s32 sp28; + s32 sp24; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D0B4.s") + if (Flags_GetSwitch(globalCtx, sp30)) { + sp28 = true; + } else { + sp28 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D1E0.s") + if (Flags_GetSwitch(globalCtx, sp2C)) { + sp24 = true; + } else { + sp24 = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D260.s") + if (!this->unk_170 && (sp28 == 1)) { + Actor_UnsetSwitchFlag(globalCtx, sp2C); + } else if (!this->unk_174 && (sp24 == 1)) { + Actor_UnsetSwitchFlag(globalCtx, sp30); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D2C4.s") + this->unk_170 = sp28; + this->unk_174 = sp24; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D360.s") +void func_80A9B554(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct, + BgHakuginPostUnkStruct1* unkStruct1) { + f32 spE4 = D_80A9D880[unkStruct1->unk_00].unk_00; + s32 i; + s16 val; + BgHakuginPostUnkStruct2* unkStruct2; + BgHakuginPostUnkStruct1* unkStruct1Temp; + f32 temp_f24; + f32 temp_f0; + f32 temp_f20; + f32 temp_f22; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + f32 temp_f28; + f32 temp_f6; + s32 pad[2]; + s16 temp_s1_3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D3E4.s") + spB8.x = unkStruct1->unk_14.x + this->dyna.actor.world.pos.x; + spB8.y = unkStruct1->unk_14.y + this->unk_16C; + spB8.z = unkStruct1->unk_14.z + this->dyna.actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D434.s") + spAC.x = Math_SinS(unkStruct1->unk_28) * unkStruct1->unk_20; + spAC.y = unkStruct1->unk_24; + spAC.z = Math_CosS(unkStruct1->unk_28) * unkStruct1->unk_20; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/BgHakuginPost_Update.s") + for (i = 0, val = 0; i < 65; i++, val += 0x3F0) { + unkStruct2 = &unkStruct->unk_02A4[i]; + unkStruct2->unk_00 = Rand_ZeroOne() * 0.038f + 0.002f; + temp_f24 = Math_SinS(val); + temp_f28 = Math_CosS(val); + temp_f20 = Rand_ZeroOne(); + temp_f20 = (1.0f - SQ(temp_f20)) * 198.0f; + unkStruct2->unk_04.x = temp_f24 * temp_f20 + spB8.x; + unkStruct2->unk_04.y = Rand_ZeroOne() * spE4 + spB8.y; + unkStruct2->unk_04.z = temp_f28 * temp_f20 + spB8.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Post/func_80A9D61C.s") + temp_f0 = unkStruct2->unk_00 - 0.002f; + temp_f22 = temp_f0 * -(450.0f / 19.0f) + 1.0f; + unkStruct2->unk_10.x = Rand_ZeroOne() * 60.0f; + temp_f20 = temp_f0 * (10.0f / 19.0f) + 0.06f; + + unkStruct2->unk_10.x = ((unkStruct2->unk_10.x - 30.0f) + temp_f24 * 50.0f) * temp_f22 + spAC.x * temp_f20; + unkStruct2->unk_10.y = (Rand_ZeroOne() * 102.0f + 18.0f) * temp_f22 + spAC.y * temp_f20; + temp_f0 = spAC.z; + unkStruct2->unk_10.z = ((Rand_ZeroOne() * 60.0f - 30.0f) + temp_f28 * 50.0f) * temp_f22 + temp_f0 * temp_f20; + unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.02f; + unkStruct2->unk_20.x = Rand_Next() >> 0x10; + unkStruct2->unk_20.y = Rand_Next() >> 0x10; + unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_26 = (Rand_Next() & 0x3FFF) - 0x1FFF; + unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; + unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; + unkStruct2->unk_2C = (Rand_Next() & 0x1F) + 0x4B; + unkStruct2->unk_2D = 2; + } + + for (i = 0, val = 0; i < 22; i++, val += 0xBA2) { + temp_f20 = Rand_ZeroOne() * 60.0f + 220.0f; + spA0.x = Math_SinS(val) * temp_f20 + spB8.x; + spA0.y = (Rand_ZeroOne() * 1.2f - 0.1f) * spE4 + spB8.y; + spA0.z = Math_CosS(val) * temp_f20 + spB8.z; + func_800B0E48(globalCtx, &spA0, &D_801D15B0, &D_80A9D8EC, &D_80A9D8E4, &D_80A9D8E8, + (Rand_Next() >> 0x1A) + 0x82, (Rand_Next() >> 0x1A) + 0x6E); + } + + unkStruct1Temp = func_80A9B32C(unkStruct, unkStruct1); + if (unkStruct1Temp != NULL) { + temp_f6 = this->unk_16C + func_80A9B2B8(unkStruct) - 40.0f; + spB8.x = unkStruct1Temp->unk_14.x + this->dyna.actor.world.pos.x; + spB8.y = unkStruct1Temp->unk_14.y + this->unk_16C; + spB8.z = unkStruct1Temp->unk_14.z + this->dyna.actor.world.pos.z; + + for (i = 65, val = 0; i < ARRAY_COUNT(unkStruct->unk_02A4); i++, val += 0x4A7) { + unkStruct2 = &unkStruct->unk_02A4[i]; + unkStruct2->unk_00 = Rand_ZeroOne() * 0.007f + 0.002f; + temp_s1_3 = (Rand_Next() & 0x7FF) + val; + temp_f24 = Math_SinS(temp_s1_3); + temp_f28 = Math_CosS(temp_s1_3); + unkStruct2->unk_04.x = temp_f24 * 225.5f + spB8.x; + if (i & 1) { + unkStruct2->unk_04.y = Rand_ZeroOne() * D_80A9D880[unkStruct1Temp->unk_00].unk_00 + spB8.y; + } else { + unkStruct2->unk_04.y = temp_f6 - Rand_ZeroOne() * 350.0f; + } + unkStruct2->unk_04.z = temp_f28 * 225.5f + spB8.z; + unkStruct2->unk_10.x = Rand_ZeroOne() + temp_f24 * 7.0f; + unkStruct2->unk_10.y = 0.0f; + unkStruct2->unk_10.z = Rand_ZeroOne() + temp_f28 * 7.0f; + unkStruct2->unk_1C = 0.90999997f - (0.04f - unkStruct2->unk_00) * (500.0f / 19.0f) * 0.075f; + unkStruct2->unk_20.x = Rand_Next() >> 0x10; + unkStruct2->unk_20.y = Rand_Next() >> 0x10; + unkStruct2->unk_20.z = Rand_Next() >> 0x10; + unkStruct2->unk_26 = (Rand_Next() & 0x1FFF) - 0xFFF; + unkStruct2->unk_28 = (Rand_Next() & 0x1FFF) - 0xFFF; + unkStruct2->unk_2A = (Rand_Next() & 0x1FFF) - 0xFFF; + unkStruct2->unk_2C = (Rand_Next() & 0x1F) + 0x41; + unkStruct2->unk_2D = 0; + } + } + unkStruct->unk_1924 = true; +} + +void func_80A9BC0C(BgHakuginPostUnkStruct* unkStruct) { + s32 i; + + if (unkStruct->unk_1924) { + unkStruct->unk_1924 = false; + + for (i = 0; i < ARRAY_COUNT(unkStruct->unk_02A4); i++) { + BgHakuginPostUnkStruct2* unkStruct2 = &unkStruct->unk_02A4[i]; + + if (unkStruct2->unk_2C > 0) { + unkStruct2->unk_10.y = unkStruct2->unk_10.y + -4.0f; + Math_Vec3f_Scale(&unkStruct2->unk_10, unkStruct2->unk_1C); + unkStruct2->unk_04.x += unkStruct2->unk_10.x; + unkStruct2->unk_04.y += unkStruct2->unk_10.y; + unkStruct2->unk_04.z += unkStruct2->unk_10.z; + unkStruct2->unk_20.x += unkStruct2->unk_26; + unkStruct2->unk_20.y += unkStruct2->unk_28; + unkStruct2->unk_20.z += unkStruct2->unk_2A; + unkStruct2->unk_2C--; + unkStruct->unk_1924 = true; + } + } + } +} + +void func_80A9BD24(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { + s32 i; + s32 j; + + for (i = 0; i < unkStruct->count; i++) { + if ((unkStruct->unk_0000[i].unk_34 == 5) || (unkStruct->unk_0000[i].unk_34 == 4)) { + unkStruct->unk_0000[i].unk_24 = 0.0f; + } else { + unkStruct->unk_0000[i].unk_24 -= 2.8f; + unkStruct->unk_0000[i].unk_24 *= 0.9f; + } + + if ((unkStruct->unk_0000[i].unk_34 == 2) || (unkStruct->unk_0000[i].unk_34 == 3)) { + unkStruct->unk_0000[i].unk_20 = 25.0f; + } else { + unkStruct->unk_0000[i].unk_20 = 0.0f; + } + + unkStruct->unk_0000[i].unk_14.x += Math_SinS(unkStruct->unk_0000[i].unk_28) * unkStruct->unk_0000[i].unk_20; + unkStruct->unk_0000[i].unk_14.z = + Math_CosS(unkStruct->unk_0000[i].unk_28) * unkStruct->unk_0000[i].unk_20 + unkStruct->unk_0000[i].unk_14.z; + unkStruct->unk_0000[i].unk_14.y += unkStruct->unk_0000[i].unk_24; + + if ((unkStruct->unk_0000[i].unk_34 == 1) || (unkStruct->unk_0000[i].unk_34 == 2)) { + for (j = i - 1; j >= 0; j--) { + if ((unkStruct->unk_0000[j].unk_34 == 1) || (unkStruct->unk_0000[j].unk_34 == 2)) { + break; + } + } + + if (j < 0) { + if (unkStruct->unk_0000[i].unk_14.y < 0.0f) { + unkStruct->unk_0000[i].unk_14.y = 0.0f; + unkStruct->unk_0000[i].unk_24 = 0.0f; + if (unkStruct->unk_0000[i].unk_2F & 1) { + unkStruct->unk_0000[i].unk_2F &= ~2; + } else { + unkStruct->unk_0000[i].unk_2F |= (2 | 1); + } + } else { + unkStruct->unk_0000[i].unk_2F &= ~(2 | 1); + } + } else { + if (unkStruct->unk_0000[i].unk_14.y < + (unkStruct->unk_0000[j].unk_14.y + D_80A9D880[unkStruct->unk_0000[j].unk_00].unk_00)) { + unkStruct->unk_0000[i].unk_14.y = + unkStruct->unk_0000[j].unk_14.y + D_80A9D880[unkStruct->unk_0000[j].unk_00].unk_00; + unkStruct->unk_0000[i].unk_24 = 0.0f; + if (unkStruct->unk_0000[i].unk_2F & 1) { + unkStruct->unk_0000[i].unk_2F &= ~2; + } else { + unkStruct->unk_0000[i].unk_2F |= (2 | 1); + } + } else { + unkStruct->unk_0000[i].unk_2F &= ~(2 | 1); + } + } + } + + if (unkStruct->unk_0000[i].unk_34 == 2) { + if (Math3D_XZLengthSquared(unkStruct->unk_0000[i].unk_14.x, unkStruct->unk_0000[i].unk_14.z) > + SQ(440.0f) + 0.02f) { + unkStruct->unk_0000[i].unk_34 = 3; + } + } else if (unkStruct->unk_0000[i].unk_34 == 3) { + if (Math3D_XZLengthSquared(unkStruct->unk_0000[i].unk_14.x, unkStruct->unk_0000[i].unk_14.z) > 278784.03f) { + func_80A9B554(this, globalCtx, unkStruct, &unkStruct->unk_0000[i]); + func_8019F128(NA_SE_EV_GLASSBROKEN_IMPACT); + unkStruct->unk_0000[i].unk_34 = 4; + unkStruct->unk_0000[i].unk_30 = 30; + } + } else if (unkStruct->unk_0000[i].unk_34 == 4) { + unkStruct->unk_0000[i].unk_30--; + if (unkStruct->unk_0000[i].unk_30 <= 0) { + unkStruct->unk_0000[i].unk_34 = 5; + } + } + } +} + +void func_80A9C058(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { + s32 i; + s32 pad; + Vec3f sp44; + s32 pad2[2]; + s16 quake; + + if (this->unk_170 == 0) { + for (i = 0; i < unkStruct->count; i++) { + BgHakuginPostUnkStruct1* unkStruct1 = &unkStruct->unk_0000[i]; + + if (unkStruct1->unk_2F & 2) { + sp44.x = this->dyna.actor.home.pos.x + unkStruct1->unk_14.x; + sp44.y = this->unk_16C + unkStruct1->unk_14.y; + sp44.z = this->dyna.actor.home.pos.z + unkStruct1->unk_14.z; + func_8013ECE0(Math3D_DistanceSquared(&sp44, &PLAYER->actor.world.pos), 255, 20, 150); + quake = Quake_Add(ACTIVE_CAM, 3); + Quake_SetSpeed(quake, 20000); + Quake_SetQuakeValues(quake, 7, 0, 0, 0); + Quake_SetCountdown(quake, 12); + if (this->unk_179 <= 0) { + func_8019F128(NA_SE_EV_STONEDOOR_STOP); + this->unk_179 = 40; + } + break; + } + } + } +} + +void func_80A9C18C(BgHakuginPost* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = PLAYER; + Camera* activeCam = ACTIVE_CAM; + s16 quake; + + func_8013ECE0(Math3D_XZDistanceSquared(player->actor.world.pos.x, player->actor.world.pos.z, + this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.z), + 255, 20, 150); + quake = Quake_Add(activeCam, 3); + Quake_SetSpeed(quake, 17232); + Quake_SetQuakeValues(quake, 6, 0, 0, 0); + Quake_SetCountdown(quake, 20); +} + +void func_80A9C228(BgHakuginPost* this, GlobalContext* globalCtx, BgHakuginPostUnkStruct* unkStruct) { + s32 val; + BgHakuginPostUnkStruct1* spC8 = NULL; + BgHakuginPostUnkStruct1* spC4; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + s32 i; + f32 temp_f20; + s16 temp_s0; + s32 j; + + for (i = 0; i < unkStruct->count; i++) { + spC4 = spC8; + spC8 = &unkStruct->unk_0000[i]; + + if (unkStruct->unk_0000[i].unk_34 == 2) { + for (j = 0, val = 0; j < 3; j++, val += 0x5555) { + temp_f20 = Rand_ZeroOne() * 264.0f; + temp_s0 = (Rand_Next() & 0xFFF) + val; + spB8.x = Math_SinS(temp_s0) * temp_f20 + spC8->unk_14.x; + spB8.z = Math_CosS(temp_s0) * temp_f20 + spC8->unk_14.z; + + if (Math3D_XZLengthSquared(spB8.x, spB8.z) < SQ(550.0f) + 0.03f) { + spB8.x += this->dyna.actor.home.pos.x; + spB8.y = spC8->unk_14.y + this->unk_16C + 20.0f; + spB8.z += this->dyna.actor.home.pos.z; + + spAC.x = Math_SinS(spC8->unk_28) * 3.0f; + spAC.y = 0.0f; + spAC.z = Math_CosS(spC8->unk_28) * 3.0f; + + spA0.x = spAC.x * -0.08f; + spA0.y = 0.2f; + spA0.z = spAC.z * -0.08f; + + func_800B0E48(globalCtx, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, 0x50, + (s32)(Rand_ZeroOne() * 60.0f) + 110); + } + } + } + + if ((unkStruct->unk_0000[i].unk_2F & 2) && (spC4 != NULL) && ((spC4->unk_34 == 3) || (spC4->unk_34 == 4))) { + for (j = 0, val = 0; j < 18; j++, val += 0xE38) { + temp_f20 = (Rand_ZeroOne() * 0.3f + 1.0f) * 220.0f; + temp_s0 = (Rand_Next() & 0xFFF) + val; + spB8.x = Math_SinS(temp_s0) * temp_f20; + spB8.z = Math_CosS(temp_s0) * temp_f20; + + spAC.x = spB8.x * (4.0f / 275.0f); + spAC.y = 0.0f; + spAC.z = spB8.z * (4.0f / 275.0f); + + spB8.x += unkStruct->unk_0000[i].unk_14.x + this->dyna.actor.home.pos.x; + spB8.y = unkStruct->unk_0000[i].unk_14.y + this->unk_16C; + spB8.z += unkStruct->unk_0000[i].unk_14.z + this->dyna.actor.home.pos.z; + + spA0.x = spAC.x * -0.08f; + spA0.y = 0.2f; + spA0.z = spAC.z * -0.08f; + + func_800B0E48(globalCtx, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, 0xC8, + (s32)(Rand_ZeroOne() * 70.0f) + 100); + } + } + } +} + +void func_80A9C634(BgHakuginPost* this, GlobalContext* globalCtx) { + s32 i; + Vec3f spB8; + Vec3f spAC; + Vec3f spA0; + s32 pad[2]; + s32 temp_s4; + f32 temp_f20; + + for (i = 0; i < 70; i++) { + temp_s4 = (s32)(Rand_ZeroOne() * 6553.0f) + i * 0x1999; + temp_f20 = ((Rand_ZeroOne() * 0.3f) + 1.0f) * 220.0f; + + spB8.x = Math_SinS(temp_s4); + spB8.y = i * -(60.0f / 7.0f); + spB8.z = Math_CosS(temp_s4); + + spAC.x = spB8.x * 19.0f; + spAC.y = 0.0f; + spAC.z = spB8.z * 19.0f; + + spB8.x = (spB8.x * temp_f20) + this->dyna.actor.home.pos.x; + spB8.y += this->unk_164 + this->unk_160; + spB8.z = (spB8.z * temp_f20) + this->dyna.actor.home.pos.z; + + spA0.x = spAC.x * -0.08f; + spA0.y = 0.8f; + spA0.z = spAC.z * -0.08f; + func_800B0DE0(globalCtx, &spB8, &spAC, &spA0, &D_80A9D8E4, &D_80A9D8E8, (s32)(Rand_ZeroOne() * 400.0f) + 2500, + -250); + } +} + +void func_80A9C854(BgHakuginPost* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp38 = false; + s32 pad2; + s32 i; + s32 pad3; + s32 sp28; + + if (this->unk_174 != 0) { + if (Flags_GetSwitch(globalCtx, this->dyna.actor.home.rot.z & 0x7F)) { + sp28 = true; + + for (i = 0; i < D_80A9E028.count; i++) { + ColliderCylinder* collider = D_80A9E028.unk_0000[i].collider; + + if ((collider != NULL) && Flags_GetSwitch(globalCtx, D_80A9E028.unk_0000[i].unk_2E)) { + sp28 = false; + break; + } + } + + if (sp28) { + sp38 = true; + } + } + } + + if (sp38) { + Actor_SetSwitchFlag(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + } else { + Actor_UnsetSwitchFlag(globalCtx, this->dyna.actor.home.rot.x & 0x7F); + } +} + +void BgHakuginPost_Init(Actor* thisx, GlobalContext* globalCtx) { + static s32 D_80A9D8FC = 1; + BgHakuginPost* this = THIS; + + if (D_80A9D8FC != 0) { + D_80A9D8FC = 0; + func_80A9ACD0(&D_80A9E028); + func_80A9ACF0(); + } + + if (BGHAKUGINPOST_GET_7(&this->dyna.actor) == 7) { + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.world.rot.z = 0; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + BcCheck3_BgActorInit(&this->dyna, 1); + BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_0600D3B0); + func_80A9B3BC(this, globalCtx); + func_80A9CA94(this); + } else { + func_80A9AFB4(this, globalCtx, &D_80A9E028); + Actor_MarkForDeath(&this->dyna.actor); + } +} + +void BgHakuginPost_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginPost* this = THIS; + + if (BGHAKUGINPOST_GET_7(&this->dyna.actor) == 7) { + BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + func_80A9AE3C(this, globalCtx); + } +} + +void func_80A9CA94(BgHakuginPost* this) { + this->actionFunc = func_80A9CAA8; +} + +void func_80A9CAA8(BgHakuginPost* this, GlobalContext* globalCtx) { + s32 pad[2]; + s32 i; + + this->unk_160 = func_80A9B244(&D_80A9E028); + Math_Vec3f_Copy(&this->dyna.actor.home.pos, &D_80A9E028.unk_0000[0].unk_08); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + this->unk_168 = this->dyna.actor.home.pos.y; + + if (1) {} + + this->unk_164 = this->unk_168 - 1800.0f; + if (this->unk_170 != 0) { + for (i = 0; i < D_80A9E028.count; i++) { + D_80A9E028.unk_0000[i].unk_08.x -= this->dyna.actor.home.pos.x; + D_80A9E028.unk_0000[i].unk_08.y -= this->dyna.actor.home.pos.y; + D_80A9E028.unk_0000[i].unk_08.z -= this->dyna.actor.home.pos.z; + + D_80A9E028.unk_0000[i].unk_14.x = D_80A9E028.unk_0000[i].unk_08.x; + D_80A9E028.unk_0000[i].unk_14.y = D_80A9E028.unk_0000[i].unk_08.y; + D_80A9E028.unk_0000[i].unk_14.z = D_80A9E028.unk_0000[i].unk_08.z; + } + } else { + f32 phi_f0 = 0.0f; + + for (i = 0; i < D_80A9E028.count; i++) { + D_80A9E028.unk_0000[i].unk_08.x -= this->dyna.actor.home.pos.x; + D_80A9E028.unk_0000[i].unk_08.y -= this->dyna.actor.home.pos.y; + D_80A9E028.unk_0000[i].unk_08.z -= this->dyna.actor.home.pos.z; + + D_80A9E028.unk_0000[i].unk_14.x = D_80A9E028.unk_0000[i].unk_08.x; + D_80A9E028.unk_0000[i].unk_14.y = phi_f0; + D_80A9E028.unk_0000[i].unk_14.z = D_80A9E028.unk_0000[i].unk_08.z; + + if (D_80A9E028.unk_0000[i].unk_34 == 1) { + phi_f0 += D_80A9D880[D_80A9E028.unk_0000[i].unk_00].unk_00; + } + } + } + + func_80A9AD18(this, globalCtx, &D_80A9E028); + this->dyna.actor.draw = func_80A9D61C; + if (this->unk_170 != 0) { + func_80A9CC84(this); + } else { + func_80A9CE00(this); + } +} + +void func_80A9CC84(BgHakuginPost* this) { + this->actionFunc = func_80A9CCA0; + this->unk_16C = this->unk_164; +} + +void func_80A9CCA0(BgHakuginPost* this, GlobalContext* globalCtx) { + if (this->unk_174 != 0) { + func_80A9D1E0(this, func_80A9CD00, (this->unk_164 - this->dyna.actor.home.pos.y) + 100.0f, 60, + this->dyna.actor.cutscene); + } +} + +void func_80A9CD00(BgHakuginPost* this) { + this->actionFunc = func_80A9CD14; +} + +void func_80A9CD14(BgHakuginPost* this, GlobalContext* globalCtx) { + f32 temp_f12 = + Math_SinS((this->unk_16C - this->unk_164) * 0x8000 / (this->unk_168 - this->unk_164)) * 140.0f + 4.0f; + + temp_f12 = CLAMP_MAX(temp_f12, 40.0f); + this->unk_16C += temp_f12; + if (this->unk_168 <= this->unk_16C) { + func_80A9C18C(this, globalCtx); + func_8019F128(NA_SE_EV_STONEDOOR_STOP); + func_80A9CE00(this); + } else { + func_800B8FE8(&this->dyna.actor, NA_SE_EV_ICE_PILLAR_RISING - SFX_FLAG); + } +} + +void func_80A9CE00(BgHakuginPost* this) { + this->actionFunc = func_80A9CE1C; + this->unk_16C = this->unk_168; +} + +void func_80A9CE1C(BgHakuginPost* this, GlobalContext* globalCtx) { + s32 pad; + Player* player = PLAYER; + ColliderCylinder* collider; + s32 yDiff; + s32 i; + s16 temp; + f32 temp_f0; + f32 temp_f2; + + if (this->unk_170 != 0) { + func_80A9D1E0(this, func_80A9D0A0, (this->unk_164 - this->dyna.actor.home.pos.y) + 100.0f, 0x3C, + ActorCutscene_GetAdditionalCutscene(this->dyna.actor.cutscene)); + return; + } + + for (i = 0; i < D_80A9E028.count; i++) { + collider = D_80A9E028.unk_0000[i].collider; + if ((collider != NULL) && (collider->base.acFlags & AT_HIT) && (D_80A9E028.unk_0000[i].unk_34 == 1)) { + temp_f2 = this->unk_16C; + yDiff = ABS_ALT(BINANG_SUB(this->dyna.actor.yawTowardsPlayer, player->actor.shape.rot.y)); + temp_f0 = temp_f2 + D_80A9E028.unk_0000[i].unk_14.y; + if ((yDiff > 0x5000) && ((temp_f0 - 60.0f) < player->actor.world.pos.y) && + (player->actor.world.pos.y < ((temp_f0 + D_80A9D880[D_80A9E028.unk_0000[i].unk_00].unk_00) - 70.0f))) { + D_80A9E028.unk_0000[i].unk_20 = 20.0f; + temp = (s16)(this->dyna.actor.yawTowardsPlayer + 0x58F0); + D_80A9E028.unk_0000[i].unk_28 = ((s16)(player->actor.shape.rot.y - temp) / 3) + temp; + D_80A9E028.unk_0000[i].unk_34 = 2; + func_800B8E58(&player->actor, NA_SE_IT_HAMMER_HIT); + func_8019F128(NA_SE_EV_SLIDE_DOOR_OPEN); + Actor_SetSwitchFlag(globalCtx, D_80A9E028.unk_0000[i].unk_2E); + this->unk_178 = 20; + func_80A9D2C4(this, func_80A9CE00, D_80A9E028.unk_0000[i].unk_14.y + 50.0f, + D_80A9E028.unk_0000[i].unk_2A, D_80A9E028.unk_0000[i].unk_2C); + break; + } + } + } + + for (i = 0; i < D_80A9E028.count; i++) { + collider = D_80A9E028.unk_0000[i].collider; + if (collider != NULL) { + collider->base.acFlags &= ~AT_HIT; + } + } + + if (this->unk_178 <= 0) { + func_80A9AEB8(this, globalCtx, &D_80A9E028); + } +} + +void func_80A9D0A0(BgHakuginPost* this) { + this->actionFunc = func_80A9D0B4; +} + +void func_80A9D0B4(BgHakuginPost* this, GlobalContext* globalCtx) { + f32 sp24 = (this->unk_164 + this->unk_160) - func_80A9B2B8(&D_80A9E028); + f32 temp_f14 = Math_SinS((this->unk_16C - sp24) * 0x8000 / (this->unk_168 - sp24)) * 140.0f + 4.0f; + + temp_f14 = CLAMP_MAX(temp_f14, 40.0f); + this->unk_16C -= temp_f14; + if (this->unk_16C <= sp24) { + func_80A9C634(this, globalCtx); + func_80A9B160(&D_80A9E028, globalCtx); + this->unk_16C = this->unk_164; + func_80A9C18C(this, globalCtx); + func_8019F128(NA_SE_EV_STONEDOOR_STOP); + func_80A9CC84(this); + } else { + func_800B8FE8(&this->dyna.actor, NA_SE_EV_ICE_PILLAR_FALL - SFX_FLAG); + } +} + +void func_80A9D1E0(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4) { + this->unkFunc = unkFunc; + this->unk_184 = arg4; + this->unk_180 = ActorCutscene_GetLength(arg4); + if (this->unk_180 < 0) { + this->unk_180 = arg3; + } + this->dyna.actor.focus.pos.x = this->dyna.actor.home.pos.x; + this->dyna.actor.focus.pos.y = this->unk_16C + arg2; + this->dyna.actor.focus.pos.z = this->dyna.actor.home.pos.z; + this->actionFunc = func_80A9D260; +} + +void func_80A9D260(BgHakuginPost* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_184)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_184, &this->dyna.actor); + this->unkFunc(this); + } else { + ActorCutscene_SetIntentToPlay(this->unk_184); + } +} + +void func_80A9D2C4(BgHakuginPost* this, BgHakuginPostFunc unkFunc, f32 arg2, s16 arg3, s16 arg4) { + this->unkFunc = unkFunc; + this->unk_184 = arg3; + this->unk_186 = arg4; + this->unk_180 = -1; + this->unk_180 = ActorCutscene_GetLength(arg3); + if (this->unk_180 < 0) { + this->unk_180 = 15; + } + this->dyna.actor.focus.pos.x = this->dyna.actor.home.pos.x; + this->dyna.actor.focus.pos.y = this->unk_16C + arg2; + this->dyna.actor.focus.pos.z = this->dyna.actor.home.pos.z; + this->actionFunc = func_80A9D360; +} + +void func_80A9D360(BgHakuginPost* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_184)) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_184, &this->dyna.actor); + if (this->unk_186 >= 0) { + func_80A9D3E4(this); + } else { + this->unkFunc(this); + } + } else { + ActorCutscene_SetIntentToPlay(this->unk_184); + } +} + +void func_80A9D3E4(BgHakuginPost* this) { + this->unk_182 = ActorCutscene_GetLength(this->unk_186); + if (this->unk_182 < 0) { + this->unk_182 = 30; + } + this->actionFunc = func_80A9D434; +} + +void func_80A9D434(BgHakuginPost* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->unk_186) != 0) { + ActorCutscene_StartAndSetUnkLinkFields(this->unk_186, &this->dyna.actor); + this->unkFunc(this); + } else { + ActorCutscene_SetIntentToPlay(this->unk_186); + } +} + +void BgHakuginPost_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakuginPost* this = THIS; + f32 temp; + + func_80A9B46C(this, globalCtx); + if ((this->unk_180 >= 0) && ((this->actionFunc != func_80A9D260) || (this->actionFunc != func_80A9D360))) { + this->unk_180--; + if (this->unk_180 < 0) { + ActorCutscene_Stop(this->unk_184); + } + } + + if ((this->unk_182 >= 0) && (this->actionFunc != func_80A9D434)) { + this->unk_182--; + if (this->unk_182 < 0) { + ActorCutscene_Stop(this->unk_186); + } + } + + if (this->unk_178 > 0) { + this->unk_178--; + } + + if (this->unk_179 > 0) { + this->unk_179--; + } + + func_80A9BC0C(&D_80A9E028); + this->actionFunc(this, globalCtx); + func_80A9BD24(this, globalCtx, &D_80A9E028); + func_80A9C058(this, globalCtx, &D_80A9E028); + func_80A9C228(this, globalCtx, &D_80A9E028); + temp = func_80A9B2B8(&D_80A9E028); + this->dyna.actor.scale.y = temp + this->unk_16C - this->dyna.actor.home.pos.y; + this->dyna.actor.scale.y *= 0.0025f; + if (thisx->scale.y < 0.0001f) { + thisx->scale.y = 0.0001f; + } + + func_80A9C854(this, globalCtx); +} + +void func_80A9D61C(Actor* thisx, GlobalContext* globalCtx) { + static Gfx* D_80A9D900[] = { + D_0600C1A8, D_0600C568, NULL, NULL, D_0600CA38, D_0600CEC8, NULL, + }; + static Gfx* D_80A9D91C[] = { + D_0600D098, + D_0600D098, + D_0600D098, + D_0600D098, + }; + BgHakuginPost* this = THIS; + BgHakuginPostUnkStruct1* unkStruct1; + BgHakuginPostUnkStruct2* unkStruct2; + Vec3f sp68; + s32 i; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + SysMatrix_SetStateRotationAndTranslation(this->dyna.actor.world.pos.x, this->dyna.actor.world.pos.y, + this->dyna.actor.world.pos.z, &this->dyna.actor.shape.rot); + Matrix_Scale(0.1f, 0.1f, 0.1f, MTXMODE_APPLY); + + for (i = 0; i < D_80A9E028.count; i++) { + unkStruct1 = &D_80A9E028.unk_0000[i]; + if (unkStruct1->unk_34 != 5 && unkStruct1->unk_34 != 4) { + sp68.x = unkStruct1->unk_14.x + this->dyna.actor.home.pos.x; + sp68.y = unkStruct1->unk_14.y + this->unk_16C; + sp68.z = unkStruct1->unk_14.z + this->dyna.actor.home.pos.z; + func_80A9B384(&sp68); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80A9D900[unkStruct1->unk_00]); + } + } + + if (D_80A9E028.unk_1924) { + for (i = 0; i < ARRAY_COUNT(D_80A9E028.unk_02A4); i++) { + unkStruct2 = &D_80A9E028.unk_02A4[i]; + if (unkStruct2->unk_2C > 0) { + SysMatrix_SetStateRotationAndTranslation(unkStruct2->unk_04.x, unkStruct2->unk_04.y, + unkStruct2->unk_04.z, &unkStruct2->unk_20); + Matrix_Scale(unkStruct2->unk_00, unkStruct2->unk_00, unkStruct2->unk_00, MTXMODE_APPLY); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_80A9D91C[unkStruct2->unk_2D]); + } + } + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h index 76dbfa0a75..4a574bc24f 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.h @@ -6,12 +6,68 @@ struct BgHakuginPost; typedef void (*BgHakuginPostActionFunc)(struct BgHakuginPost*, GlobalContext*); +typedef void (*BgHakuginPostFunc)(struct BgHakuginPost*); + +#define BGHAKUGINPOST_GET_7(thisx) ((thisx)->params & 7) +#define BGHAKUGINPOST_GET_7F00(thisx) (((thisx)->params >> 8) & 0x7F) + +typedef struct { + /* 0x00 */ s32 unk_00; + /* 0x04 */ ColliderCylinder* collider; + /* 0x08 */ Vec3f unk_08; + /* 0x14 */ Vec3f unk_14; + /* 0x20 */ f32 unk_20; + /* 0x24 */ f32 unk_24; + /* 0x28 */ s16 unk_28; + /* 0x2A */ s16 unk_2A; + /* 0x2C */ s16 unk_2C; + /* 0x2E */ u8 unk_2E; + /* 0x2F */ u8 unk_2F; + /* 0x30 */ s8 unk_30; + /* 0x34 */ s32 unk_34; +} BgHakuginPostUnkStruct1; // size = 0x38 + +typedef struct { + /* 0x00 */ f32 unk_00; + /* 0x04 */ Vec3f unk_04; + /* 0x10 */ Vec3f unk_10; + /* 0x1C */ f32 unk_1C; + /* 0x20 */ Vec3s unk_20; + /* 0x26 */ s16 unk_26; + /* 0x28 */ s16 unk_28; + /* 0x2A */ s16 unk_2A; + /* 0x2C */ s8 unk_2C; + /* 0x2D */ s8 unk_2D; +} BgHakuginPostUnkStruct2; // size = 0x30 + +typedef struct { + /* 0x0000 */ BgHakuginPostUnkStruct1 unk_0000[12]; + /* 0x02A0 */ s32 count; + /* 0x02A4 */ BgHakuginPostUnkStruct2 unk_02A4[120]; + /* 0x1924 */ u8 unk_1924; +} BgHakuginPostUnkStruct; // size = 0x1928 + +typedef struct { + /* 0x0000 */ ColliderCylinder colliders[8]; + /* 0x0260 */ s32 count; +} BgHakuginPostColliders; // size = 0x264 typedef struct BgHakuginPost { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ BgHakuginPostActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x28]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32 unk_16C; + /* 0x0170 */ s32 unk_170; + /* 0x0174 */ s32 unk_174; + /* 0x0178 */ s8 unk_178; + /* 0x0179 */ s8 unk_179; + /* 0x017C */ BgHakuginPostFunc unkFunc; + /* 0x0180 */ s16 unk_180; + /* 0x0182 */ s16 unk_182; + /* 0x0184 */ s16 unk_184; + /* 0x0186 */ s16 unk_186; } BgHakuginPost; // size = 0x188 extern const ActorInit Bg_Hakugin_Post_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index 1f0aa00a62..7fc52d938a 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -760,6 +760,11 @@ D_0600BF40 = 0x0600BF40; // ovl_Bg_Hakugin_Post D_0600D3B0 = 0x0600D3B0; +D_0600C1A8 = 0x0600C1A8; +D_0600C568 = 0x0600C568; +D_0600CA38 = 0x0600CA38; +D_0600CEC8 = 0x0600CEC8; +D_0600D098 = 0x0600D098; // ovl_Bg_Hakugin_Switch