diff --git a/include/functions.h b/include/functions.h index 4b08dca2bf..4da5b59e45 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2481,12 +2481,12 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); s32 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 SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath); void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex); s32 SubS_StartActorCutscene(Actor* actor, s16 nextCutscene, s16 curCutscene, s32 type); s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes); diff --git a/include/z64.h b/include/z64.h index 3e8219da7b..c8e423cfba 100644 --- a/include/z64.h +++ b/include/z64.h @@ -39,6 +39,7 @@ #include "z64save.h" #include "z64scene.h" #include "z64skin.h" +#include "z64subs.h" #include "z64transition.h" #include "regs.h" @@ -1369,45 +1370,6 @@ typedef struct { /* 0x8 */ s32 unk8; // game script pointer? } struct_80133038_arg2; // size = 0xC - -typedef enum { - /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, - /* 1 */ SUBS_CUTSCENE_NORMAL, - /* 2 */ SUBS_CUTSCENE_SET_FLAG -} SubSCutsceneType; - -typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); - -typedef s32 (*VerifyActor)(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/z64subs.h b/include/z64subs.h new file mode 100644 index 0000000000..7ef51c3482 --- /dev/null +++ b/include/z64subs.h @@ -0,0 +1,60 @@ +#ifndef Z64SUBS_H +#define Z64SUBS_H + +#include "z64actor.h" +#include "z64scene.h" + +typedef enum { + /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, + /* 1 */ SUBS_CUTSCENE_NORMAL, + /* 2 */ SUBS_CUTSCENE_SET_FLAG +} SubSCutsceneType; + +typedef s32 (*func_8013E748_arg6)(struct GlobalContext*, Actor*, Vec3s*); + +typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); + +#define ACTOR_PATHING_RETURN_TO_START (1 << 0) +#define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) +#define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) +#define ACTOR_PATHING_REACHED_POINT_PERMANENT (1 << 4) +#define ACTOR_PATHING_REACHED_END_PERMANENT (1 << 5) +#define ACTOR_PATHING_REACHED_POINT_TEMPORARY (1 << 6) +#define ACTOR_PATHING_REACHED_END_TEMPORARY (1 << 7) + +#define ACTOR_PATHING_REACHED_TEMPORARY \ + (ACTOR_PATHING_REACHED_POINT_TEMPORARY | ACTOR_PATHING_REACHED_END_TEMPORARY) +#define ACTOR_PATHING_REACHED_POINT \ + (ACTOR_PATHING_REACHED_POINT_PERMANENT | ACTOR_PATHING_REACHED_POINT_TEMPORARY) +#define ACTOR_PATHING_REACHED_END \ + (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) + +struct ActorPathing; +typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); +typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); + +typedef struct ActorPathing { + /* 0x00 */ Path* setupPathList; + /* 0x04 */ s32 pathIndex; + /* 0x08 */ Vec3s* points; + /* 0x0C */ s32 count; + /* 0x10 */ s32 curPointIndex; + /* 0x14 */ s32 begPointIndex; + /* 0x18 */ s32 endPointIndex; + /* 0x1C */ u8 flags; + /* 0x1D */ u8 prevFlags; + /* 0x20 */ Vec3f curPoint; + /* 0x2C */ Vec3f pointOffset; + /* 0x38 */ Vec3f prevPoint; + /* 0x44 */ Vec3f* worldPos; + /* 0x48 */ Actor* actor; + /* 0x4C */ f32 distSqToCurPointXZ; + /* 0x50 */ f32 distSqToCurPoint; + /* 0x54 */ Vec3s rotToCurPoint; + /* 0x5C */ ActorPathingComputeFunc computePointInfoFunc; + /* 0x60 */ ActorPathingUpdateFunc updateActorInfoFunc; // Return true if should setNextPoint, false if the actor should move forward + /* 0x64 */ ActorPathingUpdateFunc moveFunc; // Return true if should compute and update again + /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again +} ActorPathing; // size = 0x6C + +#endif diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index f0ed1f5163..8ad36c891b 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #define ANIM_INTERP 1 diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 52a5b07dac..630b164630 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -307,17 +307,136 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li #pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCCC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DCE0.s") +void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, + Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, + u8 flags) { + Path* path; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DE04.s") + actorPath->setupPathList = globalCtx->setupPathList; + actorPath->pathIndex = pathIndex; + path = &paths[pathIndex]; + actorPath->points = Lib_SegmentedToVirtual(path->points); + actorPath->count = path->count; + actorPath->begPointIndex = begPointIndex; + if (endPointIndex == 0) { + actorPath->endPointIndex = actorPath->count - 1; + } else if (endPointIndex > 0) { + actorPath->endPointIndex = endPointIndex; + } else { + //! @bug: endPointIndex is negative, subtraction causes result to be past the end + actorPath->endPointIndex = (actorPath->count - endPointIndex) - 1; + } + actorPath->curPointIndex = curPointIndex; + actorPath->curPoint.x = actorPath->points[0].x; + actorPath->curPoint.y = actorPath->points[0].y; + actorPath->curPoint.z = actorPath->points[0].z; + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + actorPath->worldPos = worldPos; + actorPath->actor = actor; + actorPath->flags = flags; + actorPath->prevFlags = flags; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013DF3C.s") +s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath, + ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, + ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) { + s32 shouldSetNextPoint; + s32 reupdate; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E054.s") + actorPath->computePointInfoFunc = computePointInfoFunc; + actorPath->updateActorInfoFunc = updateActorInfoFunc; + actorPath->moveFunc = moveFunc; + actorPath->setNextPointFunc = setNextPointFunc; + actorPath->flags &= ~ACTOR_PATHING_REACHED_TEMPORARY; + reupdate = false; + if (actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS) { + if (!(actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS)) { + actorPath->curPointIndex--; + } + } else if (actorPath->prevFlags & ACTOR_PATHING_MOVE_BACKWARDS) { + actorPath->curPointIndex++; + } + do { + shouldSetNextPoint = false; + if (actorPath->computePointInfoFunc != NULL) { + actorPath->computePointInfoFunc(globalCtx, actorPath); + } + if (actorPath->updateActorInfoFunc != NULL) { + shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath); + } + if (shouldSetNextPoint) { + if (actorPath->setNextPointFunc != NULL) { + reupdate = actorPath->setNextPointFunc(globalCtx, actorPath); + } + } else if (actorPath->moveFunc != NULL) { + reupdate = actorPath->moveFunc(globalCtx, actorPath); + } + } while (reupdate); + actorPath->prevFlags = actorPath->flags; + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E07C.s") +void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Vec3f diff; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013E0A4.s") + actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x; + actorPath->curPoint.y = actorPath->points[actorPath->curPointIndex].y + actorPath->pointOffset.y; + actorPath->curPoint.z = actorPath->points[actorPath->curPointIndex].z + actorPath->pointOffset.z; + diff.x = actorPath->curPoint.x - actorPath->worldPos->x; + diff.y = actorPath->curPoint.y - actorPath->worldPos->y; + diff.z = actorPath->curPoint.z - actorPath->worldPos->z; + actorPath->distSqToCurPointXZ = Math3D_XZLengthSquared(diff.x, diff.z); + actorPath->distSqToCurPoint = Math3D_LengthSquared(&diff); + actorPath->rotToCurPoint.y = Math_FAtan2F(diff.z, diff.x); + actorPath->rotToCurPoint.x = Math_FAtan2F(sqrtf(actorPath->distSqToCurPointXZ), -diff.y); + actorPath->rotToCurPoint.z = 0; +} + +s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithGravity(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor_MoveWithoutGravityReverse(actorPath->actor); + return false; +} + +s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) { + s32 reupdate = true; + + Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint); + if (!(actorPath->flags & ACTOR_PATHING_MOVE_BACKWARDS)) { + if (actorPath->curPointIndex >= actorPath->endPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->begPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags |= ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex++; + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + } else { + if (actorPath->begPointIndex >= actorPath->curPointIndex) { + if (actorPath->flags & ACTOR_PATHING_RETURN_TO_START) { + actorPath->curPointIndex = actorPath->endPointIndex; + } else if (actorPath->flags & ACTOR_PATHING_SWITCH_DIRECTION) { + actorPath->flags &= ~ACTOR_PATHING_MOVE_BACKWARDS; + } else { + reupdate = false; + } + actorPath->flags |= ACTOR_PATHING_REACHED_END; + } else { + actorPath->curPointIndex--; + } + } + actorPath->flags |= ACTOR_PATHING_REACHED_POINT; + return reupdate; +} void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* animations, s32 nextIndex, s32* curIndex) { diff --git a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c index 4306d5582d..1139f6ef47 100644 --- a/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c +++ b/src/overlays/actors/ovl_Bg_Hakugin_Post/z_bg_hakugin_post.c @@ -4,6 +4,7 @@ * Description: Snowhead Temple Central Pillar */ +#include "prevent_bss_reordering.h" #include "z_bg_hakugin_post.h" #include "objects/object_hakugin_obj/object_hakugin_obj.h" 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 d51ec8a4d8..f8ff8877de 100644 --- a/src/overlays/actors/ovl_En_Dno/z_en_dno.c +++ b/src/overlays/actors/ovl_En_Dno/z_en_dno.c @@ -687,12 +687,12 @@ void func_80A72C04(EnDno* this, GlobalContext* globalCtx) { this->actor.flags |= ACTOR_FLAG_8000000; this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_8); Math_Vec3f_Copy(&this->unk_334, &this->actor.world.pos); - 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); + SubS_ActorPathing_Init(globalCtx, &this->unk_334, &this->actor, &this->actorPath, globalCtx->setupPathList, + ENDNO_GET_7F(&this->actor), 1, 0, 1, 0); + SubS_ActorPathing_ComputePointInfo(globalCtx, &this->actorPath); - this->actor.world.rot.y = this->unk_340.unk_54.y; - this->actor.world.rot.x = this->unk_340.unk_54.x; + this->actor.world.rot.y = this->actorPath.rotToCurPoint.y; + this->actor.world.rot.x = this->actorPath.rotToCurPoint.x; Flags_SetSwitch(globalCtx, ENDNO_GET_3F80(&this->actor)); this->actionFunc = func_80A730A0; @@ -704,8 +704,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, struct_8013DF3C_arg1* arg1) { - Actor* actor = arg1->actor; +s32 EnDno_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; s32 pad; s32 ret = false; f32 sp38; @@ -713,52 +713,52 @@ s32 func_80A72D8C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 temp_v0_2; s32 sp2C; - actor->gravity = 0.0f; - temp_v0 = actor->yawTowardsPlayer - actor->world.rot.y; + thisx->gravity = 0.0f; + temp_v0 = thisx->yawTowardsPlayer - thisx->world.rot.y; if ((temp_v0 <= 0x4000) && (temp_v0 >= -0x4000)) { - Math_SmoothStepToF(&actor->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 15.0f, 0.8f, 1.0f, 0.01f); } else { - if (actor->xzDistToPlayer <= 80.0f) { - Math_SmoothStepToF(&actor->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); - } else if (actor->xzDistToPlayer <= 360.0f) { - Math_SmoothStepToF(&actor->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); + if (thisx->xzDistToPlayer <= 80.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 8.0f, 0.5f, 0.5f, 0.01f); + } else if (thisx->xzDistToPlayer <= 360.0f) { + Math_SmoothStepToF(&thisx->speedXZ, 7.0f, 0.5f, 0.5f, 0.01f); } else { - Math_SmoothStepToF(&actor->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); + Math_SmoothStepToF(&thisx->speedXZ, 3.5f, 0.5f, 0.5f, 0.01f); } } - if (arg1->unk_50 < SQ(actor->speedXZ)) { + if (actorPath->distSqToCurPoint < SQ(thisx->speedXZ)) { ret = true; } else { - sp38 = actor->speedXZ / sqrtf(arg1->unk_4C); - sp2C = ABS(arg1->unk_54.x - actor->world.rot.x); + sp38 = thisx->speedXZ / sqrtf(actorPath->distSqToCurPointXZ); + sp2C = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); temp_v0_2 = sp2C; temp_v0_2 *= sp38; temp_v0_2 += 0x71C; - sp2C = ABS(arg1->unk_54.y - actor->world.rot.y); + sp2C = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - 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); + Math_ScaledStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, temp_v0_2); + Math_ScaledStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, (s32)(sp2C * sp38) + 0x71C); } return ret; } -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; +s32 EnDno_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnDno* this = (EnDno*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; f32 sp20 = gFramerateDivisorHalf; - actor->velocity.x = Math_SinS(actor->world.rot.y) * sp24; - actor->velocity.y = Math_SinS(-actor->world.rot.x) * actor->speedXZ; - actor->velocity.z = Math_CosS(actor->world.rot.y) * sp24; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - dno->unk_334.x += (dno->actor.velocity.x * sp20) + dno->actor.colChkInfo.displacement.x; - dno->unk_334.y += (dno->actor.velocity.y * sp20) + dno->actor.colChkInfo.displacement.y; - dno->unk_334.z += (dno->actor.velocity.z * sp20) + dno->actor.colChkInfo.displacement.z; + this->unk_334.x += (this->actor.velocity.x * sp20) + this->actor.colChkInfo.displacement.x; + this->unk_334.y += (this->actor.velocity.y * sp20) + this->actor.colChkInfo.displacement.y; + this->unk_334.z += (this->actor.velocity.z * sp20) + this->actor.colChkInfo.displacement.z; - return 0; + return false; } void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { @@ -786,11 +786,13 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { } } - func_8013DE04(globalCtx, &this->unk_340, func_8013DF3C, func_80A72D8C, func_80A72FAC, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnDno_ActorPathing_UpdateActorInfo, EnDno_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); this->unk_45C += 6553; - this->unk_340.unk_2C.x = 0.0f; - this->unk_340.unk_2C.y = 0.0f; - this->unk_340.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_334); temp_f10 = (4.0f + Math_SinS(this->unk_3AE)) * Math_SinS(this->unk_3AC); this->actor.world.pos.y += temp_f10; @@ -799,8 +801,8 @@ void func_80A730A0(EnDno* this, GlobalContext* globalCtx) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; func_80A715DC(this, globalCtx); func_800B9010(&this->actor, NA_SE_EV_BUTLER_FRY - SFX_FLAG); - if (this->unk_340.unk_1C & 0x20) { - Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_340.unk_20); + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_PERMANENT) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actorPath.curPoint); this->actor.speedXZ = 0.0f; this->actor.velocity.x = 0.0f; this->actor.velocity.y = 0.0f; 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 350e0c0049..dcffee6c9d 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 */ struct_8013DF3C_arg1 unk_340; + /* 0x340 */ ActorPathing actorPath; /* 0x3AC */ s16 unk_3AC; /* 0x3AE */ s16 unk_3AE; /* 0x3B0 */ u16 unk_3B0; 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 6eb555ef15..f81a2f40d9 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -817,31 +817,27 @@ void func_80B5D160(EnOt* this, GlobalContext* globalCtx) { } } -s32 func_80B5D37C(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { - s32 pad; - EnOt* temp_s0 = (EnOt*)arg1->actor; - f32 sp24; - f32 sp20; +s32 EnOt_ActorPathing_Move(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + EnOt* this = (EnOt*)thisx; + f32 sp24 = Math_CosS(-thisx->world.rot.x) * thisx->speedXZ; + f32 sp20 = gFramerateDivisorHalf; - sp24 = Math_CosS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - sp20 = gFramerateDivisorHalf; + thisx->velocity.x = Math_SinS(thisx->world.rot.y) * sp24; + thisx->velocity.y = Math_SinS(-thisx->world.rot.x) * thisx->speedXZ; + thisx->velocity.z = Math_CosS(thisx->world.rot.y) * sp24; - temp_s0->actor.velocity.x = Math_SinS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->actor.velocity.y = Math_SinS(temp_s0->actor.world.rot.x * -1) * temp_s0->actor.speedXZ; - do { - temp_s0->actor.velocity.z = Math_CosS(temp_s0->actor.world.rot.y) * sp24; - temp_s0->unk_330.x += (temp_s0->actor.velocity.x * sp20) + temp_s0->actor.colChkInfo.displacement.x; - temp_s0->unk_330.y += (temp_s0->actor.velocity.y * sp20) + temp_s0->actor.colChkInfo.displacement.y; - } while (0); - temp_s0->unk_330.z += (temp_s0->actor.velocity.z * sp20) + temp_s0->actor.colChkInfo.displacement.z; + this->unk_330.x += (thisx->velocity.x * sp20) + thisx->colChkInfo.displacement.x; + this->unk_330.y += (thisx->velocity.y * sp20) + thisx->colChkInfo.displacement.y; + this->unk_330.z += (thisx->velocity.z * sp20) + thisx->colChkInfo.displacement.z; return false; } -s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { +s32 EnOt_ActorPathing_UpdateActorInfo(GlobalContext* globalCtx, ActorPathing* actorPath) { + Actor* thisx = actorPath->actor; + s32 ret = false; s32 pad; - s32 ret; - Actor* temp_s1 = arg1->actor; Vec3f sp50; Vec3f sp44; f32 temp; @@ -849,32 +845,31 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { s32 sp30; s32 sp34; - ret = false; - temp_s1->gravity = 0.0f; - Math_SmoothStepToF(&temp_s1->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); + thisx->gravity = 0.0f; + Math_SmoothStepToF(&thisx->speedXZ, 10.0f, 0.8f, 2.0f, 0.0f); - sp50.x = arg1->unk_20.x - temp_s1->world.pos.x; - sp50.y = arg1->unk_20.y - temp_s1->world.pos.y; - sp50.z = arg1->unk_20.z - temp_s1->world.pos.z; + sp50.x = actorPath->curPoint.x - thisx->world.pos.x; + sp50.y = actorPath->curPoint.y - thisx->world.pos.y; + sp50.z = actorPath->curPoint.z - thisx->world.pos.z; - sp44.x = arg1->unk_20.x - arg1->unk_38.x; - sp44.y = arg1->unk_20.y - arg1->unk_38.y; - sp44.z = arg1->unk_20.z - arg1->unk_38.z; + sp44.x = actorPath->curPoint.x - actorPath->prevPoint.x; + sp44.y = actorPath->curPoint.y - actorPath->prevPoint.y; + sp44.z = actorPath->curPoint.z - actorPath->prevPoint.z; temp = Math3D_Parallel(&sp50, &sp44); - if ((arg1->unk_4C < SQ(temp_s1->speedXZ)) || (temp <= 0.0f)) { + if ((actorPath->distSqToCurPointXZ < SQ(thisx->speedXZ)) || (temp <= 0.0f)) { ret = true; } else { - temp = SQ(temp_s1->speedXZ) / arg1->unk_50; - sp34 = ABS(arg1->unk_54.x - temp_s1->world.rot.x); + temp = SQ(thisx->speedXZ) / actorPath->distSqToCurPoint; + sp34 = ABS(actorPath->rotToCurPoint.x - thisx->world.rot.x); sp2C = (s32)(sp34 * temp) + 0xAAA; - sp34 = ABS(arg1->unk_54.y - temp_s1->world.rot.y); + sp34 = ABS(actorPath->rotToCurPoint.y - thisx->world.rot.y); - Math_SmoothStepToS(&temp_s1->world.rot.x, arg1->unk_54.x, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->world.rot.x, actorPath->rotToCurPoint.x, 1, sp2C, 0); sp2C = (s32)(sp34 * temp) + 0xAAA; - 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); + Math_SmoothStepToS(&thisx->world.rot.y, actorPath->rotToCurPoint.y, 1, sp2C, 0); + Math_SmoothStepToS(&thisx->shape.rot.y, thisx->world.rot.y, 2, sp2C, 0); } return ret; @@ -883,12 +878,12 @@ s32 func_80B5D470(GlobalContext* globalCtx, struct_8013DF3C_arg1* arg1) { void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { func_80B5B2E0(globalCtx, &this->actor.world.pos, this->unk_346, &this->unk_348, &this->unk_340); Math_Vec3f_Copy(&this->unk_330, &this->actor.world.pos); - func_8013DCE0(globalCtx, &this->unk_330, &this->actor, &this->unk_2C0, globalCtx->setupPathList, this->unk_346, 0, - 0, this->unk_340, 0); + SubS_ActorPathing_Init(globalCtx, &this->unk_330, &this->actor, &this->actorPath, globalCtx->setupPathList, + this->unk_346, 0, 0, this->unk_340, 0); this->unk_32C = 0; - this->unk_2C0.unk_2C.x = 0.0f; - this->unk_2C0.unk_2C.y = 0.0f; - this->unk_2C0.unk_2C.z = 0.0f; + this->actorPath.pointOffset.x = 0.0f; + this->actorPath.pointOffset.y = 0.0f; + this->actorPath.pointOffset.z = 0.0f; this->actor.gravity = 0.0f; this->actor.speedXZ = 0.0f; SubS_ChangeAnimationBySpeedInfo(&this->skelAnime, sAnimations, 1, &this->animIdx); @@ -900,16 +895,18 @@ void func_80B5D648(EnOt* this, GlobalContext* globalCtx) { void func_80B5D750(EnOt* this, GlobalContext* globalCtx) { if (!(this->unk_32C & 1) && !(this->unk_32C & 2)) { - func_8013DE04(globalCtx, &this->unk_2C0, func_8013DF3C, func_80B5D470, func_80B5D37C, func_8013E0A4); + SubS_ActorPathing_Update(globalCtx, &this->actorPath, SubS_ActorPathing_ComputePointInfo, + EnOt_ActorPathing_UpdateActorInfo, EnOt_ActorPathing_Move, + SubS_ActorPathing_SetNextPoint); } Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_330); - if (this->unk_2C0.unk_1C & 0x40) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_POINT_TEMPORARY) { this->unk_32C |= 2; } - if (this->unk_2C0.unk_1C & 0x80) { + if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) { this->unk_32C |= 1; } 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 3a52b48c6c..902cbecd7c 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 */ struct_8013DF3C_arg1 unk_2C0; + /* 0x02C0 */ ActorPathing actorPath; /* 0x032C */ u16 unk_32C; /* 0x0330 */ Vec3f unk_330; /* 0x033C */ s32 unk_33C; diff --git a/tools/actorfixer.py b/tools/actorfixer.py index b6aba86c0d..3ba0615f9d 100755 --- a/tools/actorfixer.py +++ b/tools/actorfixer.py @@ -447,6 +447,12 @@ animdict = { "func_8013D924": "SubS_GetObjectIndex", "func_8013D5E8": "SubS_AngleDiffLessEqual", "func_8012F22C": "Inventory_GetSkullTokenCount", + "func_8013DCE0": "SubS_ActorPathing_Init", + "func_8013DE04": "SubS_ActorPathing_Update", + "func_8013DF3C": "SubS_ActorPathing_ComputePointInfo", + "func_8013E054": "SubS_ActorPathing_MoveWithGravity", + "func_8013E07C": "SubS_ActorPathing_MoveWithoutGravityReverse", + "func_8013E0A4": "SubS_ActorPathing_SetNextPoint", # Struct members "skelAnime.unk03": "skelAnime.taper", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index bca55a7467..26cff71a91 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2694,12 +2694,12 @@ 0x8013DB90:("func_8013DB90",), 0x8013DC40:("func_8013DC40",), 0x8013DCCC:("func_8013DCCC",), - 0x8013DCE0:("func_8013DCE0",), - 0x8013DE04:("func_8013DE04",), - 0x8013DF3C:("func_8013DF3C",), - 0x8013E054:("func_8013E054",), - 0x8013E07C:("func_8013E07C",), - 0x8013E0A4:("func_8013E0A4",), + 0x8013DCE0:("SubS_ActorPathing_Init",), + 0x8013DE04:("SubS_ActorPathing_Update",), + 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), + 0x8013E054:("SubS_ActorPathing_MoveWithGravity",), + 0x8013E07C:("SubS_ActorPathing_MoveWithoutGravityReverse",), + 0x8013E0A4:("SubS_ActorPathing_SetNextPoint",), 0x8013E1C8:("SubS_ChangeAnimationBySpeedInfo",), 0x8013E2D4:("SubS_StartActorCutscene",), 0x8013E3B8:("SubS_FillCutscenesList",), @@ -11005,8 +11005,8 @@ 0x80A72BA4:("func_80A72BA4",), 0x80A72C04:("func_80A72C04",), 0x80A72CF8:("func_80A72CF8",), - 0x80A72D8C:("func_80A72D8C",), - 0x80A72FAC:("func_80A72FAC",), + 0x80A72D8C:("EnDno_ActorPathing_UpdateActorInfo",), + 0x80A72FAC:("EnDno_ActorPathing_Move",), 0x80A730A0:("func_80A730A0",), 0x80A73244:("func_80A73244",), 0x80A732C8:("func_80A732C8",), @@ -14116,8 +14116,8 @@ 0x80B5CEC8:("func_80B5CEC8",), 0x80B5D114:("func_80B5D114",), 0x80B5D160:("func_80B5D160",), - 0x80B5D37C:("func_80B5D37C",), - 0x80B5D470:("func_80B5D470",), + 0x80B5D37C:("EnOt_ActorPathing_Move",), + 0x80B5D470:("EnOt_ActorPathing_UpdateActorInfo",), 0x80B5D648:("func_80B5D648",), 0x80B5D750:("func_80B5D750",), 0x80B5D8AC:("EnOt_Update",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index e312fa619b..13c89fa37f 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2208,12 +2208,12 @@ asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0 asm/non_matchings/code/z_sub_s/func_8013DB90.s,func_8013DB90,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/func_8013DC40.s,func_8013DC40,0x8013DC40,0x23 asm/non_matchings/code/z_sub_s/func_8013DCCC.s,func_8013DCCC,0x8013DCCC,0x5 -asm/non_matchings/code/z_sub_s/func_8013DCE0.s,func_8013DCE0,0x8013DCE0,0x49 -asm/non_matchings/code/z_sub_s/func_8013DE04.s,func_8013DE04,0x8013DE04,0x4E -asm/non_matchings/code/z_sub_s/func_8013DF3C.s,func_8013DF3C,0x8013DF3C,0x46 -asm/non_matchings/code/z_sub_s/func_8013E054.s,func_8013E054,0x8013E054,0xA -asm/non_matchings/code/z_sub_s/func_8013E07C.s,func_8013E07C,0x8013E07C,0xA -asm/non_matchings/code/z_sub_s/func_8013E0A4.s,func_8013E0A4,0x8013E0A4,0x49 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Init.s,SubS_ActorPathing_Init,0x8013DCE0,0x49 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_Update.s,SubS_ActorPathing_Update,0x8013DE04,0x4E +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_ComputePointInfo.s,SubS_ActorPathing_ComputePointInfo,0x8013DF3C,0x46 +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithGravity.s,SubS_ActorPathing_MoveWithGravity,0x8013E054,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_MoveWithoutGravityReverse.s,SubS_ActorPathing_MoveWithoutGravityReverse,0x8013E07C,0xA +asm/non_matchings/code/z_sub_s/SubS_ActorPathing_SetNextPoint.s,SubS_ActorPathing_SetNextPoint,0x8013E0A4,0x49 asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationBySpeedInfo.s,SubS_ChangeAnimationBySpeedInfo,0x8013E1C8,0x43 asm/non_matchings/code/z_sub_s/SubS_StartActorCutscene.s,SubS_StartActorCutscene,0x8013E2D4,0x39 asm/non_matchings/code/z_sub_s/SubS_FillCutscenesList.s,SubS_FillCutscenesList,0x8013E3B8,0x3E