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 a88c67f7f..3e130641f 100644 --- a/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c +++ b/src/overlays/actors/ovl_Obj_Mure2/z_obj_mure2.c @@ -13,13 +13,19 @@ void ObjMure2_Init(Actor* thisx, PlayState* play); void ObjMure2_Update(Actor* thisx, PlayState* play); +void func_8096104C(ObjMure2* this, PlayState* play); void func_809613C4(ObjMure2* this, PlayState* play); void func_809613FC(ObjMure2* this, PlayState* play); void func_80961490(ObjMure2* this, PlayState* play); +void func_809611BC(ObjMure2* this, PlayState* play); +void func_809613B0(ObjMure2* this); +void func_809613E8(ObjMure2* this); +void func_8096147C(ObjMure2* this); +void func_80961018(s16*, ObjMure2*); -void func_80960CF0(Vec3f*, Vec3f*); -void func_80960E0C(Vec3f*, Vec3f*); -void func_80960F0C(Vec3f*, Vec3f*); +void func_80960CF0(Vec3f*, ObjMure2*); +void func_80960E0C(Vec3f*, ObjMure2*); +void func_80960F0C(Vec3f*, ObjMure2*); #if 1 ActorInit Obj_Mure2_InitVars = { @@ -34,48 +40,47 @@ ActorInit Obj_Mure2_InitVars = { (ActorFunc)NULL, }; -Vec3f D_80961590 = { -2560000.0, -2560000.0, -2560000.0, +f32 D_80961590[] = { + 2560000.0, + 2560000.0, + 2560000.0, }; -Vec3f D_8096159C = { -2907025.0, -2907025.0, -2907025.0, +f32 D_8096159C[] = { + 2907025.0, + 2907025.0, + 2907025.0, }; s16 D_809615A8[] = { -0x0009,0x000C, -0x0008,0x0000, + 9, + 12, + 8, + 0, }; s16 D_809615B0[] = { -0x0090,0x0090, -0x00B0,0x0000, + 0x0090, + 0x0090, + 0x00B0, + 0x0000, +}; +typedef struct Mure2SpawnInfo { + s16 dist; + s16 angle; +} Mure2SpawnInfo; + +Mure2SpawnInfo D_809615B8[] = { + { 0x0028, 0x0666 }, { 0x0028, 0x2CCC }, { 0x0028, 0x5999 }, { 0x0028, 0x8666 }, + { 0x0014, 0xC000 }, { 0x0050, 0x1333 }, { 0x0050, 0x4000 }, { 0x0050, 0x6CCC }, + { 0x0050, 0x9333 }, { 0x0050, 0xACCC }, { 0x0050, 0xC666 }, { 0x003C, 0xE000 }, }; -s16 D_809615B8[] = { -0x0028,0x0666, -0x0028,0x2CCC, -0x0028,0x5999, -0x0028,0x8666, -0x0014,0xC000, -0x0050,0x1333, -0x0050,0x4000, -0x0050,0x6CCC, -0x0050,0x9333, -0x0050,0xACCC, -0x0050,0xC666, -0x003C,0xE000, -}; - -typedef void (*ObjMure2UnkFunc)(Vec3f*, Vec3f*); +typedef void (*ObjMure2UnkFunc)(Vec3f*, ObjMure2*); ObjMure2UnkFunc D_809615E8[] = { -func_80960CF0, -func_80960E0C, -func_80960F0C, + func_80960CF0, + func_80960E0C, + func_80960F0C, }; // static InitChainEntry sInitChain[] = { @@ -89,32 +94,159 @@ static InitChainEntry D_809615F4[] = { extern InitChainEntry D_809615F4[]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80960CF0.s") +void func_80960CF0(Vec3f* arg0, ObjMure2* arg1) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80960E0C.s") + Math_Vec3f_Copy(&arg0[0], &arg1->actor.world.pos); + for (i = 1; i < D_809615A8[arg1->actor.params & 3]; i++) { + Math_Vec3f_Copy(&arg0[i], &arg1->actor.world.pos); + (arg0 + i)->x += 80.0f * Math_SinS((i - 1) * 0x2000); + (arg0 + i)->z += 80.0f * Math_CosS((i - 1) * 0x2000); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80960F0C.s") +void func_80960E0C(Vec3f* arg0, ObjMure2* arg1) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80961018.s") + for (i = 0; i < D_809615A8[arg1->actor.params & 3]; i++) { + Math_Vec3f_Copy(arg0 + i, &arg1->actor.world.pos); + (arg0 + i)->x += D_809615B8[i].dist * Math_CosS(D_809615B8[i].angle); + (arg0 + i)->z -= D_809615B8[i].dist * Math_SinS(D_809615B8[i].angle); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_8096104C.s") +void func_80960F0C(Vec3f* arg0, ObjMure2* arg1) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809611BC.s") + for (i = 0; i < D_809615A8[arg1->actor.params & 3]; i++) { + Math_Vec3f_Copy(&arg0[i], &arg1->actor.world.pos); + (arg0 + i)->x += 80.0f * Math_SinS(i * 0x2000); + (arg0 + i)->z += 80.0f * Math_CosS(i * 0x2000); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809612BC.s") +void func_80961018(s16* arg0, ObjMure2* this) { + s32 temp_v1; + s32 temp_a2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/ObjMure2_Init.s") + temp_v1 = this->actor.params & 3; + temp_a2 = (this->actor.params >> 8) & 0x1F; + if (temp_v1 == 2) { + *arg0 = temp_a2 << 4; + return; + } + *arg0 = temp_a2 << 8; +} +void func_8096104C(ObjMure2* this, PlayState* play) { + Vec3f* temp_v0; + s32 temp_s0; + Vec3f sp80[12]; + s16 sp7E; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613B0.s") + temp_s0 = this->actor.params & 3; + D_809615E8[temp_s0](&sp80, this); + func_80961018(&sp7E, this); + for (i = 0; i < D_809615A8[temp_s0]; i++) { + if (this->unk_148[i] != NULL) { + continue; + } + if (((this->unk_178 >> i) & 1) == 0) { + temp_v0 = &sp80[i]; + this->unk_148[i] = Actor_SpawnAsChildAndCutscene( + &play->actorCtx, play, D_809615B0[temp_s0], temp_v0->x, temp_v0->y, temp_v0->z, this->actor.world.rot.x, + 0, this->actor.world.rot.z, sp7E, this->actor.csId, this->actor.halfDaysBits, NULL); + if (this->unk_148[i] != NULL) { + this->unk_148[i]->room = this->actor.room; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613C4.s") +void func_809611BC(ObjMure2* this, PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613E8.s") + for (i = 0; i < D_809615A8[this->actor.params & 3]; i++) { + if (((this->unk_178 >> i) & 1) == 0) { + if (this->unk_148[i] != NULL) { + if (Actor_HasParent(this->unk_148[i], play)) { + this->unk_178 |= 1 << i; + } else { + Actor_Kill(this->unk_148[i]); + } + this->unk_148[i] = NULL; + } + } else { + this->unk_148[i] = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_809613FC.s") +void func_809612BC(ObjMure2* this) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_8096147C.s") + for (i = 0; i < D_809615A8[this->actor.params & 3]; i++) { + if (this->unk_148[i] == NULL) { + continue; + } + if ((((this->unk_178 >> i) & 1) == 0) && (this->unk_148[i]->update == NULL)) { + this->unk_178 |= (1 << i); + this->unk_148[i] = NULL; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/func_80961490.s") +void ObjMure2_Init(Actor* thisx, PlayState* play) { + ObjMure2* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mure2/ObjMure2_Update.s") + Actor_ProcessInitChain(&this->actor, D_809615F4); + if (play->csCtx.state != 0) { + this->actor.uncullZoneForward += 1200.0f; + } + func_809613B0(this); +} + +void func_809613B0(ObjMure2* this) { + this->actionFunc = func_809613C4; +} + +void func_809613C4(ObjMure2* this, PlayState* play) { + func_809613E8(this); +} + +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); +} \ No newline at end of file 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..bcdb8e969 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]; + /* 0x148 */ Actor* unk_148[12]; + u16 unk_178; + /* 0x17C */ f32 unk_17C; + } ObjMure2; // size = 0x180 #endif // Z_OBJ_MURE2_H