ovl_Obj_Hsblock decompiled (#866)

* ovl_Obj_Hsblock decompiled

* PlayState + PR Reviews

* s

* pr review

* sFocusHeights

* displaylists rename

* bring up names from OOT

* fix

* fix

* xml comment
This commit is contained in:
Alejandro Asenjo 2022-07-19 12:38:47 -03:00 committed by GitHub
parent 356fde3045
commit d150a04e6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 27 deletions

View File

@ -1,10 +1,11 @@
<Root>
<!-- Assets for the hookshot post -->
<File Name="object_d_hsblock" Segment="6">
<DList Name="object_d_hsblock_DL_000210" Offset="0x210" />
<DList Name="object_d_hsblock_DL_000470" Offset="0x470" />
<Collision Name="object_d_hsblock_Colheader_000578" Offset="0x578" />
<Collision Name="object_d_hsblock_Colheader_000730" Offset="0x730" />
<Texture Name="object_d_hsblock_Tex_000760" OutName="tex_000760" Format="i4" Width="64" Height="64" Offset="0x760" />
<Texture Name="object_d_hsblock_Tex_000F60" OutName="tex_000F60" Format="i8" Width="32" Height="64" Offset="0xF60" />
<DList Name="gHookshotPostDL" Offset="0x210" />
<DList Name="gHookshotTargetDL" Offset="0x470" />
<Collision Name="gHookshotTargetCol" Offset="0x578" />
<Collision Name="gHookshotPostCol" Offset="0x730" />
<Texture Name="gHookshotTargetTex" OutName="tex_000760" Format="i4" Width="64" Height="64" Offset="0x760" />
<Texture Name="gHookshotPostTex" OutName="tex_000F60" Format="i8" Width="32" Height="64" Offset="0xF60" />
</File>
</Root>

3
spec
View File

@ -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

View File

@ -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);
}

View File

@ -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