diff --git a/spec b/spec index e17d3af91b..9a0f31668b 100644 --- a/spec +++ b/spec @@ -4850,8 +4850,7 @@ beginseg name "ovl_Obj_Usiyane" compress include "build/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.o" - include "build/data/ovl_Obj_Usiyane/ovl_Obj_Usiyane.data.o" - include "build/data/ovl_Obj_Usiyane/ovl_Obj_Usiyane.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Usiyane/ovl_Obj_Usiyane_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c index e895eeba9b..33ebf1e500 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.c @@ -5,6 +5,7 @@ */ #include "z_obj_usiyane.h" +#include "objects/object_obj_usiyane/object_obj_usiyane.h" #define FLAGS (ACTOR_FLAG_20) @@ -15,7 +16,6 @@ void ObjUsiyane_Destroy(Actor* thisx, PlayState* play); void ObjUsiyane_Update(Actor* thisx, PlayState* play); void ObjUsiyane_Draw(Actor* thisx, PlayState* play); -#if 0 const ActorInit Obj_Usiyane_InitVars = { ACTOR_OBJ_USIYANE, ACTORCAT_PROP, @@ -28,40 +28,245 @@ const ActorInit Obj_Usiyane_InitVars = { (ActorFunc)ObjUsiyane_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80C086B0[] = { +PosRot D_80C08660[] = { + { { 800.0f, -940.0f, 2000.0f }, { 0, 0, 0x2AF8 } }, + { { 560.0f, -790.0f, -2000.0f }, { 0, 0, 0x2EE0 } }, + { { -480.0f, -780.0f, -1990.0f }, { 0, 0, -0x2710 } }, + { { -470.0f, -850.0f, 2000.0f }, { 0, 0, -0x2710 } }, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 3000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 900, ICHAIN_STOP), }; -#endif +s32 func_80C07C80(s32 arg0) { + s32 var_v1; -extern InitChainEntry D_80C086B0[]; + if (!(arg0 & 1)) { + var_v1 = gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF; + } else { + var_v1 = (gSaveContext.save.unk_E88[arg0 >> 1] & 0xFFFF0000) >> 0x10; + } + return var_v1 + CLOCK_TIME(2, 30); +} -extern UNK_TYPE D_06000838; -extern UNK_TYPE D_060022AC; +s32 func_80C07CD0(void) { + if (CURRENT_DAY <= 0) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07C80.s") + if (CURRENT_DAY == 1) { + s32 time = gSaveContext.save.time; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07CD0.s") + if ((time < CLOCK_TIME(2, 30)) || (time >= CLOCK_TIME(6, 0))) { + return false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07DC4.s") + if (time < CLOCK_TIME(5, 15)) { + s32 var_s1 = CLOCK_TIME(5, 15); + s32 temp_v0_2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07DFC.s") + for (i = 0; i < 8; i++) { + temp_v0_2 = func_80C07C80(i); + var_s1 = CLAMP_MAX(var_s1, temp_v0_2); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C07F30.s") + if (time < (var_s1 + 0xE11)) { + return false; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C081C8.s") + if (gSaveContext.save.weekEventReg[22] & 1) { + return false; + } + return true; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C082CC.s") +void func_80C07DC4(ObjUsiyane* this, PlayState* play) { + if (func_80C07CD0()) { + Actor_MarkForDeath(&this->dyna.actor); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/func_80C082E0.s") +void func_80C07DFC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5, Vec3f* arg6, Vec3s* arg7) { + f32 temp_fv0 = (f32)arg4 / arg5; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Init.s") + // VEC3F_LERPIMPDST + arg6->x = ((arg2->x - arg0->x) * temp_fv0) + arg0->x; + arg6->y = ((arg2->y - arg0->y) * temp_fv0) + arg0->y; + arg6->z = ((arg2->z - arg0->z) * temp_fv0) + arg0->z; + arg7->x = (((f32)arg3->x - (f32)arg1->x) * temp_fv0) + arg1->x; + arg7->y = (((f32)arg3->y - (f32)arg1->y) * temp_fv0) + arg1->y; + arg7->z = (((f32)arg3->z - (f32)arg1->z) * temp_fv0) + arg1->z; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Destroy.s") +void func_80C07F30(ObjUsiyane* this, PlayState* play) { + s32 i; + s32 j; + Vec3f sp94; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Update.s") + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + if (i != ARRAY_COUNT(this->unk_168[0]) - 1) { + func_80C07DFC(&this->unk_710[i], &D_80C08660[i].rot, &this->unk_710[i + 1], &D_80C08660[i + 1].rot, j, + 10, &this->unk_168[j][i].unk_00, &this->unk_168[j][i].unk_18); + } else { + func_80C07DFC(&this->unk_710[i], &D_80C08660[i].rot, &this->unk_710[0], &D_80C08660[0].rot, j, 10, + &this->unk_168[j][i].unk_00, &this->unk_168[j][i].unk_18); + } + func_800B12F0(play, &this->unk_168[j][i].unk_00, &gZeroVec3f, &gZeroVec3f, 100, 30, 7); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Usiyane/ObjUsiyane_Draw.s") + this->unk_168[j][i].unk_18.y = (s32)Rand_Next() >> 0x10; + + sp94.x = this->unk_168[j][i].unk_00.x - this->unk_708; + sp94.y = 0.0f; + sp94.z = this->unk_168[j][i].unk_00.z - this->unk_70C; + Math3D_Normalize(&sp94); + + sp94.x *= 5.0f; + sp94.y = 19.0f; + sp94.z *= 5.0f; + + this->unk_168[j][i].unk_0C = sp94; + + this->unk_168[j][i].unk_1E.x = Rand_Centered() * 4000.0f; + this->unk_168[j][i].unk_1E.y = Rand_Centered() * 4000.0f; + this->unk_168[j][i].unk_1E.z = Rand_Centered() * 4000.0f; + } + } + + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_HOUSE_BROKEN); + this->unk_740 = 0; + this->unk_744 |= 4; +} + +void func_80C081C8(ObjUsiyane* this, PlayState* play) { + s32 i; + s32 j; + + this->unk_744 |= 1; + + if (this->unk_740 <= 70) { + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + this->unk_168[j][i].unk_0C.y += -0.8f; + + this->unk_168[j][i].unk_00.x += this->unk_168[j][i].unk_0C.x; + this->unk_168[j][i].unk_00.y += this->unk_168[j][i].unk_0C.y; + this->unk_168[j][i].unk_00.z += this->unk_168[j][i].unk_0C.z; + + this->unk_168[j][i].unk_18.x += this->unk_168[j][i].unk_1E.x; + this->unk_168[j][i].unk_18.y += this->unk_168[j][i].unk_1E.y; + this->unk_168[j][i].unk_18.z += this->unk_168[j][i].unk_1E.z; + } + } + + } else if (this->unk_740 >= 70) { + Actor_MarkForDeath(&this->dyna.actor); + } + this->unk_740++; +} + +void func_80C082CC(ObjUsiyane* this, PlayState* play) { + this->unk_164 = -1; +} + +void func_80C082E0(ObjUsiyane* this, PlayState* play) { + CsCmdActorAction* csAction; + + if (Cutscene_CheckActorAction(play, 0x228)) { + this->unk_160 = Cutscene_GetActorActionIndex(play, 0x228); + csAction = play->csCtx.actorActions[this->unk_160]; + if (this->unk_164 != csAction->action) { + this->unk_164 = csAction->action; + if (this->unk_164 == 2) { + func_80C07F30(this, play); + this->actionFunc = func_80C081C8; + } + } + } +} + +void ObjUsiyane_Init(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_SetScale(&this->dyna.actor, 0.1f); + + this->unk_744 = 0; + + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_obj_usiyane_Colheader_0022AC); + + switch (OBJUSIYANE_GET_F(&this->dyna.actor)) { + case OBJUSIYANE_F_0: + this->actionFunc = func_80C07DC4; + break; + + case OBJUSIYANE_F_1: + func_80C082CC(this, play); + this->actionFunc = func_80C082E0; + break; + + default: + Actor_MarkForDeath(&this->dyna.actor); + break; + } +} + +void ObjUsiyane_Destroy(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} + +void ObjUsiyane_Update(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + + this->actionFunc(this, play); +} + +void ObjUsiyane_Draw(Actor* thisx, PlayState* play) { + ObjUsiyane* this = THIS; + MtxF mf; + + if (!(this->unk_744 & 1)) { + Gfx_DrawDListOpa(play, object_obj_usiyane_DL_000838); + } + + if (!(this->unk_744 & 2)) { + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_80C08660); i++) { + Vec3f sp74; + + Matrix_MultVec3f(&D_80C08660[i].pos, &this->unk_710[i]); + Matrix_MultVec3f(&gZeroVec3f, &sp74); + this->unk_708 = sp74.x; + this->unk_70C = sp74.z; + } + this->unk_744 |= 2; + } + + if ((this->unk_744 & 4) && !(this->unk_744 & 8)) { + s32 i; + s32 j; + + for (i = 0; i < ARRAY_COUNT(this->unk_168[0]); i++) { + for (j = 0; j < ARRAY_COUNT(this->unk_168); j++) { + Matrix_Push(); + SkinMatrix_SetScaleRotateRPYTranslate(&mf, 0.1f, 0.1f, 0.1f, this->unk_168[j][i].unk_18.x, + this->unk_168[j][i].unk_18.y, this->unk_168[j][i].unk_18.z, + this->unk_168[j][i].unk_00.x, this->unk_168[j][i].unk_00.y, + this->unk_168[j][i].unk_00.z); + Matrix_Put(&mf); + Gfx_DrawDListOpa(play, object_obj_usiyane_DL_000098); + Matrix_Pop(); + } + } + } +} diff --git a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h index 7c4cdd8a5a..c38a08ed9f 100644 --- a/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h +++ b/src/overlays/actors/ovl_Obj_Usiyane/z_obj_usiyane.h @@ -7,11 +7,31 @@ struct ObjUsiyane; typedef void (*ObjUsiyaneActionFunc)(struct ObjUsiyane*, PlayState*); +#define OBJUSIYANE_GET_F(thisx) ((thisx)->params & 0xF) + +enum { + /* 0 */ OBJUSIYANE_F_0, + /* 1 */ OBJUSIYANE_F_1, +}; + +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3s unk_18; + /* 0x1E */ Vec3s unk_1E; +} ObjUsiyaneStruct; // size = 0x24 + typedef struct ObjUsiyane { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ ObjUsiyaneActionFunc actionFunc; - /* 0x160 */ char unk_160[0x5E8]; + /* 0x160 */ s32 unk_160; + /* 0x164 */ s32 unk_164; + /* 0x168 */ ObjUsiyaneStruct unk_168[10][4]; + /* 0x708 */ f32 unk_708; + /* 0x70C */ f32 unk_70C; + /* 0x710 */ Vec3f unk_710[4]; + /* 0x740 */ s32 unk_740; + /* 0x744 */ s32 unk_744; } ObjUsiyane; // size = 0x748 extern const ActorInit Obj_Usiyane_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index faf0aba385..20a4cf5e25 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1450,12 +1450,6 @@ D_06001100 = 0x06001100; D_06001140 = 0x06001140; D_06001CB0 = 0x06001CB0; -// ovl_Obj_Usiyane - -D_06000098 = 0x06000098; -D_06000838 = 0x06000838; -D_060022AC = 0x060022AC; - // ovl_player_actor D_06008860 = 0x06008860;