diff options
| author | Chloe <47910150+ChloeBangBang@users.noreply.github.com> | 2022-07-11 19:37:42 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-11 21:37:42 -0400 |
| commit | 78a29fb17b341e4c668796508ec272a9d64154a4 (patch) | |
| tree | cd47f8584a5a3a4d25920d9633f10a2bbf324c80 /src | |
| parent | 8856e07166e190fc2a9959d7741ef4c6e73e82d0 (diff) | |
ovl_Dm_Char02 decompiled (#869)
* ovl_Dm_Char02 decompiled
* remove m2c comments
* remove ovl_Dm_Char02 data in spec
* ran format.sh
* fix format version
* use our reloc
* fix reviews
* rename context/playstate structs
* format
* more review fixing
* even more review fixing
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c | 168 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h | 12 |
2 files changed, 151 insertions, 29 deletions
diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c index 590045fa0..08e6dfbcf 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.c @@ -5,6 +5,7 @@ */ #include "z_dm_char02.h" +#include "objects/object_stk2/object_stk2.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -17,7 +18,6 @@ void DmChar02_Draw(Actor* thisx, PlayState* play); void func_80AAB04C(DmChar02* this, PlayState* play); -#if 0 const ActorInit Dm_Char02_InitVars = { ACTOR_DM_CHAR02, ACTORCAT_ITEMACTION, @@ -28,30 +28,148 @@ const ActorInit Dm_Char02_InitVars = { (ActorFunc)DmChar02_Destroy, (ActorFunc)DmChar02_Update, (ActorFunc)DmChar02_Draw, -}; - -#endif - -extern UNK_TYPE D_0600AD68; - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAE30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAECC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAAF2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Init.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB04C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB23C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB258.s") +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/func_80AAB270.s") +static AnimationInfo sAnimations[] = { + { &object_stk2_Anim_00A2BC, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00A4C4, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, + { &object_stk2_Anim_00A6D4, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f }, + { &object_stk2_Anim_00A104, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char02/DmChar02_Draw.s") +void DmChar02_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animInfo, u16 index) { + f32 frameCount; + + animInfo += index; + + if (animInfo->frameCount < 0.0f) { + frameCount = Animation_GetLastFrame(animInfo->animation); + } else { + frameCount = animInfo->frameCount; + } + Animation_Change(skelAnime, animInfo->animation, animInfo->playSpeed, animInfo->startFrame, frameCount, + animInfo->mode, animInfo->morphFrames); +} + +void func_80AAAECC(Actor* actor, PlayState* play) { + switch (play->csCtx.frames) { + case 95: + Actor_PlaySfxAtPos(actor, NA_SE_EV_OCARINA_BOUND_0); + return; + case 101: + case 105: + case 112: + Actor_PlaySfxAtPos(actor, NA_SE_EV_OCARINA_BOUND_1); + return; + } +} + +void func_80AAAF2C(DmChar02* this, PlayState* play) { + if ((play->csCtx.state != 0) && (play->sceneNum == SCENE_OKUJOU) && (play->csCtx.currentCsIndex == 1)) { + func_80AAAECC(&this->actor, play); + } +} + +void DmChar02_Init(Actor* thisx, PlayState* play) { + DmChar02* this = THIS; + + if (gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) { + this->animIndex = 0; + this->actor.targetArrowOffset = 3000.0f; + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &gClockTowerOcarinaOfTimeSkel, NULL, NULL, NULL, 0); + DmChar02_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + Actor_SetScale(&this->actor, 0.01f); + this->actionFunc = func_80AAB04C; + } else { + Actor_MarkForDeath(&this->actor); + } +} + +void DmChar02_Destroy(Actor* thisx, PlayState* play) { +} + +void func_80AAB04C(DmChar02* this, PlayState* play) { + u8 sp2F = true; + s32 actionIndex; + + if (Cutscene_CheckActorAction(play, 0x83)) { + actionIndex = Cutscene_GetActorActionIndex(play, 0x83); + if (play->csCtx.frames == play->csCtx.actorActions[actionIndex]->startFrame) { + switch (play->csCtx.actorActions[actionIndex]->action) { + default: + this->animIndex = 0; + sp2F = false; + break; + case 1: + this->animIndex = 0; + break; + case 2: + this->animIndex = 1; + break; + case 4: + this->animIndex = 3; + break; + } + if (sp2F) { + DmChar02_ChangeAnimationByInfo(&this->skelAnime, &sAnimations[this->animIndex], 0); + } + } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); + } + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if (this->animIndex == 1) { + this->animIndex++; + DmChar02_ChangeAnimationByInfo(&this->skelAnime, &sAnimations[this->animIndex], 0); + } + } +} + +void DmChar02_Update(Actor* thisx, PlayState* play) { + DmChar02* this = THIS; + + SkelAnime_Update(&this->skelAnime); + this->unk2F0 = this->unk2F0; + this->actionFunc(this, play); + if (!Actor_HasParent(&this->actor, play)) { + Actor_PickUp(&this->actor, play, GI_OCARINA, 30.0f, 80.0f); + } else { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + Actor_MarkForDeath(&this->actor); + } + func_80AAAF2C(this, play); +} + +s32 DmChar02_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + return false; +} + +void DmChar02_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { +} + +void DmChar02_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { +} + +void DmChar02_Draw(Actor* thisx, PlayState* play) { + s32 pad[2]; + DmChar02* this = THIS; + s32 sp30 = false; + + if ((play->csCtx.state == 0) && (this->actor.world.pos.y < 100.0f)) { + sp30 = true; + } else if (Cutscene_CheckActorAction(play, 0x6B)) { + switch (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 0x6B)]->action) { + case 0x17: + case 0x1C: + case 0x26: + sp30 = true; + } + } + if (sp30) { + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawTransformFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, + this->skelAnime.dListCount, DmChar02_OverrideLimbDraw, DmChar02_PostLimbDraw, + DmChar02_TransformLimbDraw, &this->actor); + } +} diff --git a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h index 276a7b026..246fd5531 100644 --- a/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h +++ b/src/overlays/actors/ovl_Dm_Char02/z_dm_char02.h @@ -8,10 +8,14 @@ struct DmChar02; typedef void (*DmChar02ActionFunc)(struct DmChar02*, PlayState*); typedef struct DmChar02 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x14C]; - /* 0x0290 */ DmChar02ActionFunc actionFunc; - /* 0x0294 */ char unk_294[0x60]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ UNK_TYPE1 pad188[0x108]; + /* 0x290 */ DmChar02ActionFunc actionFunc; + /* 0x294 */ UNK_TYPE1 pad294[0x4C]; + /* 0x2E0 */ s16 animIndex; + /* 0x2E2 */ UNK_TYPE1 pad2E2[0xE]; + /* 0x2F0 */ u32 unk2F0; } DmChar02; // size = 0x2F4 extern const ActorInit Dm_Char02_InitVars; |
