en_baisen OK and mostly documented (#205)

* en_baisen OK and mostly documented

* Fixed warning

* Made all suggested changes
This commit is contained in:
kyleburnette 2021-07-13 19:01:57 -07:00 committed by GitHub
parent fe6cce76dc
commit 12217a2081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 286 additions and 20 deletions

View File

@ -8449,9 +8449,9 @@ SECTIONS
ovl_En_Baisen : AT(RomLocation)
{
build/src/overlays/actors/ovl_En_Baisen/z_en_baisen.o(.text)
build/asm/overlays/ovl_En_Baisen_data.o(.data)
build/src/overlays/actors/ovl_En_Baisen/z_en_baisen.o(.data)
build/src/overlays/actors/ovl_En_Baisen/z_en_baisen.o(.rodata)
build/asm/overlays/ovl_En_Baisen_rodata.o(.rodata)
build/src/overlays/actors/ovl_En_Baisen/z_en_baisen_overlay.o(.ovl)
}
SegmentEnd = .;
SegmentSize = SegmentEnd - SegmentStart;

View File

@ -217,6 +217,11 @@ D_06013EA8 = 0x06013EA8;
/* z_eff_dust */
D_04054A90 = 0x04054A90;
/* z_en_baisen */
D_060011C0 = 0x060011C0;
D_060008B4 = 0x060008B4;
D_06008198 = 0x06008198;
/* z_en_cha */
D_06000710 = 0x06000710;
D_06000958 = 0x06000958;

View File

@ -1,3 +1,9 @@
/*
* File: z_en_baisen.c
* Overlay: ovl_En_Baisen
* Description: Viscen (leader of the guards in Clock Town)
*/
#include "z_en_baisen.h"
#define FLAGS 0x00000009
@ -9,7 +15,18 @@ void EnBaisen_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx);
void EnBaisen_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void func_80BE87B0(EnBaisen* this, GlobalContext* globalCtx);
void func_80BE87FC(EnBaisen* this);
void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx);
void func_80BE895C(EnBaisen* this, GlobalContext* globalCtx);
void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx);
void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx);
extern FlexSkeletonHeader D_06007908;
extern AnimationHeader D_060011C0;
extern AnimationHeader D_060008B4;
extern AnimationHeader D_06008198;
const ActorInit En_Baisen_InitVars = {
ACTOR_EN_BAISEN,
ACTORCAT_NPC,
@ -21,30 +38,252 @@ const ActorInit En_Baisen_InitVars = {
(ActorFunc)EnBaisen_Update,
(ActorFunc)EnBaisen_Draw,
};
*/
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/EnBaisen_Init.asm")
static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
AT_NONE,
AC_NONE,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_2,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0xF7CFFFFF, 0x00, 0x00 },
TOUCH_NONE | TOUCH_SFX_NORMAL,
BUMP_NONE,
OCELEM_ON,
},
{ 20, 60, 0, { 0, 0, 0 } },
};
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/EnBaisen_Destroy.asm")
static u16 sTextIds[] = { 0x2ABD, 0x2ABB, 0x2AD5, 0x2AD6, 0x2AD7, 0x2AD8, 0x2AC6 };
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE8690.asm")
static AnimationHeader* D_80BE8E4C[] = { &D_060011C0, &D_060008B4, &D_06008198 };
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE871C.asm")
static u8 animModes[] = { 0, 0 };
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE87B0.asm")
void EnBaisen_Init(Actor* thisx, GlobalContext* globalCtx) {
EnBaisen* this = THIS;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE87FC.asm")
ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f);
SkelAnime_InitSV(globalCtx, &this->skelAnime, &D_06007908, &D_060011C0, this->jointTable, this->morphTable, 20);
this->actor.colChkInfo.mass = MASS_IMMOVABLE;
this->paramCopy = this->actor.params;
if (this->actor.params == 0) {
this->unk290 = true;
if (!(gSaveContext.weekEventReg[63] & 0x80) && ((gSaveContext.day != 3) || !gSaveContext.isNight)) {
Actor_MarkForDeath(&this->actor);
}
} else {
this->collider.dim.radius = 30;
this->collider.dim.height = 60;
this->collider.dim.yShift = 0;
if ((gSaveContext.weekEventReg[63] & 0x80) || ((gSaveContext.day == 3) && (gSaveContext.isNight))) {
Actor_MarkForDeath(&this->actor);
}
}
this->actor.targetMode = 6;
this->actor.gravity = -3.0f;
Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
if (this->paramCopy == 0) {
this->actionFunc = func_80BE87B0;
} else {
func_80BE87FC(this);
}
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE887C.asm")
void EnBaisen_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnBaisen* this = THIS;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE895C.asm")
Collider_DestroyCylinder(globalCtx, &this->collider);
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE89D8.asm")
void EnBaisen_ChangeAnimation(EnBaisen* this, s32 animIndex) {
this->animIndex = animIndex;
this->frameCount = SkelAnime_GetFrameCount(&D_80BE8E4C[animIndex]->common);
SkelAnime_ChangeAnim(&this->skelAnime, D_80BE8E4C[this->animIndex], 1.0f, 0.0f, this->frameCount,
animModes[this->animIndex], -10.0f);
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE8AAC.asm")
void func_80BE871C(EnBaisen* this) {
s16 yawTemp = this->unk29E - this->actor.world.rot.y;
s32 yaw = ABS_ALT(yawTemp);
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/EnBaisen_Update.asm")
this->headRotXTarget = 0;
if ((this->actor.xzDistToPlayer < 200.0f) && (yaw < 0x4E20)) {
this->headRotXTarget = this->unk29E - this->actor.world.rot.y;
if (this->headRotXTarget > 0x2710) {
this->headRotXTarget = 0x2710;
} else if (this->headRotXTarget < -0x2710) {
this->headRotXTarget = -0x2710;
}
}
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/func_80BE8D3C.asm")
void func_80BE87B0(EnBaisen* this, GlobalContext* globalCtx) {
Actor* actorIterator = globalCtx->actorCtx.actorList[ACTORCAT_NPC].first;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Baisen_0x80BE84F0/EnBaisen_Draw.asm")
while (actorIterator != NULL) {
if (actorIterator->id == ACTOR_EN_HEISHI) {
this->heishiPointer = actorIterator;
}
actorIterator = actorIterator->next;
}
func_80BE87FC(this);
}
void func_80BE87FC(EnBaisen* this) {
if (this->paramCopy == 0) {
this->textIdIndex = 2;
EnBaisen_ChangeAnimation(this, 2);
this->unk29E = this->actor.world.rot.y;
} else {
EnBaisen_ChangeAnimation(this, 0);
}
this->actor.textId = sTextIds[this->textIdIndex];
this->unk29C = 0;
this->actionFunc = func_80BE887C;
}
void func_80BE887C(EnBaisen* this, GlobalContext* globalCtx) {
if (func_800B84D0(&this->actor, globalCtx)) {
func_80BE895C(this, globalCtx);
} else {
if (this->paramCopy != 0) {
this->textIdIndex = 0;
if (gSaveContext.weekEventReg[60] & 8) {
this->textIdIndex = 1;
}
if (Player_GetMask(globalCtx) == PLAYER_MASK_COUPLES_MASK) {
this->textIdIndex = 6;
}
if (this->unk2AC == 1) {
func_80BE895C(this, globalCtx);
return;
}
}
this->actor.textId = sTextIds[this->textIdIndex];
func_800B8614(&this->actor, globalCtx, 70.0f);
}
}
void func_80BE895C(EnBaisen* this, GlobalContext* globalCtx) {
if (this->unk2A4 != NULL) {
this->unk290 = true;
this->unk2AC = 1;
func_800B86C8(this->unk2A4, globalCtx, this->unk2A4);
}
this->unk29C = 1;
if (this->paramCopy == 0) {
this->unk2A4 = this->heishiPointer;
this->actionFunc = func_80BE8AAC;
} else {
this->actionFunc = func_80BE89D8;
}
}
void func_80BE89D8(EnBaisen* this, GlobalContext* globalCtx) {
if (&this->actor == this->unk2A4) {
this->unk29E = this->actor.world.rot.y;
if (this->animIndex == 0) {
EnBaisen_ChangeAnimation(this, 1);
}
} else {
this->unk29E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk2A4->world.pos);
if (this->animIndex != 0) {
EnBaisen_ChangeAnimation(this, 0);
}
}
if ((globalCtx->msgCtx.unk11F04 == 0x2AC6) || (globalCtx->msgCtx.unk11F04 == 0x2AC7) ||
(globalCtx->msgCtx.unk11F04 == 0x2AC8)) {
this->skelAnime.animPlaybackSpeed = 0.0f;
this->unk29E = this->actor.yawTowardsPlayer;
}
if (this->unk2AC == 2) { // Note: This variable is only ever set to 1.
func_80BE87FC(this);
}
}
void func_80BE8AAC(EnBaisen* this, GlobalContext* globalCtx) {
if ((this->textIdIndex % 2) != 0) {
this->unk29E = this->actor.world.rot.y;
if (this->animIndex == 0) {
EnBaisen_ChangeAnimation(this, 1);
}
} else {
if (this->unk2A4 != NULL) {
this->unk29E = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk2A4->world.pos);
}
if (this->animIndex != 0) {
EnBaisen_ChangeAnimation(this, 0);
}
}
if ((func_80152498(&globalCtx->msgCtx) == 5) && func_80147624(globalCtx)) {
func_801477B4(globalCtx);
this->textIdIndex++;
if (this->textIdIndex < 6) {
func_80151938(globalCtx, sTextIds[this->textIdIndex]);
if ((this->textIdIndex % 2) == 0) {
this->unk2A4 = this->heishiPointer;
} else {
this->unk2A4 = &this->actor;
}
func_800B86C8(this->unk2A4, globalCtx, this->unk2A4);
} else {
func_80BE87FC(this);
}
}
}
void EnBaisen_Update(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
EnBaisen* this = THIS;
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
if (this->unusedCounter != 0) {
this->unusedCounter--;
}
this->actor.shape.rot.y = this->actor.world.rot.y;
if ((this->paramCopy != 0) && (gSaveContext.day == 3) && gSaveContext.isNight) {
Actor_MarkForDeath(&this->actor);
return;
}
this->actionFunc(this, globalCtx);
Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor);
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1D);
Actor_SetScale(&this->actor, 0.01f);
if (this->unk290) {
func_80BE871C(this);
}
Actor_SetHeight(&this->actor, 60.0f);
Math_SmoothStepToS(&this->headRotX, this->headRotXTarget, 1, 0xBB8, 0);
Math_SmoothStepToS(&this->headRotY, this->headRotYTarget, 1, 0x3E8, 0);
Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
}
s32 EnBaisen_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
Actor* thisx) {
EnBaisen* this = THIS;
if (limbIndex == 9) {
rot->x += this->headRotX;
rot->y += this->headRotY;
rot->z += this->headRotZ;
}
return false;
}
void EnBaisen_Draw(Actor* thisx, GlobalContext* globalCtx) {
EnBaisen* this = THIS;
func_8012C28C(globalCtx->state.gfxCtx);
SkelAnime_DrawSV(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, this->skelAnime.dListCount,
EnBaisen_OverrideLimbDraw, NULL, &this->actor);
}

View File

@ -5,9 +5,31 @@
struct EnBaisen;
typedef void (*EnBaisenActionFunc)(struct EnBaisen*, GlobalContext*);
typedef struct EnBaisen {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x1B8];
/* 0x144 */ SkelAnime skelAnime;
/* 0x188 */ Vec3s jointTable[20];
/* 0x200 */ Vec3s morphTable[20];
/* 0x278 */ EnBaisenActionFunc actionFunc;
/* 0x27C */ s16 headRotY;
/* 0x27E */ s16 headRotX;
/* 0x280 */ s16 headRotZ;
/* 0x282 */ s16 headRotYTarget;
/* 0x284 */ s16 headRotXTarget;
/* 0x288 */ s32 animIndex;
/* 0x28C */ s32 paramCopy;
/* 0x290 */ s32 unk290;
/* 0x294 */ s16 unusedCounter;
/* 0x298 */ f32 frameCount;
/* 0x29C */ s16 unk29C;
/* 0x29E */ s16 unk29E;
/* 0x2A0 */ s16 textIdIndex;
/* 0x2A4 */ Actor* unk2A4;
/* 0x2A8 */ Actor* heishiPointer;
/* 0x2AC */ s32 unk2AC;
/* 0x2B0 */ ColliderCylinder collider;
} EnBaisen; // size = 0x2FC
extern const ActorInit En_Baisen_InitVars;

View File

@ -16161,7 +16161,7 @@
0x80BE8390:("EnMuto_Draw",),
0x80BE84F0:("EnBaisen_Init",),
0x80BE8664:("EnBaisen_Destroy",),
0x80BE8690:("func_80BE8690",),
0x80BE8690:("EnBaisen_ChangeAnimation",),
0x80BE871C:("func_80BE871C",),
0x80BE87B0:("func_80BE87B0",),
0x80BE87FC:("func_80BE87FC",),
@ -16170,7 +16170,7 @@
0x80BE89D8:("func_80BE89D8",),
0x80BE8AAC:("func_80BE8AAC",),
0x80BE8BE0:("EnBaisen_Update",),
0x80BE8D3C:("func_80BE8D3C",),
0x80BE8D3C:("EnBaisen_OverrideLimbDraw",),
0x80BE8D94:("EnBaisen_Draw",),
0x80BE8F20:("EnHeishi_Init",),
0x80BE9090:("EnHeishi_Destroy",),