From 25682591dfb6e85be01ea9c4caede45c80c38684 Mon Sep 17 00:00:00 2001 From: LtPeriwinkle <62761190+LtPeriwinkle@users.noreply.github.com> Date: Thu, 18 Nov 2021 10:08:49 -0700 Subject: [PATCH 1/5] EnMm OK (#452) * EnMm OK * remove commented InitVars * switch >= to >; 0x1F to 31 * style fixes * use macros and enums * fix formatting * Fix function naming --- spec | 3 +- src/overlays/actors/ovl_En_Mm/z_en_mm.c | 190 +++++++++++++++++++++--- src/overlays/actors/ovl_En_Mm/z_en_mm.h | 5 +- 3 files changed, 173 insertions(+), 25 deletions(-) diff --git a/spec b/spec index c68c1cf91..3e5f38911 100644 --- a/spec +++ b/spec @@ -1726,8 +1726,7 @@ beginseg name "ovl_En_Mm" compress include "build/src/overlays/actors/ovl_En_Mm/z_en_mm.o" - include "build/data/ovl_En_Mm/ovl_En_Mm.data.o" - include "build/data/ovl_En_Mm/ovl_En_Mm.reloc.o" + include "build/src/overlays/actors/ovl_En_Mm/ovl_En_Mm_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.c b/src/overlays/actors/ovl_En_Mm/z_en_mm.c index 60cd43246..ed4c15544 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.c +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.c @@ -18,10 +18,8 @@ void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80965D3C(EnMm* this, GlobalContext* globalCtx); void func_80965DB4(EnMm* this, GlobalContext* globalCtx); void func_8096611C(EnMm* this, GlobalContext* globalCtx); - void EnMm_SetupAction(EnMm* this, EnMmActionFunc actionFunc); -#if 0 const ActorInit En_Mm_InitVars = { ACTOR_EN_MM, ACTORCAT_ITEMACTION, @@ -34,38 +32,190 @@ const ActorInit En_Mm_InitVars = { (ActorFunc)EnMm_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80966340 = { - { COLTYPE_METAL, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK2, { 0x00100000, 0x00, 0x00 }, { 0x01000202, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_METAL, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0x00, 0x00 }, + { 0x01000202, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 6, 30, 0, { 0, 0, 0 } }, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096636C[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32_DIV1000(gravity, -1200, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 270, ICHAIN_STOP), }; -#endif +void EnMm_SetupAction(EnMm* this, EnMmActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -extern ColliderCylinderInit D_80966340; -extern InitChainEntry D_8096636C[]; +void func_80965BBC(EnMm* this) { + EnMm_SetupAction(this, func_8096611C); + this->actor.room = -1; + if (this->actor.parent->id == ACTOR_PLAYER) { + gSaveContext.unk_1014 = 1; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_SetupAction.s") +void EnMm_Init(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; + EnMmActionFunc action; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_80965BBC.s") + if ((this->actor.params >= 0) && ((!(gSaveContext.weekEventReg[37] & 0x10)) || + (gSaveContext.weekEventReg[37] & 8) || (gSaveContext.unk_1014 != 0))) { + Actor_MarkForDeath(&this->actor); + return; + } + Actor_ProcessInitChain(&this->actor, sInitChain); + ActorShape_Init(&this->actor.shape, 50.0f, func_800B3FC0, 1.2f); + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + if (this->actor.parent != NULL) { + func_80965BBC(this); + return; + } + if (this->actor.cutscene >= 0) { + action = func_80965D3C; + } else { + action = func_80965DB4; + } + EnMm_SetupAction(this, action); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Init.s") +void EnMm_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Destroy.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_80965D3C.s") +void func_80965D3C(EnMm* this, GlobalContext* globalCtx) { + s16 cutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_80965DB4.s") + if (ActorCutscene_GetCanPlayNext(cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(cutscene, &this->actor); + EnMm_SetupAction(this, func_80965DB4); + } else { + ActorCutscene_SetIntentToPlay(cutscene); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/func_8096611C.s") +void func_80965DB4(EnMm* this, GlobalContext* globalCtx) { + s16 direction; + Vec3f sp50; + s16 unused; + f32 temp_f14; + f32 temp_f12; + f32 temp_f2; + s32 angle; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Update.s") + if (Actor_HasParent(&this->actor, globalCtx)) { + func_80965BBC(this); + Audio_PlayActorSound2(&this->actor, NA_SE_PL_PULL_UP_ROCK); + } else { + if ((this->actor.velocity.y > 0.0f) && (this->actor.bgCheckFlags & 0x10)) { + this->actor.velocity.y = 0.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Mm/EnMm_Draw.s") + if ((this->actor.speedXZ != 0.0f) && (this->actor.bgCheckFlags & 8)) { + angle = BINANG_SUB(this->actor.world.rot.y, BINANG_ROT180(this->actor.wallYaw)); + this->actor.world.rot.y += BINANG_SUB(0x8000, (s16)(angle * 2)); + this->actor.speedXZ *= 0.5f; + CollisionCheck_SpawnShieldParticles(globalCtx, &this->actor.world.pos); + Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + } + + if (!(this->actor.bgCheckFlags & 1)) { + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.08f); + } else { + temp_f14 = Math_SinS(this->actor.world.rot.y) * this->actor.speedXZ; + temp_f12 = Math_CosS(this->actor.world.rot.y) * this->actor.speedXZ; + func_800B75A0(this->actor.floorPoly, &sp50, &unused); + temp_f14 += 3.0f * sp50.x; + temp_f12 += 3.0f * sp50.z; + temp_f2 = sqrtf(SQ(temp_f14) + SQ(temp_f12)); + + if ((temp_f2 < this->actor.speedXZ) || + (func_800C9C74(&globalCtx->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 1)) { + this->actor.speedXZ = CLAMP_MAX(temp_f2, 16.0f); + this->actor.world.rot.y = Math_FAtan2F(temp_f12, temp_f14); + } + + if (!Math_StepToF(&this->actor.speedXZ, 0.0f, 1.0f)) { + direction = this->actor.world.rot.y; + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, this->actor.shape.rot.y)) > 0x4000) { + direction = BINANG_ROT180(direction); + } + Math_ScaledStepToS(&this->actor.shape.rot.y, direction, this->actor.speedXZ * 100.0f); + this->unk_190 += (s16)(this->actor.speedXZ * 800.0f); + } + + if (this->actor.bgCheckFlags & 2) { + if (this->actor.velocity.y < -6.0f) { + this->actor.velocity.y *= -0.3f; + this->actor.bgCheckFlags &= ~1; + } + + Audio_PlayActorSound2(&this->actor, NA_SE_EV_HUMAN_BOUND); + } else { + func_800B8A1C(&this->actor, globalCtx, GI_NONE, 50.0f, 30.0f); + } + } + + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); +} + +void func_8096611C(EnMm* this, GlobalContext* globalCtx) { + if (Actor_HasNoParent(&this->actor, globalCtx)) { + EnMm_SetupAction(this, func_80965DB4); + this->actor.room = globalCtx->roomCtx.currRoom.num; + this->actor.bgCheckFlags &= ~1; + Math_Vec3s_ToVec3f(&this->actor.prevPos, &this->actor.home.rot); + gSaveContext.unk_1014 = 0; + } else { + Math_Vec3f_ToVec3s(&this->actor.home.rot, &this->actor.parent->world.pos); + } + Math_ScaledStepToS(&this->unk_190, 0, 2000); +} + +void EnMm_Update(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; + + Collider_ResetCylinderAC(globalCtx, &this->collider.base); + this->actionFunc(this, globalCtx); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 10.0f, 20.0f, 31); + Actor_SetHeight(&this->actor, 20.0f); +} + +void EnMm_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnMm* this = THIS; + + OPEN_DISPS(globalCtx->state.gfxCtx); + func_8012C28C(globalCtx->state.gfxCtx); + if (this->unk_190 != 0) { + s16 rotY = this->actor.world.rot.y - this->actor.shape.rot.y; + + Matrix_RotateY(rotY, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk_190, MTXMODE_APPLY); + Matrix_RotateY(-rotY, MTXMODE_APPLY); + } + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, &D_04055628); + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Mm/z_en_mm.h b/src/overlays/actors/ovl_En_Mm/z_en_mm.h index bfda85e4a..d83ebc961 100644 --- a/src/overlays/actors/ovl_En_Mm/z_en_mm.h +++ b/src/overlays/actors/ovl_En_Mm/z_en_mm.h @@ -9,10 +9,9 @@ typedef void (*EnMmActionFunc)(struct EnMm*, GlobalContext*); typedef struct EnMm { /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x50]; + /* 0x0144 */ ColliderCylinder collider; + /* 0x0190 */ s16 unk_190; /* 0x0194 */ EnMmActionFunc actionFunc; } EnMm; // size = 0x198 -extern const ActorInit En_Mm_InitVars; - #endif // Z_EN_MM_H From 89b9d9082669993134483d79dd8e10bff552d783 Mon Sep 17 00:00:00 2001 From: Isghj <42048411+isghj5@users.noreply.github.com> Date: Thu, 18 Nov 2021 09:33:23 -0800 Subject: [PATCH 2/5] En_Kakasi (Scarecrow) (#279) * EnKakasi: rebase progress into one commit * EnKakasi: fixes to get compiling on master, still doesn't match * EnKakasi: is this even progress? * EnKakasi: docs and cleaning * EnKaksi: damn it, that master merge really messed up more than I thought, after clean build something really weird is going on and now I REALLY need firstdiff * EnKakasi: Back to building, NOT OK * fixed a code * only rodata left to fix * EnKakasi: functions got removed in included functions * EnKakasi: thanks to fig mentioning there were missing cases, OK * EnKakasi: (OK) docs and cleaning * EnKakasi: Init now matches * EnKakasi: cleaning and docs * EnKakasi: more cleaning and docs * EnKakasi: forgot function declarations * EnKakasi: spec * EnKakasi: animation array symbols added * EnKakasi: formater pass * EnKakasi: type warning fix * EnKakasi: little descriptor * EnKakasi: OK thanks to AngheloAlf * Apply suggestions from code review Co-authored-by: Anghelo Carvajal * Update src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c Co-authored-by: Anghelo Carvajal * Apply suggestions from code review Splitting this into pieces to not have a huge pile of bugs Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EnKakasi: wrong type of inverse flag * Apply suggestions from code review Batch 2 Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EnKakasi: RIP Anime * Apply suggestions from code review Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EnKakasi: Anim enum update * EnKakasi: Removed text documentation * EnKakas: return of THIS * Update src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EnKakasi: mystery solved but not understood * Apply suggestions from code review Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> * EnKakasi: rename EnKakasi_CheckAnimateSFX to EnKakasi_CheckAnimationSfx (no real reason to shorten Animation to Animate, and SFX is not initialism, its a shorten) * EnKakasi: minor change to touch jenkins * EnKakasi: is it loise-uni? * EnKakasi: fixed skelanime changes * EnKakasi: formater pass * EnKakasi: requested changes * Update src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h Co-authored-by: Derek Hensley * EnKakasi: removed un needed pad * EnKakasi: removed redundant documentation comment Co-authored-by: isghj8 Co-authored-by: Anghelo Carvajal Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com> Co-authored-by: Derek Hensley --- include/functions.h | 10 +- include/z64.h | 6 +- spec | 3 +- .../actors/ovl_En_Kakasi/z_en_kakasi.c | 1159 ++++++++++++++++- .../actors/ovl_En_Kakasi/z_en_kakasi.h | 40 +- tools/disasm/functions.txt | 38 +- undefined_syms.txt | 9 + 7 files changed, 1173 insertions(+), 92 deletions(-) diff --git a/include/functions.h b/include/functions.h index 3c8c8a2f2..49efe79ae 100644 --- a/include/functions.h +++ b/include/functions.h @@ -3033,7 +3033,7 @@ void func_80169600(GlobalContext* globalCtx, s16 param_2); Camera* Play_GetCamera(GlobalContext* globalCtx, s16 index); s32 Play_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye); void func_8016981C(GlobalContext* globalCtx, s16 arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4); -// void func_80169940(void); +void func_80169940(GlobalContext* globalCtx, s16 camId, f32 arg2); // void func_80169988(void); void func_801699D4(GlobalContext* globalCtx, s16 arg1, s16 arg2); // void func_80169A50(void); @@ -3838,12 +3838,12 @@ void func_8019E014(void); // void func_8019EB2C(void); // void func_8019F024(void); // void func_8019F05C(void); +void func_8019F170(Vec3f* pos, u16 sfxId); +void func_8019F1C0(Vec3f* pos, u16 sfxId); void play_sound(u16 sfxId); void func_8019F128(u16 sfxId); -// void func_8019F170(void); -void func_8019F1C0(Vec3f* pos, u16 sfxId); -void func_8019F208(void); -void func_8019F230(void); // Plays "No" sound +void func_8019F208(void); // decide +void func_8019F230(void); // cancel // void func_8019F258(void); // void func_8019F300(void); void func_8019F420(Vec3f* pos, u16 sfxId); diff --git a/include/z64.h b/include/z64.h index dbc7b60f4..2425f47be 100644 --- a/include/z64.h +++ b/include/z64.h @@ -948,7 +948,7 @@ typedef struct { /* 0x11F23 */ UNK_TYPE1 pad11F23[0xFD]; /* 0x12020 */ u8 unk12020; /* 0x12021 */ u8 choiceIndex; - /* 0x12022 */ UNK_TYPE1 unk12022; + /* 0x12022 */ u8 unk12022; /* 0x12023 */ u8 unk12023; /* 0x12024 */ UNK_TYPE1 unk12024[0x6]; /* 0x1202A */ u16 unk1202A; @@ -956,7 +956,9 @@ typedef struct { /* 0x1202E */ u16 unk1202E; /* 0x12030 */ UNK_TYPE1 pad12030[0x14]; /* 0x12044 */ s16 unk12044; - /* 0x12046 */ UNK_TYPE1 pad12046[0x24]; + /* 0x12046 */ UNK_TYPE1 pad12046[0x2]; + /* 0x12048 */ u8 unk12048; // EnKakasi + /* 0x12049 */ UNK_TYPE1 pad12049[0x21]; /* 0x1206A */ s16 unk1206A; /* 0x1206C */ s32 unk1206C; /* 0x12070 */ UNK_TYPE1 pad12070[0x8]; diff --git a/spec b/spec index 3e5f38911..2983af4dc 100644 --- a/spec +++ b/spec @@ -1788,8 +1788,7 @@ beginseg name "ovl_En_Kakasi" compress include "build/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.o" - include "build/data/ovl_En_Kakasi/ovl_En_Kakasi.data.o" - include "build/data/ovl_En_Kakasi/ovl_En_Kakasi.reloc.o" + include "build/src/overlays/actors/ovl_En_Kakasi/ovl_En_Kakasi_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 0617bcdd3..436386af9 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -1,7 +1,7 @@ /* * File: z_en_kakasi.c * Overlay: ovl_En_Kakasi - * Description: Pierre + * Description: Pierre the Scarecorw */ #include "z_en_kakasi.h" @@ -15,28 +15,55 @@ void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx); void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_8096FCC4(EnKakasi* this, GlobalContext* globalCtx); -void func_8096FE00(EnKakasi* this, GlobalContext* globalCtx); -void func_8097006C(EnKakasi* this, GlobalContext* globalCtx); -void func_80970658(EnKakasi* this, GlobalContext* globalCtx); -void func_80970740(EnKakasi* this, GlobalContext* globalCtx); -void func_80970978(EnKakasi* this, GlobalContext* globalCtx); -void func_80970A9C(EnKakasi* this, GlobalContext* globalCtx); -void func_80970F20(EnKakasi* this, GlobalContext* globalCtx); -void func_80971064(EnKakasi* this, GlobalContext* globalCtx); -void func_80971430(EnKakasi* this, GlobalContext* globalCtx); -void func_809714BC(EnKakasi* this, GlobalContext* globalCtx); -void func_809717D0(EnKakasi* this, GlobalContext* globalCtx); -void func_8097185C(EnKakasi* this, GlobalContext* globalCtx); -void func_8097193C(EnKakasi* this, GlobalContext* globalCtx); -void func_80971A64(EnKakasi* this, GlobalContext* globalCtx); -void func_80971AD4(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_InitTimeSkipDialogue(EnKakasi* this); +void EnKakasi_SetupIdleStanding(EnKakasi* this); + +void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this); + +void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_PostSongLearnTwirl(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupDigAway(EnKakasi* this); +void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupIdleUnderground(EnKakasi* this); +void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupIdleRisen(EnKakasi* this); +void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupDanceNightAway(EnKakasi* this); +void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_DoNothing(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx); +void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx); + +void EnKakasi_SetupDialogue(EnKakasi* this); + +void EnKakasi_LimbDraw(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, struct Actor* actor); -#if 0 -// static ColliderCylinderInit sCylinderInit = { static ColliderCylinderInit D_80971D80 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 20, 70, 0, { 0, 0, 0 } }, }; @@ -52,80 +79,1092 @@ const ActorInit En_Kakasi_InitVars = { (ActorFunc)EnKakasi_Draw, }; -#endif +static Vec3f D_80971DCC[] = { + { 0.0f, 60.0f, 60.0f }, { 40.0f, 40.0f, 50.0f }, { -40.0f, 40.0f, 50.0f }, + { 40.0f, 20.0f, 110.0f }, { -40.0f, 20.0f, 110.0f }, { 0.0f, 80.0f, 60.0f }, + { 50.0f, 40.0f, -30.0f }, { -50.0f, 40.0f, -30.0f }, { 0.0f, 50.0f, 60.0f }, +}; +Vec3f D_80971E38[] = { + { 0.0f, 55.0f, 60.0f }, { 0.0f, 55.0f, 60.0f }, { -80.0f, 35.0f, 15.0f }, { 80.0f, 45.0f, 15.0f }, + { -10.0f, 35.0f, 65.0f }, { 0.0f, 110.0f, 180.0f }, { 0.0f, 60.0f, 70.0f }, { 0.0f, 60.0f, 70.0f }, + { -80.0f, 50.0f, 40.0f }, { 0.0f, -10.0f, 50.0f }, { 80.0f, 50.0f, 40.0f }, { 0.0f, 120.0f, 40.0f }, + { 0.0f, 28.0f, -50.0f }, { 0.0f, 60.0f, 50.0f }, { 0.0f, 80.0f, 160.0f }, +}; -extern ColliderCylinderInit D_80971D80; +Vec3f D_80971EEC[] = { + { 12.0f, 1.0f, 2.0f }, { 12.0f, 1.0f, 2.0f }, { 2.0f, -6.0f, 0.0f }, { 12.0f, -6.0f, -10.0f }, + { -88.0f, 14.0, -10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, + { 0.0f, -10.0f, 0.0f }, { 0.0f, -10.0f, 0.0f }, { 0.0f, -10.0f, 0.0f }, { 0.0f, -10.0f, 0.0f }, + { 0.0f, -10.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, +}; -extern UNK_TYPE D_06000214; +Vec3f D_80971FA0[] = { + { -50.0f, 160.0f, -40.0f }, { -50.0f, 160.0f, -40.0f }, { -20.0f, 80.0f, 60.0f }, + { 57.0f, 60.0f, 120.0f }, { 27.0f, 80.0f, 60.0f }, { -3.0f, 50.0f, 70.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Destroy.s") +Vec3f D_80971FE8[] = { + { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { -10.0f, -5.0f, 0.0f }, + { 10.0f, -10.0f, 7.0f }, { 20.0f, 5.0f, 2.0f }, { 10.0f, 5.0f, 2.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Init.s") +// both use in digging away function +Vec3f D_80972030 = { -3.0f, 50.0f, 90.0f }; +Vec3f D_8097203C = { 10.0f, -15.0f, 2.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096F800.s") +typedef enum { + /* 0x0 */ ENKAKASI_ANIM_ARMS_CROSSED_ROCKING, // arms crossed and rocking back and forth + /* 0x1 */ ENKAKASI_ANIM_SIDEWAYS_SHAKING, + /* 0x2 */ ENKAKASI_ANIM_HOPPING_REGULAR, // bounce bounce bounce (repeat) + /* 0x3 */ ENKAKASI_ANIM_SPIN_REACH_OFFER, // spin and then reaching toward player + /* 0x4 */ ENKAKASI_ANIM_TWIRL, // slower cinimatic twirl + /* 0x5 */ ENKAKASI_ANIM_ARMS_CROSSED_STILL, // arms crossed but still, also some noise sfx + /* 0x6 */ ENKAKASI_ANIM_WAVE, // "wave" short sideways shake, stops early, partial? unused? + /* 0x7 */ ENKAKASI_ANIM_SLOWROLL, // partial bounch, ends looking left, OFFER anim takes over + /* 0x8 */ ENKAKASI_ANIM_IDLE, // slow stretching wiggle, ends in regular position +} EnKakasi_Animations; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096F88C.s") +extern AnimationHeader D_06007444; +extern AnimationHeader D_0600686C; +extern AnimationHeader D_060081A4; +extern AnimationHeader D_06007B90; +extern AnimationHeader D_060071EC; +extern AnimationHeader D_06007444; +extern AnimationHeader D_0600686C; +extern AnimationHeader D_060081A4; +extern AnimationHeader D_06000214; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096F8D8.s") +static AnimationHeader* kakasiAnimations[] = { + &D_06007444, &D_0600686C, &D_060081A4, &D_06007B90, &D_060071EC, &D_06007444, &D_0600686C, &D_060081A4, &D_06000214, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FA18.s") +static u8 sAnimModes[] = { ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_LOOP, ANIMMODE_ONCE, ANIMMODE_ONCE, + ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE, ANIMMODE_ONCE }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FAAC.s") +void EnKakasi_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FBB8.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FC8C.s") +extern FlexSkeletonHeader D_060065B0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FCC4.s") +void EnKakasi_Init(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; + s32 tempCutscene; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FDE8.s") + Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &D_80971D80); + SkelAnime_InitFlex(globalCtx, &this->skelanime, &D_060065B0, &D_06000214, 0, 0, 0); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8096FE00.s") + this->songSummonDist = GET_KAKASI_SUMMON_DISTANCE(this) * 20.0f; + if (this->songSummonDist < 40.0f) { + this->songSummonDist = 40.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970008.s") + this->unkHeight = (this->actor.world.rot.z * 20.0f) + 60.0f; + this->actor.world.rot.z = 0; + this->actor.targetMode = 0; + if (this->actor.world.rot.x > 0 && this->actor.world.rot.x < 8) { + this->actor.targetMode = this->actor.world.rot.x - 1; + } + this->actor.shape.rot.y = this->actor.world.rot.y; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8097006C.s") + this->aboveGroundStatus = GET_KAKASI_ABOVE_GROUND(this); + this->actor.world.rot.x = 0; + this->actor.flags |= 0x400; + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Actor_SetScale(&this->actor, 0.01f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_809705E4.s") + i = 0; + tempCutscene = this->actor.cutscene; + while (tempCutscene != -1) { + // This might be a fake match, no others found yet + tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actorCutscenes[i] = tempCutscene); + i++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970658.s") + if (this->aboveGroundStatus) { + if (gSaveContext.weekEventReg[79] & 0x8) { + this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; + this->songSummonDist = 80.0f; + EnKakasi_SetupIdleUnderground(this); + } else { + Actor_SetHeight(&this->actor, 60.0f); + this->unkFunc = EnKakasi_8096F88C; + if (gSaveContext.weekEventReg[83] & 0x1) { + EnKakasi_InitTimeSkipDialogue(this); + } else { + EnKakasi_SetupIdleStanding(this); + } + } + } else { + EnKakasi_SetupIdleUnderground(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970740.s") +void EnKakasi_SetAnimation(EnKakasi* this, s32 index) { + this->animIndex = index; + this->animeFrameCount = Animation_GetLastFrame(&kakasiAnimations[this->animIndex]->common); + // 1: regular playback speed, 0: starting frame + Animation_Change(&this->skelanime, kakasiAnimations[this->animIndex], 1.0f, 0.0f, this->animeFrameCount, + sAnimModes[this->animIndex], -4.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970978.s") +/* + * set by init, called... nowhere? left over from OOT? + */ +void EnKakasi_8096F88C(GlobalContext* globalCtx, EnKakasi* this) { + func_8013A530(globalCtx, &this->actor, 0x7, &this->actor.focus.pos, &this->actor.shape.rot, 280.0f, 1800.0f, -1); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970A10.s") +void EnKakasi_CheckAnimationSfx(EnKakasi* this) { + if (this->animIndex == ENKAKASI_ANIM_SIDEWAYS_SHAKING || this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_STILL) { + if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + } + } + if (this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR || this->animIndex == ENKAKASI_ANIM_SLOWROLL) { + if (Animation_OnFrame(&this->skelanime, 4.0f) || Animation_OnFrame(&this->skelanime, 8.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_SWING); + } + if (Animation_OnFrame(&this->skelanime, 1.0f) || Animation_OnFrame(&this->skelanime, 9.0f) || + Animation_OnFrame(&this->skelanime, 16.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_IT_KAKASHI_JUMP); + } + if (Animation_OnFrame(&this->skelanime, 18.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASHI_ROLL); + } + } + if (this->animIndex == ENKAKASI_ANIM_SPIN_REACH_OFFER || this->animIndex == ENKAKASI_ANIM_TWIRL) { + if (Animation_OnFrame(&this->skelanime, 1.0f)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KAKASH_LONGI_ROLL); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970A9C.s") +/* + * moves the player's position relative to scarecrow during song teach, also each frame of dance the night away + */ +void EnKakasi_CheckPlayerPosition(EnKakasi* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970F20.s") + if (globalCtx->sceneNum == SCENE_8ITEMSHOP) { + player->actor.world.pos.x = -50.0f; + player->actor.world.pos.z = 155.0f; + } else if (globalCtx->sceneNum == SCENE_TENMON_DAI) { + player->actor.world.pos.x = 60.0f; + player->actor.world.pos.z = -190.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80970FF8.s") + Math_SmoothStepToS(&player->actor.shape.rot.y, (this->actor.yawTowardsPlayer + 0x8000), 5, 1000, 0); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971064.s") +/* + * this goes off every frame of dancing the night away, and song teaching + * something to do with cutscene camera? + */ +void func_8096FAAC(EnKakasi* this, GlobalContext* globalCtx) { + if (this->cutsceneCamId != MAIN_CAM) { + Math_ApproachF(&this->unk214.x, this->unk238.x, 0.4f, 4.0f); + Math_ApproachF(&this->unk214.y, this->unk238.y, 0.4f, 4.0f); + Math_ApproachF(&this->unk214.z, this->unk238.z, 0.4f, 4.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971430.s") + Math_ApproachF(&this->unk220.x, this->unk244.x, 0.4f, 4.0f); + Math_ApproachF(&this->unk220.y, this->unk244.y, 0.4f, 4.0f); + Math_ApproachF(&this->unk220.z, this->unk244.z, 0.4f, 4.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971440.s") + Math_ApproachF(&this->unk20C, this->unk210, 0.3f, 10.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_809714BC.s") + Play_CameraSetAtEye(globalCtx, this->cutsceneCamId, &this->unk220, &this->unk214); + func_80169940(globalCtx, this->cutsceneCamId, this->unk20C); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971794.s") +/* + * goes off every frame of song teach, but... doing what? + */ +void func_8096FBB8(EnKakasi* this, GlobalContext* globalCtx) { + if (globalCtx->msgCtx.unk12048 == 0 || globalCtx->msgCtx.unk12048 == 1 || globalCtx->msgCtx.unk12048 == 2 || + globalCtx->msgCtx.unk12048 == 3 || globalCtx->msgCtx.unk12048 == 4) { + // why not 0 < x < 4? fewer branches + this->unk190++; + } + if (this->unk190 != 0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + if (this->unk190 > 8) { + this->unk190 = 8; + } + if (this->unk190 != 0) { + Math_ApproachF(&this->skelanime.playSpeed, 1.0f, 0.1f, 0.2f); + this->actor.shape.rot.y += 0x800; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_809717D0.s") +void EnKakasi_InitTimeSkipDialogue(EnKakasi* this) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SLOWROLL); + this->actionFunc = EnKakasi_TimeSkipDialogue; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8097185C.s") +void EnKakasi_TimeSkipDialogue(EnKakasi* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_8097193C.s") + if (gSaveContext.respawnFlag != -4 && gSaveContext.respawnFlag != -8) { + if (gSaveContext.time != CLOCK_TIME(6, 0) && gSaveContext.time != CLOCK_TIME(18, 0) && + !(gSaveContext.eventInf[1] & 0x80)) { -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971A38.s") + if (this->actor.textId == 0) { + // dialogue after skipped time 'did you feel that? went by in an instant' + this->actor.textId = 0x1653; + gSaveContext.weekEventReg[0x53] &= (u8)~1; + this->unkMsgState1AC = 5; + player->stateFlags1 |= 0x20; + this->actor.flags |= 0x10000; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971A64.s") + if (func_800B84D0(&this->actor, globalCtx) != 0) { + player->stateFlags1 &= ~0x20; + this->unkState196 = 2; + this->actor.flags &= ~0x10000; + this->actionFunc = EnKakasi_RegularDialogue; + } else { + func_800B8500(&this->actor, globalCtx, 9999.9f, 9999.9f, -1); + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971AD4.s") +void EnKakasi_SetupIdleStanding(EnKakasi* this) { + this->unkState196 = 0; + this->actionFunc = EnKakasi_IdleStanding; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Update.s") +void EnKakasi_IdleStanding(EnKakasi* this, GlobalContext* globalCtx) { + u32 saveContextDay = gSaveContext.day; + s16 passedValue1; + s16 passedValue2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/func_80971CE0.s") + // first talk to scarecrow dialogue + this->actor.textId = 0x1644; + if (func_800B8718(&this->actor, globalCtx) != 0) { + this->skelanime.playSpeed = 1.0f; + EnKakasi_SetupSongTeach(this, globalCtx); + return; + } + if (func_800B84D0(&this->actor, globalCtx) != 0) { + this->skelanime.playSpeed = 1.0f; + EnKakasi_SetupDialogue(this); + return; + } + if (globalCtx->actorCtx.unk5 & 0x4) { + func_800B8898(globalCtx, &this->actor, &passedValue1, &passedValue2); + if (this->actor.projectedPos.z > -20.0f && passedValue1 > 0 && passedValue1 < 0x140 && passedValue2 > 0 && + passedValue2 < 0xF0 && this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + // faster shaking + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + this->skelanime.playSpeed = 2.0f; + } + } else if (Player_GetMask(globalCtx) == PLAYER_MASK_KAMARO) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + this->skelanime.playSpeed = 2.0f; + } + } else if (saveContextDay == 3 && gSaveContext.isNight) { + this->skelanime.playSpeed = 1.0f; + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, 1); + } + } else if (this->animIndex != ENKAKASI_ANIM_IDLE) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_IDLE); + } + if (this->actor.xzDistToPlayer < 120.0f) { + func_800B8614(&this->actor, globalCtx, 100.0f); + func_800B874C(&this->actor, globalCtx, 100.0f, 80.0f); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Kakasi/EnKakasi_Draw.s") +void EnKakasi_SetupDialogue(EnKakasi* this) { + // bug? starts one animation then changes it a few lines down? + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + + this->unkMsgState1AC = 5; + this->unkState196 = 1; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + this->actionFunc = EnKakasi_RegularDialogue; +} + +void EnKakasi_RegularDialogue(EnKakasi* this, GlobalContext* globalCtx) { + u32 saveContextDay = gSaveContext.day; + f32 currentAnimeFrame = this->skelanime.curFrame; + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 2000, 0); + // if first dialogue + if (this->actor.textId != 0x1644 && this->animeFrameCount <= currentAnimeFrame && + this->animIndex == ENKAKASI_ANIM_SLOWROLL) { + + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + this->unkCounter1A4 = 0; + } + + // if dialogue: oh sorry come back again + if (this->actor.textId == 0x1651 || this->actor.textId == 0x1659) { + if (this->animeFrameCount <= currentAnimeFrame && this->animIndex != ENKAKASI_ANIM_SPIN_REACH_OFFER) { + if (++this->unkCounter1A4 >= 2) { + this->unkCounter1A4 = 0; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + } + } + } + + if (this->unkState1A8 == 2 && this->unkState196 == 2) { + func_800B7298(globalCtx, &this->actor, 0x49); + this->unkState1A8 = 0; + } + + if (this->unkMsgState1AC == func_80152498(&globalCtx->msgCtx) && func_80147624(globalCtx) != 0) { + func_801477B4(globalCtx); + if (this->unkMsgState1AC == 5) { + // bad song input + if (this->unkState196 == 2 && this->actor.textId == 0x1647) { + func_800B7298(globalCtx, &this->actor, 6); + } + + // after timeskip + if (this->actor.textId == 0x1653) { + u32 saveContextDay2 = gSaveContext.day; + + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + + if (saveContextDay2 == 3 && gSaveContext.isNight) { + // text: dangerous outside + this->actor.textId = 0x164F; + } else if (gSaveContext.isNight) { + // text: would you like to skip time? + this->actor.textId = 0x164E; + } else { + // text: would you like to skip time? 2 + this->actor.textId = 0x1645; + } + + func_80151938(globalCtx, this->actor.textId); + return; + + } else if (this->actor.textId == 0x165D || this->actor.textId == 0x165F || this->actor.textId == 0x1660 || + this->actor.textId == 0x1652) { + func_800B7298(globalCtx, &this->actor, 4); + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_DancingRemark; + } else { + if (!ActorCutscene_GetCanPlayNext(this->actorCutscenes[0])) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_DancingRemark; + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + this->actionFunc = EnKakasi_DancingRemark; + } + } + return; + + } else if (this->actor.textId == 0x1645 || this->actor.textId == 0x164E) { + this->actor.textId = 0x1650; // "Shall we dance? No Yes" + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->unkMsgState1AC = 4; + + } else if (this->actor.textId == 0x1644) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + if (gSaveContext.isNight) { + this->actor.textId = 0x164E; + } else { + this->actor.textId = 0x1645; + } + + } else if (this->actor.textId == 0x164F) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->actor.textId = 0x165A; + } else if (this->actor.textId == 0x1651) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->actor.textId = 0x1654; + } else if (this->actor.textId == 0x1654) { + this->actor.textId = 0x1655; + } else if (this->actor.textId == 0x1655) { + this->actor.textId = 0x1656; + this->unkMsgState1AC = 4; + } else if (this->actor.textId == 0x1658) { + this->actor.textId = 0x1659; + } else if (this->actor.textId == 0x165A) { + this->actor.textId = 0x165B; + } else if (this->actor.textId == 0x165B) { + this->actor.textId = 0x165C; + this->unkMsgState1AC = 4; + + } else if (this->actor.textId == 0x165E) { + this->actor.textId = 0x165F; + } else { + EnKakasi_SetupIdleStanding(this); + return; + } + } else { + this->unkMsgState1AC = 5; + + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F208(); + if (this->actor.textId == 0x1656) { + this->actor.textId = 0x1658; + } else if (this->actor.textId == 0x165C) { + this->actor.textId = 0x165E; + } else if (saveContextDay == 3 && gSaveContext.isNight) { + this->actor.textId = 0x164F; + } else { + this->actor.textId = 0x1652; + } + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + } else { + func_8019F230(); + if (this->actor.textId == 0x1656) { // would you like to learn a song? yes/no + this->actor.textId = 0x1657; + } else if (this->actor.textId == 0x165C) { // would you like to learn a song? yes/no + this->actor.textId = 0x165D; + } else { + this->actor.textId = 0x1651; + } + this->unkCounter1A4 = 0; + if (this->animIndex != ENKAKASI_ANIM_ARMS_CROSSED_ROCKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + } + } + } + func_80151938(globalCtx, this->actor.textId); + } +} + +void EnKakasi_SetupSongTeach(EnKakasi* this, GlobalContext* globalCtx) { + this->actor.textId = 0x1646; + func_801518B0(globalCtx, this->actor.textId, &this->actor); + this->cutsceneCamId = MAIN_CAM; + this->unk20C = 0.0f; + this->unk210 = 60.0f; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + this->unkState196 = 2; + this->actionFunc = EnKakasi_OcarinaRemark; +} + +/* + * you took out ocarina hes talking about how he wants to hear you play him a song + * before actually teaching + */ +void EnKakasi_OcarinaRemark(EnKakasi* this, GlobalContext* globalCtx) { + if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + func_80152434(globalCtx, 0x35); + this->unkState1A8 = 0; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_TeachingSong; + + } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + this->actionFunc = EnKakasi_TeachingSong; + + } else { + this->unkState1A8 = 1; + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->actionFunc = EnKakasi_TeachingSong; + } + } +} + +void EnKakasi_TeachingSong(EnKakasi* this, GlobalContext* globalCtx) { + Vec3f tempVec; + + EnKakasi_CheckPlayerPosition(this, globalCtx); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); + if (this->unkState1A8 == 0) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->unkState1A8 = 1; + this->unkState1A8 = 1; + } + + if (this->unkState1A8 == 1) { + this->unk22C.y = this->actor.home.pos.y + 50.0f; + this->unk238.x = D_80971DCC[this->unk190].x; + this->unk238.y = D_80971DCC[this->unk190].y; + this->unk238.z = D_80971DCC[this->unk190].z; + + Math_Vec3f_Copy(&tempVec, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &tempVec, &this->unk238, 1); + Math_Vec3f_Copy(&this->unk244, &this->unk22C); + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + func_8096FAAC(this, globalCtx); + func_8096FBB8(this, globalCtx); + + if (globalCtx->msgCtx.unk1202A == 4) { // song failed + this->unk190 = 0; + this->unkCounter1A4 = 0; + ActorCutscene_Stop(this->actorCutscenes[0]); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_YASE_DEAD); + if (this) {} + this->unkState196 = 2; + this->cutsceneCamId = MAIN_CAM; + this->actor.textId = 0x1647; + this->unkState1A8 = 2; + this->unkMsgState1AC = 5; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + this->actionFunc = EnKakasi_RegularDialogue; + + } else if (globalCtx->msgCtx.unk1202A == 3) { // song success + this->postTeachTimer = 30; + this->skelanime.playSpeed = 2.0f; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + this->actionFunc = EnKakasi_PostSongLearnTwirl; + } + } +} + +void EnKakasi_PostSongLearnTwirl(EnKakasi* this, GlobalContext* globalCtx) { + f32 animeFrame = this->skelanime.curFrame; + + if (this->postTeachTimer == 0 && this->animIndex != ENKAKASI_ANIM_TWIRL) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + this->skelanime.playSpeed = 2.0f; + } + if (this->postTeachTimer == 0 && this->animIndex == ENKAKASI_ANIM_TWIRL && this->animeFrameCount <= animeFrame) { + EnKakasi_SetupPostSongLearnDialogue(this, globalCtx); + } +} + +void EnKakasi_SetupPostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { + ActorCutscene_Stop(this->actorCutscenes[0]); + globalCtx->msgCtx.unk1202A = 4; + this->unk190 = 0; + this->unkCounter1A4 = 0; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_HOPPING_REGULAR); + this->cutsceneCamId = MAIN_CAM; + this->unkMsgState1AC = 5; + this->unkState1A8 = 1; + this->actionFunc = EnKakasi_PostSongLearnDialogue; + this->unk20C = 0.0f; + this->unk210 = 60.0f; +} + +void EnKakasi_PostSongLearnDialogue(EnKakasi* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + f32 tempAnimFrame = this->skelanime.curFrame; + Vec3f vec3fCopy; + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); + Math_SmoothStepToS(&player->actor.shape.rot.y, this->actor.yawTowardsPlayer + 0x8000, 5, 1000, 0); + + if (this->unk190 == 0) { + func_801477B4(globalCtx); + func_800B7298(globalCtx, &this->actor, 0x56); + this->actor.textId = 0x1648; + func_801518B0(globalCtx, (this->actor.textId), &this->actor); + this->unkState1A8 = 0; + this->unk190 = 1; + } + + if (this->actor.textId == 0x1648 && this->animIndex == ENKAKASI_ANIM_HOPPING_REGULAR && + this->animeFrameCount <= tempAnimFrame) { + this->unkCounter1A4++; + if (this->unkCounter1A4 >= 2) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + } + } + + if (this->actor.textId == 0x164B && this->animIndex == ENKAKASI_ANIM_ARMS_CROSSED_ROCKING && + this->animeFrameCount <= tempAnimFrame) { + this->unkCounter1A4++; + if (this->unkCounter1A4 >= 2) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SPIN_REACH_OFFER); + } + } + + if (this->unkState1A8 == 0) { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + return; + } + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + func_800B7298(globalCtx, &this->actor, 0x56); + this->unkState1A8 = 1; + } + + if (this->cutsceneCamId != MAIN_CAM) { + this->unk22C.y = this->actor.home.pos.y + 50.0f; + EnKakasi_CheckPlayerPosition(this, globalCtx); + this->unk238.x = D_80971FA0[this->unk190].x; + this->unk238.y = D_80971FA0[this->unk190].y; + this->unk238.z = D_80971FA0[this->unk190].z; + Math_Vec3f_Copy(&vec3fCopy, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &vec3fCopy, &this->unk238, 1); + this->unk244.x = D_80971FE8[this->unk190].x + this->unk22C.x; + this->unk244.y = D_80971FE8[this->unk190].y + this->unk22C.y; + this->unk244.z = D_80971FE8[this->unk190].z + this->unk22C.z; + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + } + + func_8096FAAC(this, globalCtx); + + if (this->unkState1A8 != 0 && func_80152498(&globalCtx->msgCtx) == this->unkMsgState1AC && + func_80147624(globalCtx) != 0) { + + func_801477B4(globalCtx); + + if (this->unkMsgState1AC == 5) { + this->unk190++; + if (this->unk190 > 5) { + this->unk190 = 5; + } + + if (this->actor.textId == 0x1648) { + func_800B7298(globalCtx, &this->actor, 7); + this->actor.textId = 0x1649; + if (this->animIndex != ENKAKASI_ANIM_ARMS_CROSSED_ROCKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_ARMS_CROSSED_ROCKING); + } + + } else if (this->actor.textId == 0x1649) { + this->actor.textId = 0x1660; + this->unkMsgState1AC = 4; + + } else if (this->actor.textId == 0x164A) { + this->actor.textId = 0x164B; + + } else if (this->actor.textId == 0x164B) { + this->actor.textId = 0x164C; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + + } else { + if (this->actor.textId == 0x164C || this->actor.textId == 0x1661) { + EnKakasi_SetupDigAway(this); + return; + } + } + + } else { + this->unkMsgState1AC = 5; + if (globalCtx->msgCtx.choiceIndex == 1) { + func_8019F208(); // play 0x4808 sfx (decide) and calls func_801A75E8 + this->actor.textId = 0x164A; + } else { + func_8019F230(); // play 0x480A sfx (cancel) and calls func_801A75E8 + this->actor.textId = 0x1661; + } + } + func_80151938(globalCtx, this->actor.textId); + } +} + +/* + * talking before dancing the night away, and cutscene setup + */ +void EnKakasi_DancingRemark(EnKakasi* this, GlobalContext* globalCtx) { + u32 currentDay = gSaveContext.day; + + this->unkState196 = 3; + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[0]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[0]); + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[0], &this->actor); + this->cutsceneCamId = ActorCutscene_GetCurrentCamera(this->actor.cutscene); + if (currentDay == 3 && gSaveContext.isNight) { + EnKakasi_SetupDigAway(this); + } else { + func_801A2BB8(0x3E); + EnKakasi_SetupDanceNightAway(this); + } + } +} + +void EnKakasi_SetupDanceNightAway(EnKakasi* this) { + this->unk190 = 0; + this->unkCounter1A4 = 0; + this->unk20C = 0.0f; + this->unk210 = 60.0f; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_TWIRL); + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + func_8016566C(0xB4); + this->actionFunc = EnKakasi_DancingNightAway; +} + +void EnKakasi_DancingNightAway(EnKakasi* this, GlobalContext* globalCtx) { + f32 currentFrame; + Vec3f localVec3f; + Player* player; + + currentFrame = this->skelanime.curFrame; + EnKakasi_CheckPlayerPosition(this, globalCtx); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 1, 3000, 0); + this->unk22C.y = this->actor.home.pos.y + 50.0f; + + this->unk238.x = D_80971E38[this->unk190].x; + this->unk238.y = D_80971E38[this->unk190].y; + this->unk238.z = D_80971E38[this->unk190].z; + Math_Vec3f_Copy(&localVec3f, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &localVec3f, &this->unk238, 1); + + if (1) {} + this->unk244.x = D_80971EEC[this->unk190].x + this->unk22C.x; + this->unk244.y = D_80971EEC[this->unk190].y + this->unk22C.y; + this->unk244.z = D_80971EEC[this->unk190].z + this->unk22C.z; + if (this->unk190 != 6 && this->unk190 != 7) { + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + } + if (this->unk190 >= 7 && this->unk190 != 0xE) { + this->actor.shape.rot.y += 0x800; + } + + func_8096FAAC(this, globalCtx); + + // switching through manual cutscene states + switch (this->unk190) { + case 0: + // twirling + this->unk204 = 0x28; + this->unk190++; + return; + case 1: + // end of twirl, start shaking back and forth + if (this->unk204 == 0 && this->animeFrameCount <= currentFrame) { + this->unk204 = 0x14; + this->unk190++; + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + return; + case 2: + // camera view on the left + if (this->unk204 == 0) { + this->unk204 = 0x14; + this->unk190++; + } + return; + case 3: + // camera view on the right + if (this->unk204 == 0) { + this->unk204 = 0x14; + this->unk190++; + } + return; + case 4: + // camera view close up front + if (this->unk204 == 0) { + this->unk204 = 0x14; + this->unk190++; + } + return; + case 5: + // camera view zoomed out front + if (this->unk204 == 0) { + this->unk204 = 0xF; + this->unk190++; + } + return; + case 6: + // zoom in and sweep down in from case 5 + if (this->unk204 == 0) { + this->unk204 = 0xF; + this->unk190++; + } + return; + case 7: + // zoom in close from case 6 + if (this->unk204 == 0) { + this->unk204 = 0xA; + this->unk190++; + } + return; + + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + // multiple quick angle cuts viewing from multiple sides + if (this->unk204 == 0) { + this->unk190++; + this->unk204 = 0xA; + if (this->unk190 == 0xE) { + func_800B7298(globalCtx, &this->actor, 0x49); + func_80165690(); + this->unk204 = 0x14; + } + } + return; + case 14: + // goes off once for some camera changes, + // otherwise its the end when camera is back to normal and link is confused + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); + if (this->unk204 == 0) { + player = GET_PLAYER(globalCtx); + + func_80169DCC(globalCtx, 0, Entrance_CreateIndexFromSpawn(0), player->unk_3CE, 0xBFF, &player->unk_3C0, + player->unk_3CC); + func_80169EFC(globalCtx); + + if (0) {} + if (gSaveContext.time > CLOCK_TIME(18, 0) || gSaveContext.time < CLOCK_TIME(6, 0)) { + gSaveContext.time = CLOCK_TIME(6, 0); + gSaveContext.respawnFlag = -4; + gSaveContext.eventInf[2] |= 0x80; + } else { + gSaveContext.time = CLOCK_TIME(18, 0); + gSaveContext.respawnFlag = -8; + } + gSaveContext.weekEventReg[0x53] |= 1; + this->unk190 = 0; + this->actionFunc = EnKakasi_DoNothing; + } + } +} + +void EnKakasi_DoNothing(EnKakasi* this, GlobalContext* globalCtx) { +} + +void EnKakasi_SetupDigAway(EnKakasi* this) { + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + this->unk190 = 0; + this->unkCounter1A4 = 0; + this->unk210 = 60.0f; + this->unk20C = 60.0f; + Math_Vec3f_Copy(&this->unk22C, &this->actor.home.pos); + this->unkState196 = 4; + this->actionFunc = EnKakasi_DiggingAway; +} + +void EnKakasi_DiggingAway(EnKakasi* this, GlobalContext* globalCtx) { + Vec3f tempunk238; + Vec3f tempWorldPos; + + if (this->cutsceneCamId != MAIN_CAM) { + this->unk22C.y = this->actor.home.pos.y + 50.0f; + this->unk238.x = D_80972030.x; + this->unk238.y = D_80972030.y; + this->unk238.z = D_80972030.z; + + Math_Vec3f_Copy(&tempunk238, &this->unk238); + OLib_DbCameraVec3fSum(&this->actor.home, &tempunk238, &this->unk238, 1); + this->unk244.x = ((f32)D_8097203C.x) + this->unk22C.x; // cast req + this->unk244.y = ((f32)D_8097203C.y) + this->unk22C.y; + this->unk244.z = ((f32)D_8097203C.z) + this->unk22C.z; + Math_Vec3f_Copy(&this->unk214, &this->unk238); + Math_Vec3f_Copy(&this->unk220, &this->unk244); + func_8096FAAC(this, globalCtx); + } + + if (this->unkCounter1A4 < 15) { + this->unkCounter1A4++; + return; + } + + this->actor.shape.rot.y += 0x3000; + Math_SmoothStepToS(&this->unk190, 500, 5, 50, 0); + if ((globalCtx->gameplayFrames % 4) == 0) { + Math_Vec3f_Copy(&tempWorldPos, &this->actor.world.pos); + tempWorldPos.y = this->actor.floorHeight; + tempWorldPos.x += randPlusMinusPoint5Scaled(2.0f); + tempWorldPos.z += randPlusMinusPoint5Scaled(2.0f); + + if (globalCtx->sceneNum == SCENE_8ITEMSHOP) { + EffectSsGSplash_Spawn(globalCtx, &tempWorldPos, 0, 0, 0, randPlusMinusPoint5Scaled(100.0f) + 200.0f); + Audio_PlaySoundAtPosition(globalCtx, &tempWorldPos, 0x32, NA_SE_EV_BOMB_DROP_WATER); + + } else { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 5, + 4.0f, 200, 10, 1); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + } + } + + Math_ApproachF(&this->actor.shape.yOffset, -6000.0f, 0.5f, 200.0f); + if (fabsf(this->actor.shape.yOffset + 6000.0f) < 10.0f) { + gSaveContext.weekEventReg[79] |= 8; + func_800B7298(globalCtx, &this->actor, 6); + ActorCutscene_Stop(this->actorCutscenes[0]); + this->aboveGroundStatus = ENKAKASI_ABOVE_GROUND_TYPE; + this->songSummonDist = 80.0f; + EnKakasi_SetupIdleUnderground(this); + } +} + +void EnKakasi_SetupIdleUnderground(EnKakasi* this) { + this->actor.shape.yOffset = -7000.0; + this->actor.draw = NULL; + this->actor.flags |= 0x8000000; + this->unkState196 = 5; + this->actionFunc = EnKakasi_IdleUnderground; +} + +void EnKakasi_IdleUnderground(EnKakasi* this, GlobalContext* globalCtx) { + if ((gSaveContext.weekEventReg[79] & 0x8) && this->actor.xzDistToPlayer < this->songSummonDist && + (BREG(1) != 0 || globalCtx->msgCtx.unk1202A == 0xD)) { + this->actor.flags &= ~0x8000000; + globalCtx->msgCtx.unk1202A = 4; + this->actionFunc = EnKakasi_SetupRiseOutOfGround; + } +} + +void EnKakasi_SetupRiseOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { + s32 cutsceneIndex; + + cutsceneIndex = 0; + if (this->aboveGroundStatus == ENKAKASI_ABOVE_GROUND_TYPE) { + cutsceneIndex = 1; + } + + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actorCutscenes[cutsceneIndex]); + + } else if (ActorCutscene_GetCanPlayNext(this->actorCutscenes[cutsceneIndex]) == 0) { + ActorCutscene_SetIntentToPlay(this->actorCutscenes[cutsceneIndex]); + + } else { + ActorCutscene_StartAndSetUnkLinkFields(this->actorCutscenes[cutsceneIndex], &this->actor); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actor.draw = EnKakasi_Draw; + this->unkState196 = 6; + this->actionFunc = EnKakasi_RisingOutOfGround; + } +} + +void EnKakasi_RisingOutOfGround(EnKakasi* this, GlobalContext* globalCtx) { + this->actor.shape.rot.y += 0x3000; + + if (this->animIndex != ENKAKASI_ANIM_SIDEWAYS_SHAKING) { + EnKakasi_SetAnimation(this, ENKAKASI_ANIM_SIDEWAYS_SHAKING); + } + if (this->actor.shape.yOffset < -10.0f) { + if ((globalCtx->gameplayFrames % 8) == 0) { + func_800BBDAC(globalCtx, &this->actor, &this->actor.world.pos, this->actor.shape.shadowScale - 20.0f, 10, + 8.0f, 500, 10, 1); + Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + } + Math_ApproachF(&this->actor.shape.yOffset, 0.0f, 0.5f, 200.0f); + } else { + EnKakasi_SetupIdleRisen(this); + } +} + +void EnKakasi_SetupIdleRisen(EnKakasi* this) { + // text: great to see you again + this->actor.textId = 0x164D; + this->unkState196 = 7; + this->actionFunc = EnKakasi_IdleRisen; + this->actor.shape.yOffset = 0.0f; +} + +void EnKakasi_IdleRisen(EnKakasi* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); + if (func_800B84D0(&this->actor, globalCtx)) { + this->actionFunc = EnKakasi_RisenDialogue; + } else { + func_800B8614(&this->actor, globalCtx, 70.0f); + } +} + +void EnKakasi_RisenDialogue(EnKakasi* this, GlobalContext* globalCtx) { + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 5, 1000, 0); + + if (func_80152498(&globalCtx->msgCtx) == 5 && func_80147624(globalCtx) != 0) { + func_801477B4(globalCtx); + EnKakasi_SetupIdleRisen(this); + } +} + +void EnKakasi_Update(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; + s32 pad; + + SkelAnime_Update(&this->skelanime); + if (this->actor.draw != NULL) { + EnKakasi_CheckAnimationSfx(this); + } + + this->actor.world.rot.y = this->actor.shape.rot.y; + DECR(this->postTeachTimer); + DECR(this->unk204); + + if (this->unkState196 != 5) { + if (this->unk1BC.x != 0.0f || this->unk1BC.z != 0.0f) { + Math_Vec3f_Copy(&this->actor.focus.pos, &this->unk1BC); + this->actor.focus.pos.y += 10.0f; + if (this->cutsceneCamId == MAIN_CAM) { + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.world.rot); + } else { + Math_Vec3s_Copy(&this->actor.focus.rot, &this->actor.home.rot); + } + } + } else { + Actor_SetHeight(&this->actor, this->unkHeight); + } + + this->actionFunc(this, globalCtx); + Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 50.0f, 50.0f, 100.0f, 0x1C); + if (this->actor.draw != NULL) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +void EnKakasi_LimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* actor) { + EnKakasi* this = (EnKakasi*)actor; + + if (limbIndex == 4) { + // what is D_801D15B0 ? we didn't have to define it, we store the output though + Matrix_MultiplyVector3fByState(&D_801D15B0, &this->unk1BC); + } +} + +void EnKakasi_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnKakasi* this = THIS; + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelanime.skeleton, this->skelanime.jointTable, this->skelanime.dListCount, + NULL, EnKakasi_LimbDraw, &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h index b9a18adc5..2cb4f6cba 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.h @@ -6,14 +6,46 @@ struct EnKakasi; typedef void (*EnKakasiActionFunc)(struct EnKakasi*, GlobalContext*); +typedef void (*EnKakasiUnkFunc)(GlobalContext*, struct EnKakasi*); typedef struct EnKakasi { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x4]; - /* 0x0148 */ EnKakasiActionFunc actionFunc; - /* 0x014C */ char unk_14C[0x154]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnKakasiUnkFunc unkFunc; // used for one z_snap calling function? + /* 0x148 */ EnKakasiActionFunc actionFunc; + /* 0x14C */ SkelAnime skelanime; + /* 0x190 */ s16 unk190; // camera index for song teaching angles? + /* 0x192 */ s16 postTeachTimer; + /* 0x194 */ s16 aboveGroundStatus; // from params, changed to 2 in init + /* 0x196 */ s16 unkState196; + /* 0x19A */ UNK_TYPE1 pad198[0x8]; + /* 0x1A0 */ s32 animIndex; + /* 0x1A4 */ s32 unkCounter1A4; // counter, counts up to F while he digs away, reused elsewhere + /* 0x1A8 */ s32 unkState1A8; + /* 0x1AC */ s16 unkMsgState1AC; // might be dialog state, compared against func(msgCtx) + /* 0x1AE */ s16 actorCutscenes[3]; + /* 0x1B4 */ f32 animeFrameCount; + /* 0x1B8 */ f32 unkHeight; + /* 0x1BC */ Vec3f unk1BC; // set by post limbdraw func for one limb + /* 0x1C8 */ UNK_TYPE1 pad1C8[0x3C]; + /* 0x204 */ s16 unk204; // set to A, F, 0x14, 0x28 frequently + /* 0x206 */ UNK_TYPE1 pad206[2]; + /* 0x208 */ s16 cutsceneCamId; + /* 0x20C */ f32 unk20C; // passed to unknown function + /* 0x210 */ f32 unk210; // used as a target for 20C to approach + /* 0x214 */ Vec3f unk214; // copied from unk238 regularly + /* 0x220 */ Vec3f unk220; //EnKakasi_TeachingSong + /* 0x22C */ Vec3f unk22C; //actor home copied to here + /* 0x238 */ Vec3f unk238; //copied from D_80971E38[unk190] + /* 0x244 */ Vec3f unk244; + /* 0x250 */ f32 songSummonDist; + /* 0x254 */ ColliderCylinder collider; } EnKakasi; // size = 0x2A0 extern const ActorInit En_Kakasi_InitVars; +#define ENKAKASI_ABOVE_GROUND_TYPE 2 + +#define GET_KAKASI_SUMMON_DISTANCE(this) ((this->actor.params >> 0x8) & 0xFF) +#define GET_KAKASI_ABOVE_GROUND(this) (this->actor.params & 0x1) + #endif // Z_EN_KAKASI_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7dab11b4d..43024464d 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8016,37 +8016,37 @@ 0x8096F4DC:("BgF40Swlift_Draw",), 0x8096F5E0:("EnKakasi_Destroy",), 0x8096F60C:("EnKakasi_Init",), - 0x8096F800:("func_8096F800",), - 0x8096F88C:("func_8096F88C",), + 0x8096F800:("EnKakasi_SetAnimation",), + 0x8096F88C:("EnKakasi_8096F88C",), 0x8096F8D8:("func_8096F8D8",), 0x8096FA18:("func_8096FA18",), 0x8096FAAC:("func_8096FAAC",), 0x8096FBB8:("func_8096FBB8",), - 0x8096FC8C:("func_8096FC8C",), - 0x8096FCC4:("func_8096FCC4",), - 0x8096FDE8:("func_8096FDE8",), - 0x8096FE00:("func_8096FE00",), - 0x80970008:("func_80970008",), - 0x8097006C:("func_8097006C",), + 0x8096FC8C:("EnKakasi_InitTimeSkipDialogue",), + 0x8096FCC4:("EnKakasi_TimeSkipDialogue",), + 0x8096FDE8:("EnKakasi_SetupIdleStanding",), + 0x8096FE00:("EnKakasi_IdleStanding",), + 0x80970008:("EnKakasi_SetupDialogue",), + 0x8097006C:("EnKakasi_RegularDialogue",), 0x809705E4:("func_809705E4",), 0x80970658:("func_80970658",), 0x80970740:("func_80970740",), 0x80970978:("func_80970978",), - 0x80970A10:("func_80970A10",), - 0x80970A9C:("func_80970A9C",), - 0x80970F20:("func_80970F20",), - 0x80970FF8:("func_80970FF8",), - 0x80971064:("func_80971064",), - 0x80971430:("func_80971430",), + 0x80970A10:("EnKakasi_SetupPostSongLearnDialogue",), + 0x80970A9C:("EnKakasi_PostSongLearnDialogue",), + 0x80970F20:("EnKakasi_DancingRemark",), + 0x80970FF8:("EnKakasi_SetupDanceNightAway",), + 0x80971064:("EnKakasi_DancingNightAway",), + 0x80971430:("EnKakasi_DoNothing",), 0x80971440:("func_80971440",), 0x809714BC:("func_809714BC",), 0x80971794:("func_80971794",), 0x809717D0:("func_809717D0",), - 0x8097185C:("func_8097185C",), - 0x8097193C:("func_8097193C",), - 0x80971A38:("func_80971A38",), - 0x80971A64:("func_80971A64",), - 0x80971AD4:("func_80971AD4",), + 0x8097185C:("EnKakasi_SetupRiseOutOfGround",), + 0x8097193C:("EnKakasi_RisingOutOfGround",), + 0x80971A38:("EnKakasi_SetupIdleRisen",), + 0x80971A64:("EnKakasi_IdleRisen",), + 0x80971AD4:("EnKakasi_RisenDialogue",), 0x80971B48:("EnKakasi_Update",), 0x80971CE0:("func_80971CE0",), 0x80971D20:("EnKakasi_Draw",), diff --git a/undefined_syms.txt b/undefined_syms.txt index 56f4cb1b1..211f78865 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -2723,6 +2723,15 @@ D_0600D828 = 0x0600D828; D_06000214 = 0x06000214; D_060065B0 = 0x060065B0; +D_06007444 = 0x06007444; +D_0600686C = 0x0600686C; +D_060081A4 = 0x060081A4; +D_06007B90 = 0x06007B90; +D_060071EC = 0x060071EC; +D_06007444 = 0x06007444; +D_0600686C = 0x0600686C; +D_060081A4 = 0x060081A4; +D_06000214 = 0x06000214; // ovl_En_Kame From dfc146663fe21311044ff8a2896e13513af1a590 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 18 Nov 2021 18:15:09 +0000 Subject: [PATCH 3/5] aisetfreq OK, some libultra improvements (#416) * aisetfreq OK * Add a lot of HW_REG and some other macros to libultra * Format * Remove extra volatile * Review * De-C guNormalize * Correct typo in crc.c --- include/ultra64.h | 1 + include/ultra64/hardware.h | 1 + include/ultra64/rdp.h | 45 +++++++++++++++++++++++++++++++++++++ include/variables.h | 2 +- spec | 2 +- src/libultra/gu/normalize.c | 3 --- src/libultra/io/aigetlen.c | 2 +- src/libultra/io/aisetfreq.c | 19 +++++++++++++++- src/libultra/io/crc.c | 2 +- src/libultra/io/dpgetstat.c | 2 +- src/libultra/io/dpsetstat.c | 2 +- src/libultra/io/pirawdma.c | 21 +++++++++-------- src/libultra/io/si.c | 12 +++++----- src/libultra/io/sirawdma.c | 18 +++++++-------- src/libultra/io/sp.c | 3 ++- src/libultra/io/spgetstat.c | 2 +- src/libultra/io/sprawdma.c | 12 +++++----- src/libultra/io/spsetstat.c | 2 +- src/libultra/io/vi.c | 2 +- 19 files changed, 107 insertions(+), 46 deletions(-) create mode 100644 include/ultra64/rdp.h delete mode 100644 src/libultra/gu/normalize.c diff --git a/include/ultra64.h b/include/ultra64.h index d309026b9..49323cc2b 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -11,6 +11,7 @@ #include "ultra64/sptask.h" #include "ultra64/thread.h" #include "ultra64/rcp.h" +#include "ultra64/rdp.h" #include "ultra64/rsp.h" #include "ultra64/vi.h" diff --git a/include/ultra64/hardware.h b/include/ultra64/hardware.h index c3eb8dd4c..ae6470d51 100644 --- a/include/ultra64/hardware.h +++ b/include/ultra64/hardware.h @@ -96,6 +96,7 @@ #define SI_STATUS_INTERRUPT (1 << 12) #define PIF_RAM_START 0x1FC007C0 +#define PIF_RAM_SIZE 0x40 #define MI_INIT_MODE_REG 0x04300000 #define MI_MODE_REG MI_INIT_MODE_REG diff --git a/include/ultra64/rdp.h b/include/ultra64/rdp.h new file mode 100644 index 000000000..b4b3bb532 --- /dev/null +++ b/include/ultra64/rdp.h @@ -0,0 +1,45 @@ +#ifndef ULTRA64_RDP_H +#define ULTRA64_RDP_H + +/* DP Command Registers */ +#define DPC_START_REG 0x04100000 +#define DPC_END_REG 0x04100004 +#define DPC_CURRENT_REG 0x04100008 +#define DPC_STATUS_REG 0x0410000C +#define DPC_CLOCK_REG 0x04100010 +#define DPC_BUFBUSY_REG 0x04100014 +#define DPC_PIPEBUSY_REG 0x04100018 +#define DPC_TMEM_REG 0x0410001C + +/* DP Span Registers */ +#define DPS_TBIST_REG 0x04200000 +#define DPS_TEST_MODE_REG 0x04200004 +#define DPS_BUFTEST_ADDR_REG 0x04200008 +#define DPS_BUFTEST_DATA_REG 0x0420000C + +/* DP Status Read Flags */ +#define DPC_STATUS_XBUS_DMEM_DMA (1 << 0) +#define DPC_STATUS_FREEZE (1 << 1) +#define DPC_STATUS_FLUSH (1 << 2) +#define DPC_STATUS_START_GCLK (1 << 3) +#define DPC_STATUS_TMEM_BUSY (1 << 4) +#define DPC_STATUS_PIPE_BUSY (1 << 5) +#define DPC_STATUS_CMD_BUSY (1 << 6) +#define DPC_STATUS_CBUF_READY (1 << 7) +#define DPC_STATUS_DMA_BUSY (1 << 8) +#define DPC_STATUS_END_VALID (1 << 9) +#define DPC_STATUS_START_VALID (1 << 10) + +/* DP Status Write Flags */ +#define DPC_CLR_XBUS_DMEM_DMA (1 << 0) +#define DPC_SET_XBUS_DMEM_DMA (1 << 1) +#define DPC_CLR_FREEZE (1 << 2) +#define DPC_SET_FREEZE (1 << 3) +#define DPC_CLR_FLUSH (1 << 4) +#define DPC_SET_FLUSH (1 << 5) +#define DPC_CLR_TMEM_CTR (1 << 6) +#define DPC_CLR_PIPE_CTR (1 << 7) +#define DPC_CLR_CMD_CTR (1 << 8) +#define DPC_CLR_CLOCK_CTR (1 << 9) + +#endif diff --git a/include/variables.h b/include/variables.h index 93b7790cb..624940525 100644 --- a/include/variables.h +++ b/include/variables.h @@ -8,7 +8,7 @@ // pre-boot variables extern u32 osTvType; extern u32 osRomType; -extern u32 osRomBase; +extern uintptr_t osRomBase; extern u32 osResetType; extern u32 osCicId; extern u32 osVersion; diff --git a/spec b/spec index 2983af4dc..c9458d939 100644 --- a/spec +++ b/spec @@ -170,7 +170,7 @@ beginseg include "build/src/libultra/voice/voicecontwrite20.o" include "build/src/libultra/io/crc.o" include "build/src/libultra/os/getactivequeue.o" - include "build/src/libultra/gu/normalize.o" + include "build/asm/boot/normalize.text.o" include "build/asm/boot/setcompare.text.o" include "build/asm/boot/getcompare.text.o" include "build/src/libultra/io/dpgetstat.o" diff --git a/src/libultra/gu/normalize.c b/src/libultra/gu/normalize.c deleted file mode 100644 index 3fdbbe880..000000000 --- a/src/libultra/gu/normalize.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/boot/normalize/guNormalize.s") diff --git a/src/libultra/io/aigetlen.c b/src/libultra/io/aigetlen.c index e3e7289ac..58d8db487 100644 --- a/src/libultra/io/aigetlen.c +++ b/src/libultra/io/aigetlen.c @@ -1,5 +1,5 @@ #include "global.h" u32 osAiGetLength(void) { - return *(u32*)0xA4500004; + return HW_REG(AI_LEN_REG, u32); } diff --git a/src/libultra/io/aisetfreq.c b/src/libultra/io/aisetfreq.c index ef0a8d2de..8702941b9 100644 --- a/src/libultra/io/aisetfreq.c +++ b/src/libultra/io/aisetfreq.c @@ -1,3 +1,20 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/boot/aisetfreq/osAiSetFrequency.s") +s32 osAiSetFrequency(u32 frequency) { + u8 bitrate; + f32 dacRateF = ((f32)osViClock / frequency) + 0.5f; + u32 dacRate = dacRateF; + + if (dacRate < 132) { + return -1; + } + + bitrate = (dacRate / 66); + if (bitrate > 16) { + bitrate = 16; + } + + HW_REG(AI_DACRATE_REG, u32) = dacRate - 1; + HW_REG(AI_BITRATE_REG, u32) = bitrate - 1; + return osViClock / (s32)dacRate; +} diff --git a/src/libultra/io/crc.c b/src/libultra/io/crc.c index e2f3fb991..acae7b408 100644 --- a/src/libultra/io/crc.c +++ b/src/libultra/io/crc.c @@ -34,7 +34,7 @@ * \f[ m(X) X^n = Q(X) p(X) + R(X) \f] * (\f$ R(X) \f$ is the *remainder after dividing by \f$ p(X) \f$*). * - Therefore, \f$ m(X) X^n - R(X) \f$ is divisible by the generator polynomial. This means that if we append the - * binary number corresponding to \f$ R(X) \f$ to the message and rerun the algorithm, we will get 0 if now errors have + * binary number corresponding to \f$ R(X) \f$ to the message and rerun the algorithm, we will get 0 if no errors have * been introduced. * * diff --git a/src/libultra/io/dpgetstat.c b/src/libultra/io/dpgetstat.c index 763c6622e..0c4b3073b 100644 --- a/src/libultra/io/dpgetstat.c +++ b/src/libultra/io/dpgetstat.c @@ -1,5 +1,5 @@ #include "global.h" u32 osDpGetStatus(void) { - return *(u32*)0xA410000C; + return HW_REG(DPC_STATUS_REG, u32); } diff --git a/src/libultra/io/dpsetstat.c b/src/libultra/io/dpsetstat.c index c653a0817..d2655626c 100644 --- a/src/libultra/io/dpsetstat.c +++ b/src/libultra/io/dpsetstat.c @@ -1,5 +1,5 @@ #include "global.h" void osDpSetStatus(u32 data) { - *(u32*)0xA410000C = data; + HW_REG(DPC_STATUS_REG, u32) = data; } diff --git a/src/libultra/io/pirawdma.c b/src/libultra/io/pirawdma.c index 242a91c24..07aa1b822 100644 --- a/src/libultra/io/pirawdma.c +++ b/src/libultra/io/pirawdma.c @@ -1,23 +1,22 @@ #include "global.h" -s32 __osPiRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size) { - register int stat; +s32 __osPiRawStartDma(s32 direction, uintptr_t devAddr, void* dramAddr, size_t size) { + register int status = HW_REG(PI_STATUS_REG, u32); - stat = *(vu32*)0xA4600010; - while (stat & (2 | 1)) { - stat = *(vu32*)0xA4600010; + while (status & (PI_STATUS_IOBUSY | PI_STATUS_BUSY)) { + status = HW_REG(PI_STATUS_REG, u32); } - *(u32*)0xA4600000 = osVirtualToPhysical(dramAddr); + HW_REG(PI_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr); - *(u32*)0xA4600004 = ((osRomBase | devAddr) & 0x1fffffff); + HW_REG(PI_CART_ADDR_REG, u32) = ((osRomBase | devAddr) & 0x1FFFFFFF); switch (direction) { - case 0: - *(u32*)0xA460000C = size - 1; + case OS_READ: + HW_REG(PI_WR_LEN_REG, u32) = size - 1; break; - case 1: - *(u32*)0xA4600008 = size - 1; + case OS_WRITE: + HW_REG(PI_RD_LEN_REG, u32) = size - 1; break; default: return -1; diff --git a/src/libultra/io/si.c b/src/libultra/io/si.c index 6de5874b9..563c68276 100644 --- a/src/libultra/io/si.c +++ b/src/libultra/io/si.c @@ -1,11 +1,11 @@ #include "global.h" -int __osSiDeviceBusy() { - register u32 status; - status = *(u32*)0xA4800018; - if (status & 3) { - return 1; +s32 __osSiDeviceBusy() { + register u32 status = HW_REG(SI_STATUS_REG, u32); + + if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) { + return true; } else { - return 0; + return false; } } diff --git a/src/libultra/io/sirawdma.c b/src/libultra/io/sirawdma.c index ff57e21c2..eb62fa2a3 100644 --- a/src/libultra/io/sirawdma.c +++ b/src/libultra/io/sirawdma.c @@ -1,24 +1,24 @@ #include "global.h" s32 __osSiRawStartDma(s32 direction, void* dramAddr) { - if ((*(u32*)0xA4800018 & 0x3) != 0) { + if (HW_REG(SI_STATUS_REG, u32) & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) { return -1; } - if (direction == 1) { - osWritebackDCache(dramAddr, 64); + if (direction == OS_WRITE) { + osWritebackDCache(dramAddr, PIF_RAM_SIZE); } - *(u32*)0xA4800000 = osVirtualToPhysical(dramAddr); + HW_REG(SI_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr); - if (direction == 0) { - *(u32*)0xA4800004 = 0x1FC007C0; + if (direction == OS_READ) { + HW_REG(SI_PIF_ADDR_RD64B_REG, void*) = (void*)PIF_RAM_START; } else { - *(u32*)0xA4800010 = 0x1FC007C0; + HW_REG(SI_PIF_ADDR_WR64B_REG, void*) = (void*)PIF_RAM_START; } - if (direction == 0) { - osInvalDCache(dramAddr, 64); + if (direction == OS_READ) { + osInvalDCache(dramAddr, PIF_RAM_SIZE); } return 0; } diff --git a/src/libultra/io/sp.c b/src/libultra/io/sp.c index db2e5b451..c028c7692 100644 --- a/src/libultra/io/sp.c +++ b/src/libultra/io/sp.c @@ -5,6 +5,7 @@ s32 __osSpDeviceBusy(void) { if (status & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) { return true; + } else { + return false; } - return false; } diff --git a/src/libultra/io/spgetstat.c b/src/libultra/io/spgetstat.c index 98a3dc23b..8987b2414 100644 --- a/src/libultra/io/spgetstat.c +++ b/src/libultra/io/spgetstat.c @@ -1,5 +1,5 @@ #include "global.h" u32 __osSpGetStatus() { - return *(vu32*)0xA4040010; + return HW_REG(SP_STATUS_REG, u32); } diff --git a/src/libultra/io/sprawdma.c b/src/libultra/io/sprawdma.c index 95395a29d..494f3db50 100644 --- a/src/libultra/io/sprawdma.c +++ b/src/libultra/io/sprawdma.c @@ -1,17 +1,17 @@ #include "global.h" s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size) { - if (__osSpDeviceBusy() != 0) { + if (__osSpDeviceBusy()) { return -1; } - *(vu32*)0xA4040000 = devAddr; - *(vu32*)0xA4040004 = osVirtualToPhysical(dramAddr); + HW_REG(SP_MEM_ADDR_REG, u32) = devAddr; + HW_REG(SP_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr); - if (direction == 0) { - *(vu32*)0xA404000C = size - 1; + if (direction == OS_READ) { + HW_REG(SP_WR_LEN_REG, u32) = size - 1; } else { - *(vu32*)0xA4040008 = size - 1; + HW_REG(SP_RD_LEN_REG, u32) = size - 1; } return 0; diff --git a/src/libultra/io/spsetstat.c b/src/libultra/io/spsetstat.c index 346577218..eb183eab4 100644 --- a/src/libultra/io/spsetstat.c +++ b/src/libultra/io/spsetstat.c @@ -1,5 +1,5 @@ #include "global.h" void __osSpSetStatus(u32 data) { - *(vu32*)0xA4040010 = data; + HW_REG(SP_STATUS_REG, u32) = data; } diff --git a/src/libultra/io/vi.c b/src/libultra/io/vi.c index 7b64b4449..ec0b1de70 100644 --- a/src/libultra/io/vi.c +++ b/src/libultra/io/vi.c @@ -17,7 +17,7 @@ void __osViInit(void) { __osViNext->modep = &osViModePalLan1; } else if (osTvType == OS_TV_MPAL) { __osViNext->modep = &osViModeMpalLan1; - } else { + } else { // OS_TV_NTSC or OS_TV_UNK28 __osViNext->modep = &osViModeNtscLan1; } From d190b265f6f232ac7423d72b55f8c42583c93cb2 Mon Sep 17 00:00:00 2001 From: engineer124 <47598039+engineer124@users.noreply.github.com> Date: Sat, 20 Nov 2021 01:36:50 +1100 Subject: [PATCH 4/5] Audio Files & Data: Fix File/Data Splits and Compiler Flags (#456) * Properly split audio voice * Split off jpeg code from audio * Fix compiler flags * Properly split libultra audio file * Split audio data for many files correctly * Fix remaining data splits * Fix up troublesome data * Fix variables.txt * Missed two files that need to go in audio/ * Add missing `/` * `D_801E1100` -> audio_init_params * Properly split code_801D9090.data.s * Fix code_801A5BD0 bss * Move audio_dramStack to a blob --- Makefile | 3 ++ spec | 45 +++++++++++++++++--------- src/code/{ => audio}/audio_effects.c | 0 src/code/{ => audio}/audio_heap.c | 0 src/code/{ => audio}/audio_load.c | 0 src/code/{ => audio}/audio_playback.c | 0 src/code/{ => audio}/audio_seqplayer.c | 0 src/code/{ => audio}/audio_synthesis.c | 0 src/code/{ => audio}/code_80192BE0.c | 0 src/code/audio/code_80194710.c | 5 +++ src/code/audio/code_80194790.c | 9 ++++++ src/code/{ => audio}/code_8019AF00.c | 16 --------- src/code/audio/code_801A4EB0.c | 17 ++++++++++ src/code/{ => audio}/code_801A51F0.c | 0 src/code/{ => audio}/code_801A5BD0.c | 0 src/code/{ => audio}/code_801A7B10.c | 16 --------- src/code/code_80194710.c | 13 -------- src/code/code_801AA020.c | 2 -- src/code/jpegutils.c | 17 ++++++++++ tools/disasm/files.txt | 24 ++++++++++---- tools/disasm/variables.txt | 21 ++++++------ 21 files changed, 107 insertions(+), 81 deletions(-) rename src/code/{ => audio}/audio_effects.c (100%) rename src/code/{ => audio}/audio_heap.c (100%) rename src/code/{ => audio}/audio_load.c (100%) rename src/code/{ => audio}/audio_playback.c (100%) rename src/code/{ => audio}/audio_seqplayer.c (100%) rename src/code/{ => audio}/audio_synthesis.c (100%) rename src/code/{ => audio}/code_80192BE0.c (100%) create mode 100644 src/code/audio/code_80194710.c create mode 100644 src/code/audio/code_80194790.c rename src/code/{ => audio}/code_8019AF00.c (96%) create mode 100644 src/code/audio/code_801A4EB0.c rename src/code/{ => audio}/code_801A51F0.c (100%) rename src/code/{ => audio}/code_801A5BD0.c (100%) rename src/code/{ => audio}/code_801A7B10.c (65%) delete mode 100644 src/code/code_80194710.c create mode 100644 src/code/jpegutils.c diff --git a/Makefile b/Makefile index 0891f7841..827f15c77 100644 --- a/Makefile +++ b/Makefile @@ -156,6 +156,8 @@ build/src/libultra/rmon/%.o: OPTFLAGS := -O2 build/src/libultra/flash/%.o: OPTFLAGS := -g build/src/libultra/flash/%.o: MIPS_VERSION := -mips1 +build/src/code/audio/%.o: OPTFLAGS := -O2 + # file flags build/src/boot_O2_g3/fault.o: CFLAGS += -trapuv build/src/boot_O2_g3/fault_drawer.o: CFLAGS += -trapuv @@ -172,6 +174,7 @@ build/src/boot_O2_g3/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $( build/src/libultra/%.o: CC := python3 tools/asm-processor/build.py $(CC_OLD) -- $(AS) $(ASFLAGS) -- build/src/code/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- +build/src/code/audio/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/actors/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- build/src/overlays/effects/%.o: CC := python3 tools/asm-processor/build.py $(CC) -- $(AS) $(ASFLAGS) -- diff --git a/spec b/spec index c9458d939..b50573ebc 100644 --- a/spec +++ b/spec @@ -639,37 +639,50 @@ beginseg pad_text pad_text pad_text - include "build/src/code/audio_synthesis.o" - include "build/src/code/audio_heap.o" - include "build/data/code/code_801D2E80.data.o" + include "build/data/code/audio_data.data.o" + include "build/src/code/audio/audio_synthesis.o" + include "build/data/code/audio_synthesis.data.o" + include "build/src/code/audio/audio_heap.o" include "build/data/code/audio_heap.bss.o" - include "build/data/code/code_801D3D90.data.o" - include "build/src/code/audio_load.o" + include "build/src/code/audio/audio_load.o" + include "build/data/code/audio_load.data.o" include "build/data/code/audio_load.bss.o" - include "build/src/code/code_80192BE0.o" - include "build/src/code/code_80194710.o" - include "build/src/code/audio_playback.o" - include "build/src/code/audio_effects.o" - include "build/src/code/audio_seqplayer.o" + include "build/src/code/audio/code_80192BE0.o" + include "build/data/code/code_80192BE0.data.o" + include "build/src/code/audio/code_80194710.o" + include "build/src/code/audio/code_80194790.o" + include "build/data/code/code_80194790.data.o" + include "build/src/code/audio/audio_playback.o" + include "build/src/code/audio/audio_effects.o" + include "build/data/code/audio_effects.data.o" + include "build/src/code/audio/audio_seqplayer.o" + include "build/data/code/audio_seqplayer.data.o" + include "build/data/code/audio_dramStack.data.o" include "build/asm/code/code_8019AE40.text.o" // handwritten pad_text include "build/asm/code/code_8019AEC0.text.o" // handwritten - include "build/src/code/code_8019AF00.o" + include "build/src/code/audio/code_8019AF00.o" + include "build/data/code/code_8019AF00.data.o" include "build/data/code/code_8019AF00.bss.o" - include "build/data/code/code_801D55B0.data.o" - include "build/src/code/code_801A51F0.o" + include "build/src/code/audio/code_801A4EB0.o" + include "build/data/code/code_801A4EB0.data.o" + include "build/src/code/audio/code_801A51F0.o" include "build/data/code/code_801A51F0.data.o" include "build/data/code/code_801A51F0.bss.o" pad_text - include "build/src/code/code_801A5BD0.o" + include "build/data/code/audio_sound_params.data.o" + include "build/src/code/audio/code_801A5BD0.o" + include "build/data/code/code_801A5BD0.data.o" include "build/data/code/code_801A5BD0.bss.o" - include "build/src/code/code_801A7B10.o" + include "build/src/code/audio/code_801A7B10.o" + include "build/data/code/code_801A7B10.data.o" include "build/data/code/code_801A7B10.bss.o" + include "build/data/code/audio_init_params.rodata.o" + include "build/src/code/jpegutils.o" include "build/src/code/code_801AA020.o" include "build/data/code/code_801AA020.bss.o" include_readonly "build/src/code/z_game_over.o" include "build/src/code/z_construct.o" - include "build/data/code/code_801D9090.data.o" include "build/data/code/code_801E1180.rodata.o" endseg diff --git a/src/code/audio_effects.c b/src/code/audio/audio_effects.c similarity index 100% rename from src/code/audio_effects.c rename to src/code/audio/audio_effects.c diff --git a/src/code/audio_heap.c b/src/code/audio/audio_heap.c similarity index 100% rename from src/code/audio_heap.c rename to src/code/audio/audio_heap.c diff --git a/src/code/audio_load.c b/src/code/audio/audio_load.c similarity index 100% rename from src/code/audio_load.c rename to src/code/audio/audio_load.c diff --git a/src/code/audio_playback.c b/src/code/audio/audio_playback.c similarity index 100% rename from src/code/audio_playback.c rename to src/code/audio/audio_playback.c diff --git a/src/code/audio_seqplayer.c b/src/code/audio/audio_seqplayer.c similarity index 100% rename from src/code/audio_seqplayer.c rename to src/code/audio/audio_seqplayer.c diff --git a/src/code/audio_synthesis.c b/src/code/audio/audio_synthesis.c similarity index 100% rename from src/code/audio_synthesis.c rename to src/code/audio/audio_synthesis.c diff --git a/src/code/code_80192BE0.c b/src/code/audio/code_80192BE0.c similarity index 100% rename from src/code/code_80192BE0.c rename to src/code/audio/code_80192BE0.c diff --git a/src/code/audio/code_80194710.c b/src/code/audio/code_80194710.c new file mode 100644 index 000000000..090c5735b --- /dev/null +++ b/src/code/audio/code_80194710.c @@ -0,0 +1,5 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194710.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194750.s") diff --git a/src/code/audio/code_80194790.c b/src/code/audio/code_80194790.c new file mode 100644 index 000000000..9ba2436de --- /dev/null +++ b/src/code/audio/code_80194790.c @@ -0,0 +1,9 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194790.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194804.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_80194840.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194790/func_801948B0.s") diff --git a/src/code/code_8019AF00.c b/src/code/audio/code_8019AF00.c similarity index 96% rename from src/code/code_8019AF00.c rename to src/code/audio/code_8019AF00.c index 8f0d129ad..227384d0a 100644 --- a/src/code/code_8019AF00.c +++ b/src/code/audio/code_8019AF00.c @@ -411,19 +411,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4DF4.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4E64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4EB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4FD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5080.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A50C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5100.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A510C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A5118.s") diff --git a/src/code/audio/code_801A4EB0.c b/src/code/audio/code_801A4EB0.c new file mode 100644 index 000000000..d3461c8f5 --- /dev/null +++ b/src/code/audio/code_801A4EB0.c @@ -0,0 +1,17 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4EB8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A4FD8.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5080.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A50C0.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5100.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A510C.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A4EB0/func_801A5118.s") diff --git a/src/code/code_801A51F0.c b/src/code/audio/code_801A51F0.c similarity index 100% rename from src/code/code_801A51F0.c rename to src/code/audio/code_801A51F0.c diff --git a/src/code/code_801A5BD0.c b/src/code/audio/code_801A5BD0.c similarity index 100% rename from src/code/code_801A5BD0.c rename to src/code/audio/code_801A5BD0.c diff --git a/src/code/code_801A7B10.c b/src/code/audio/code_801A7B10.c similarity index 65% rename from src/code/code_801A7B10.c rename to src/code/audio/code_801A7B10.c index 707996820..d2d9a71a2 100644 --- a/src/code/code_801A7B10.c +++ b/src/code/audio/code_801A7B10.c @@ -29,19 +29,3 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A99B8.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9A74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9B10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9B78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9BFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9C68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9D10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9DCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9EA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801A7B10/func_801A9F4C.s") diff --git a/src/code/code_80194710.c b/src/code/code_80194710.c deleted file mode 100644 index aa4f784c4..000000000 --- a/src/code/code_80194710.c +++ /dev/null @@ -1,13 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194710.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194750.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194790.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194804.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_80194840.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_80194710/func_801948B0.s") diff --git a/src/code/code_801AA020.c b/src/code/code_801AA020.c index 2144c6bcb..6cefc66d9 100644 --- a/src/code/code_801AA020.c +++ b/src/code/code_801AA020.c @@ -1,7 +1,5 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/D_801E1100.s") - #pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA020.s") #pragma GLOBAL_ASM("asm/non_matchings/code/code_801AA020/func_801AA248.s") diff --git a/src/code/jpegutils.c b/src/code/jpegutils.c new file mode 100644 index 000000000..89ed4e97d --- /dev/null +++ b/src/code/jpegutils.c @@ -0,0 +1,17 @@ +#include "global.h" + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9B10.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9B78.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9BFC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9C68.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9D10.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9DCC.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9EA4.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/jpegutils/func_801A9F4C.s") diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index bf786209c..2c22781ba 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -484,6 +484,7 @@ 0x8018EB60 : "audio_load", 0x80192BE0 : "code_80192BE0", 0x80194710 : "code_80194710", + 0x80194790 : "code_80194790", 0x80194930 : "audio_playback", 0x80196A00 : "audio_effects", 0x801974D0 : "audio_seqplayer", @@ -491,10 +492,12 @@ 0x8019AEB0 : "[PADDING]", 0x8019AEC0 : "code_8019AEC0", 0x8019AF00 : "code_8019AF00", + 0x801A4EB0 : "code_801A4EB0", 0x801A51F0 : "code_801A51F0", 0x801A5BC0 : "[PADDING]", 0x801A5BD0 : "code_801A5BD0", 0x801A7B10 : "code_801A7B10", + 0x801A9B10 : "jpegutils", 0x801AA020 : "code_801AA020", 0x801AA610 : "z_game_over", 0x801AAAA0 : "z_construct", @@ -573,11 +576,20 @@ 0x801D15D0 : "sys_math_atan", 0x801D1DE0 : "sys_matrix", 0x801D1E70 : "", - 0x801D2E80 : "", # audio_heap? - 0x801D3D90 : "", - 0x801D55B0 : "", + 0x801D2E80 : "audio_data", + 0x801D5FB0 : "audio_synthesis", + 0x801D5FE0 : "audio_load", + 0x801D5FF0 : "code_80192BE0", + 0x801D6010 : "code_80194790", + 0x801D6190 : "audio_effects", + 0x801D61A0 : "audio_seqplayer", + 0x801D6200 : "audio_dramStack", + 0x801D6600 : "code_8019AF00", + 0x801D8BE0 : "code_801A4EB0", 0x801D8E50 : "code_801A51F0", - 0x801D9090 : "", + 0x801D9090 : "audio_sound_params", + 0x801DB470 : "code_801A5BD0", + 0x801DB4C0 : "code_801A7B10", # .rodata section 0x801DBDF0 : "z_en_item00", @@ -658,7 +670,7 @@ 0x801E0EC0 : "code_801A51F0", 0x801E1050 : "code_801A5BD0", 0x801E1070 : "code_801A7B10", - 0x801E1100 : "code_801AA020", + 0x801E1100 : "audio_init_params", 0x801E1110 : "z_game_over", 0x801E1180 : "", @@ -714,7 +726,7 @@ 0x801FD140 : "audio_load", 0x801FD1F0 : "code_8019AF00", 0x801FD5A0 : "code_801A51F0", - 0x801FE7C0 : "code_801A5BD0", + 0x801FD710 : "code_801A5BD0", 0x801FFD00 : "code_801A7B10", 0x80208E90 : "code_801AA020", 0x80208EA0 : "gfxbuffers", diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index cdff64742..5dd49fdaa 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -2274,11 +2274,9 @@ 0x801D4D90:("D_801D4D90","UNK_PTR","",0x4), 0x801D4D98:("D_801D4D98","UNK_PTR","",0x4), 0x801D4DB0:("D_801D4DB0","UNK_PTR","",0x4), - 0x801D4DB4:("D_801D4DB4","UNK_TYPE1","",0x1), - 0x801D4FB4:("D_801D4FB4","UNK_TYPE1","",0x1), - 0x801D51B4:("D_801D51B4","UNK_TYPE4","",0x4), - 0x801D53B4:("D_801D53B4","UNK_TYPE4","",0x4), - 0x801D55B4:("D_801D55B4","UNK_TYPE1","",0x1), + 0x801D4DB4:("D_801D4DB4","f32","[256]",0x400), + 0x801D51B4:("D_801D51B4","f32","[256]",0x400), + 0x801D55B4:("D_801D55B4","f32","[128]",0x200), 0x801D57B4:("D_801D57B4","UNK_TYPE1","",0x1), 0x801D57C4:("D_801D57C4","UNK_TYPE1","",0x1), 0x801D57D4:("D_801D57D4","UNK_TYPE1","",0x1), @@ -2287,12 +2285,11 @@ 0x801D5824:("D_801D5824","UNK_TYPE2","",0x2), 0x801D58A2:("D_801D58A2","UNK_TYPE2","",0x2), 0x801D58AA:("D_801D58AA","UNK_TYPE1","",0x1), - 0x801D5928:("D_801D5928","UNK_TYPE1","",0x1), - 0x801D5B24:("D_801D5B24","UNK_TYPE1","",0x1), - 0x801D5B28:("D_801D5B28","UNK_TYPE1","",0x1), - 0x801D5D24:("D_801D5D24","UNK_TYPE1","",0x1), - 0x801D5D28:("D_801D5D28","UNK_TYPE1","",0x1), - 0x801D5F24:("D_801D5F24","UNK_TYPE1","",0x1), + 0x801D5928:("D_801D5928","f32","[128]",0x200), + 0x801D5B28:("D_801D5B28","f32","[128]",0x200), + 0x801D5D28:("D_801D5D28","f32","[128]",0x200), + 0x801D5F28:("D_801D5F28","s16","[64]",0x80), + 0x801D5FB0:("D_801D5FB0","UNK_TYPE4","",0x4), 0x801D5FB4:("D_801D5FB4","UNK_TYPE4","",0x4), 0x801D5FB8:("D_801D5FB8","UNK_TYPE4","",0x4), 0x801D5FBC:("D_801D5FBC","UNK_TYPE4","",0x4), @@ -2311,11 +2308,11 @@ 0x801D6014:("D_801D6014","UNK_TYPE1","",0x1), 0x801D6028:("D_801D6028","UNK_TYPE1","",0x1), 0x801D6098:("D_801D6098","UNK_TYPE1","",0x1), - 0x801D6100:("D_801D6100","UNK_TYPE1","",0x1), 0x801D6188:("D_801D6188","UNK_PTR","",0x4), 0x801D618C:("D_801D618C","UNK_PTR","",0x4), 0x801D6190:("D_801D6190","f32","",0x4), 0x801D6194:("D_801D6194","UNK_TYPE4","",0x4), + 0x801D61A0:("D_801D61A0","u8","[96]",0x60), 0x801D6200:("D_801D6200","UNK_TYPE1","",0x1), 0x801D6600:("D_801D6600","UNK_TYPE1","",0x1), 0x801D6608:("D_801D6608","UNK_TYPE1","",0x1), From 9b51336f097cd235144b758b2415706cbec117ce Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 19 Nov 2021 07:45:26 -0800 Subject: [PATCH 5/5] Sub_S Prototypes and approriate header stuff (#408) * Add sub_s prototypes * Rename limbDrawTable to jointTable * Rename UnkActorDraws * Fix warnings * Fix warnings --- include/functions.h | 98 +++++++++---------- include/z64.h | 32 ++++++ include/z64actor.h | 26 ----- include/z64animation.h | 4 +- src/code/z_skelanime.c | 4 +- src/overlays/actors/ovl_En_Dno/z_en_dno.c | 20 ++-- src/overlays/actors/ovl_En_Dno/z_en_dno.h | 2 +- src/overlays/actors/ovl_En_In/z_en_in.c | 32 +++--- src/overlays/actors/ovl_En_In/z_en_in.h | 13 +-- src/overlays/actors/ovl_En_Ot/z_en_ot.c | 16 +-- src/overlays/actors/ovl_En_Ot/z_en_ot.h | 2 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 3 +- src/overlays/actors/ovl_En_Pm/z_en_pm.h | 2 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 61 ++++++------ .../actors/ovl_En_Suttari/z_en_suttari.h | 15 +-- src/overlays/actors/ovl_En_Sw/z_en_sw.c | 4 +- src/overlays/actors/ovl_En_Sw/z_en_sw.h | 7 +- 17 files changed, 166 insertions(+), 175 deletions(-) diff --git a/include/functions.h b/include/functions.h index 49efe79ae..ca04a6c47 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2536,10 +2536,10 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor); void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, Actor* actor, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, Mtx** mtx); void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, Actor* actor); + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor); void SkelAnime_GetFrameData(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst); s16 Animation_GetLength(void* animation); s16 Animation_GetLastFrame(void* animation); @@ -2676,59 +2676,59 @@ u32 func_8013A4C4(s32 flag); s16 func_8013A504(s16 val); s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleError); Actor* func_8013A7C0(GlobalContext* globalCtx, s32 arg1); -// void func_8013A860(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, void* func1, void* func2, void* func3, Actor* actor, Gfx* gfx); +Gfx* func_8013A860(GlobalContext* globalCtx, s32 idx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* func_8013AB00(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, UnkActorDraw unkActorDraw, Actor* actor, Gfx* gfx); s32 func_8013AD6C(GlobalContext* globalCtx); -void func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); -void func_8013AED4(u16* param_1, u16 param_2, u16 param_3); -void func_8013AF00(f32 arg0[], UNK_TYPE arg1, UNK_TYPE arg2); -// void func_8013B010(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013B0C8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8013B350(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -s32 func_8013B6B0(Path* path, UNK_PTR arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32 arg6[], Vec3f* arg7, s16 arg8); +s32 func_8013AD9C(s16 arg0, s16 arg1, Vec3f* arg2, Vec3s* arg3, s32 arg4, s32 arg5); +void func_8013AED4(u16* arg0, u16 arg1, u16 arg2); +void func_8013AF00(f32* arg0, s32 arg1, s32 arg2); +s32 func_8013B010(f32* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, f32* arg6); +void func_8013B0C8(s32 arg0, f32 arg1, s32 arg2, f32* arg3, f32* arg4); +void func_8013B350(Vec3f* arg0, f32* arg1, f32 arg2, s32 arg3, s32 arg4, Vec3s* arg5, f32* arg6); +s32 func_8013B6B0(Path* path, f32* arg1, s32* arg2, s32 arg3, s32 arg4, s32* arg5, f32* arg6, Vec3f* arg7, s32 arg8); void func_8013B878(GlobalContext* globalCtx, Path* path, s32 arg2, Vec3f* arg3); Path* func_8013BB34(GlobalContext* globalCtx, u8 arg1, s32 arg2); -Actor* func_8013BB7C(Actor* actor, GlobalContext* globalCtx, s32 actorCategory, s32 actorId); +Actor* func_8013BB7C(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); s32 func_8013BC6C(SkelAnime* skelAnime, ActorAnimationEntryS* arg1, s32 arg2); -// void func_8013BD40(void); -s32 func_8013BEDC(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32* arg3); -// void func_8013C068(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5); -// void func_8013C624(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -// void func_8013C8B8(void); -void func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 param_3, f32 param_4, s32 param_5, s16 param_6); -// void func_8013CC2C(void); -// void func_8013CD64(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013CF04(void); -// void func_8013D0E0(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); -void func_8013D2E0(Vec3f* arg0, PosRot* arg1, ActorShape* arg2, s16* arg3, s16* arg4, s16* arg5, s16* arg6); -UNK_TYPE func_8013D5E8(s16 arg0, UNK_TYPE arg1, s16 arg2); -Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s32 arg2); -UNK_TYPE func_8013D68C(Path* path, s16 arg1, UNK_PTR arg2); -// void func_8013D720(void); -UNK_TYPE func_8013D768(Actor* actor, UNK_PTR arg1, s16 arg2); -// void func_8013D83C(void); -s32 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); -s8 func_8013D924(s32 arg0, GlobalContext* globalCtx); +s32 func_8013BD40(Actor* actor, Path* path, s32 arg2); +Path* func_8013BEDC(GlobalContext* globalCtx, u8 arg1, u8 arg2, s32* arg3); +s32 func_8013C068(Path* path, s32 arg1, Vec3f* arg2, f32 arg3, s32 arg4); +s32 func_8013C624(Actor* actor, Path* path, s32* arg2, f32* arg3, s32 arg4, s32 arg5); +s32 func_8013C8B8(Path* path, s32 arg1, Vec3f* arg2); +s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s32 arg5); +void func_8013CC2C(s32 arg0, s32 arg1, u8* arg2, s32 arg3); +void func_8013CD64(Vec3f* arg0, Vec3f* arg1, u8* arg2, f32 arg3, u8 arg4, u8* arg5, s8* arg6); +void func_8013CF04(Actor* actor, GraphicsContext** gfxCtxPtr, u8* arg2); +s16 func_8013D0E0(s16* arg0, s16 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5); +s32 func_8013D2E0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3, Vec3s* arg4, Vec3s* arg5, u16* arg6); +s32 func_8013D5E8(s16 arg0, s16 arg1, s16 arg2); +Path* func_8013D648(GlobalContext* globalCtx, s16 arg1, s16 arg2); +s32 func_8013D68C(Path* path, s32 arg1, Vec3f* arg2); +s16 func_8013D720(Vec3f* arg0, Vec3f* arg1, f32* arg2); +s32 func_8013D768(Actor* actor, Vec3f* arg1, s16 arg2); +s16 func_8013D83C(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); +s8 func_8013D8DC(s8 arg0, GlobalContext* globalCtx); +s8 func_8013D924(s16 arg0, GlobalContext* globalCtx); Actor* func_ActorCategoryIterateById(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -void func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, UNK_TYPE arg3); -u8 func_8013DB90(GlobalContext* globalCtx, UNK_PTR arg1, f32 arg2); -// void func_8013DC40(void); -void func_8013DCE0(GlobalContext* globalCtx, Vec3f* param_2, Actor* actor, EnDno_ActorUnkStruct* param_4, Path* param_5, s32 param_6, s32 param_7, s32 param_8, s32 param_9, s32 param_10); -void func_8013DE04(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1, EnDno_ActorUnkFunc arg2, EnDno_ActorUnkFunc arg3, EnDno_ActorUnkFunc arg4, EnDno_ActorUnkFunc arg5); -s32 func_8013DF3C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1); -// void func_8013E054(void); -// void func_8013E07C(void); -s32 func_8013E0A4(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1); +s32 func_8013D9C8(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3); +u8 func_8013DB90(GlobalContext* globalCtx, Vec3f* arg1, f32 arg2); +s32 func_8013DC40(Path* arg0, s32 arg1, s32 arg2, Vec3f* arg3); +void func_8013DCE0(GlobalContext* globalCtx, Vec3f* arg1, Actor* arg2, struct_8013DF3C_arg1* arg3, Path* arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8, u8 arg9); +s32 func_8013DE04(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1, struct_8013DF3C_arg1_unk_func1 arg2, struct_8013DF3C_arg1_unk_func2 arg3, struct_8013DF3C_arg1_unk_func2 arg4, struct_8013DF3C_arg1_unk_func2 arg5); +void func_8013DF3C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +s32 func_8013E054(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +s32 func_8013E07C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); +s32 func_8013E0A4(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1); void func_8013E1C8(SkelAnime* skelAnime, struct_80B8E1A8 animations[], s32 animationIndex, s32* actorAnimationIndex); -s32 func_8013E2D4(Actor* actor, s16 arg1, s32 arg2, s32 arg3); -s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s32 cutsceneArrayLen); -// void func_8013E4B0(void); -s32 func_8013E5CC(Vec3f* param_1, Vec3s* param_2, Vec3f* param_3, Vec3f* param_4, Vec3f* param_5, Vec3f* param_6); -// void func_8013E640(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE2 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013E748(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7); -// void func_8013E7C0(void); -// void func_8013E8F8(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE2 param_6, UNK_TYPE2 param_7); -s32 func_8013E950(Vec3f* param_1, Vec3f* param_2, s16 param_3, Vec3f* param_4, Vec3f* param_5, s16* param_6, s16* param_7, s16* param_8, s16* param_9, u16 param_10, u16 param_11, u16 param_12, u16 param_13); +s32 func_8013E2D4(Actor* actor, s16 arg1, s16 arg2, s32 arg3); +s32 func_8013E3B8(Actor* actor, s16 cutscenes[], s16 len); +void func_8013E4B0(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, Plane* plane); +s32 func_8013E5CC(Vec3f* arg0, Vec3s* arg1, Vec3f* arg2, Vec3f* arg3, Vec3f* arg4, Vec3f* arg5); +Actor* func_8013E640(GlobalContext* globalCtx, Actor* arg1, Actor* actorListStart, u8 actorCategory, s16 actorId, void* arg5, func_8013E640_arg6 arg6); +s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, Vec3s* arg5, func_8013E748_arg6 arg6); +s32 func_8013E7C0(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2); +void func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, s32 arg4, s16 arg5, s16 arg6); +s32 func_8013E950(Vec3f* arg0, Vec3f* arg1, s16 arg2, Vec3f* arg3, Vec3f* arg4, s16* arg5, s16* arg6, s16* arg7, s16* arg8, u16 arg9, u16 arg10, u16 arg11, u16 arg12); // void func_8013EC10(void); void func_8013EC44(f32 arg0, u8 arg1, u8 arg2, u8 arg3); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); diff --git a/include/z64.h b/include/z64.h index 2425f47be..bf430d143 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1567,6 +1567,38 @@ typedef struct { /* 0x8 */ s32 unk8; } struct_80133038_arg2; // size = 0xC +typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); + +typedef s32 (*func_8013E640_arg6)(struct GlobalContext*, Actor*, Actor*, void*); + +struct struct_8013DF3C_arg1; +typedef void (*struct_8013DF3C_arg1_unk_func1)(struct GlobalContext*, struct struct_8013DF3C_arg1*); +typedef s32 (*struct_8013DF3C_arg1_unk_func2)(struct GlobalContext*, struct struct_8013DF3C_arg1*); + +typedef struct struct_8013DF3C_arg1 { + /* 0x00 */ Path* setupPathList; + /* 0x04 */ s32 pathIndex; + /* 0x08 */ Vec3s* points; + /* 0x0C */ s32 count; + /* 0x10 */ s32 unk_10; + /* 0x14 */ s32 unk_14; + /* 0x18 */ s32 unk_18; + /* 0x1C */ u8 unk_1C; + /* 0x1D */ u8 unk_1D; + /* 0x20 */ Vec3f unk_20; + /* 0x2C */ Vec3f unk_2C; + /* 0x38 */ Vec3f unk_38; + /* 0x44 */ Vec3f* unk_44; + /* 0x48 */ Actor* actor; + /* 0x4C */ f32 unk_4C; + /* 0x50 */ f32 unk_50; + /* 0x54 */ Vec3s unk_54; + /* 0x5C */ struct_8013DF3C_arg1_unk_func1 unk_5C; + /* 0x60 */ struct_8013DF3C_arg1_unk_func2 unk_60; + /* 0x64 */ struct_8013DF3C_arg1_unk_func2 unk_64; + /* 0x68 */ struct_8013DF3C_arg1_unk_func2 unk_68; +} struct_8013DF3C_arg1; // size = 0x6C + typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; diff --git a/include/z64actor.h b/include/z64actor.h index 7923e3da9..2b35bec24 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -76,32 +76,6 @@ typedef struct { /* 0x3A */ s16 unk3A; } ActorEnTest20C; // size = 0x3C -struct EnDno_ActorUnkStruct; -typedef s32 (*EnDno_ActorUnkFunc)(struct GlobalContext*, struct EnDno_ActorUnkStruct*); - -typedef struct EnDno_ActorUnkStruct { - /* 0x00 */ Vec3f unk_00; - /* 0x0C */ UNK_TYPE1 unk_0C[0x4]; - /* 0x10 */ s16 unk_10; - /* 0x12 */ UNK_TYPE1 unk_12[0xA]; - /* 0x1C */ u8 unk_1C; - /* 0x1D */ u8 unk_1D; - /* 0x20 */ Vec3f unk_20; - /* 0x2C */ Vec3f unk_2C; - /* 0x38 */ Vec3f unk_38; - /* 0x44 */ UNK_TYPE1 unk_44[0x4]; - /* 0x48 */ struct Actor* unk_48; - /* 0x4C */ f32 unk_4C; - /* 0x50 */ f32 unk_50; - /* 0x54 */ s16 unk_54; - /* 0x56 */ s16 unk_56; - /* 0x58 */ s32 unk_58; - /* 0x5C */ EnDno_ActorUnkFunc unk_5C; - /* 0x60 */ EnDno_ActorUnkFunc unk_60; - /* 0x64 */ EnDno_ActorUnkFunc unk_64; - /* 0x68 */ EnDno_ActorUnkFunc unk_68; -} EnDno_ActorUnkStruct; // size >= 0x6C - typedef struct { /* 0x00 */ s16 id; /* 0x02 */ u8 type; diff --git a/include/z64animation.h b/include/z64animation.h index 2eed33ffd..abd95423b 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -213,7 +213,9 @@ typedef s32 (*OverrideLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbInd typedef void (*PostLimbDrawFlex)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList1, Gfx** dList2, Vec3s* rot, struct Actor* actor); -typedef void (*UnkActorDraw)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* actor); +typedef void (*UnkActorDrawOpa)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* actor); + +typedef void (*UnkActorDraw)(struct GlobalContext* globalCtx, s32 limbIndex, struct Actor* actor, Gfx** gfx); typedef void (*AnimationEntryCallback)(struct GlobalContext*, AnimationEntryData*); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index ad3e93a5f..7f79bb51c 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -474,7 +474,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi } void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor, Mtx** mtx) { StandardLimb* limb; Gfx* newDList; @@ -538,7 +538,7 @@ void func_80134148(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec } void func_801343C0(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDraw unkDraw, + OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, UnkActorDrawOpa unkDraw, Actor* actor) { StandardLimb* rootLimb; s32 pad; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.c b/src/overlays/actors/ovl_En_Dno/z_en_dno.c index a99777eda..3fe0b0299 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -709,8 +709,8 @@ void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { func_8013DCE0(globalCtx, &this->unk_334, &this->actor, &this->unk_340, globalCtx->setupPathList, ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); func_8013DF3C(globalCtx, &this->unk_340); - this->actor.world.rot.y = this->unk_340.unk_56; - this->actor.world.rot.x = this->unk_340.unk_54; + this->actor.world.rot.y = this->unk_340.unk_54.y; + this->actor.world.rot.x = this->unk_340.unk_54.x; Actor_SetSwitchFlag(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; } @@ -721,8 +721,8 @@ void func_80A72CF8(EnDno* this, GlobalContext* globalCtx) { this->actor.floorHeight, this->actor.world.pos.z, 0, 0, 0, 0x201); } -s32 func_80A72D8C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { - Actor* actor = arg1->unk_48; +s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { + Actor* actor = arg1->actor; s32 pad; s32 ret = false; f32 sp38; @@ -748,21 +748,21 @@ s32 func_80A72D8C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { ret = true; } else { sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); - sp2C = ABS(arg1->unk_54 - actor->world.rot.x); + sp2C = ABS(arg1->unk_54.x - actor->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; temp_v0_2 += 0x71C; - sp2C = ABS(arg1->unk_56 - actor->world.rot.y); + sp2C = ABS(arg1->unk_54.y - actor->world.rot.y); - Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54, temp_v0_2); - Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_56, (s32)(sp2C * sp38) + 0x71C); + Math_ScaledStepToS(&actor->world.rot.x, arg1->unk_54.x, temp_v0_2); + Math_ScaledStepToS(&actor->world.rot.y, arg1->unk_54.y, (s32)(sp2C * sp38) + 0x71C); } return ret; } -s32 func_80A72FAC(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { - Actor* actor = arg1->unk_48; +s32 func_80A72FAC(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { + Actor* actor = arg1->actor; EnDno* dno = (EnDno*)actor; f32 sp24 = Math_CosS(-actor->world.rot.x) * actor->speedXZ; f32 sp20 = gFramerateDivisorHalf; diff --git a/src/overlays/actors/ovl_En_Dno/z_en_dno.h b/src/overlays/actors/ovl_En_Dno/z_en_dno.h index 1f7bff87f..ed9ee52c6 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.h +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.h @@ -34,7 +34,7 @@ typedef struct EnDno { /* 0x32C */ s32 unk_32C; /* 0x330 */ UNK_TYPE1 unk_330[0x4]; /* 0x334 */ Vec3f unk_334; - /* 0x340 */ EnDno_ActorUnkStruct unk_340; + /* 0x340 */ struct_8013DF3C_arg1 unk_340; /* 0x3AC */ s16 unk_3AC; /* 0x3AE */ s16 unk_3AE; /* 0x3B0 */ u16 unk_3B0; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index 381dd693f..194780688 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -187,7 +187,7 @@ static ActorAnimationEntryS sAnimations[] = { { &D_0601B3C4, 0.0f, 0, -1, 2, 0 }, { &D_0601B3C4, 1.0f, 0, -1, 0, -4 }, { &D_06019EB4, 1.0f, 0, -1, 2, -4 }, }; -static s16 D_808F6C0C[] = { +static u16 D_808F6C0C[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, }; @@ -215,11 +215,11 @@ s32 func_808F3178(EnIn* this, GlobalContext* globalCtx) { this->unk260 = tmp = func_8013DB90(globalCtx, &this->unk248, -6.0f); if (this->unk260 != 0 && prevUnk260 == 0 && tmp & 0xFF) { - Audio_PlayActorSound2(&this->actor, 0x802); + Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); } this->unk261 = tmp = func_8013DB90(globalCtx, &this->unk254, -6.0f); if (this->unk261 != 0 && prevUnk261 == 0 && tmp & 0xFF) { - Audio_PlayActorSound2(&this->actor, 0x802); + Audio_PlayActorSound2(&this->actor, NA_SE_PL_WALK_CONCRETE); } return 0; } @@ -285,15 +285,15 @@ void func_808F3414(EnIn* this, GlobalContext* globalCtx) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus, &this->actor.shape, &this->unk352, &this->unk358, &this->unk35E, - D_808F6C0C); + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk352, &this->unk358, + &this->unk35E, D_808F6C0C); } else { - Math_SmoothStepToS(&this->unk352, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk354, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk358, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35A, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk35E, 0, 4, 1000, 1); - Math_SmoothStepToS(&this->unk360, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk352.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk352.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk358.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk358.y, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk35E.x, 0, 4, 1000, 1); + Math_SmoothStepToS(&this->unk35E.y, 0, 4, 1000, 1); } func_808F322C(this, 3); func_808F3178(this, globalCtx); @@ -330,7 +330,7 @@ void func_808F3618(EnIn* this, GlobalContext* globalCtx) { void func_808F3690(EnIn* this, GlobalContext* globalCtx) { s16 sp36; - Vec3f sp28; // unsure if Vec3f, but it is probably size 0xC + Vec3f sp28; Math_SmoothStepToF(&this->actor.speedXZ, 1.0f, 0.4f, 1000.0f, 0.0f); sp36 = this->actor.speedXZ * 400.0f; @@ -1566,14 +1566,14 @@ s32 EnIn_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, if (limbIndex == 16) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk35A, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk358, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk358.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk358.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); func_808F6334(this, globalCtx); } if (limbIndex == 9) { - Matrix_RotateY(this->unk360, MTXMODE_APPLY); - Matrix_InsertXRotation_s(this->unk35E, MTXMODE_APPLY); + Matrix_RotateY(this->unk35E.y, MTXMODE_APPLY); + Matrix_InsertXRotation_s(this->unk35E.x, MTXMODE_APPLY); } if (limbIndex == 9 || limbIndex == 10 || limbIndex == 13) { rot->y += (s16)(Math_SinS(this->unk376[limbIndex]) * 200.0f); diff --git a/src/overlays/actors/ovl_En_In/z_en_in.h b/src/overlays/actors/ovl_En_In/z_en_in.h index ca67df431..0a6f4be75 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.h +++ b/src/overlays/actors/ovl_En_In/z_en_in.h @@ -36,15 +36,10 @@ typedef struct EnIn { /* 0x261 */ u8 unk261; /* 0x262 */ Vec3s jointTable[20]; /* 0x2DA */ Vec3s morphTable[20]; - /* 0x352 */ s16 unk352; - /* 0x354 */ s16 unk354; - /* 0x356 */ char unk356[0x2]; - /* 0x358 */ s16 unk358; - /* 0x35A */ s16 unk35A; - /* 0x35C */ char unk35C[0x2]; - /* 0x35E */ s16 unk35E; - /* 0x360 */ s16 unk360; - /* 0x362 */ char unk362[0x14]; + /* 0x352 */ Vec3s unk352; + /* 0x358 */ Vec3s unk358; + /* 0x35E */ Vec3s unk35E; + /* 0x364 */ char unk364[0x12]; /* 0x376 */ s16 unk376[20]; /* 0x39E */ s16 unk39E[20]; /* 0x3C6 */ char unk3C6[0xBC]; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index b47fc8025..5018a6bc2 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -822,9 +822,9 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 func_80B5D37C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { +s32 func_80B5D37C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 pad; - EnOt* temp_s0 = (EnOt*)arg1->unk_48; + EnOt* temp_s0 = (EnOt*)arg1->actor; f32 sp24; f32 sp20; @@ -843,10 +843,10 @@ s32 func_80B5D37C(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { return false; } -s32 func_80B5D470(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { +s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 pad; s32 ret; - Actor* temp_s1 = arg1->unk_48; + Actor* temp_s1 = arg1->actor; Vec3f sp50; Vec3f sp44; f32 temp; @@ -871,14 +871,14 @@ s32 func_80B5D470(GlobalContext* globalCtx, EnDno_ActorUnkStruct* arg1) { ret = true; } else { temp = SQ(temp_s1->speedXZ) / arg1->unk_50; - sp34 = ABS(arg1->unk_54 - temp_s1->world.rot.x); + sp34 = ABS(arg1->unk_54.x - temp_s1->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; - sp34 = ABS(arg1->unk_56 - temp_s1->world.rot.y); + sp34 = ABS(arg1->unk_54.y - temp_s1->world.rot.y); - Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54, 1, sp2C, 0); + Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54.x, 1, sp2C, 0); sp2C = (s32)(sp34 * temp) + 0xAAA; - Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_56, 1, sp2C, 0); + Math_SmoothStepToS(&temp_s1->world.rot.y, arg1->unk_54.y, 1, sp2C, 0); Math_SmoothStepToS(&temp_s1->shape.rot.y, temp_s1->world.rot.y, 2, sp2C, 0); } diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.h b/src/overlays/actors/ovl_En_Ot/z_en_ot.h index f0adb73e4..3a52b48c6 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.h +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.h @@ -36,7 +36,7 @@ typedef struct EnOt { /* 0x01D8 */ Vec3s jointTable[19]; /* 0x024A */ Vec3s morphTable[19]; /* 0x02BC */ s32 animIdx; - /* 0x02C0 */ EnDno_ActorUnkStruct unk_2C0; + /* 0x02C0 */ struct_8013DF3C_arg1 unk_2C0; /* 0x032C */ u16 unk_32C; /* 0x0330 */ Vec3f unk_330; /* 0x033C */ s32 unk_33C; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 55b888a53..62749bf09 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1854,7 +1854,8 @@ void func_80AFAA44(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -void func_80AFABAC(GlobalContext* globalCtx, s32 arg1, EnPm* this, Gfx** gfx) { +void func_80AFABAC(GlobalContext* globalCtx, s32 arg1, Actor* thisx, Gfx** gfx) { + EnPm* this = THIS; s32 phi_v0; s32 phi_v1; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.h b/src/overlays/actors/ovl_En_Pm/z_en_pm.h index 0261221d7..d571f43bd 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -18,7 +18,7 @@ typedef struct EnPm { /* 0x01DC */ ColliderSphere colliderSphere; /* 0x0234 */ Path* unk_234; /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ s32 unk_244; + /* 0x0244 */ f32 unk_244; /* 0x0248 */ s32 unk_248; /* 0x024C */ s32 unk_24C; /* 0x0250 */ s32 unk_250; diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 3a8db7839..fcf86fdcd 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -126,7 +126,7 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0xE), }; -static s16 D_80BAE800[] = { +static u16 D_80BAE800[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, }; @@ -496,15 +496,15 @@ void func_80BAB4F0(EnSuttari* this, GlobalContext* globalCtx) { sp30.x = player->actor.world.pos.x; sp30.y = player->bodyPartsPos[7].y + 3.0f; sp30.z = player->actor.world.pos.z; - func_8013D2E0(&sp30, &this->actor.focus, &this->actor.shape, &this->unk2D6, &this->unk2DC, &this->unk2E2, - D_80BAE800); + func_8013D2E0(&sp30, &this->actor.focus.pos, &this->actor.shape.rot, &this->unk2D6, &this->unk2DC, + &this->unk2E2, D_80BAE800); } else { - Math_SmoothStepToS(&this->unk2D6, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2D8, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DC, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2DE, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E2, 0, 4, 0x3E8, 1); - Math_SmoothStepToS(&this->unk2E4, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2D6.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2D6.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2DC.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2DC.y, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2E2.x, 0, 4, 0x3E8, 1); + Math_SmoothStepToS(&this->unk2E2.y, 0, 4, 0x3E8, 1); } } func_8013D9C8(globalCtx, this->unk2FA, this->unk31A, 16); @@ -530,29 +530,26 @@ s16 func_80BAB698(Path* path, s32 idx, Vec3f* pos, f32* distSQ) { s32 func_80BAB758(EnSuttari* this, Path* path, s32 arg2) { Vec3s* sp5C = Lib_SegmentedToVirtual(path->points); - s32 sp58; + s32 sp58 = path->count; + s32 idx = arg2; + s32 ret = false; f32 sp54; - s32 ret; - s32 pad4C; f32 sp48; f32 sp44; f32 sp40; f32 sp3C; Vec3f sp30; - if (sp5C[arg2].x) {} - sp58 = path->count; - ret = false; - Math_Vec3s_ToVec3f(&sp30, &sp5C[arg2]); - if (arg2 == 0) { + Math_Vec3s_ToVec3f(&sp30, &sp5C[idx]); + if (idx == 0) { sp54 = sp5C[1].x - sp5C[0].x; sp48 = sp5C[1].z - sp5C[0].z; - } else if (arg2 == sp58 - 1) { + } else if (idx == sp58 - 1) { sp54 = sp5C[sp58 - 1].x - sp5C[sp58 - 2].x; sp48 = sp5C[sp58 - 1].z - sp5C[sp58 - 2].z; } else { - sp54 = sp5C[arg2 + 1].x - sp5C[arg2 - 1].x; - sp48 = sp5C[arg2 + 1].z - sp5C[arg2 - 1].z; + sp54 = sp5C[idx + 1].x - sp5C[idx - 1].x; + sp48 = sp5C[idx + 1].z - sp5C[idx - 1].z; } func_8017B7F8(&sp30, RADF_TO_BINANG(func_80086B30(sp54, sp48)), &sp44, &sp40, &sp3C); if (((sp44 * this->actor.world.pos.x) + (sp40 * this->actor.world.pos.z) + sp3C) > 0.0f) { @@ -987,12 +984,12 @@ void func_80BACA14(EnSuttari* this, GlobalContext* globalCtx) { func_80BAB434(this); if (player->transformation == PLAYER_FORM_GORON || player->transformation == PLAYER_FORM_ZORA) { if (this->actor.playerHeightRel < 60.0f && this->actor.xzDistToPlayer < 500.0f) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; this->actionFunc = func_80BACBB0; } } else if ((player->transformation == PLAYER_FORM_HUMAN) && CUR_EQUIP_VALUE_VOID(EQUIP_SWORD) != 0) { if (func_800B84D0(&this->actor, globalCtx)) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; func_80BAAB78(this, globalCtx); this->actionFunc = func_80BADA9C; } else if (this->actor.xzDistToPlayer < 200.0f) { @@ -1007,7 +1004,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); s16 target; - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1037,7 +1034,7 @@ void func_80BACBB0(EnSuttari* this, GlobalContext* globalCtx) { void func_80BACD2C(EnSuttari* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; if (player->transformation == PLAYER_FORM_HUMAN || player->transformation == PLAYER_FORM_DEKU) { this->actionFunc = func_80BACA14; } @@ -1207,7 +1204,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { this->flags2 |= 4; EnSuttari_SetNextEntrance(globalCtx, 0xD670); } else { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 4.0f, 0.2f, 0.5f); Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); func_80BAB374(this, globalCtx); @@ -1307,7 +1304,7 @@ void func_80BADA9C(EnSuttari* this, GlobalContext* globalCtx) { s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIdx].animation); if (this->flags1 & 1) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; func_80BAA9B4(this); } else if ((this->animationIdx == 7) && (curFrame == frameCount)) { this->animationIdx = 1; @@ -1383,14 +1380,14 @@ void func_80BADE14(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[1] == -0x63) { this->actor.speedXZ = 0.0f; } else { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor); } void func_80BADE8C(EnSuttari* this, GlobalContext* globalCtx) { - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0xBB8, 0); if (func_800B84D0(&this->actor, globalCtx)) { this->actor.flags &= ~0x10000; @@ -1407,7 +1404,7 @@ void func_80BADF3C(EnSuttari* this, GlobalContext* globalCtx) { if (this->unk1F4[0] == -0x63) { Actor_MarkForDeath(&this->actor); } - this->unk3F2 = this->unk2DE; + this->unk3F2 = this->unk2DC.y; if (DECR(this->unk3F6) == 0) { Math_ApproachF(&this->actor.speedXZ, 6.0f, 0.2f, 0.5f); } @@ -1478,13 +1475,13 @@ s32 EnSuttari_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dL if (!(this->flags1 & 4)) { Matrix_InsertTranslation(1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); Matrix_InsertXRotation_s(this->unk3F2, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2DC, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk2DC.x, MTXMODE_APPLY); Matrix_InsertTranslation(-1500.0f, 0.0f, 0.0f, MTXMODE_APPLY); } } if (limbIndex == 8) { - Matrix_InsertXRotation_s(-this->unk2E4, MTXMODE_APPLY); - Matrix_InsertZRotation_s(-this->unk2E2, MTXMODE_APPLY); + Matrix_InsertXRotation_s(-this->unk2E2.y, MTXMODE_APPLY); + Matrix_InsertZRotation_s(-this->unk2E2.x, MTXMODE_APPLY); } if (limbIndex == 8 || limbIndex == 9 || limbIndex == 0xC) { rot->y += (s16)(Math_SinS(this->unk2FA[limbIndex]) * 200.0f); diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h index 93423fe77..9c62be60f 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -27,15 +27,10 @@ typedef struct EnSuttari { /* 0x1FC */ UNK_TYPE1 unk_1FC[0x1A]; /* 0x216 */ Vec3s jointTable[16]; /* 0x276 */ Vec3s morphTable[16]; - /* 0x2D6 */ s16 unk2D6; - /* 0x2D8 */ s16 unk2D8; - /* 0x2DA */ UNK_TYPE1 unk_2DA[0x2]; - /* 0x2DC */ s16 unk2DC; - /* 0x2DE */ s16 unk2DE; - /* 0x2E0 */ UNK_TYPE1 unk_2E0[0x2]; - /* 0x2E2 */ s16 unk2E2; - /* 0x2E4 */ s16 unk2E4; - /* 0x2E6 */ UNK_TYPE1 unk_2E6[0x14]; + /* 0x2D6 */ Vec3s unk2D6; + /* 0x2DC */ Vec3s unk2DC; + /* 0x2E2 */ Vec3s unk2E2; + /* 0x2E8 */ UNK_TYPE1 unk_2E8[0x12]; /* 0x2FA */ s16 unk2FA[16]; /* 0x31A */ s16 unk31A[16]; /* 0x33A */ UNK_TYPE1 unk_33A[0xB6]; @@ -46,7 +41,7 @@ typedef struct EnSuttari { /* 0x3F8 */ Vec3f unk3F8; /* 0x404 */ Path* unk404; /* 0x408 */ Vec3f unk408; - /* 0x414 */ s32 unk414; + /* 0x414 */ f32 unk414; /* 0x418 */ s32 unk418; /* 0x41C */ s32 unk41C; /* 0x420 */ s32 unk420; diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 9cc79183e..31f4d1922 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -934,7 +934,7 @@ void func_808DAA60(EnSw* this, GlobalContext* globalCtx) { Vec3f sp34; f32 temp_f16; - sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->unk_04); + sp44 = (Vec3s*)Lib_SegmentedToVirtual(this->unk_1E4->points); sp40 = 0; if (DECR(this->unk_454) == 0) { @@ -1009,7 +1009,7 @@ void func_808DACF4(EnSw* this, GlobalContext* globalCtx) { if ((temp_f6 != 0) && (temp_f6 < (s32)sp4C)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_374); this->unk_4A0 += this->unk_49C; - if ((this->unk_4A0 >= this->unk_1E4->unk_00) || (this->unk_4A0 < 0)) { + if ((this->unk_4A0 >= this->unk_1E4->count) || (this->unk_4A0 < 0)) { this->unk_49C = -this->unk_49C; this->unk_4A0 += this->unk_49C * 2; } diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.h b/src/overlays/actors/ovl_En_Sw/z_en_sw.h index b64b6d02a..975e4e36d 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.h +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.h @@ -11,17 +11,12 @@ typedef void (*EnSwActionFunc)(struct EnSw*, GlobalContext*); #define ENSW_GET_3FC(thisx) (((thisx)->params & 0x3FC) >> 2) #define ENSW_GET_FF00(thisx) ((((thisx)->params & 0xFF00) >> 8) & 0xFF) -typedef struct { - u8 unk_00; - s32 unk_04; -} EnSwUnkStruct; - typedef struct EnSw { /* 0x0000 */ Actor actor; /* 0x0144 */ SkelAnime skelAnime; /* 0x0188 */ EnSwActionFunc actionFunc; /* 0x018C */ ColliderSphere collider; - /* 0x01E4 */ EnSwUnkStruct* unk_1E4; + /* 0x01E4 */ Path* unk_1E4; /* 0x01E8 */ Vec3s jointTable[30]; /* 0x029C */ Vec3s morphTable[30]; /* 0x0350 */ Vec3f unk_350;