diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c index 78fc7263a..ad7f760ae 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c @@ -17,6 +17,17 @@ void func_809613C4(ObjMure2* this, PlayState* play); void func_809613FC(ObjMure2* this, PlayState* play); void func_80961490(ObjMure2* this, PlayState* play); +void func_809613B0(ObjMure2*); +void func_809613E8(ObjMure2*); +void func_8096104C(ObjMure2*, PlayState*); +void func_8096147C(ObjMure2*); +void func_809611BC(ObjMure2*, PlayState*); +void func_809612BC(ObjMure2*); + +extern f32 D_80961590[]; +extern f32 D_8096159C[]; +extern s16 D_809615A8[]; + #if 0 ActorInit Obj_Mure2_InitVars = { /**/ ACTOR_OBJ_MURE2, @@ -47,26 +58,113 @@ extern InitChainEntry D_809615F4[]; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80960F0C.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80961018.s") +void func_80961018(s16* arg0, ObjMure2* arg1) { + s32 value = arg1->actor.params & 3; + s32 temp_a2 = (arg1->actor.params >> 8) & 0x1F; + + if (value == 2) { + *arg0 = temp_a2 * 0x10; + return; + } + + *arg0 = temp_a2 << 8; +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_8096104C.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809611BC.s") +void func_809611BC(ObjMure2* arg0, PlayState* arg1) { + s16 var_v0 = D_809615A8[arg0->actor.params & 3]; + s32 var_s2 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809612BC.s") + if (var_v0 > 0) { + do { + if (!((arg0->unk_178 >> var_s2) & 1)) { + if (arg0->unk_148[var_s2] != NULL) { + if (Actor_HasParent(arg0->unk_148[var_s2], arg1) != 0) { + arg0->unk_178 |= 1 << var_s2; + } else { + Actor_Kill(arg0->unk_148[var_s2]); + } + arg0->unk_148[var_s2] = NULL; + } + } else { + arg0->unk_148[var_s2] = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/ObjMure2_Init.s") + var_v0 = D_809615A8[arg0->actor.params & 3]; + } while (++var_s2 < var_v0); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613B0.s") +void func_809612BC(ObjMure2* arg0) { + s32 var_v0 = 0; + s16 var_v1 = D_809615A8[arg0->actor.params & 3]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613C4.s") + if (var_v1 > 0) { + do { + if (arg0->unk_148[var_v0] != NULL) { + if (!(((s32)arg0->unk_178 >> var_v0) & 1) && (arg0->unk_148[var_v0]->update == NULL)) { + arg0->unk_178 = arg0->unk_178 | (1 << var_v0); + arg0->unk_148[var_v0] = NULL; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613E8.s") + var_v1 = D_809615A8[arg0->actor.params & 3]; + } while (++var_v0 < var_v1); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613FC.s") +void ObjMure2_Init(Actor* thisx, PlayState* play) { + ObjMure2* this = THIS; + Actor_ProcessInitChain(&this->actor, D_809615F4); + if (play->csCtx.state != 0) { + this->actor.uncullZoneForward += 1200.0f; + } + func_809613B0(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_8096147C.s") +void func_809613B0(ObjMure2* this) { + this->actionFunc = func_809613C4; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80961490.s") +void func_809613C4(ObjMure2* this, PlayState* play) { + func_809613E8(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/ObjMure2_Update.s") +void func_809613E8(ObjMure2* this) { + this->actionFunc = func_809613FC; +} + +void func_809613FC(ObjMure2* this, PlayState* play) { + if (Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z) < + D_80961590[this->actor.params & 3] * this->unk_17C) { + this->actor.flags |= 0x10; + func_8096104C(this, play); + func_8096147C(this); + } +} + +void func_8096147C(ObjMure2* this) { + this->actionFunc = func_80961490; +} + +void func_80961490(ObjMure2* this, PlayState* play) { + func_809612BC(this); + + if ((D_8096159C[this->actor.params & 3] * this->unk_17C) <= + Math3D_XZLengthSquared(this->actor.projectedPos.x, this->actor.projectedPos.z)) { + this->actor.flags &= ~0x10; + func_809611BC(this, play); + func_809613E8(this); + } +} + +void ObjMure2_Update(Actor* thisx, PlayState* play) { + ObjMure2* this = THIS; + if (play->csCtx.state == 0) { + this->unk_17C = 1.0f; + } else { + this->unk_17C = 4.0f; + } + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h index f70d45f1e..12fdb387e 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.h @@ -10,7 +10,10 @@ typedef void (*ObjMure2ActionFunc)(struct ObjMure2*, PlayState*); typedef struct ObjMure2 { /* 0x000 */ Actor actor; /* 0x144 */ ObjMure2ActionFunc actionFunc; - /* 0x148 */ char unk_148[0x38]; -} ObjMure2; // size = 0x180 + /* 0x148 */ Actor* unk_148[0xC]; /* inferred */ + /* 0x178 */ u16 unk_178; /* inferred */ + /* 0x17A */ char pad_17A[2]; + /* 0x17C */ f32 unk_17C; /* inferred */ +} ObjMure2; /* size = 0x180 */ #endif // Z_OBJ_MURE2_H