From a441a3cb2d51632f07b79579f0b100b962a3be76 Mon Sep 17 00:00:00 2001 From: Tharo <17233964+Thar0@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:52:11 +0000 Subject: [PATCH] Decompile ovl_En_Po_Composer (#1391) * Decompiled, mostly named * Few more labels and document object * Review changes * Further review changes * Improve EnPoComposer_UpdateEnvColor * PO_COMPOSER -> POE_COMPOSER, tweak animation names * More changes * OCARINA_MODE_EVENT * fix merge --------- Co-authored-by: angie --- assets/xml/objects/object_po_composer.xml | 86 ++- spec | 3 +- .../ovl_En_Po_Composer/z_en_po_composer.c | 709 ++++++++++++++++-- .../ovl_En_Po_Composer/z_en_po_composer.h | 47 +- 4 files changed, 726 insertions(+), 119 deletions(-) diff --git a/assets/xml/objects/object_po_composer.xml b/assets/xml/objects/object_po_composer.xml index c45cf9039b..81042139f8 100644 --- a/assets/xml/objects/object_po_composer.xml +++ b/assets/xml/objects/object_po_composer.xml @@ -1,35 +1,37 @@  + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - + - - - - - + + + + + + + @@ -42,17 +44,21 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/spec b/spec index 1344fcadee..be052f9e81 100644 --- a/spec +++ b/spec @@ -4229,8 +4229,7 @@ beginseg name "ovl_En_Po_Composer" compress include "build/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.o" - include "build/data/ovl_En_Po_Composer/ovl_En_Po_Composer.data.o" - include "build/data/ovl_En_Po_Composer/ovl_En_Po_Composer.reloc.o" + include "build/src/overlays/actors/ovl_En_Po_Composer/ovl_En_Po_Composer_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c index ed8606208e..c668b054c4 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.c @@ -1,7 +1,7 @@ /* * File: z_en_po_composer.c * Overlay: ovl_En_Po_Composer - * Description: Poe Composers + * Description: Poe Composers Flat and Sharp */ #include "z_en_po_composer.h" @@ -15,19 +15,23 @@ void EnPoComposer_Destroy(Actor* thisx, PlayState* play); void EnPoComposer_Update(Actor* thisx, PlayState* play); void EnPoComposer_Draw(Actor* thisx, PlayState* play); -void func_80BC5294(EnPoComposer* this, PlayState* play); -void func_80BC52F0(EnPoComposer* this, PlayState* play); -void func_80BC53A0(EnPoComposer* this, PlayState* play); -void func_80BC5404(EnPoComposer* this, PlayState* play); -void func_80BC5570(EnPoComposer* this, PlayState* play); -void func_80BC55E0(EnPoComposer* this, PlayState* play); -void func_80BC5670(EnPoComposer* this, PlayState* play); -void func_80BC56D0(EnPoComposer* this, PlayState* play); -void func_80BC5780(EnPoComposer* this, PlayState* play); -void func_80BC5830(EnPoComposer* this, PlayState* play); -void func_80BC58E0(EnPoComposer* this, PlayState* play); +void EnPoComposer_AwaitPlayer(EnPoComposer* this, PlayState* play); +void EnPoComposer_StartCutscene(EnPoComposer* this, PlayState* play); +void EnPoComposer_StartedCutscene(EnPoComposer* this, PlayState* play); +void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play); +void EnPoComposer_IdleStill(EnPoComposer* this, PlayState* play); +void EnPoComposer_Appear(EnPoComposer* this, PlayState* play); +void EnPoComposer_Idle(EnPoComposer* this, PlayState* play); +void EnPoComposer_RaiseArms(EnPoComposer* this, PlayState* play); +void EnPoComposer_LowerArms(EnPoComposer* this, PlayState* play); +void EnPoComposer_CutscenePlayCurse(EnPoComposer* this, PlayState* play); +void EnPoComposer_Roll(EnPoComposer* this, PlayState* play); + +void EnPoComposer_SetupAwaitPlayer(EnPoComposer* this); +void EnPoComposer_SetupStartCutscene(EnPoComposer* this); +void EnPoComposer_SetupStartedCutscene(EnPoComposer* this); +void EnPoComposer_StepLightAlpha(EnPoComposer* this); -#if 0 ActorInit En_Po_Composer_InitVars = { /**/ ACTOR_EN_PO_COMPOSER, /**/ ACTORCAT_ITEMACTION, @@ -40,32 +44,56 @@ ActorInit En_Po_Composer_InitVars = { /**/ EnPoComposer_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BC6780 = { - { COLTYPE_HIT3, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_HIT3, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 20, { 0, 0, 0 } }, }; -// static ColliderJntSphElementInit sJntSphElementsInit[1] = { -static ColliderJntSphElementInit D_80BC67AC[1] = { +static ColliderJntSphElementInit sJntSphElementsInit[1] = { { - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x08 }, { 0x00000000, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, - { 9, { { 0, -1500, 0 }, 10 }, 100 }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x08 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, + { POE_COMPOSER_LIMB_LANTERN, { { 0, -1500, 0 }, 10 }, 100 }, }, }; -// static ColliderJntSphInit sJntSphInit = { -static ColliderJntSphInit D_80BC67D0 = { - { COLTYPE_HIT3, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_JNTSPH, }, - ARRAY_COUNT(sJntSphElementsInit), D_80BC67AC, // sJntSphElementsInit, +static ColliderJntSphInit sJntSphInit = { + { + COLTYPE_HIT3, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_JNTSPH, + }, + ARRAY_COUNT(sJntSphElementsInit), + sJntSphElementsInit, }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80BC67E0 = { 4, 25, 50, 40 }; +static CollisionCheckInfoInit sColChkInfoInit = { 4, 25, 50, 40 }; -// static DamageTable sDamageTable = { -static DamageTable D_80BC67E8 = { +static DamageTable sDamageTable = { /* Deku Nut */ DMG_ENTRY(0, 0x0), /* Deku Stick */ DMG_ENTRY(2, 0x0), /* Horse trample */ DMG_ENTRY(1, 0x0), @@ -100,88 +128,619 @@ static DamageTable D_80BC67E8 = { /* Powder Keg */ DMG_ENTRY(0, 0x0), }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80BC6958[] = { +typedef enum { + /* 0 */ POE_COMPOSER_ANIM_STILL, + /* 1 */ POE_COMPOSER_ANIM_APPEAR_DISAPPEAR, + /* 2 */ POE_COMPOSER_ANIM_IDLE, + /* 3 */ POE_COMPOSER_ANIM_RAISE_ARMS, + /* 4 */ POE_COMPOSER_ANIM_ARMS_RAISED, + /* 5 */ POE_COMPOSER_ANIM_LOWER_ARMS, + /* 6 */ POE_COMPOSER_ANIM_LOOKING_DOWN, + /* 7 */ POE_COMPOSER_ANIM_BEGIN_PLAYING_CURSE, + /* 8 */ POE_COMPOSER_ANIM_PLAYING_CURSE, + /* 9 */ POE_COMPOSER_ANIM_BEGIN_ROLLING, + /* 10 */ POE_COMPOSER_ANIM_ROLLING, + /* 11 */ POE_COMPOSER_ANIM_FLEE, + /* 12 */ POE_COMPOSER_ANIM_ATTACK, + /* 13 */ POE_COMPOSER_ANIM_MAX +} EnPoComposerAnim; + +static AnimationInfo sAnimationInfo[POE_COMPOSER_ANIM_MAX] = { + /* 0 */ { &gPoeComposerStillAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 1 */ { &gPoeComposerAppearDisappearAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + /* 2 */ { &gPoeComposerIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 3 */ { &gPoeComposerRaiseArmsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 4 */ { &gPoeComposerArmsRaisedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 5 */ { &gPoeComposerLowerArmsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 6 */ { &gPoeComposerLookDownAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 7 */ { &gPoeComposerBeginPlayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 8 */ { &gPoeComposerPlayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 9 */ { &gPoeComposerBeginRollAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 10 */ { &gPoeComposerRollAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 11 */ { &gPoeComposerFleeAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + /* 12 */ { &gPoeComposerAttackAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, +}; + +static Color_RGBA8 sLightColorInit = { 255, 255, 210, 0 }; + +static Color_RGBA8 sEnvColorInit = { 0, 0, 0, 255 }; + +static Color_RGBA8 sSharpClothingColor1 = { 75, 20, 25, 255 }; + +static Color_RGBA8 sFlatClothingColor1 = { 80, 110, 90, 255 }; + +static Color_RGBA8 sSharpClothingColor2 = { 90, 85, 50, 255 }; + +static Color_RGBA8 sFlatClothingColor2 = { 100, 90, 100, 255 }; + +static InitChainEntry sInitChain[] = { ICHAIN_F32(targetArrowOffset, 3200, ICHAIN_STOP), }; -#endif +static s32 sPlayerIsPlayingOcarina = false; -extern ColliderCylinderInit D_80BC6780; -extern ColliderJntSphElementInit D_80BC67AC[1]; -extern ColliderJntSphInit D_80BC67D0; -extern CollisionCheckInfoInit D_80BC67E0; -extern DamageTable D_80BC67E8; -extern InitChainEntry D_80BC6958[]; +void EnPoComposer_Init(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; -extern UNK_TYPE D_0600188C; -extern UNK_TYPE D_06006E08; -extern UNK_TYPE D_06006FD8; + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gPoeComposerSkel, &gPoeComposerIdleAnim, this->jointTable, + this->morphTable, POE_COMPOSER_LIMB_MAX); + Collider_InitJntSph(play, &this->lanternCollider); + Collider_SetJntSph(play, &this->lanternCollider, &this->actor, &sJntSphInit, this->lanternColliderElements); + Collider_InitCylinder(play, &this->bodyCollider); + Collider_SetCylinder(play, &this->bodyCollider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); + Lights_PointGlowSetInfo(&this->lightInfo, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z, + 255, 255, 255, 0); + this->actor.flags &= ~ACTOR_FLAG_TARGETABLE; + this->lightColor = sLightColorInit; + this->envColor = sEnvColorInit; + this->cueId = POE_COMPOSER_CUEID_NONE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Init.s") + if (POE_COMPOSER_IS_FLAT(&this->actor)) { + this->sharpCsNum = 0; + this->inCutscene = true; + EnPoComposer_SetupStartedCutscene(this); + } else if (POE_COMPOSER_4000(&this->actor)) { + if (gSaveContext.save.entrance != ENTRANCE(IKANA_CANYON, 10)) { + Actor_Kill(&this->actor); + return; + } + this->sharpCsNum = SHARP_CS_ENCOUNTER_FIRST; + this->inCutscene = true; + EnPoComposer_SetupStartedCutscene(this); + } else { + s32 i; + s16 csId = this->actor.csId; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Destroy.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_04)) { + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5250.s") + for (i = 0; i < ARRAY_COUNT(this->csIds); i++) { + if (csId == CS_ID_NONE) { + break; + } + this->csIds[i] = csId; + csId = CutsceneManager_GetAdditionalCsId(csId); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5294.s") + if (CHECK_WEEKEVENTREG(WEEKEVENTREG_14_02)) { + this->sharpCsNum = SHARP_CS_ENCOUNTER_OTHER; + } else { + this->sharpCsNum = SHARP_CS_ENCOUNTER_FIRST; + } + this->inCutscene = false; + EnPoComposer_SetupAwaitPlayer(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC52D4.s") +void EnPoComposer_Destroy(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC52F0.s") + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); + Collider_DestroyJntSph(play, &this->lanternCollider); + Collider_DestroyCylinder(play, &this->bodyCollider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC538C.s") +void EnPoComposer_SetupAwaitPlayer(EnPoComposer* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_STILL); + this->actionFunc = EnPoComposer_AwaitPlayer; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC53A0.s") +void EnPoComposer_AwaitPlayer(EnPoComposer* this, PlayState* play) { + if (this->actor.xzDistToPlayer < 200.0f) { + EnPoComposer_SetupStartCutscene(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC53B0.s") +void EnPoComposer_SetupStartCutscene(EnPoComposer* this) { + this->inCutscene = true; + this->actionFunc = EnPoComposer_StartCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5404.s") +void EnPoComposer_StartCutscene(EnPoComposer* this, PlayState* play) { + if (CutsceneManager_IsNext(this->csIds[this->sharpCsNum])) { + CutsceneManager_Start(this->csIds[this->sharpCsNum], &this->actor); + EnPoComposer_SetupStartedCutscene(this); + } else { + if (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_TALK) { + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + } + CutsceneManager_Queue(this->csIds[this->sharpCsNum]); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC552C.s") +void EnPoComposer_SetupStartedCutscene(EnPoComposer* this) { + this->actionFunc = EnPoComposer_StartedCutscene; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5570.s") +void EnPoComposer_StartedCutscene(EnPoComposer* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5580.s") +void EnPoComposer_SetupPlayCurse(EnPoComposer* this) { + this->actionTimer = 0; + this->actor.flags |= ACTOR_FLAG_TARGETABLE; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_PLAYING_CURSE); + this->actionFunc = EnPoComposer_PlayCurse; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC55E0.s") +void EnPoComposer_PlayCurse(EnPoComposer* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC562C.s") + // Damage the player every second + if (this->actionTimer == 20) { + func_800B8D10(play, &this->actor, 0.0f, 0, 0.0f, 1, 4); + this->actionTimer = 0; + } else { + this->actionTimer++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5670.s") + // Ocarina check + if (player->stateFlags2 & PLAYER_STATE2_8000000) { + if (!sPlayerIsPlayingOcarina) { + // Play sound whenever the player begins playing the Ocarina + Audio_PlaySfx(NA_SE_SY_TRE_BOX_APPEAR); + } + sPlayerIsPlayingOcarina = true; + } else { + sPlayerIsPlayingOcarina = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5680.s") + // Song check, check if player just played song of storms or song of healing + if (play->msgCtx.ocarinaMode == OCARINA_MODE_EVENT) { + switch (play->msgCtx.lastPlayedSong) { + case OCARINA_SONG_STORMS: + this->sharpCsNum = SHARP_CS_SONG_STORMS; + EnPoComposer_SetupStartCutscene(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC56D0.s") + case OCARINA_SONG_HEALING: + this->sharpCsNum = SHARP_CS_SONG_HEALING; + EnPoComposer_SetupStartCutscene(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5738.s") + default: + break; + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5780.s") + // Play sharp's curse bgm + Audio_PlaySequenceAtPos(SEQ_PLAYER_BGM_SUB, &this->actor.projectedPos, NA_BGM_SHARPS_CURSE, 2000.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC57E8.s") +void EnPoComposer_SetupIdleStill(EnPoComposer* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_STILL); + this->actionFunc = EnPoComposer_IdleStill; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5830.s") +void EnPoComposer_IdleStill(EnPoComposer* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5898.s") +void EnPoComposer_SetupAppear(EnPoComposer* this) { + this->actionTimer = 0; + Actor_PlaySfx(&this->actor, NA_SE_EN_STALKIDS_APPEAR); + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_LAUGH); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_APPEAR_DISAPPEAR); + this->actionFunc = EnPoComposer_Appear; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC58E0.s") +void EnPoComposer_Appear(EnPoComposer* this, PlayState* play) { + this->actionTimer++; + this->actor.shape.rot.y += 0x1000; + if (this->actionTimer == 32) { + EnPoComposer_SetupIdleStill(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC59BC.s") +void EnPoComposer_SetupIdle(EnPoComposer* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_IDLE); + this->actionFunc = EnPoComposer_Idle; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC59EC.s") +void EnPoComposer_Idle(EnPoComposer* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5CC8.s") +void EnPoComposer_SetupRaiseArms(EnPoComposer* this) { + this->csCueTimer = 0; + Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_RAISE_ARMS); + this->actionFunc = EnPoComposer_RaiseArms; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5D34.s") +void EnPoComposer_RaiseArms(EnPoComposer* this, PlayState* play) { + if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csCueTimer++; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_ARMS_RAISED); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5DEC.s") +void EnPoComposer_SetupLowerArms(EnPoComposer* this) { + this->csCueTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_LOWER_ARMS); + this->actionFunc = EnPoComposer_LowerArms; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC5FE8.s") +void EnPoComposer_LowerArms(EnPoComposer* this, PlayState* play) { + if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csCueTimer++; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_LOOKING_DOWN); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Update.s") +void EnPoComposer_SetupCutscenePlayCurse(EnPoComposer* this) { + this->csCueTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_BEGIN_PLAYING_CURSE); + this->actionFunc = EnPoComposer_CutscenePlayCurse; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC60BC.s") +void EnPoComposer_CutscenePlayCurse(EnPoComposer* this, PlayState* play) { + if ((this->csCueTimer == 0) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csCueTimer++; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_PLAYING_CURSE); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/func_80BC617C.s") +void EnPoComposer_SetupRoll(EnPoComposer* this) { + this->csCueTimer = 0; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_BEGIN_ROLLING); + this->actionFunc = EnPoComposer_Roll; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Po_Composer/EnPoComposer_Draw.s") +void EnPoComposer_Roll(EnPoComposer* this, PlayState* play) { + if (this->csCueTimer == 0) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + this->csCueTimer++; + Actor_PlaySfx(&this->actor, NA_SE_EN_SHARP_REACTION); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, POE_COMPOSER_ANIM_ROLLING); + } + } else if (Animation_OnFrame(&this->skelAnime, 1.0f) && (this->lightColor.a > 32)) { + if (this->csCueTimer == 1) { + Actor_PlaySfx(&this->actor, NA_SE_EN_LAST3_DEAD_WIND2_OLD); + this->csCueTimer = 2; + } else { + Actor_PlaySfx(&this->actor, NA_SE_EN_LAST3_DEAD_WIND3_OLD); + this->csCueTimer = 1; + } + } +} + +void EnPoComposer_SharpCutsceneDone(EnPoComposer* this) { + SET_WEEKEVENTREG(WEEKEVENTREG_14_04); + Actor_Kill(&this->actor); +} + +s32 EnPoComposer_UpdateAction(EnPoComposer* this, PlayState* play) { + u16 cueType = POE_COMPOSER_IS_FLAT(&this->actor) ? CS_CMD_ACTOR_CUE_482 : CS_CMD_ACTOR_CUE_481; + s32 cueChannel; + + if (!this->inCutscene) { + return false; + } + + if (Cutscene_IsCueInChannel(play, cueType)) { + cueChannel = Cutscene_GetCueChannel(play, cueType); + + if (this->cueId != play->csCtx.actorCues[cueChannel]->id) { + this->cueId = play->csCtx.actorCues[cueChannel]->id; + + switch (play->csCtx.actorCues[cueChannel]->id) { + case POE_COMPOSER_CUEID_IDLE: // loop idle + EnPoComposer_SetupIdleStill(this); + break; + + case POE_COMPOSER_CUEID_APPEAR_SPIN: // appear/disappear -> loop idle + EnPoComposer_SetupAppear(this); + break; + + case POE_COMPOSER_CUEID_IDLE2: // loop sharp idle + EnPoComposer_SetupIdle(this); + break; + + case POE_COMPOSER_CUEID_RAISE_ARMS: // raise arms -> loop arms raised + EnPoComposer_SetupRaiseArms(this); + break; + + case POE_COMPOSER_CUEID_LOWER_ARMS: // lower arms -> loop idle + EnPoComposer_SetupLowerArms(this); + break; + + case POE_COMPOSER_CUEID_PLAY_CURSE: // begin playing -> loop playing + EnPoComposer_SetupCutscenePlayCurse(this); + break; + + case POE_COMPOSER_CUEID_ROLL: // begin rolling -> loop rolling + EnPoComposer_SetupRoll(this); + break; + + case POE_COMPOSER_CUEID_APPEAR: // appear + this->visible = true; + break; + + case POE_COMPOSER_CUEID_DISAPPEAR: // disappear + this->visible = false; + Actor_PlaySfx(&this->actor, NA_SE_EN_PO_DISAPPEAR); + break; + + case POE_COMPOSER_CUEID_DONE: + if (cueType == CS_CMD_ACTOR_CUE_481) { + EnPoComposer_SharpCutsceneDone(this); + } else { + Actor_Kill(&this->actor); + } + break; + + default: + break; + } + } + + if (this->actionFunc != EnPoComposer_Appear) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, cueChannel); + } else { + Cutscene_ActorTranslate(&this->actor, play, cueChannel); + } + + EnPoComposer_StepLightAlpha(this); + + if ((this->sharpCsNum == SHARP_CS_SONG_STORMS) && (play->csCtx.curFrame == 204)) { + Audio_PlaySfx(NA_SE_SY_DIZZY_EFFECT); + } + + if (this->visible == true) { + Actor_PlaySfx_Flagged(&this->actor, NA_SE_EN_SHARP_FLOAT - SFX_FLAG); + } + return true; + } + + if ((this->actionFunc != EnPoComposer_StartedCutscene) && (this->actionFunc != EnPoComposer_StartCutscene) && + (this->actionFunc != EnPoComposer_PlayCurse) && (play->csCtx.state == CS_STATE_IDLE)) { + + if (POE_COMPOSER_IS_FLAT(&this->actor)) { + EnPoComposer_SetupStartedCutscene(this); + } else if (POE_COMPOSER_4000(&this->actor)) { + EnPoComposer_SetupStartedCutscene(this); + } else { + this->inCutscene = false; + + if (this->sharpCsNum < SHARP_CS_SONG_STORMS) { + if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_14_02)) { + SET_WEEKEVENTREG(WEEKEVENTREG_14_02); + } + EnPoComposer_SetupPlayCurse(this); + } else { + EnPoComposer_SetupStartedCutscene(this); + } + } + } + + this->cueId = POE_COMPOSER_CUEID_NONE; + return false; +} + +void EnPoComposer_StepLightAlpha(EnPoComposer* this) { + if ((this->visible == true) && (this->lightColor.a != 255)) { + if (this->lightColor.a > 247) { + this->lightColor.a = 255; + } else { + this->lightColor.a += 7; + } + } else if (!this->visible && (this->lightColor.a != 0)) { + if (this->lightColor.a < 8) { + this->lightColor.a = 0; + } else { + this->lightColor.a -= 7; + } + } +} + +void EnPoComposer_StepLightColor(EnPoComposer* this) { + s16 color; + + color = this->lightColor.r + 5; + this->lightColor.r = CLAMP_MAX(color, 255); + + color = this->lightColor.g + 5; + this->lightColor.g = CLAMP_MAX(color, 255); + + if (this->lightColor.b > 210) { + color = this->lightColor.b - 5; + this->lightColor.b = CLAMP_MIN(color, 210); + } else { + color = this->lightColor.b + 5; + this->lightColor.b = CLAMP_MAX(color, 210); + } +} + +void EnPoComposer_UpdateEnvColor(EnPoComposer* this) { + if ((this->actionFunc == EnPoComposer_Appear) && (this->skelAnime.curFrame < 12.0f)) { + // Step rgb from 55 to 255 and alpha from 0 to 200 over the first 12 frames of the appear anim + this->envColor.r = this->envColor.g = this->envColor.b = 55.0f + this->skelAnime.curFrame * 16.66f; + this->envColor.a = this->skelAnime.curFrame * (200.0f / 12.0f); + } else { + f32 rand = Rand_ZeroOne(); + + this->envColor.r = 225 + (s32)(rand * 30.0f); + this->envColor.g = 155 + (s32)(rand * 100.0f); + this->envColor.b = 95 + (s32)(rand * 160.0f); + this->envColor.a = 200; + } + if (this->lightColor.a == 0) { + this->envColor.a = 0; + } +} + +void EnPoComposer_UpdateCollision(EnPoComposer* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->bodyCollider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->bodyCollider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->lanternCollider.base); +} + +void EnPoComposer_Update(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; + + EnPoComposer_UpdateEnvColor(this); + SkelAnime_Update(&this->skelAnime); + Actor_SetFocus(&this->actor, 42.0f); + + this->actionFunc(this, play); + + if (!EnPoComposer_UpdateAction(this, play)) { + EnPoComposer_UpdateCollision(this, play); + } +} + +s32 EnPoComposer_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, + Gfx** gfx) { + EnPoComposer* this = THIS; + + if ((this->lightColor.a == 0) || (limbIndex == POE_COMPOSER_LIMB_LANTERN)) { + *dList = NULL; + } else if (POE_COMPOSER_IS_FLAT(&this->actor) && (limbIndex == POE_COMPOSER_LIMB_HEAD)) { + *dList = gPoeComposerFlatHeadDL; + } + + if (limbIndex == 19) { + //! @bug skeleton does not have a limb 19, this is leftover from OoT Poes + gDPPipeSync((*gfx)++); + gDPSetEnvColor((*gfx)++, this->lightColor.r, this->lightColor.g, this->lightColor.b, this->lightColor.a); + } + + return false; +} + +void EnPoComposer_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { + EnPoComposer* this = THIS; + + Collider_UpdateSpheres(limbIndex, &this->lanternCollider); + if (limbIndex == POE_COMPOSER_LIMB_LANTERN) { + Matrix_Get(&this->lanternMtxF); + } +} + +void EnPoComposer_Draw(Actor* thisx, PlayState* play) { + EnPoComposer* this = THIS; + s32 pad; + Gfx* dl; + Color_RGBA8* clothingColor; + Color_RGBA8* var_t0; + Vec3f lightOffset; + Vec3s lightPos; + + OPEN_DISPS(play->state.gfxCtx); + + EnPoComposer_StepLightColor(this); + + // Select colors + + if (POE_COMPOSER_IS_FLAT(&this->actor)) { + clothingColor = &sFlatClothingColor1; + var_t0 = &sFlatClothingColor2; + } else { + clothingColor = &sSharpClothingColor1; + var_t0 = &sSharpClothingColor2; + } + + // Draw skeleton + + if ((this->lightColor.a == 255) || (this->lightColor.a == 0)) { + Gfx_SetupDL25_Opa(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x08, + Gfx_EnvColor(play->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, + this->lightColor.a)); + gSPSegment( + POLY_OPA_DISP++, 0x0A, + Gfx_EnvColor(play->state.gfxCtx, clothingColor->r, clothingColor->g, clothingColor->b, this->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0B, + Gfx_EnvColor(play->state.gfxCtx, var_t0->r, var_t0->g, var_t0->b, this->lightColor.a)); + gSPSegment(POLY_OPA_DISP++, 0x0C, D_801AEFA0); + + POLY_OPA_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnPoComposer_OverrideLimbDraw, EnPoComposer_PostLimbDraw, &this->actor, POLY_OPA_DISP); + } else { + Gfx_SetupDL25_Opa(play->state.gfxCtx); + Gfx_SetupDL25_Xlu(play->state.gfxCtx); + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_EnvColor(play->state.gfxCtx, this->lightColor.r, this->lightColor.g, this->lightColor.b, + this->lightColor.a)); + gSPSegment( + POLY_XLU_DISP++, 0x0A, + Gfx_EnvColor(play->state.gfxCtx, clothingColor->r, clothingColor->g, clothingColor->b, this->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0B, + Gfx_EnvColor(play->state.gfxCtx, var_t0->r, var_t0->g, var_t0->b, this->lightColor.a)); + gSPSegment(POLY_XLU_DISP++, 0x0C, D_801AEF88); + + POLY_XLU_DISP = + SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnPoComposer_OverrideLimbDraw, EnPoComposer_PostLimbDraw, &this->actor, POLY_XLU_DISP); + } + + if (this->lightColor.a != 0) { + // Draw lantern if visible + + if (this->lightColor.a == 255) { + Scene_SetRenderModeXlu(play, 0, 1); + dl = POLY_OPA_DISP; + } else { + Scene_SetRenderModeXlu(play, 1, 2); + dl = POLY_XLU_DISP; + } + + gDPPipeSync(&dl[0]); + gDPSetEnvColor(&dl[1], this->envColor.r, this->envColor.g, this->envColor.b, this->lightColor.a); + + Matrix_Put(&this->lanternMtxF); + gSPMatrix(&dl[2], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(&dl[3], gPoeComposerLanternBaseDL); + gSPDisplayList(&dl[4], gPoeComposerLanternGlassDL); + + gDPPipeSync(&dl[5]); + gDPSetEnvColor(&dl[6], clothingColor->r, clothingColor->g, clothingColor->b, this->lightColor.a); + gSPDisplayList(&dl[7], gPoeComposerLanternTopDL); + + if (this->lightColor.a == 255) { + POLY_OPA_DISP = &dl[8]; + } else { + POLY_XLU_DISP = &dl[8]; + } + } + + Matrix_Put(&play->billboardMtxF); + Matrix_MultVecZ(15.0f, &lightOffset); + lightPos = this->lanternCollider.elements[0].dim.worldSphere.center; + lightPos.x += (s16)lightOffset.x; + lightPos.y += (s16)lightOffset.y; + lightPos.z += (s16)lightOffset.z; + + Lights_PointGlowSetInfo(&this->lightInfo, lightPos.x, lightPos.y, lightPos.z, this->envColor.r, this->envColor.g, + this->envColor.b, this->envColor.a * (200.0f / 255.0f)); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h index a42b5048f7..55d7518391 100644 --- a/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h +++ b/src/overlays/actors/ovl_En_Po_Composer/z_en_po_composer.h @@ -2,6 +2,32 @@ #define Z_EN_PO_COMPOSER_H #include "global.h" +#include "objects/object_po_composer/object_po_composer.h" + +#define POE_COMPOSER_IS_FLAT(thisx) ((thisx)->params & 0x8000) +#define POE_COMPOSER_4000(thisx) ((thisx)->params & 0x4000) + +typedef enum { + /* 1 */ POE_COMPOSER_CUEID_IDLE = 1, + /* 2 */ POE_COMPOSER_CUEID_APPEAR_SPIN, + /* 3 */ POE_COMPOSER_CUEID_IDLE2, + /* 4 */ POE_COMPOSER_CUEID_RAISE_ARMS, + /* 5 */ POE_COMPOSER_CUEID_LOWER_ARMS, + /* 6 */ POE_COMPOSER_CUEID_PLAY_CURSE, + /* 7 */ POE_COMPOSER_CUEID_ROLL, + /* 8 */ POE_COMPOSER_CUEID_APPEAR, + /* 9 */ POE_COMPOSER_CUEID_DISAPPEAR, + /* 10 */ POE_COMPOSER_CUEID_DONE, + /* 99 */ POE_COMPOSER_CUEID_NONE = 99 +} EnPoComposerCueId; + +typedef enum { + /* 0 */ SHARP_CS_ENCOUNTER_FIRST, + /* 1 */ SHARP_CS_ENCOUNTER_OTHER, + /* 2 */ SHARP_CS_SONG_HEALING, + /* 3 */ SHARP_CS_SONG_STORMS, + /* 4 */ SHARP_CS_MAX +} SharpCsIdIndex; struct EnPoComposer; @@ -9,9 +35,26 @@ typedef void (*EnPoComposerActionFunc)(struct EnPoComposer*, PlayState*); typedef struct EnPoComposer { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xF0]; + /* 0x144 */ ColliderCylinder bodyCollider; + /* 0x190 */ ColliderJntSph lanternCollider; + /* 0x1B0 */ ColliderJntSphElement lanternColliderElements[1]; + /* 0x1F0 */ SkelAnime skelAnime; /* 0x234 */ EnPoComposerActionFunc actionFunc; - /* 0x238 */ char unk_238[0x108]; + /* 0x238 */ MtxF lanternMtxF; + /* 0x278 */ LightNode* lightNode; + /* 0x27C */ LightInfo lightInfo; + /* 0x28A */ UNK_TYPE1 unk_28A[0x6]; + /* 0x290 */ s32 sharpCsNum; + /* 0x294 */ Vec3s jointTable[POE_COMPOSER_LIMB_MAX]; + /* 0x2DC */ Vec3s morphTable[POE_COMPOSER_LIMB_MAX]; + /* 0x324 */ s16 csIds[SHARP_CS_MAX]; + /* 0x32C */ s16 actionTimer; + /* 0x32E */ s16 csCueTimer; + /* 0x330 */ s16 inCutscene; + /* 0x332 */ s16 visible; + /* 0x334 */ u16 cueId; + /* 0x336 */ Color_RGBA8 lightColor; + /* 0x33A */ Color_RGBA8 envColor; } EnPoComposer; // size = 0x340 #endif // Z_EN_PO_COMPOSER_H