From 4ca8658d77616fb20579db69a87e2bee3b239c81 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Mon, 3 Jan 2022 21:57:00 -0800 Subject: [PATCH] Document object_giant and finish documenting En_Giant (#521) * First stab at XML * Use object symbols in En_Giant * Finish documenting En_Giant * Document unknown blob and all Vtx * Improve XML * Respond to Elliptic's review * Remove EN_ from the limb enum * palette -> tlut * File comment header * Some reordering to make things more sensible * One line comment styling * Preserve ordering --- assets/xml/objects/object_giant.xml | 145 +++++++++++------- src/overlays/actors/ovl_En_Giant/z_en_giant.c | 110 ++++++------- src/overlays/actors/ovl_En_Giant/z_en_giant.h | 28 +++- undefined_syms.txt | 24 --- 4 files changed, 154 insertions(+), 153 deletions(-) diff --git a/assets/xml/objects/object_giant.xml b/assets/xml/objects/object_giant.xml index 9e1815528e..edaeee0398 100644 --- a/assets/xml/objects/object_giant.xml +++ b/assets/xml/objects/object_giant.xml @@ -1,63 +1,90 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.c b/src/overlays/actors/ovl_En_Giant/z_en_giant.c index 547bfd8c63..68ccef9fc9 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.c +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.c @@ -5,6 +5,7 @@ */ #include "z_en_giant.h" +#include "objects/object_giant/object_giant.h" #define FLAGS 0x00000030 @@ -31,41 +32,21 @@ const ActorInit En_Giant_InitVars = { (ActorFunc)EnGiant_Draw, }; -extern AnimationHeader D_06002168; -extern Gfx D_06005A80[]; -extern Gfx D_06006280[]; -extern Gfx D_06007610[]; -extern Gfx D_06006A80[]; -extern FlexSkeletonHeader D_060079B0; -extern AnimationHeader D_06008394; -extern AnimationHeader D_060096E4; -extern AnimationHeader D_0600A1C4; -extern AnimationHeader D_0600ACA4; -extern AnimationHeader D_0600B784; -extern AnimationHeader D_0600C5D4; -extern AnimationHeader D_0600D040; -extern AnimationHeader D_0600DE84; -extern AnimationHeader D_060102A4; -extern AnimationHeader D_060116E4; -extern AnimationHeader D_06012A38; -extern AnimationHeader D_06013004; -extern AnimationHeader D_06013FE8; -extern AnimationHeader D_06015334; -extern AnimationHeader D_06017944; - -static AnimationHeader* sAnimationTable[] = { - &D_06008394, &D_060096E4, &D_060102A4, &D_060116E4, &D_06012A38, &D_06013004, &D_06013FE8, &D_06015334, - &D_06017944, &D_0600A1C4, &D_0600D040, &D_0600DE84, &D_0600ACA4, &D_0600B784, &D_0600C5D4, +static AnimationHeader* sAnimations[] = { + &gGiantLookUpStartAnim, &gGiantLookUpLoopAnim, &gGiantFallingOverAnim, &gGiantRaisedArmsStartAnim, + &gGiantRaisedArmsLoopAnim, &gGiantStruggleStartAnim, &gGiantStruggleLoopAnim, &gGiantIdleAnim, + &gGiantWalkingAnim, &gGiantBigCallStartAnim, &gGiantBigCallLoopAnim, &gGiantBigCallEndAnim, + &gGiantSmallCallStartAnim, &gGiantSmallCallLoopAnim, &gGiantSmallCallEndAnim, }; void EnGiant_ChangeAnimation(EnGiant* this, s16 newAnimationId) { if (newAnimationId >= GIANT_ANIMATION_LOOK_UP_START && newAnimationId < GIANT_ANIMATION_MAX) { if ((this->animationId == GIANT_ANIMATION_WALKING_LOOP && newAnimationId != GIANT_ANIMATION_WALKING_LOOP) || (newAnimationId == GIANT_ANIMATION_WALKING_LOOP && this->animationId != GIANT_ANIMATION_WALKING_LOOP)) { - Animation_Change(&this->skelAnime, sAnimationTable[newAnimationId], 1.0f, 0.0f, - Animation_GetLastFrame(&sAnimationTable[newAnimationId]->common), 2, 10.0f); + Animation_Change(&this->skelAnime, sAnimations[newAnimationId], 1.0f, 0.0f, + Animation_GetLastFrame(&sAnimations[newAnimationId]->common), 2, 10.0f); } else { - Animation_PlayOnce(&this->skelAnime, sAnimationTable[newAnimationId]); + Animation_PlayOnce(&this->skelAnime, sAnimations[newAnimationId]); } this->animationId = newAnimationId; } @@ -118,7 +99,8 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.uncullZoneScale = 2000.0f; this->actor.uncullZoneDownward = 2400.0f; Actor_SetScale(&this->actor, 0.32f); - SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_060079B0, &D_06002168, this->jointTable, this->morphTable, 16); + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gGiantSkel, &gGiantLargeStrideAnim, this->jointTable, + this->morphTable, GIANT_LIMB_MAX); EnGiant_ChangeAnimation(this, GIANT_ANIMATION_IDLE_LOOP); this->csAction = GIANT_CS_ACTION_NONE; this->actionFunc = EnGiant_PerformCutsceneActions; @@ -131,20 +113,20 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { case GIANT_TYPE_CANYON_TERMINA_FIELD: case GIANT_TYPE_CANYON_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_CANYON_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C6; + this->actorActionCommand = 0x1C6; break; case GIANT_TYPE_SWAMP_TERMINA_FIELD: case GIANT_TYPE_SWAMP_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_SWAMP_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C7; + this->actorActionCommand = 0x1C7; break; case GIANT_TYPE_OCEAN_TERMINA_FIELD: case GIANT_TYPE_OCEAN_CLOCK_TOWER_SUCCESS: case GIANT_TYPE_OCEAN_GIANTS_CHAMBER_AND_ENDING: - this->unk_24A = 0x1C8; + this->actorActionCommand = 0x1C8; break; default: - this->unk_24A = 0x1C5; + this->actorActionCommand = 0x1C5; break; } @@ -153,11 +135,12 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { Actor_MarkForDeath(&this->actor); return; } - this->unk_24A = 0x1C5; + this->actorActionCommand = 0x1C5; Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PerformClockTowerSuccessActions; - Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, - Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; this->actor.minVelocityY = 0.0f; @@ -167,7 +150,8 @@ void EnGiant_Init(Actor* thisx, GlobalContext* globalCtx) { if (GIANT_TYPE_IS_CLOCK_TOWER_FAILURE(type)) { Actor_SetScale(&this->actor, 0.32f); this->actionFunc = EnGiant_PlayClockTowerFailureAnimation; - Animation_Change(&this->skelAnime, &D_06013FE8, 1.0f, 0.0f, Animation_GetLastFrame(&D_06013004), 0, 0.0f); + Animation_Change(&this->skelAnime, &gGiantStruggleLoopAnim, 1.0f, 0.0f, + Animation_GetLastFrame(&gGiantStruggleStartAnim), 0, 0.0f); this->actor.draw = EnGiant_Draw; this->actor.velocity.y = 0.0f; this->actor.minVelocityY = 0.0f; @@ -204,7 +188,7 @@ void EnGiant_Destroy(Actor* thisx, GlobalContext* globalCtx) { } /** - * The animations in sAnimationTable are organized such that looping animations + * The animations in sAnimations are organized such that looping animations * appear immediately after their respective starting animations. The point of * this function is to play the requested start animation if it has not been * played yet and play the respetive looping animation otherwise. @@ -266,8 +250,9 @@ void EnGiant_ChangeAnimationBasedOnCsAction(EnGiant* this) { } break; case GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER: - Animation_Change(&this->skelAnime, &D_060116E4, 0.0f, Animation_GetLastFrame(&D_060116E4) - 1.0f, - Animation_GetLastFrame(&D_060116E4), 2, 0.0f); + Animation_Change(&this->skelAnime, &gGiantRaisedArmsStartAnim, 0.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim) - 1.0f, + Animation_GetLastFrame(&gGiantRaisedArmsStartAnim), 2, 0.0f); break; } } @@ -352,20 +337,19 @@ void EnGiant_PlaySound(EnGiant* this) { void EnGiant_UpdatePosition(EnGiant* this, GlobalContext* globalCtx, u32 actionIndex) { CsCmdActorAction* actorAction = globalCtx->csCtx.npcActions[actionIndex]; - f32 floatUnk10 = actorAction->unk0C.y; + f32 startPosY = actorAction->unk0C.y; s32 pad[2]; - f32 floatUnk1C = actorAction->unk18.y; - f32 functionTemp; + f32 endPosY = actorAction->unk18.y; + f32 scale = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); - functionTemp = func_800F5A8C(actorAction->endFrame, actorAction->startFrame, globalCtx->csCtx.frames, globalCtx); - this->actor.world.pos.y = ((floatUnk1C - floatUnk10) * functionTemp) + floatUnk10; + this->actor.world.pos.y = ((endPosY - startPosY) * scale) + startPosY; } void EnGiant_PerformClockTowerSuccessActions(EnGiant* this, GlobalContext* globalCtx) { - if (func_800EE29C(globalCtx, this->unk_24A)) { - EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->unk_24A)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + if (func_800EE29C(globalCtx, this->actorActionCommand)) { + EnGiant_UpdatePosition(this, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -385,10 +369,10 @@ void EnGiant_PlayClockTowerFailureAnimation(EnGiant* this, GlobalContext* global void EnGiant_PerformCutsceneActions(EnGiant* this, GlobalContext* globalCtx) { this->actor.draw = EnGiant_Draw; - if (func_800EE29C(globalCtx, this->unk_24A)) { - func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->unk_24A)); - if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0) { - this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->unk_24A)]->unk0; + if (func_800EE29C(globalCtx, this->actorActionCommand)) { + func_800EDF24(&this->actor, globalCtx, func_800EE200(globalCtx, this->actorActionCommand)); + if (this->csAction != globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0) { + this->csAction = globalCtx->csCtx.npcActions[func_800EE200(globalCtx, this->actorActionCommand)]->unk0; EnGiant_ChangeAnimationBasedOnCsAction(this); } EnGiant_UpdateAlpha(this); @@ -427,10 +411,10 @@ void EnGiant_Update(Actor* thisx, GlobalContext* globalCtx) { } void EnGiant_PostLimbDrawOpa(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { - if (limbIndex == 1) { + if (limbIndex == GIANT_LIMB_HEAD) { OPEN_DISPS(globalCtx->state.gfxCtx); - gSPDisplayList(POLY_OPA_DISP++, D_06007610); + gSPDisplayList(POLY_OPA_DISP++, gGiantBeardDL); CLOSE_DISPS(globalCtx->state.gfxCtx); } @@ -440,21 +424,15 @@ void EnGiant_PostLimbDrawXlu(GlobalContext* globalCtx, s32 limbIndex, Gfx** dLis Gfx** gfx) { EnGiant* this = THIS; - if (limbIndex == 1) { - Matrix_CopyCurrentState(&this->unk_254); + if (limbIndex == GIANT_LIMB_HEAD) { + Matrix_CopyCurrentState(&this->headDrawMtxF); } } void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnGiant* this = THIS; - - /** - * 0 = eyes fully open face - * 1 = eyes half-closed face - * 2 = eyes fully closed face - */ - static TexturePtr sFaceTextures[] = { D_06005A80, D_06006280, D_06006A80 }; + static TexturePtr sFaceTextures[] = { gGiantFaceEyeOpenTex, gGiantFaceEyeHalfTex, gGiantFaceEyeClosedTex }; if (this->alpha > 0) { OPEN_DISPS(globalCtx->state.gfxCtx); @@ -479,10 +457,10 @@ void EnGiant_Draw(Actor* thisx, GlobalContext* globalCtx) { POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, EnGiant_PostLimbDrawXlu, thisx, POLY_XLU_DISP); - Matrix_InsertMatrix(&this->unk_254, MTXMODE_NEW); + Matrix_InsertMatrix(&this->headDrawMtxF, MTXMODE_NEW); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, D_06007610); + gSPDisplayList(POLY_XLU_DISP++, gGiantBeardDL); } CLOSE_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Giant/z_en_giant.h b/src/overlays/actors/ovl_En_Giant/z_en_giant.h index 6f50370f7b..e28aa2a32a 100644 --- a/src/overlays/actors/ovl_En_Giant/z_en_giant.h +++ b/src/overlays/actors/ovl_En_Giant/z_en_giant.h @@ -86,6 +86,26 @@ typedef enum { /* 15 */ GIANT_CS_ACTION_HOLDING_UP_MOON_IN_CLOCK_TOWER } GiantCsActionIndex; +typedef enum { + /* 0 */ GIANT_LIMB_NONE, + /* 1 */ GIANT_LIMB_HEAD, + /* 2 */ GIANT_LIMB_LEFT_THIGH, + /* 3 */ GIANT_LIMB_LEFT_LOWER_LEG, + /* 4 */ GIANT_LIMB_LEFT_FOOT, + /* 5 */ GIANT_LIMB_RIGHT_THIGH, + /* 6 */ GIANT_LIMB_RIGHT_LOWER_LEG, + /* 7 */ GIANT_LIMB_RIGHT_FOOT, + /* 8 */ GIANT_LIMB_LEFT_SHOULDER, + /* 9 */ GIANT_LIMB_LEFT_UPPER_ARM, + /* 10 */ GIANT_LIMB_LEFT_FOREARM, + /* 11 */ GIANT_LIMB_LEFT_HAND, + /* 12 */ GIANT_LIMB_RIGHT_SHOULDER, + /* 13 */ GIANT_LIMB_RIGHT_UPPER_ARM, + /* 14 */ GIANT_LIMB_RIGHT_FOREARM, + /* 15 */ GIANT_LIMB_RIGHT_HAND, + /* 16 */ GIANT_LIMB_MAX, +} EnGiantLimbs; + struct EnGiant; typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); @@ -93,14 +113,14 @@ typedef void (*EnGiantActionFunc)(struct EnGiant*, GlobalContext*); typedef struct EnGiant { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; - /* 0x188 */ Vec3s jointTable[16]; - /* 0x1E8 */ Vec3s morphTable[16]; + /* 0x188 */ Vec3s jointTable[GIANT_LIMB_MAX]; + /* 0x1E8 */ Vec3s morphTable[GIANT_LIMB_MAX]; /* 0x248 */ s16 animationId; - /* 0x24A */ u16 unk_24A; + /* 0x24A */ u16 actorActionCommand; /* 0x24C */ u16 csAction; /* 0x24E */ s16 alpha; /* 0x250 */ u16 sfxId; - /* 0x254 */ MtxF unk_254; + /* 0x254 */ MtxF headDrawMtxF; /* 0x294 */ s16 faceIndex; /* 0x296 */ s16 blinkTimer; /* 0x298 */ EnGiantActionFunc actionFunc; diff --git a/undefined_syms.txt b/undefined_syms.txt index 9a52cd69a5..43adb28672 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2308,30 +2308,6 @@ D_0600F6C0 = 0x0600F6C0; D_0600F578 = 0x0600F578; D_0600F6C0 = 0x0600F6C0; -// ovl_En_Giant - -D_06002168 = 0x06002168; -D_06005A80 = 0x06005A80; -D_06006280 = 0x06006280; -D_06006A80 = 0x06006A80; -D_06007610 = 0x06007610; -D_060079B0 = 0x060079B0; -D_06008394 = 0x06008394; -D_060096E4 = 0x060096E4; -D_0600A1C4 = 0x0600A1C4; -D_0600ACA4 = 0x0600ACA4; -D_0600B784 = 0x0600B784; -D_0600C5D4 = 0x0600C5D4; -D_0600D040 = 0x0600D040; -D_0600DE84 = 0x0600DE84; -D_060102A4 = 0x060102A4; -D_060116E4 = 0x060116E4; -D_06012A38 = 0x06012A38; -D_06013004 = 0x06013004; -D_06013FE8 = 0x06013FE8; -D_06015334 = 0x06015334; -D_06017944 = 0x06017944; - // ovl_En_Ginko_Man D_060008C0 = 0x060008C0;