diff --git a/include/functions.h b/include/functions.h index ebc3447d4d..0fe7a0088d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2808,7 +2808,7 @@ void SpeedMeter_DrawTimeEntries(void* displayList, GraphicsContext* gfxCtx); void SpeedMeter_DrawAllocEntries(void* displayList, GraphicsContext* gfxCtx, GameState* gameState); void func_801780F0(Mtx* param_1, f32 param_2, f32 param_3, f32 param_4, f32 param_5, f32 param_6, f32 param_7); // void func_801781EC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8017842C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10, UNK_TYPE4 param_11); +void func_8017842C(MtxF* arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4, f32 arg5, f32 arg6, f32 arg7, f32 arg8, f32 arg9, f32 arg10); // void func_80178750(void); // void func_80178818(void); void func_80178978(void); diff --git a/spec b/spec index e161e5939b..8b764625fb 100644 --- a/spec +++ b/spec @@ -5095,8 +5095,7 @@ beginseg name "ovl_En_Paper" compress include "build/src/overlays/actors/ovl_En_Paper/z_en_paper.o" - include "build/data/ovl_En_Paper/ovl_En_Paper.data.o" - include "build/data/ovl_En_Paper/ovl_En_Paper.reloc.o" + include "build/src/overlays/actors/ovl_En_Paper/ovl_En_Paper_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.c b/src/overlays/actors/ovl_En_Paper/z_en_paper.c index 5554c9182f..fd6ac67785 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.c +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.c @@ -5,6 +5,7 @@ */ #include "z_en_paper.h" +#include "objects/object_bal/object_bal.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_100000 | ACTOR_FLAG_2000000) @@ -17,8 +18,11 @@ void EnPaper_Draw(Actor* thisx, PlayState* play); void func_80C1F480(EnPaper* this, PlayState* play); void func_80C1F4FC(EnPaper* this, PlayState* play); +void func_80C1F46C(EnPaper* this); +void func_80C1F4E8(EnPaper* this); +void func_80C1F55C(EnPaper* this, EnPaperStruct* arg1); +void func_80C1F6E0(EnPaper* this, EnPaperStruct* arg1); -#if 0 const ActorInit En_Paper_InitVars = { ACTOR_EN_PAPER, ACTORCAT_ITEMACTION, @@ -31,28 +35,165 @@ const ActorInit En_Paper_InitVars = { (ActorFunc)EnPaper_Draw, }; -#endif +Vec3f D_80C1FC60 = { 0.0f, 0.0f, 1.0f }; -extern UNK_TYPE D_0600D5A0; +void EnPaper_Init(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Init.s") + Actor_SetScale(&this->actor, 0.01f); + this->timer = 70; + this->unk_D78 = D_80C1FC60; + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + func_80C1F46C(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Destroy.s") +void EnPaper_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F46C.s") +void func_80C1F46C(EnPaper* this) { + this->actionFunc = func_80C1F480; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F480.s") +void func_80C1F480(EnPaper* this, PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F4E8.s") + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + func_80C1F55C(this, &this->unk_148[i]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F4FC.s") + func_80C1F4E8(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F55C.s") +void func_80C1F4E8(EnPaper* this) { + this->actionFunc = func_80C1F4FC; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F6E0.s") +void func_80C1F4FC(EnPaper* this, PlayState* play) { + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/func_80C1F87C.s") + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++) { + func_80C1F6E0(this, &this->unk_148[i]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Update.s") +void func_80C1F55C(EnPaper* this, EnPaperStruct* arg1) { + Matrix_RotateZYX(Rand_Next(), Rand_Next(), Rand_Next(), MTXMODE_NEW); + Matrix_MultVec3f(&D_80C1FC60, &arg1->unk_0C); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Paper/EnPaper_Draw.s") + arg1->unk_18 = this->actor.world.pos; + + arg1->unk_18.x += Rand_Centered() * 4.0f; + arg1->unk_18.y += Rand_Centered() * 4.0f; + arg1->unk_18.z += Rand_Centered() * 4.0f; + + arg1->unk_24 = this->actor.velocity; + + arg1->unk_24.x += Rand_Centered() * 9.0f; + arg1->unk_24.y += Rand_ZeroOne() * 6.0f; + arg1->unk_24.z += Rand_Centered() * 9.0f; + + arg1->unk_30 = Rand_Next(); + arg1->unk_32 = (Rand_Next() >> 4) + 0x16C; + + Matrix_RotateAxisS(arg1->unk_30, &arg1->unk_0C, MTXMODE_NEW); + Matrix_MultVec3f(&D_80C1FC60, &arg1->unk_00); +} + +void func_80C1F6E0(EnPaper* this, EnPaperStruct* arg1) { + f32 sp1C = Math_CosS(arg1->unk_30); + f32 sp18 = Math_SinS(arg1->unk_30); + f32 temp_ft4 = 1.0f - sp1C; + + if (arg1->unk_18.y < (this->actor.floorHeight - 40.0f)) { + return; + } + + arg1->unk_24.y += this->actor.gravity; + + arg1->unk_24.x -= 0.2f * fabsf(arg1->unk_00.x) * (arg1->unk_24.x + this->unk_D78.x); + arg1->unk_24.y -= 0.2f * fabsf(arg1->unk_00.y) * (arg1->unk_24.y + this->unk_D78.y); + arg1->unk_24.z -= 0.2f * fabsf(arg1->unk_00.z) * (arg1->unk_24.z + this->unk_D78.z); + + arg1->unk_30 += arg1->unk_32; + + arg1->unk_18.x += arg1->unk_24.x; + arg1->unk_18.y += arg1->unk_24.y; + arg1->unk_18.z += arg1->unk_24.z; + + arg1->unk_00.x = (arg1->unk_0C.x * temp_ft4 * arg1->unk_0C.z) - (arg1->unk_0C.y * sp18); + arg1->unk_00.y = (arg1->unk_0C.y * temp_ft4 * arg1->unk_0C.z) + (arg1->unk_0C.x * sp18); + arg1->unk_00.z = (arg1->unk_0C.z * temp_ft4 * arg1->unk_0C.z) + sp1C; +} + +void func_80C1F87C(EnPaper* this) { + f32 sp2C = (Rand_Centered() * 4.0f) + 6.0f; + f32 sp28; + + this->unk_D78.y = Math_SinS(this->actor.shape.rot.x) * -sp2C; + + sp28 = Math_CosS(this->actor.shape.rot.x) * -sp2C; + this->unk_D78.x = Math_SinS(this->actor.shape.rot.y) * sp28; + this->unk_D78.z = Math_CosS(this->actor.shape.rot.y) * sp28; + + this->actor.shape.rot.x += (s16)(Rand_Next() >> 8); + this->actor.shape.rot.y += (s16)(Rand_Next() >> 6); + + if (ABS_ALT(this->actor.shape.rot.x) > 0x1555) { + if (this->actor.shape.rot.x > 0) { + this->actor.shape.rot.x = 0x1555; + } else { + this->actor.shape.rot.x = -0x1555; + } + } +} + +void EnPaper_Update(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; + + this->actionFunc(this, play); + + func_80C1F87C(this); + if (this->timer == 0) { + Actor_MarkForDeath(&this->actor); + } else { + this->timer--; + } +} + +void EnPaper_Draw(Actor* thisx, PlayState* play) { + EnPaper* this = THIS; + EnPaperStruct* ptr = this->unk_148; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, SHADE, 0, 0, 0, SHADE, PRIMITIVE, 0, COMBINED, 0, 0, 0, 0, COMBINED); + gSPLoadGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH); + + for (i = 0; i < ARRAY_COUNT(this->unk_148); i++, ptr++) { + if (i == 0) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, 255); + } else if (i == 30) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 32, 32, 255); + } else if (i == 40) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 64, 128, 255, 255); + } else if (i == 50) { + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 64, 255, 128, 255); + } + + if ((this->actor.floorHeight - 40.0f) < ptr->unk_18.y) { + MtxF* mf = GRAPH_ALLOC(play->state.gfxCtx, sizeof(MtxF)); + + func_8017842C(mf, this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, ptr->unk_30, ptr->unk_0C.x, + ptr->unk_0C.y, ptr->unk_0C.z, ptr->unk_18.x, ptr->unk_18.y, ptr->unk_18.z); + + gSPMatrix(POLY_OPA_DISP++, mf, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_bal_DL_00D5A0); + } + } + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Paper/z_en_paper.h b/src/overlays/actors/ovl_En_Paper/z_en_paper.h index 9c4e6cc501..457229c3d9 100644 --- a/src/overlays/actors/ovl_En_Paper/z_en_paper.h +++ b/src/overlays/actors/ovl_En_Paper/z_en_paper.h @@ -7,10 +7,21 @@ struct EnPaper; typedef void (*EnPaperActionFunc)(struct EnPaper*, PlayState*); +typedef struct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ Vec3f unk_0C; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f unk_24; + /* 0x30 */ s16 unk_30; + /* 0x32 */ s16 unk_32; +} EnPaperStruct; // size = 0x34 + typedef struct EnPaper { /* 0x000 */ Actor actor; /* 0x144 */ EnPaperActionFunc actionFunc; - /* 0x148 */ char unk_148[0xC40]; + /* 0x148 */ EnPaperStruct unk_148[60]; + /* 0xD78 */ Vec3f unk_D78; + /* 0xD84 */ s16 timer; } EnPaper; // size = 0xD88 extern const ActorInit En_Paper_InitVars;