diff --git a/spec b/spec index c4b69ae8e..91212d5ff 100644 --- a/spec +++ b/spec @@ -2244,8 +2244,7 @@ beginseg name "ovl_Bg_Fire_Wall" compress include "build/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.o" - include "build/data/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall.data.o" - include "build/data/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Fire_Wall/ovl_Bg_Fire_Wall_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c index 9e87d66bb..1ad295e68 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c @@ -5,6 +5,8 @@ */ #include "z_bg_fire_wall.h" +#include "objects/object_fwall/object_fwall.h" +#include "overlays/actors/ovl_En_Encount4/z_en_encount4.h" #define FLAGS 0x00000000 @@ -12,14 +14,13 @@ void BgFireWall_Init(Actor* thisx, PlayState* play); void BgFireWall_Destroy(Actor* thisx, PlayState* play); -void BgFireWall_Update(Actor* thisx, PlayState* play); +void BgFireWall_Update(Actor* thisx, PlayState* play2); +void BgFireWall_Draw(Actor* thisx, PlayState* play); void func_809AC638(BgFireWall* this, PlayState* play); void func_809AC68C(BgFireWall* this, PlayState* play); void func_809AC6C0(BgFireWall* this, PlayState* play); -void func_809AC970(BgFireWall* this, PlayState* play); -#if 0 const ActorInit Bg_Fire_Wall_InitVars = { ACTOR_BG_FIRE_WALL, ACTORCAT_BG, @@ -32,41 +33,184 @@ const ActorInit Bg_Fire_Wall_InitVars = { (ActorFunc)NULL, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_809ACC60 = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_NONE, OC1_ON | OC1_TYPE_PLAYER, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x20000000, 0x01, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_NONE, + OC1_ON | OC1_TYPE_PLAYER, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x20000000, 0x01, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_NONE, + OCELEM_ON, + }, { 34, 85, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_809ACC8C = { 1, 80, 100, MASS_IMMOVABLE }; +static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE }; -#endif +static TexturePtr sFlameTextures[] = { + gFwallFireball0Tex, gFwallFireball1Tex, gFwallFireball2Tex, gFwallFireball3Tex, + gFwallFireball4Tex, gFwallFireball5Tex, gFwallFireball6Tex, gFwallFireball7Tex, +}; -extern ColliderCylinderInit D_809ACC60; -extern CollisionCheckInfoInit D_809ACC8C; +void BgFireWall_Init(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; -extern UNK_TYPE D_06000040; + this->unk_14C = this->actor.params; + this->actor.scale.y = 0.005f; + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, NULL, &sColChkInfoInit); + this->actor.scale.z = 0.12f; + this->actor.scale.x = 0.12f; + this->unk_15C = 0.09f; + this->unk_158 = 0.1f; + this->unk_160 = 300.0f; + this->texIndex = Rand_S16Offset(0, ARRAY_COUNT(sFlameTextures) - 1); + this->actor.flags |= ACTOR_FLAG_10; + this->collider.dim.pos.y = this->actor.world.pos.y; + this->actionFunc = func_809AC638; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Init.s") +void BgFireWall_Destroy(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Destroy.s") + Collider_DestroyCylinder(play, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC5C0.s") +s32 func_809AC5C0(BgFireWall* thisx, PlayState* play) { + BgFireWall* this = THIS; + Player* player = GET_PLAYER(play); + Vec3f sp1C; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC638.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp1C, &player->actor.world.pos); + if ((fabsf(sp1C.x) < this->unk_160) && (fabsf(sp1C.z) < (this->unk_160 + 20.0f))) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC68C.s") +void func_809AC638(BgFireWall* this, PlayState* play) { + if ((this->unk_14C != 0) || (func_809AC5C0(this, play))) { + this->actor.draw = BgFireWall_Draw; + this->timer = 5; + this->actionFunc = func_809AC68C; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC6C0.s") +void func_809AC68C(BgFireWall* this, PlayState* play) { + if (this->timer != 0) { + this->timer--; + } + if (this->timer == 0) { + this->actionFunc = func_809AC6C0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC760.s") +void func_809AC6C0(BgFireWall* this, PlayState* play) { + if ((this->unk_14C != 0) || (func_809AC5C0(this, play))) { + this->unk_15C = 0.09f; + Math_StepToF(&this->actor.scale.y, this->unk_15C + this->unk_154, this->unk_158); + } else if (Math_StepToF(&this->actor.scale.y, 0.005f, this->unk_158)) { + this->actionFunc = func_809AC638; + } else { + this->timer = 0; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC7F8.s") +void func_809AC760(BgFireWall* this, PlayState* play) { + s16 phi_a3; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809AC970.s") + if (Actor_IsFacingPlayer(&this->actor, 0x4000)) { + phi_a3 = this->actor.shape.rot.y; + } else { + phi_a3 = (this->actor.shape.rot.y + 0x8000); + } + func_800B8D98(play, &this->actor, BREG(48) + 10.0f, phi_a3, BREG(49) + 5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/BgFireWall_Update.s") +void func_809AC7F8(BgFireWall* this, PlayState* play) { + Player* player = GET_PLAYER(play); + Vec3f sp38; + f32 val = 25.0f; + f32 sin; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Fire_Wall/func_809ACB28.s") + Actor_OffsetOfPointInActorCoords(&this->actor, &sp38, &player->actor.world.pos); + sp38.x = CLAMP(sp38.x, -80.0f, 80.0f); + + if (this->step == 0) { + if (sp38.z > 0.0f) { + sp38.z = -val; + this->step = -1.0f; + } else { + sp38.z = val; + this->step = 1.0f; + } + } else { + sp38.z = this->step * 25.0f; + } + + sin = Math_SinS(this->actor.shape.rot.y); + cos = Math_CosS(this->actor.shape.rot.y); + this->collider.dim.pos.x = this->actor.world.pos.x + (sp38.x * cos) + (sp38.z * sin); + this->collider.dim.pos.z = this->actor.world.pos.z - (sp38.x * sin) + (sp38.z * cos); +} + +void func_809AC970(BgFireWall* this, PlayState* play) { + if (Math_StepToF(&this->actor.scale.y, 0.005f, this->unk_158)) { + Actor_MarkForDeath(&this->actor); + } +} + +void BgFireWall_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgFireWall* this = THIS; + + this->actionFunc(this, play); + if ((this->unk_14C == 0) || ((this->unk_14C != 0) && (this->actor.xzDistToPlayer < 240.0f))) { + if (this->collider.base.atFlags & AT_HIT) { + this->collider.base.atFlags &= ~AT_HIT; + func_809AC760(this, play); + } + } + if (this->actionFunc == func_809AC6C0) { + func_800B9010(&this->actor, NA_SE_EV_FIRE_PLATE - SFX_FLAG); + if ((this->unk_14C == 0) || ((this->unk_14C != 0) && (this->actor.xzDistToPlayer < 240.0f))) { + func_809AC7F8(this, play); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + } + } + this->texIndex = (this->texIndex + 1) % ARRAY_COUNT(sFlameTextures); + if (this->actionFunc != func_809AC970) { + if (this->actor.parent != NULL) { + EnEncount4* parent = (EnEncount4*)this->actor.parent; + if ((parent->actor.update != NULL) && (parent->unk_150 != 0)) { + this->actionFunc = func_809AC970; + } + } + } +} + +void BgFireWall_Draw(Actor* thisx, PlayState* play) { + BgFireWall* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sFlameTextures[this->texIndex])); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_fwall_DL_000040); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h index f65fe6e59..018e9f5f1 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h @@ -10,7 +10,15 @@ typedef void (*BgFireWallActionFunc)(struct BgFireWall*, PlayState*); typedef struct BgFireWall { /* 0x000 */ Actor actor; /* 0x144 */ BgFireWallActionFunc actionFunc; - /* 0x148 */ char unk_148[0x68]; + /* 0x148 */ s16 texIndex; + /* 0x14A */ s16 timer; + /* 0x14C */ s16 unk_14C; + /* 0x150 */ f32 step; + /* 0x154 */ f32 unk_154; + /* 0x158 */ f32 unk_158; + /* 0x15C */ f32 unk_15C; + /* 0x160 */ f32 unk_160; + /* 0x164 */ ColliderCylinder collider; } BgFireWall; // size = 0x1B0 extern const ActorInit Bg_Fire_Wall_InitVars; diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h index 013c907a5..499da9663 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h @@ -8,12 +8,13 @@ struct EnEncount4; typedef void (*EnEncount4ActionFunc)(struct EnEncount4*, PlayState*); typedef struct EnEncount4 { - /* 0x000 */ Actor actor; - /* 0x144 */ EnEncount4ActionFunc actionFunc; - /* 0x148 */ char unk_148[0x4]; - /* 0x14C */ s16 unk_14C; - /* 0x14E */ s16 unk_14E; - /* 0x150 */ char unk_150[0x8]; + /* 0x0000 */ Actor actor; + /* 0x0144 */ EnEncount4ActionFunc actionFunc; + /* 0x0148 */ char unk_148[0x4]; + /* 0x014C */ s16 unk_14C; + /* 0x014E */ s16 unk_14E; + /* 0x0150 */ s16 unk_150; + /* 0x0152 */ char unk_152[0x6]; } EnEncount4; // size = 0x158 extern const ActorInit En_Encount4_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0855966fe..935a0b226 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8830,7 +8830,7 @@ 0x809AC7F8:("func_809AC7F8",), 0x809AC970:("func_809AC970",), 0x809AC9B8:("BgFireWall_Update",), - 0x809ACB28:("func_809ACB28",), + 0x809ACB28:("BgFireWall_Draw",), 0x809ACD90:("EnBu_Init",), 0x809ACDA8:("EnBu_Destroy",), 0x809ACDB8:("EnBu_DoNothing",),