From 60522302336ed9cc41f9bf910a6d249f9aef0f42 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Mon, 11 Jul 2022 22:02:15 -0300 Subject: [PATCH] ovl_Bg_Botihasira decompiled (#857) * ovl_Bg_Botihasira decompiled * pr fixes * PR review changes * undef syms * PlayState Co-authored-by: SonicDcer --- spec | 3 +- .../ovl_Bg_Botihasira/z_bg_botihasira.c | 80 +++++++++++++++---- .../ovl_Bg_Botihasira/z_bg_botihasira.h | 7 +- undefined_syms.txt | 5 -- 4 files changed, 69 insertions(+), 26 deletions(-) diff --git a/spec b/spec index fc996ed66a..c1ef2f24cc 100644 --- a/spec +++ b/spec @@ -3840,8 +3840,7 @@ beginseg name "ovl_Bg_Botihasira" compress include "build/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.o" - include "build/data/ovl_Bg_Botihasira/ovl_Bg_Botihasira.data.o" - include "build/data/ovl_Bg_Botihasira/ovl_Bg_Botihasira.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Botihasira/ovl_Bg_Botihasira_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c index 65080bd3d4..dfa31a6a0c 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.c @@ -5,6 +5,7 @@ */ #include "z_bg_botihasira.h" +#include "objects/object_botihasira/object_botihasira.h" #define FLAGS 0x00000000 @@ -12,10 +13,11 @@ void BgBotihasira_Init(Actor* thisx, PlayState* play); void BgBotihasira_Destroy(Actor* thisx, PlayState* play); -void BgBotihasira_Update(Actor* thisx, PlayState* play); +void BgBotihasira_Update(Actor* thisx, PlayState* play2); void BgBotihasira_Draw(Actor* thisx, PlayState* play); -#if 0 +void BgBotihasira_DoNothing(BgBotihasira* this, PlayState* play); + const ActorInit Bg_Botihasira_InitVars = { ACTOR_BG_BOTIHASIRA, ACTORCAT_ITEMACTION, @@ -28,26 +30,74 @@ const ActorInit Bg_Botihasira_InitVars = { (ActorFunc)BgBotihasira_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B282F0 = { - { COLTYPE_METAL, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 27, 80, 0, { 0, 0, 0 } }, }; -#endif +void BgBotihasira_Init(Actor* thisx, PlayState* play) { + s32 pad; + BgBotihasira* this = THIS; + CollisionHeader* colHeader = NULL; -extern ColliderCylinderInit D_80B282F0; + if (this->dyna.actor.params == 0) { + DynaPolyActor_Init(&this->dyna, 0); + CollisionHeader_GetVirtual(&object_botihasira_Colheader_001BD8, &colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); + } else { + Collider_InitAndSetCylinder(play, &this->collider, &this->dyna.actor, &sCylinderInit); + } + this->actionFunc = BgBotihasira_DoNothing; + this->dyna.actor.scale.z = this->dyna.actor.scale.y = this->dyna.actor.scale.x = 0.1f; +} -extern UNK_TYPE D_06000638; -extern UNK_TYPE D_06001BD8; +void BgBotihasira_Destroy(Actor* thisx, PlayState* play) { + BgBotihasira* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Init.s") + if (this->dyna.actor.params == 0) { + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Destroy.s") +void BgBotihasira_DoNothing(BgBotihasira* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/func_80B2815C.s") +void BgBotihasira_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgBotihasira* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Update.s") + this->actionFunc(this, play); + if (this->dyna.actor.params != 0) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + (Math_SinS(this->dyna.actor.world.rot.y) * -27.0f); + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + (Math_CosS(this->dyna.actor.world.rot.y) * 7.0f); + Collider_UpdateCylinder(&this->dyna.actor, &this->collider); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Botihasira/BgBotihasira_Draw.s") +void BgBotihasira_Draw(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, object_botihasira_DL_000638); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h index c66b00b0a9..529b5a904f 100644 --- a/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h +++ b/src/overlays/actors/ovl_Bg_Botihasira/z_bg_botihasira.h @@ -8,10 +8,9 @@ struct BgBotihasira; typedef void (*BgBotihasiraActionFunc)(struct BgBotihasira*, PlayState*); typedef struct BgBotihasira { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ BgBotihasiraActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x4C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgBotihasiraActionFunc actionFunc; + /* 0x160 */ ColliderCylinder collider; } BgBotihasira; // size = 0x1AC extern const ActorInit Bg_Botihasira_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index bcda4aec02..dbe7b4da24 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -540,11 +540,6 @@ D_06011AB8 = 0x06011AB8; D_06012A80 = 0x06012A80; D_06013138 = 0x06013138; -// ovl_Bg_Botihasira - -D_06000638 = 0x06000638; -D_06001BD8 = 0x06001BD8; - // ovl_Bg_Crace_Movebg D_060003A0 = 0x060003A0;