ovl_En_Sth2 Decompiled and Documented (#898)

* ovl_En_Sth2 Decompiled and Documented

* &

* enum

* space

* pr review

* warnings

* pr review

* trailing coma + format

* pr review

* trailing coma

* review

* focusOffset
This commit is contained in:
Alejandro Asenjo 2022-07-22 00:57:49 -03:00 committed by GitHub
parent 6661b566a9
commit f0e4581e22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 116 additions and 19 deletions

View File

@ -0,0 +1,14 @@
<Root>
<File Name="ovl_En_Sth2" BaseAddress="0x80BF74E0" RangeStart="0x460" RangeEnd="0x2B30">
<Texture Name="gEnSth2SkinBlotchTex" OutName="en_sth2_skin_blotch" Format="rgba16" Width="8" Height="8" Offset="0x460"/>
<Texture Name="gEnSth2HairWithSkinTex" OutName="en_sth2_hair_with_skin" Format="rgba16" Width="8" Height="16" Offset="0x4E0"/>
<Texture Name="gEnSth2EarTex" OutName="en_sth2_ear" Format="rgba16" Width="8" Height="8" Offset="0x5E0"/>
<Texture Name="gEnSth2NoseTex" OutName="en_sth2_nose" Format="rgba16" Width="8" Height="8" Offset="0x660"/>
<Texture Name="gEnSth2EyeTex" OutName="en_sth2_eye" Format="rgba16" Width="32" Height="32" Offset="0x6E0"/>
<Texture Name="gEnSth2MouthTex" OutName="en_sth2_mouth" Format="rgba16" Width="32" Height="16" Offset="0xEE0"/>
<Texture Name="gEnSth2HairTex" OutName="en_sth2_hair" Format="rgba16" Width="8" Height="16" Offset="0x12E0"/>
<DList Name="gEnSth2HeadDL" Offset="0x2070"/>
<DList Name="gEnSth2HairDL" Offset="0x2390"/>
<Animation Name="gEnSth2WavingHandAnim" Offset="0x2B20"/>
</File>
</Root>

3
spec
View File

@ -4797,8 +4797,7 @@ beginseg
name "ovl_En_Sth2"
compress
include "build/src/overlays/actors/ovl_En_Sth2/z_en_sth2.o"
include "build/data/ovl_En_Sth2/ovl_En_Sth2.data.o"
include "build/data/ovl_En_Sth2/ovl_En_Sth2.reloc.o"
include "build/src/overlays/actors/ovl_En_Sth2/ovl_En_Sth2_reloc.o"
endseg
beginseg

View File

@ -13,8 +13,11 @@
void EnSth2_Init(Actor* thisx, PlayState* play);
void EnSth2_Destroy(Actor* thisx, PlayState* play);
void EnSth2_Update(Actor* thisx, PlayState* play);
void EnSth2_Draw(Actor* thisx, PlayState* play2);
void EnSth2_UpdateSkelAnime(EnSth2* this, PlayState* play);
void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play);
#if 0
const ActorInit En_Sth2_InitVars = {
ACTOR_EN_STH2,
ACTORCAT_NPC,
@ -27,22 +30,95 @@ const ActorInit En_Sth2_InitVars = {
(ActorFunc)NULL,
};
#endif
#include "overlays/ovl_En_Sth2/ovl_En_Sth2.c"
extern UNK_TYPE D_060031F8;
void EnSth2_Init(Actor* thisx, PlayState* play) {
EnSth2* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Init.s")
this->objIndex = Object_GetIndex(&play->objectCtx, OBJECT_STH);
Actor_SetScale(&this->actor, 0.01f);
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f);
this->unused = 0;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Destroy.s")
if (play->actorCtx.unk5 & 2) {
this->actor.flags |= (ACTOR_FLAG_10 | ACTOR_FLAG_20);
} else {
Actor_MarkForDeath(&this->actor);
return;
}
this->actionFunc = EnSth2_UpdateSkelAnime;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF75A0.s")
void EnSth2_Destroy(Actor* thisx, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/EnSth2_Update.s")
void EnSth2_UpdateSkelAnime(EnSth2* this, PlayState* play) {
SkelAnime_Update(&this->skelAnime);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF7688.s")
void EnSth2_Update(Actor* thisx, PlayState* play) {
s32 pad;
EnSth2* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF76AC.s")
if (Object_IsLoaded(&play->objectCtx, this->objIndex)) {
this->actor.objBankIndex = this->objIndex;
Actor_SetObjectDependency(play, &this->actor);
SkelAnime_InitFlex(play, &this->skelAnime, &object_sth_Skel_0031F8, &gEnSth2WavingHandAnim, this->jointTable,
this->morphTable, OBJECT_STH_LIMB_MAX);
Animation_PlayLoop(&this->skelAnime, &gEnSth2WavingHandAnim);
this->actor.update = EnSth2_UpdateActionFunc;
this->actor.draw = EnSth2_Draw;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF77AC.s")
void EnSth2_UpdateActionFunc(Actor* thisx, PlayState* play) {
EnSth2* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Sth2/func_80BF7814.s")
this->actionFunc(this, play);
}
s32 EnSth2_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) {
s32 pad;
if (limbIndex == OBJECT_STH_LIMB_0F) {
*dList = gEnSth2HeadDL;
}
if ((limbIndex == OBJECT_STH_LIMB_08) || (limbIndex == OBJECT_STH_LIMB_0A) || (limbIndex == OBJECT_STH_LIMB_0D)) {
rot->y += (s16)(Math_SinS((play->state.frames * ((limbIndex * 50) + 0x814))) * 200.0f);
rot->z += (s16)(Math_CosS((play->state.frames * ((limbIndex * 50) + 0x940))) * 200.0f);
}
return false;
}
void EnSth2_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) {
static Vec3f focusOffset = { 700.0f, 400.0f, 0.0f };
if (limbIndex == OBJECT_STH_LIMB_0F) {
Matrix_MultVec3f(&focusOffset, &thisx->focus.pos);
OPEN_DISPS(play->state.gfxCtx);
gSPDisplayList(POLY_OPA_DISP++, gEnSth2HairDL);
CLOSE_DISPS(play->state.gfxCtx);
}
}
void EnSth2_Draw(Actor* thisx, PlayState* play2) {
static Color_RGB8 sEnvColors[] = {
{ 190, 110, 0 }, { 0, 180, 110 }, { 0, 255, 80 }, { 255, 160, 60 }, { 190, 230, 250 }, { 240, 230, 120 },
};
PlayState* play = play2;
EnSth2* this = THIS;
OPEN_DISPS(play->state.gfxCtx);
func_8012C28C(play->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x08,
Gfx_EnvColor(play->state.gfxCtx, sEnvColors[1].r, sEnvColors[1].g, sEnvColors[1].b, 255));
gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_EnvColor(play->state.gfxCtx, 90, 110, 130, 255));
SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount,
EnSth2_OverrideLimbDraw, EnSth2_PostLimbDraw, &this->actor);
CLOSE_DISPS(play->state.gfxCtx);
}

View File

@ -2,12 +2,20 @@
#define Z_EN_STH2_H
#include "global.h"
#include "objects/object_sth/object_sth.h"
struct EnSth2;
typedef void (*EnSth2ActionFunc)(struct EnSth2*, PlayState*);
typedef struct EnSth2 {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x10C];
/* 0x144 */ SkelAnime skelAnime;
/* 0x188 */ Vec3s jointTable[OBJECT_STH_LIMB_MAX];
/* 0x1E8 */ Vec3s morphTable[OBJECT_STH_LIMB_MAX];
/* 0x248 */ s16 unused;
/* 0x24A */ u8 objIndex;
/* 0x24C */ EnSth2ActionFunc actionFunc;
} EnSth2; // size = 0x250
extern const ActorInit En_Sth2_InitVars;

View File

@ -16370,12 +16370,12 @@
0x80BF6C94:("EnOsk_Draw",),
0x80BF74E0:("EnSth2_Init",),
0x80BF7590:("EnSth2_Destroy",),
0x80BF75A0:("func_80BF75A0",),
0x80BF75A0:("EnSth2_UpdateSkelAnime",),
0x80BF75CC:("EnSth2_Update",),
0x80BF7688:("func_80BF7688",),
0x80BF76AC:("func_80BF76AC",),
0x80BF77AC:("func_80BF77AC",),
0x80BF7814:("func_80BF7814",),
0x80BF7688:("EnSth2_UpdateActionFunc",),
0x80BF76AC:("EnSth2_OverrideLimbDraw",),
0x80BF77AC:("EnSth2_PostLimbDraw",),
0x80BF7814:("EnSth2_Draw",),
0x80BFA100:("EnYb_Init",),
0x80BFA2D0:("EnYb_Destroy",),
0x80BFA2FC:("func_80BFA2FC",),