diff --git a/assets/xml/objects/object_d_hsblock.xml b/assets/xml/objects/object_d_hsblock.xml index e9f90c011b..b43647dc39 100644 --- a/assets/xml/objects/object_d_hsblock.xml +++ b/assets/xml/objects/object_d_hsblock.xml @@ -1,10 +1,11 @@  + - - - - - - + + + + + + diff --git a/spec b/spec index 2255ad5c08..c4b69ae8ef 100644 --- a/spec +++ b/spec @@ -1463,8 +1463,7 @@ beginseg name "ovl_Obj_Hsblock" compress include "build/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.o" - include "build/data/ovl_Obj_Hsblock/ovl_Obj_Hsblock.data.o" - include "build/data/ovl_Obj_Hsblock/ovl_Obj_Hsblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Hsblock/ovl_Obj_Hsblock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c index d67da85606..3339d14401 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.c @@ -5,6 +5,7 @@ */ #include "z_obj_hsblock.h" +#include "objects/object_d_hsblock/object_d_hsblock.h" #define FLAGS 0x00000000 @@ -17,9 +18,11 @@ void ObjHsblock_Draw(Actor* thisx, PlayState* play); void func_8093E0A0(ObjHsblock* this, PlayState* play); -void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc); +void func_8093E03C(ObjHsblock* this); +void func_8093E05C(ObjHsblock* this); +void func_8093E0E8(ObjHsblock* this); +void func_8093E10C(ObjHsblock* this, PlayState* play); -#if 0 const ActorInit Obj_Hsblock_InitVars = { ACTOR_OBJ_HSBLOCK, ACTORCAT_BG, @@ -32,36 +35,120 @@ const ActorInit Obj_Hsblock_InitVars = { (ActorFunc)ObjHsblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8093E33C[] = { +static f32 sFocusHeights[] = { 85.0f, 85.0f, 0.0f }; + +static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), }; -#endif +static CollisionHeader* sColHeaders[] = { + &gHookshotPostCol, + &gHookshotPostCol, + &gHookshotTargetCol, +}; -extern InitChainEntry D_8093E33C[]; +static Gfx* sDisplayLists[] = { gHookshotPostDL, gHookshotPostDL, gHookshotTargetDL }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_SetupAction.s") +void ObjHsblock_SetupAction(ObjHsblock* this, ObjHsblockActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093DEAC.s") +void func_8093DEAC(ObjHsblock* this, PlayState* play) { + if (OBJHSBLOCK_GET_5(&this->dyna.actor) != 0) { + Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ICE_POLY, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.world.rot.x, + this->dyna.actor.world.rot.y, this->dyna.actor.world.rot.z, 0xFF64); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Init.s") +void ObjHsblock_Init(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Destroy.s") + DynaPolyActor_Init(&this->dyna, 0); + DynaPolyActor_LoadMesh(play, &this->dyna, sColHeaders[OBJHSBLOCK_GET_3(thisx)]); + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + func_8093DEAC(this, play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E03C.s") + switch (OBJHSBLOCK_GET_3(&this->dyna.actor)) { + case 0: + case 2: + func_8093E03C(this); + break; + case 1: + if (Flags_GetSwitch(play, OBJHSBLOCK_GET_SWITCH(thisx))) { + func_8093E03C(this); + } else { + func_8093E05C(this); + } + break; + default: + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E05C.s") +void ObjHsblock_Destroy(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E0A0.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E0E8.s") +void func_8093E03C(ObjHsblock* this) { + ObjHsblock_SetupAction(this, NULL); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/func_8093E10C.s") +void func_8093E05C(ObjHsblock* this) { + this->dyna.actor.flags |= ACTOR_FLAG_10; + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 105.0f; + ObjHsblock_SetupAction(this, func_8093E0A0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Update.s") +void func_8093E0A0(ObjHsblock* this, PlayState* play) { + if (Flags_GetSwitch(play, OBJHSBLOCK_GET_SWITCH(&this->dyna.actor))) { + func_8093E0E8(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Hsblock/ObjHsblock_Draw.s") +void func_8093E0E8(ObjHsblock* this) { + ObjHsblock_SetupAction(this, func_8093E10C); +} + +void func_8093E10C(ObjHsblock* this, PlayState* play) { + Math_SmoothStepToF(&this->dyna.actor.velocity.y, 16.0f, 0.1f, 0.8f, 0.0f); + if (fabsf(Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 0.3f, + this->dyna.actor.velocity.y, 0.3f)) < 0.001f) { + this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y; + func_8093E03C(this); + this->dyna.actor.flags &= ~ACTOR_FLAG_10; + } +} + +void ObjHsblock_Update(Actor* thisx, PlayState* play) { + ObjHsblock* this = THIS; + + if (this->actionFunc != NULL) { + this->actionFunc(this, play); + } + Actor_SetFocus(&this->dyna.actor, sFocusHeights[OBJHSBLOCK_GET_3(thisx)]); +} + +void ObjHsblock_Draw(Actor* thisx, PlayState* play) { + static Color_RGB8 sEnvColors[] = { + { 60, 60, 120 }, + { 120, 100, 70 }, + { 100, 150, 120 }, + { 255, 255, 255 }, + }; + Color_RGB8* envColor = &sEnvColors[OBJHSBLOCK_GET_6(thisx)]; + + 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); + gDPSetEnvColor(POLY_OPA_DISP++, envColor->r, envColor->g, envColor->b, 255); + gSPDisplayList(POLY_OPA_DISP++, sDisplayLists[OBJHSBLOCK_GET_3(thisx)]); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h index 375a18625a..0411cc9e4e 100644 --- a/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h +++ b/src/overlays/actors/ovl_Obj_Hsblock/z_obj_hsblock.h @@ -3,13 +3,17 @@ #include "global.h" +#define OBJHSBLOCK_GET_SWITCH(thisx) (((thisx)->params >> 8) & 0x7F) +#define OBJHSBLOCK_GET_3(thisx) ((thisx)->params & 3) +#define OBJHSBLOCK_GET_5(thisx) (((thisx)->params >> 5) & 1) +#define OBJHSBLOCK_GET_6(thisx) (((thisx)->params >> 6) & 3) + struct ObjHsblock; typedef void (*ObjHsblockActionFunc)(struct ObjHsblock*, PlayState*); typedef struct ObjHsblock { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x18]; + /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ ObjHsblockActionFunc actionFunc; } ObjHsblock; // size = 0x160