diff --git a/assets/xml/objects/object_moonend.xml b/assets/xml/objects/object_moonend.xml index e677f9c3f1..666e9e07ca 100644 --- a/assets/xml/objects/object_moonend.xml +++ b/assets/xml/objects/object_moonend.xml @@ -1,6 +1,7 @@  - + + @@ -19,7 +20,8 @@ - + + diff --git a/include/z64animation.h b/include/z64animation.h index 316dfe3415..67c9d76414 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -304,7 +304,7 @@ typedef struct SkeletonInfo { typedef s32 (*OverrideKeyframeDrawScaled)(struct PlayState* play, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); -typedef void (*PostKeyframeDrawScaled)(struct PlayState* play, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, +typedef s32 (*PostKeyframeDrawScaled)(struct PlayState* play, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, u8* flags, struct Actor* actor, Vec3f* scale, Vec3s* rot, Vec3f* pos); void SkelAnime_DrawLod(struct PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, struct Actor* actor, s32 lod); diff --git a/spec b/spec index 51a80f17a3..8ddf28c014 100644 --- a/spec +++ b/spec @@ -4852,8 +4852,7 @@ beginseg name "ovl_Demo_Moonend" compress include "build/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.o" - include "build/data/ovl_Demo_Moonend/ovl_Demo_Moonend.data.o" - include "build/data/ovl_Demo_Moonend/ovl_Demo_Moonend.reloc.o" + include "build/src/overlays/actors/ovl_Demo_Moonend/ovl_Demo_Moonend_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c index 76a4230f55..ba8d1b8344 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.c @@ -15,8 +15,12 @@ void DemoMoonend_Destroy(Actor* thisx, PlayState* play); void DemoMoonend_Update(Actor* thisx, PlayState* play); void DemoMoonend_Draw(Actor* thisx, PlayState* play); -#if 0 -ActorInit Demo_Moonend_InitVars = { +void DemoMoonend_DoNothing(DemoMoonend* this, PlayState* play); +void func_80C17B60(DemoMoonend* this, PlayState* play); +void func_80C17C48(DemoMoonend* this, PlayState* play); +void func_80C17FCC(Actor* thisx, PlayState* play); + +const ActorInit Demo_Moonend_InitVars = { ACTOR_DEMO_MOONEND, ACTORCAT_ITEMACTION, FLAGS, @@ -28,28 +32,185 @@ ActorInit Demo_Moonend_InitVars = { (ActorFunc)DemoMoonend_Draw, }; -#endif +void DemoMoonend_Init(Actor* thisx, PlayState* play) { + DemoMoonend* this = THIS; -extern UNK_TYPE D_06001214; -extern UNK_TYPE D_0600B540; -extern UNK_TYPE D_060129F0; + Actor_SetScale(&this->actor, 0.1f); + this->actionFunc = DemoMoonend_DoNothing; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/DemoMoonend_Init.s") + if (DEMOMOONEND_GET_PARAMS_F(thisx) == 1) { + Actor_SetScale(&this->actor, 0.05f); + Actor_SetScale(&this->actor, 6.0f); + this->actor.draw = NULL; + this->cueType = CS_CMD_ACTOR_CUE_558; + this->actionFunc = func_80C17B60; + } else { + Actor_SetScale(&this->actor, 0.095f); + func_80183430(&this->skeletonInfo, &object_moonend_Blob_00B5A0, &object_moonend_Blob_001214, this->jointTable, + this->morphTable, NULL); + func_801834A8(&this->skeletonInfo, &object_moonend_Blob_001214); + this->cueType = CS_CMD_ACTOR_CUE_560; + this->actionFunc = func_80C17C48; + this->actor.home.rot.z = 0; + this->actor.draw = NULL; + this->skeletonInfo.frameCtrl.unk_C = 2.0f / 3.0f; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/DemoMoonend_Destroy.s") +void DemoMoonend_Destroy(Actor* thisx, PlayState* play) { + DemoMoonend* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/func_80C17B50.s") + if (DEMOMOONEND_GET_PARAMS_F(thisx) != 1) { + func_8018349C(&this->skeletonInfo); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/func_80C17B60.s") +void DemoMoonend_DoNothing(DemoMoonend* this, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/func_80C17C48.s") +void func_80C17B60(DemoMoonend* this, PlayState* play) { + if (Cutscene_IsCueInChannel(play, this->cueType)) { + u16 cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/DemoMoonend_Update.s") + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + if (this->cueId != cueId) { + this->cueId = cueId; + switch (this->cueId) { + case 1: + this->actor.draw = NULL; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/func_80C17E70.s") + case 2: + this->actor.draw = func_80C17FCC; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/func_80C17EE0.s") + default: + break; + } + } + if (this->cueId == 2) { + func_800B9010(&this->actor, NA_SE_EV_RAINBOW - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/DemoMoonend_Draw.s") +void func_80C17C48(DemoMoonend* this, PlayState* play) { + if (func_80183DE0(&this->skeletonInfo)) { + this->actor.home.rot.z = 0; + } + if (Cutscene_IsCueInChannel(play, this->cueType)) { + u16 cueId = play->csCtx.actorCues[Cutscene_GetCueChannel(play, this->cueType)]->id; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Demo_Moonend/func_80C17FCC.s") + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetCueChannel(play, this->cueType)); + + if (this->cueId != cueId) { + this->cueId = cueId; + switch (this->cueId) { + case 1: + this->actor.draw = DemoMoonend_Draw; + func_801834A8(&this->skeletonInfo, &object_moonend_Blob_001214); + this->skeletonInfo.frameCtrl.unk_C = 0.0f; + break; + + case 2: + this->actor.draw = DemoMoonend_Draw; + func_801834A8(&this->skeletonInfo, &object_moonend_Blob_001214); + this->skeletonInfo.frameCtrl.unk_C = 2.0f / 3.0f; + Actor_PlaySfx(&this->actor, NA_SE_EV_MOON_EXPLOSION); + this->actor.home.rot.z = 1; + break; + + default: + break; + } + } + if (this->actor.home.rot.z != 0) { + func_800B9010(&this->actor, NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG); + } + } else { + this->actor.draw = NULL; + } + if ((play->csCtx.state != CS_STATE_IDLE) && (gSaveContext.sceneLayer == 8) && (play->csCtx.scriptIndex == 0)) { + switch (play->csCtx.curFrame) { + case 5: + Actor_PlaySfx(&this->actor, NA_SE_EN_MOON_SCREAM1); + break; + + case 50: + Actor_PlaySfx(&this->actor, NA_SE_EN_MOON_SCREAM2); + break; + + case 100: + Actor_PlaySfx(&this->actor, NA_SE_EN_MOON_SCREAM3); + break; + + case 150: + Actor_PlaySfx(&this->actor, NA_SE_EN_MOON_SCREAM2); + break; + + case 200: + Actor_PlaySfx(&this->actor, NA_SE_EN_MOON_SCREAM4); + break; + + default: + break; + } + } +} + +void DemoMoonend_Update(Actor* thisx, PlayState* play) { + DemoMoonend* this = THIS; + + this->actionFunc(this, play); +} + +s32 func_80C17E70(PlayState* play, SkeletonInfo* skeletonInfo, s32 limbIndex, Gfx** dList, u8* flags, Actor* thisx, + Vec3f* scale, Vec3s* rot, Vec3f* pos) { + DemoMoonend* this = THIS; + + if (limbIndex == 2) { + Matrix_Push(); + Matrix_RotateYS(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000, MTXMODE_APPLY); + } + + return true; +} + +s32 func_80C17EE0(PlayState* play, SkeletonInfo* skeleton, s32 limbIndex, Gfx** dList, u8* flags, Actor* thisx, + Vec3f* scale, Vec3s* rot, Vec3f* pos) { + DemoMoonend* this = THIS; + + if (limbIndex == 8) { + Matrix_Pop(); + } + + return true; +} + +void DemoMoonend_Draw(Actor* thisx, PlayState* play) { + DemoMoonend* this = THIS; + Mtx* mtx; + + AnimatedMat_Draw(play, (AnimatedMaterial*)Lib_SegmentedToVirtual(object_moonend_Matanimheader_00B540)); + + mtx = GRAPH_ALLOC(play->state.gfxCtx, this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx)); + + if (mtx != NULL) { + Gfx_SetupDL25_Xlu(play->state.gfxCtx); + Gfx_SetupDL25_Opa(play->state.gfxCtx); + func_8018450C(play, &this->skeletonInfo, mtx, func_80C17E70, func_80C17EE0, &this->actor); + } +} + +void func_80C17FCC(Actor* thisx, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); + + Gfx_SetupDL25_Xlu(play->state.gfxCtx); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(object_moonend_Matanimheader_0129F0)); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, object_moonend_DL_010C40); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h index d36dcb284f..fd229e0046 100644 --- a/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h +++ b/src/overlays/actors/ovl_Demo_Moonend/z_demo_moonend.h @@ -2,14 +2,21 @@ #define Z_DEMO_MOONEND_H #include "global.h" +#include "objects/object_moonend/object_moonend.h" struct DemoMoonend; typedef void (*DemoMoonendActionFunc)(struct DemoMoonend*, PlayState*); +#define DEMOMOONEND_GET_PARAMS_F(thisx) (((thisx)->params) & 0xF) + typedef struct DemoMoonend { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x19C]; + /* 0x144 */ SkeletonInfo skeletonInfo; + /* 0x174 */ Vec3s jointTable[30]; + /* 0x228 */ Vec3s morphTable[30]; + /* 0x2DC */ u16 cueType; + /* 0x2DE */ u16 cueId; /* 0x2E0 */ DemoMoonendActionFunc actionFunc; } DemoMoonend; // size = 0x2E4 diff --git a/undefined_syms.txt b/undefined_syms.txt index 336a6c4b4d..a45e5c682d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -725,14 +725,6 @@ D_060134D0 = 0x060134D0; D_06013828 = 0x06013828; D_06014040 = 0x06014040; -// ovl_Demo_Moonend - -D_06001214 = 0x06001214; -D_0600B540 = 0x0600B540; -D_0600B5A0 = 0x0600B5A0; -D_06010C40 = 0x06010C40; -D_060129F0 = 0x060129F0; - // ovl_Dm_Tsg D_06002D30 = 0x06002D30;