From ea42d8d118ad0eae0a5349c0f07f64a706ff0287 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Mon, 11 Jul 2022 18:06:06 -0700 Subject: [PATCH] Ds2n: OK (unused potion shop man from OoT) (#858) * Ds2n: OK * Ds2n: requested changes * EnDs2n: GlobalCtx is dead * Ds2n: formater pls * Update src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h Co-authored-by: Derek Hensley * Update src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c Co-authored-by: Derek Hensley * Ds2n: more limbs named * Ds2n: right, formatter for longer limb names * EnDs2: moved comment back... did git merge the wrong way? * Ds2n: broken anim is clearly wrong, its something else * Ds2n: almost mappeded entire blob * Ds2n: found another texture Co-authored-by: Isghj8 Co-authored-by: Derek Hensley --- assets/xml/objects/object_ds2n.xml | 140 +++++++++++++------- spec | 3 +- src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c | 106 +++++++++++++-- src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h | 16 ++- tools/disasm/functions.txt | 10 +- 5 files changed, 201 insertions(+), 74 deletions(-) diff --git a/assets/xml/objects/object_ds2n.xml b/assets/xml/objects/object_ds2n.xml index 8cee6b22e7..721eec6771 100644 --- a/assets/xml/objects/object_ds2n.xml +++ b/assets/xml/objects/object_ds2n.xml @@ -1,55 +1,93 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index c1ef2f24cc..ca0cf9a0dc 100644 --- a/spec +++ b/spec @@ -3531,8 +3531,7 @@ beginseg name "ovl_En_Ds2n" compress include "build/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.o" - include "build/data/ovl_En_Ds2n/ovl_En_Ds2n.data.o" - include "build/data/ovl_En_Ds2n/ovl_En_Ds2n.reloc.o" + include "build/src/overlays/actors/ovl_En_Ds2n/ovl_En_Ds2n_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c index 7f05e9e505..0d274c0e41 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.c @@ -2,6 +2,9 @@ * File: z_en_ds2n.c * Overlay: ovl_En_Ds2n * Description: Potion Shop Owner from OoT (unused) + * + * This actor was placed in the Staff Office of Stockpot inn + * but does not spawn because their object is missing. */ #include "z_en_ds2n.h" @@ -15,7 +18,8 @@ void EnDs2n_Destroy(Actor* thisx, PlayState* play); void EnDs2n_Update(Actor* thisx, PlayState* play); void EnDs2n_Draw(Actor* thisx, PlayState* play); -#if 0 +void EnDs2n_Idle(EnDs2n* this, PlayState* play); + const ActorInit En_Ds2n_InitVars = { ACTOR_EN_DS2N, ACTORCAT_NPC, @@ -28,24 +32,102 @@ const ActorInit En_Ds2n_InitVars = { (ActorFunc)EnDs2n_Draw, }; -#endif +static AnimationInfo sAnimations[] = { + { &gDs2nIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; -extern UNK_TYPE D_06008038; +static Vec3f sZeroVec = { 0, 0, 0 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE1650.s") +static TexturePtr sEyeTextures[] = { gDs2nEyeOpenTex, gDs2nEyeHalfTex, gDs2nEyeClosedTex }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE16A0.s") +void EnDs2n_SetupIdle(EnDs2n* this) { + this->blinkTimer = 20; + this->blinkState = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + this->actionFunc = EnDs2n_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE16D8.s") +void EnDs2n_Idle(EnDs2n* this, PlayState* play) { + SubS_FillLimbRotTables(play, this->limbRotTableY, this->limbRotTableZ, DS2N_LIMB_MAX); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Init.s") +void EnDs2n_UpdateEyes(EnDs2n* this) { + s16 nextBlinkTime = this->blinkTimer - 1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Destroy.s") + if (nextBlinkTime >= 3) { + this->blinkState = 0; + this->blinkTimer = nextBlinkTime; + } else if (nextBlinkTime == 0) { + this->blinkState = 2; + this->blinkTimer = (s32)(Rand_ZeroOne() * 60.0f) + 20; + } else { + this->blinkState = 1; + this->blinkTimer = nextBlinkTime; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Update.s") +void EnDs2n_Init(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE1874.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gDs2nSkeleton, &gDs2nIdleAnim, NULL, NULL, 0); + EnDs2n_SetupIdle(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/func_80AE18B4.s") +void EnDs2n_Destroy(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Ds2n/EnDs2n_Draw.s") + SkelAnime_Free(&this->skelAnime, play); +} + +void EnDs2n_Update(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; + + this->actionFunc(this, play); + Actor_MoveWithGravity(&this->actor); + SkelAnime_Update(&this->skelAnime); + + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->chestRot, this->actor.focus.pos); + EnDs2n_UpdateEyes(this); +} + +s32 EnDs2n_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnDs2n* this = THIS; + + if (limbIndex == DS2N_LIMB_HEAD) { + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); + } + + return false; +} + +void EnDs2n_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + EnDs2n* this = THIS; + Vec3f focusOffset = sZeroVec; + + if ((limbIndex == DS2N_LIMB_HIPS) || (limbIndex == DS2N_LIMB_LEFT_UPPER_ARM) || + (limbIndex == DS2N_LIMB_RIGHT_UPPER_ARM)) { + rot->y += (s16)Math_SinS(this->limbRotTableY[limbIndex]) * 0xC8; + rot->z += (s16)Math_CosS(this->limbRotTableZ[limbIndex]) * 0xC8; + } + + if (limbIndex == DS2N_LIMB_HEAD) { + Matrix_MultVec3f(&focusOffset, &thisx->focus.pos); + } +} + +void EnDs2n_Draw(Actor* thisx, PlayState* play) { + EnDs2n* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C5B0(play->state.gfxCtx); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->blinkState])); + + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->blinkState])); + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnDs2n_OverrideLimbDraw, EnDs2n_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h index e182edfd19..c7155ed740 100644 --- a/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h +++ b/src/overlays/actors/ovl_En_Ds2n/z_en_ds2n.h @@ -2,16 +2,24 @@ #define Z_EN_DS2N_H #include "global.h" +#include "objects/object_ds2n/object_ds2n.h" struct EnDs2n; typedef void (*EnDs2nActionFunc)(struct EnDs2n*, PlayState*); typedef struct EnDs2n { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x90]; - /* 0x01D4 */ EnDs2nActionFunc actionFunc; - /* 0x01D8 */ char unk_1D8[0x5C]; + /* 0x000 */ Actor actor; + /* 0x144 */ ColliderCylinder collider; // unused + /* 0x190 */ SkelAnime skelAnime; + /* 0x1D4 */ EnDs2nActionFunc actionFunc; + /* 0x1D8 */ s16 limbRotTableY[DS2N_LIMB_MAX]; + /* 0x1FE */ s16 limbRotTableZ[DS2N_LIMB_MAX]; + /* 0x224 */ Vec3s headRot; + /* 0x22A */ Vec3s chestRot; // set by function, but not applied in limbdraw + /* 0x230 */ s16 blinkState; + /* 0x232 */ s16 blinkTimer; + } EnDs2n; // size = 0x234 extern const ActorInit En_Ds2n_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index ee4bd732fc..adc0b08ecb 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12387,14 +12387,14 @@ 0x80AE0FA8:("EnTsn_OverrideLimbDraw",), 0x80AE1024:("EnTsn_PostLimbDraw",), 0x80AE1080:("EnTsn_Draw",), - 0x80AE1650:("func_80AE1650",), - 0x80AE16A0:("func_80AE16A0",), - 0x80AE16D8:("func_80AE16D8",), + 0x80AE1650:("EnDs2n_SetupIdle",), + 0x80AE16A0:("EnDs2n_Idle",), + 0x80AE16D8:("EnDs2n_UpdateEyes",), 0x80AE1760:("EnDs2n_Init",), 0x80AE17D0:("EnDs2n_Destroy",), 0x80AE17F4:("EnDs2n_Update",), - 0x80AE1874:("func_80AE1874",), - 0x80AE18B4:("func_80AE18B4",), + 0x80AE1874:("EnDs2n_OverrideLimbDraw",), + 0x80AE18B4:("EnDs2n_PostLimbDraw",), 0x80AE19B8:("EnDs2n_Draw",), 0x80AE1B70:("EnFsn_TestItemSelected",), 0x80AE1BF0:("EnFsn_GetWelcome",),