From d318b1f2854e98e2510812dd09e7c84b14f17622 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Sun, 19 Jun 2022 16:49:20 -0700 Subject: [PATCH] SubS Time Paths (Finale) (#823) * Merge in sub_s_models * Update subs DL names * Unused Weight pathing * Function headers for weightpathing * TimePathing WIP * Timepathing, still unsure about unk184 * Move subs functions from functions.h to z64subs.h * Add fake comment * Some cleanup and renames * Renames/cleanup of actors that use timepath * Cleanup * More cleanup * Rename unk stuff * Merge in upstream/master * TimeElapsed -> elapsedTime * Fix * Final cleanup * Fix waypoint comments * Review pt. 1 * Add clarifying comment to SubS_TimePathing_FillWeightArray * format.sh * Fix order comments * weightArray -> knots * Review pt 1 * Review pt 2 * Update src/code/z_sub_s.c Co-authored-by: EllipticEllipsis * Update src/code/z_sub_s.c Co-authored-by: EllipticEllipsis Co-authored-by: Maide <34639600+Kelebek1@users.noreply.github.com> Co-authored-by: Tom Overton Co-authored-by: EllipticEllipsis --- assets/xml/code/sub_s.xml | 4 +- include/functions.h | 56 +-- include/z64subs.h | 115 ++++- src/code/z_sub_s.c | 470 +++++++++++++++++- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 68 +-- .../actors/ovl_Bg_Ingate/z_bg_ingate.h | 16 +- src/overlays/actors/ovl_En_Baba/z_en_baba.c | 66 +-- src/overlays/actors/ovl_En_Baba/z_en_baba.h | 16 +- src/overlays/actors/ovl_En_Gm/z_en_gm.c | 107 ++-- src/overlays/actors/ovl_En_Gm/z_en_gm.h | 16 +- src/overlays/actors/ovl_En_Ig/z_en_ig.c | 110 ++-- src/overlays/actors/ovl_En_Ig/z_en_ig.h | 16 +- src/overlays/actors/ovl_En_Pm/z_en_pm.c | 115 ++--- src/overlays/actors/ovl_En_Pm/z_en_pm.h | 16 +- .../actors/ovl_En_Suttari/z_en_suttari.c | 160 +++--- .../actors/ovl_En_Suttari/z_en_suttari.h | 17 +- src/overlays/actors/ovl_En_Tk/z_en_tk.c | 105 ++-- src/overlays/actors/ovl_En_Tk/z_en_tk.h | 16 +- tools/disasm/functions.txt | 18 +- tools/disasm/variables.txt | 7 +- tools/sizes/code_functions.csv | 18 +- 21 files changed, 1004 insertions(+), 528 deletions(-) diff --git a/assets/xml/code/sub_s.xml b/assets/xml/code/sub_s.xml index 03329f0c59..76db7e32c0 100644 --- a/assets/xml/code/sub_s.xml +++ b/assets/xml/code/sub_s.xml @@ -1,6 +1,6 @@ - - + + diff --git a/include/functions.h b/include/functions.h index 7e01d5afe5..372f4d5fc3 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2392,61 +2392,7 @@ void func_8013A46C(s32 flag); 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); -struct EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag); -Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); -Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); -s32 SubS_InCsMode(GlobalContext* globalCtx); -s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); -void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); -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* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max); -Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId); -s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); -s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); -Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); -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 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); -s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); -void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); -void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); -void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex); -s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); -s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); -s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); -Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max); -s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); -s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); -s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); -s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); -s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx); -s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx); -Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); -s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); -s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); -s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); -u8 SubS_GetPathCount(Path* paths, s32 index); -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); -void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); -s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); -Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); -s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); -s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data); -s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); -s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); + // void func_8013EC10(void); void func_8013EC44(f32 a, u8 b, u8 c, u8 d); void func_8013ECE0(f32 xyzDistToPlayerSq, u8 arg1, u8 arg2, u8 arg3); diff --git a/include/z64subs.h b/include/z64subs.h index 3b13d2adda..b39842195a 100644 --- a/include/z64subs.h +++ b/include/z64subs.h @@ -8,6 +8,8 @@ extern Vec3f gOneVec3f; +#define SUBS_TIME_PATHING_ORDER 3 + typedef enum { /* 0 */ SUBS_CUTSCENE_SET_UNK_LINK_FIELDS, /* 1 */ SUBS_CUTSCENE_NORMAL, @@ -23,6 +25,20 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define SUBS_SHADOW_TEX_HEIGHT 64 #define SUBS_SHADOW_TEX_SIZE ((s32)sizeof(u8[SUBS_SHADOW_TEX_HEIGHT][SUBS_SHADOW_TEX_WIDTH])) +typedef struct TurnOptions { + /* 0x0 */ u16 rotMax; // binary angles + /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 + /* 0x4 */ u16 rotStepMin; // degrees + /* 0x6 */ u16 rotStepMax; // degrees +} TurnOptions; // size = 0x8 + +typedef struct TurnOptionsSet { + /* 0x00 */ TurnOptions headRotX; + /* 0x08 */ TurnOptions headRotY; + /* 0x10 */ TurnOptions torsoRotX; + /* 0x18 */ TurnOptions torsoRotY; +} TurnOptionsSet; // size = 0x20 + #define ACTOR_PATHING_RETURN_TO_START (1 << 0) #define ACTOR_PATHING_SWITCH_DIRECTION (1 << 1) #define ACTOR_PATHING_MOVE_BACKWARDS (1 << 3) @@ -38,20 +54,6 @@ typedef s32 (*VerifyActor)(struct GlobalContext*, Actor*, Actor*, void*); #define ACTOR_PATHING_REACHED_END \ (ACTOR_PATHING_REACHED_END_PERMANENT | ACTOR_PATHING_REACHED_END_TEMPORARY) -typedef struct TurnOptions { - /* 0x0 */ u16 rotMax; // binary angles - /* 0x2 */ u16 slowness; // larger for slower rotation, cannot be 0 - /* 0x4 */ u16 rotStepMin; // degrees - /* 0x6 */ u16 rotStepMax; // degrees -} TurnOptions; // size = 0x8 - -typedef struct TurnOptionsSet { - /* 0x00 */ TurnOptions headRotX; - /* 0x08 */ TurnOptions headRotY; - /* 0x10 */ TurnOptions torsoRotX; - /* 0x18 */ TurnOptions torsoRotY; -} TurnOptionsSet; // size = 0x20 - struct ActorPathing; typedef void (*ActorPathingComputeFunc)(struct GlobalContext*, struct ActorPathing*); typedef s32 (*ActorPathingUpdateFunc)(struct GlobalContext*, struct ActorPathing*); @@ -80,4 +82,89 @@ typedef struct ActorPathing { /* 0x68 */ ActorPathingUpdateFunc setNextPointFunc; // Return true if should compute and update again } ActorPathing; // size = 0x6C +struct EnDoor* SubS_FindDoor(struct GlobalContext* globalCtx, s32 switchFlag); + +Gfx* SubS_DrawTransformFlexLimb(struct GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx); +Gfx* SubS_DrawTransformFlex(struct GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx); + +s32 SubS_InCsMode(struct GlobalContext* globalCtx); + +s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot); + +void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits); + +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints); +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, s32 order, f32 knots[]); +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]); +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], f32 knots[]); +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, f32 knots[], Vec3f* targetPos, s32 timeSpeed); +void SubS_TimePathing_ComputeInitialY(struct GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos); + +Path* SubS_GetAdditionalPath(struct GlobalContext* globalCtx, u8 pathIndex, s32 max); + +Actor* SubS_FindNearestActor(Actor* actor, struct GlobalContext* globalCtx, u8 actorCategory, s16 actorId); + +s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animations, s32 index); + +s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex); + +Path* SubS_GetDayDependentPath(struct GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex); + +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction); +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart); + +s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst); + +s32 func_8013C964(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type); + +void SubS_FillShadowTex(s32 startCol, s32 startRow, u8* tex, s32 size); +void SubS_GenShadowTex(Vec3f bodyPartsPos[], Vec3f* worldPos, u8* tex, f32 tween, u8 bodyPartsNum, u8 sizes[], s8 parentBodyParts[]); +void SubS_DrawShadowTex(Actor* actor, struct GameState* gameState, u8* tex); + +s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f32 stepMin, f32 stepMax); +s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options); + +s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB); + +Path* SubS_GetPathByIndex(struct GlobalContext* globalCtx, s16 pathIndex, s16 max); +s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst); +s16 SubS_GetDistSqAndOrientPoints(Vec3f* vecA, Vec3f* vecB, f32* distSq); +s32 SubS_MoveActorToPoint(Actor* actor, Vec3f* point, s16 rotStep); +s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIdx, Vec3f* pos, f32* distSq); + +s8 SubS_IsObjectLoaded(s8 index, struct GlobalContext* globalCtx); +s8 SubS_GetObjectIndex(s16 id, struct GlobalContext* globalCtx); + +Actor* SubS_FindActor(struct GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId); + +s32 SubS_FillLimbRotTables(struct GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs); + +s32 SubS_IsFloorAbove(struct GlobalContext* globalCtx, Vec3f* pos, f32 distAbove); + +s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst); +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex); + +void SubS_ActorPathing_Init(struct GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags); +s32 SubS_ActorPathing_Update(struct GlobalContext* globalCtx, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc); +void SubS_ActorPathing_ComputePointInfo(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithGravity(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_MoveWithoutGravityReverse(struct GlobalContext* globalCtx, ActorPathing* actorPath); +s32 SubS_ActorPathing_SetNextPoint(struct 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); + +void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane); +s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePointA, Vec3f* linePointB, Vec3f* intersect); + +Actor* SubS_FindActorCustom(struct GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId, void* verifyData, VerifyActor verifyActor); + +s32 func_8013E748(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data, func_8013E748_VerifyFunc verifyFunc); +s32 SubS_ActorAndPlayerFaceEachOther(struct GlobalContext* globalCtx, Actor* actor, void* data); +s32 func_8013E8F8(Actor* actor, struct GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol, s16 actorYawTol); + +s32 SubS_TurnToPointStep(Vec3f* worldPos, Vec3f* focusPos, s16 shapeYRot, Vec3f* yawTarget, Vec3f* pitchTarget, s16* headZRotStep, s16* headXRotStep, s16* torsoZRotStep, s16* torsoXRotStep, u16 headZRotStepMax, u16 headXRotStepMax, u16 torsoZRotStepMax, u16 torsoXRotStepMax); + #endif diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index 3e5443bc6c..d5b4f33b24 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -178,8 +178,7 @@ s32 SubS_InCsMode(GlobalContext* globalCtx) { * @param[in] stepRot boolean, step towards newRot instead of setting directly * @param[in] overrideRot boolean, override newRot with the specified input. * - * Note: - * If overrideRot is true, the rotation will automatically step instead of setting directly + * @note if overrideRot is true, the rotation will automatically step instead of setting directly */ s32 SubS_UpdateLimb(s16 newRotZ, s16 newRotY, Vec3f* pos, Vec3s* rot, s32 stepRot, s32 overrideRot) { Vec3f newPos; @@ -214,17 +213,273 @@ void SubS_UpdateFlags(u16* flags, u16 setBits, u16 unsetBits) { *flags = (*flags & ~unsetBits) | setBits; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013AF00.s") +/** + * Fills the knot array to be used with time paths + * + * The default knot array just pads with `order` duplicate knots of the first knot at the front and of the last knot + * at the end. + * + * @param[out] knots an array of values that are used to compute the progress and the individual weights + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] numPoints the number of points to fill, generally the path count + order + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_FillKnots(f32 knots[], s32 order, s32 numPoints) { + s32 i; + f32 val = 0.0f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B010.s") + for (i = 0; i < numPoints; i++) { + if ((i >= order) && (i < (numPoints - order + 1))) { + val += 1.0f; + } + knots[i] = val; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B0C8.s") +typedef enum { + /* 0 */ SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR, + /* 1 */ SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH, + /* 2 */ SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END +} SUBS_TIME_PATHING_PROGRESS_STATUS; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B350.s") +/** + * Computes the progress to be used with time paths + * + * @param[out] progress the progress along the path, used to compute the weights + * @param[in] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in] pathCount the path count + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation + * @param[in] knots see SubS_TimePathing_FillKnots() + * + * @return see SUBS_TIME_PATHING_PROGRESS_STATUS + */ +s32 SubS_TimePathing_ComputeProgress(f32* progress, s32 elapsedTime, s32 waypointTime, s32 totalTime, s32 pathCount, + s32 order, f32 knots[]) { + s32 i; + s32 j; + s32 k; + f32 waypointTimeInv; // The fraction of a waypoint a single unit of time contains -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B6B0.s") + *progress = 0.0f; + if ((waypointTime <= 0) || (elapsedTime < 0)) { + return SUBS_TIME_PATHING_PROGRESS_STATUS_ERROR; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013B878.s") + // When using the knots from SubS_TimePathing_FillKnots() these nested loops seem to simplify to + // *progress = (f32)elapsedTime / (f32)waypointTime; + waypointTimeInv = 1.0f / waypointTime; + k = 0; + for (i = order - 1; i < pathCount; i++) { + for (j = 0; j < waypointTime; j++) { + if (k == elapsedTime) { + break; + } + *progress += (knots[i + 1] - knots[i]) * waypointTimeInv; + k++; + } + } + + return (elapsedTime == totalTime) ? SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END + : SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH; +} + +/** + * Computes the interpolation weights to be used with time paths + * + * Seems to use some kind of B-Spline interpolation algorithm + * + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] waypoint the current waypoint + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] weights how much to weight each point considered + */ +void SubS_TimePathing_ComputeWeights(s32 order, f32 progress, s32 waypoint, f32 knots[], f32 weights[]) { + f32 weightsTemp[10][11]; + s32 i; + s32 j; + s32 k; + + for (i = 0; i < order; i++) { + for (j = 0; j < order + 1; j++) { + weightsTemp[i][j] = 0.0f; + } + } + + weightsTemp[0][order - 1] = 1.0f; + + for (i = 1; i < order; i++) { + for (j = waypoint - i, k = (order - 1) - i; j <= waypoint; j++, k++) { + if (knots[j + i] != knots[j]) { + weightsTemp[i][k] = ((progress - knots[j]) / (knots[j + i] - knots[j])) * weightsTemp[i - 1][k]; + } else { + weightsTemp[i][k] = 0.0f; + } + + if (knots[j + i + 1] != knots[j + 1]) { + weightsTemp[i][k] += + ((knots[j + i + 1] - progress) / (knots[j + i + 1] - knots[j + 1])) * weightsTemp[i - 1][k + 1]; + } + } + } + for (j = 0; j < order; j++) { + weights[j] = weightsTemp[order - 1][j]; + } +} + +/** + * Computes the X and Z component of the position to move to in time based paths + * + * @param[out] x computed x position + * @param[out] z computed z position + * @param[in] progress see SubS_TimePathing_ComputeProgress() + * @param[in] order the order of the interpolation i.e. the number of points in the interpolation, max is 10 + * @param[in] waypoint the current waypoint + * @param[in] points the path's points + * @param[in] knots see SubS_TimePathing_FillKnots() + */ +void SubS_TimePathing_ComputeTargetPosXZ(f32* x, f32* z, f32 progress, s32 order, s32 waypoint, Vec3s points[], + f32 knots[]) { + f32 xPos; + f32 zPos; + f32 weights[11]; + f32 weightedX; + f32 weightedZ; + f32 weightedTotal; + s32 i; + + SubS_TimePathing_ComputeWeights(order, progress, waypoint, knots, weights); + weightedTotal = 0.0f; + weightedZ = 0.0f; + weightedX = 0.0f; + + for (i = 0; i < order; i++) { + xPos = points[waypoint - order + i + 1].x; + zPos = points[waypoint - order + i + 1].z; + + weightedX += weights[i] * xPos; + weightedZ += weights[i] * zPos; + weightedTotal += weights[i]; + } + *x = weightedX / weightedTotal; + *z = weightedZ / weightedTotal; +} + +/** + * Updates a time based path that an actor follows by: + * - Computing the X and Z components of the next point to move to + * - Updating the waypoint + * - Updating the time + * + * @param[in] path + * @param[out] progress see SubS_TimePathing_ComputeProgress() + * @param[in,out] elapsedTime how much time has passed + * @param[in] waypointTime how much time per each waypoint + * @param[in] totalTime how much time the path should take to travel + * @param[in,out] waypoint the current waypoint, this and the previous two points will be used to compute the targetPos + * @param[in] knots see SubS_TimePathing_FillKnots() + * @param[out] targetPos the computed position to move to + * @param[in] timeSpeed how fast time moves + * + * @return s32 returns true when the end has been reached. + * + * @note This system/function makes a couple of assumptions about the order used: + * 1. the order is assumed to be 3, see SUBS_TIME_PATHING_ORDER + * 2. even if SUBS_TIME_PATHING_ORDER is updated, the order can only be a max of 10 + */ +s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 waypointTime, s32 totalTime, s32* waypoint, + f32 knots[], Vec3f* targetPos, s32 timeSpeed) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + s32 state; + f32 endX; + f32 endZ; + s32 reachedEnd = false; + + if (*waypoint >= path->count) { + state = SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END; + } else { + state = SubS_TimePathing_ComputeProgress(progress, *elapsedTime, waypointTime, totalTime, path->count, + SUBS_TIME_PATHING_ORDER, knots); + } + + switch (state) { + case SUBS_TIME_PATHING_PROGRESS_STATUS_STILL_ON_PATH: + reachedEnd = false; + SubS_TimePathing_ComputeTargetPosXZ(&targetPos->x, &targetPos->z, *progress, SUBS_TIME_PATHING_ORDER, + *waypoint, points, knots); + break; + case SUBS_TIME_PATHING_PROGRESS_STATUS_SHOULD_REACH_END: + endX = points[path->count - 1].x; + endZ = points[path->count - 1].z; + targetPos->x = endX * 1; + targetPos->z = endZ * 1; + reachedEnd = true; + break; + } + + *elapsedTime += timeSpeed; + if (*elapsedTime >= totalTime) { + *elapsedTime = totalTime; + } else if (*elapsedTime < 0) { + *elapsedTime = 0; + } + *waypoint = (*elapsedTime / waypointTime) + (SUBS_TIME_PATHING_ORDER - 1); + + return reachedEnd; +} + +/** + * Computes the initial Y component of a time based path + * + * @param[in] globalCtx + * @param[in] path + * @param[in] waypoint the current waypoint, this and the previous two points will be used to compute the target pos + * @param[out] targetPos the computed position to move to, only the Y component has meaning + * + * @note Same note as SubS_TimePathing_Update() + */ +void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos) { + Vec3s* points = Lib_SegmentedToVirtual(path->points); + Vec3f posA; + Vec3f posB; + Vec3f posResult; + s32 i = waypoint - (SUBS_TIME_PATHING_ORDER - 1); + s16 max; + s16 min; + s32 isSetup; + CollisionPoly* outPoly = NULL; + s32 bgId = 0; + + max = 0; + min = 0; + isSetup = false; + for (; i <= waypoint; i++) { + if (isSetup) { + if (max < points[i].y) { + max = points[i].y; + } + if (points[i].y < min) { + min = points[i].y; + } + } else { + max = min = points[i].y; + } + isSetup = true; + } + max += 30; + min -= 30; + posA = *targetPos; + posB = *targetPos; + posA.y = max; + posB.y = min; + if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true, + &bgId)) { + targetPos->y = posResult.y; + } +} Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) { Path* path; @@ -362,9 +617,189 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s return path; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C068.s") +/** + * Computes the point to move toward using a weight based algorithm that considers 4 points along the path + * + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to compute the point + * @param point the point computed + * @param progress the main weight value used to compute the weights for the points considered + * @param direction the direciton along the path to move, 1 for forwards, anything else for backwards + * + * @note only computes X and Z components of the point + */ +s32 SubS_WeightPathing_ComputePoint(Path* path, s32 waypoint, Vec3f* point, f32 progress, s32 direction) { + s32 i; + f32 weight0; + f32 weight1; + f32 weight2; + f32 weight3; + s32 lastPoint; + s32 secondLastPoint; + s32 secondPoint; + s32 firstPoint; + f32 xPoints[4]; + f32 zPoints[4]; + f32 oneMinusProgress; + f32 squared; + f32 cubed; + Vec3s* points; + s32 count = path->count; + s32 pointIndex; + s32 tmp; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_sub_s/func_8013C624.s") + if (path == NULL) { + return false; + } + if (direction == 1) { + if (waypoint <= 2) { + pointIndex = 2; + } else { + pointIndex = (waypoint == 3) ? 3 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex--) { + if (pointIndex <= 0) { + pointIndex = 0; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = count - 1; + secondLastPoint = count - 2; + secondPoint = 3; + firstPoint = 2; + } else { + if (waypoint >= count - 3) { + pointIndex = count - 3; + } else { + tmp = waypoint + 4; + pointIndex = (count == tmp) ? count - 4 : waypoint; + } + for (i = 0; i < 4; i++, pointIndex++) { + if (pointIndex >= path->count) { + pointIndex = path->count - 1; + } + points = Lib_SegmentedToVirtual(path->points); + points = &points[pointIndex]; + xPoints[i] = points->x; + zPoints[i] = points->z; + } + lastPoint = 0; + secondLastPoint = 1; + secondPoint = count - 4; + firstPoint = count - 3; + } + if (waypoint == lastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress; + weight1 = (1.75f * cubed) - (4.5f * squared) + (3.0f * progress); + weight2 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight3 = (1.0f / 6.0f) * cubed; + } else if (waypoint == secondLastPoint) { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = progress * squared; + weight0 = oneMinusProgress * oneMinusProgress * oneMinusProgress * ((void)0, 0.25f); //! FAKE: + weight1 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * progress) + (7.0f / 12.0f); + weight2 = (-0.5f * cubed) + (0.5f * squared) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed * (1.0f / 6.0f); + } else if (waypoint == secondPoint) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = (-0.5f * cubed) + (0.5f * squared) + (0.5f * oneMinusProgress) + (1.0f / 6.0f); + weight2 = ((7.0f / 12.0f) * cubed) - (1.25f * squared) + (0.25f * oneMinusProgress) + (7.0f / 12.0f); + weight3 = progress * progress * progress * 0.25f; + } else if (((direction == 1) && (firstPoint >= waypoint)) || ((direction != 1) && (waypoint >= firstPoint))) { + oneMinusProgress = 1.0f - progress; + squared = oneMinusProgress * oneMinusProgress; + cubed = oneMinusProgress * squared; + weight0 = (1.0f / 6.0f) * cubed; + weight1 = ((-11.0f / 12.0f) * cubed) + (1.5f * squared); + weight2 = (1.75f * cubed) - (4.5f * squared) + (3.0f * oneMinusProgress); + weight3 = progress * progress * progress; + } else { + oneMinusProgress = 1.0f - progress; + squared = progress * progress; + cubed = squared * progress; + weight0 = oneMinusProgress * oneMinusProgress; + weight0 = oneMinusProgress * weight0 / 6.0f; + weight1 = (cubed * 0.5f) - squared + (2.0f / 3.0f); + weight2 = (cubed / -2.0f) + (squared * 0.5f) + (progress * 0.5f) + (1.0f / 6.0f); + weight3 = cubed / 6.0f; + } + point->x = (weight0 * xPoints[0]) + (weight1 * xPoints[1]) + (weight2 * xPoints[2]) + (weight3 * xPoints[3]); + point->z = (weight0 * zPoints[0]) + (weight1 * zPoints[1]) + (weight2 * zPoints[2]) + (weight3 * zPoints[3]); + + return true; +} + +// WeightPathing System is completely unused +/** + * Moves an actor based on a weight based algorithm that takes into account 4 points along the path + * + * @param actor + * @param path + * @param waypoint the current waypoint, this and the previous three points will be used to move forward + * @param progress the progress towards a given waypoint, used to compute the weights + * @param direction the direction along the path to move, 1 for forwards, anything else for backwards + * @param returnStart boolean, true if the actor should wrap back to start when reaching the end + * + * @return s32 true if actor reached the end of the path in this iteration, false otherwise + */ +s32 SubS_WeightPathing_Move(Actor* actor, Path* path, s32* waypoint, f32* progress, s32 direction, s32 returnStart) { + Vec3f worldPos = actor->world.pos; + Vec3f velocity = actor->velocity; + Vec3f point; + f32 dist; + + if (((direction != 1) && (*waypoint >= (path->count - 2))) || ((direction == 1) && (*waypoint < 2))) { + return false; + } + while (true) { + if (!SubS_WeightPathing_ComputePoint(path, *waypoint, &point, *progress, direction) || + ((s32)(actor->speedXZ * 10000.0f) == 0)) { + return false; + } + dist = Math_Vec3f_DistXZ(&actor->world.pos, &point); + actor->world.rot.y = Math_Vec3f_Yaw(&actor->world.pos, &point); + Actor_MoveWithGravity(actor); + if (Math_Vec3f_DistXZ(&actor->world.pos, &point) < dist) { + break; + } + *progress += 0.1f; + if (*progress >= 1.1f) { + if (direction != 1) { + (*waypoint)++; + if (*waypoint >= (path->count - 2)) { + if (returnStart) { + *waypoint = 0; + } else { + return true; + } + } + } else { + (*waypoint)--; + if (*waypoint < 2) { + if (returnStart) { + *waypoint = path->count - 2; + } else { + return true; + } + } + } + *progress = 0.0f; + } + actor->world.pos = worldPos; + actor->velocity = velocity; + } + return false; +} s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) { Vec3s* point; @@ -557,10 +992,10 @@ void SubS_DrawShadowTex(Actor* actor, GameState* gameState, u8* tex) { Matrix_Translate(actor->world.pos.x, 0.0f, actor->world.pos.z, MTXMODE_NEW); Matrix_Scale(0.6f, 1.0f, 0.6f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gShadowDL); + gSPDisplayList(POLY_OPA_DISP++, gShadowMaterialDL); gDPLoadTextureBlock(POLY_OPA_DISP++, tex, G_IM_FMT_I, G_IM_SIZ_8b, SUBS_SHADOW_TEX_WIDTH, SUBS_SHADOW_TEX_HEIGHT, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD); - gSPDisplayList(POLY_OPA_DISP++, gShadowVtxDL); + gSPDisplayList(POLY_OPA_DISP++, gShadowModelDL); CLOSE_DISPS(gfxCtx); } @@ -617,9 +1052,7 @@ s16 SubS_ComputeTurnToPointRot(s16* rot, s16 rotMax, s16 target, f32 slowness, f * @param[in,out] turnTarget the intermediate target step that headRot and torsoRot step towards * @param[in,out] headRot the computed head rotation * @param[in,out] torsoRot the computed torso rotation - * @param[in] options various options to adjust how the actor turns, see `SubS_ComputeTurnToPointRot and - * TurnOptions/TurnOptionsSet` - * + * @param[in] options various options to adjust how the actor turns, see SubS_ComputeTurnToPointRot() */ s32 SubS_TurnToPoint(Vec3f* point, Vec3f* focusPos, Vec3s* shapeRot, Vec3s* turnTarget, Vec3s* headRot, Vec3s* torsoRot, TurnOptionsSet* options) { @@ -781,8 +1214,8 @@ s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f return false; } -u8 SubS_GetPathCount(Path* paths, s32 index) { - Path* path = &paths[index]; +u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex) { + Path* path = &paths[pathIndex]; return path->count; } @@ -1004,8 +1437,7 @@ s32 SubS_FillCutscenesList(Actor* actor, s16 cutscenes[], s16 numCutscenes) { * @param[in] rot the angles to rotate with, uses just the x and y components * @param[out] plane the computed plane * - * Notes: - * The unit input vector is expected to already be normalized (only uses are with the z unit vector) + * @note the unit input vector is expected to already be normalized (only uses are with the z unit vector) * */ void SubS_ConstructPlane(Vec3f* point, Vec3f* unitVec, Vec3s* rot, Plane* plane) { diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index 11936a9d29..1cda3dc8c4 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -73,45 +73,47 @@ void func_80953B40(BgIngate* this) { s32 temp; if (!(gSaveContext.eventInf[3] & 0x20)) { - this->unk180 = 0xFA0; - this->unk168 = 4; + this->timePathTotalTime = 4 * 1000; + this->timePathTimeSpeed = 4; } else { - this->unk180 = 0x7D0; - this->unk168 = 1; + this->timePathTotalTime = 1 * 2000; + this->timePathTimeSpeed = 1; } - temp = this->unk164->count - 2; - this->unk184 = this->unk180 / temp; - this->unk188 = 2; - this->unk18C = 0; + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; + this->timePathWaypoint = SUBS_TIME_PATHING_ORDER - 1; + this->timePathElapsedTime = 0; this->unk160 &= ~0x1; this->unk160 &= ~0x2; } s32 func_80953BEC(BgIngate* this) { - f32 sp74[265]; + f32 knots[265]; Vec3f sp68; Vec3f sp5C; - Vec3f unkVec; + Vec3f timePathTargetPos; s16 yaw; - func_8013AF00(sp74, 3, this->unk164->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk160 & 1)) { - unkVec = gZeroVec3f; - func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &unkVec, this->unk168); + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); this->unk160 |= 1; } else { - unkVec = this->unk170; + timePathTargetPos = this->timePathTargetPos; } - this->dyna.actor.world.pos.x = unkVec.x; - this->dyna.actor.world.pos.z = unkVec.z; - this->unk170 = gZeroVec3f; - if (func_8013B6B0(this->unk164, &this->unk17C, &this->unk18C, this->unk184, this->unk180, &this->unk188, sp74, - &this->unk170, this->unk168) != 0) { + this->dyna.actor.world.pos.x = timePathTargetPos.x; + this->dyna.actor.world.pos.z = timePathTargetPos.z; + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk160 |= 2; } else { sp68 = this->dyna.actor.world.pos; - sp5C = this->unk170; + sp5C = this->timePathTargetPos; yaw = Math_Vec3f_Yaw(&sp68, &sp5C); this->dyna.actor.world.rot.y = yaw; this->dyna.actor.shape.rot.y = yaw; @@ -164,7 +166,7 @@ void func_80953F14(BgIngate* this, GlobalContext* globalCtx) { player->actor.focus.rot.y = player->actor.shape.rot.y; this->unk160 |= 0x10; func_80953DA8(this, globalCtx); - if (this->unk164 != NULL) { + if (this->timePath != NULL) { func_80953B40(this); } this->unk16E = -1; @@ -188,7 +190,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { if (this->unk160 & 2) { - if (this->unk164->unk1 != 0xFF) { + if (this->timePath->unk1 != 0xFF) { func_80953E38(globalCtx); func_800B7298(globalCtx, &this->dyna.actor, 7); this->dyna.actor.textId = 0x9E4; @@ -205,7 +207,7 @@ void func_80953F9C(BgIngate* this, GlobalContext* globalCtx) { } this->actionFunc = func_809542A0; } - } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->unk164 != NULL)) { + } else if ((ActorCutscene_GetCurrentIndex() == -1) && (this->timePath != NULL)) { Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_CRUISER - SFX_FLAG); func_80953BEC(this); } @@ -259,9 +261,9 @@ void func_809542A0(BgIngate* this, GlobalContext* globalCtx) { void func_80954340(BgIngate* this, GlobalContext* globalCtx) { if (!DECR(this->unk16A)) { - if (this->unk164 != NULL) { + if (this->timePath != NULL) { func_800B7298(globalCtx, &this->dyna.actor, 6); - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; func_80953F14(this, globalCtx); func_800FE484(); } @@ -285,8 +287,8 @@ void func_809543D4(BgIngate* this, GlobalContext* globalCtx) { func_800FE498(); func_8019F208(); } else { - if (this->unk164 != NULL) { - this->unk164 = &globalCtx->setupPathList[this->unk164->unk1]; + if (this->timePath != NULL) { + this->timePath = &globalCtx->setupPathList[this->timePath->unk1]; } func_80953F14(this, globalCtx); gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -327,7 +329,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->unk160 |= 0x8; this->unk160 |= 0x10; Actor_SetScale(&this->dyna.actor, 1.0f); - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); this->dyna.actor.room = -1; if (gSaveContext.save.weekEventReg[20] & 2) { gSaveContext.save.weekEventReg[90] &= (u8)~0x40; @@ -349,9 +351,9 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->actionFunc = func_80953F8C; } } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); - if (this->unk164 != NULL) { - sp38 = Lib_SegmentedToVirtual(this->unk164->points); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), phi_a2); + if (this->timePath != NULL) { + sp38 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp2C, &sp38[0]); Math_Vec3s_ToVec3f(&sp20, &sp38[1]); this->dyna.actor.world.rot.y = Math_Vec3f_Yaw(&sp2C, &sp20); @@ -360,7 +362,7 @@ void BgIngate_Init(Actor* thisx, GlobalContext* globalCtx2) { this->dyna.actor.world.pos.y = -15.0f; this->dyna.actor.world.pos.z = sp2C.z; } - this->unk164 = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); + this->timePath = SubS_GetAdditionalPath(globalCtx, BGINGATE_GET_FF(&this->dyna.actor), 0); } else { Actor_MarkForDeath(&this->dyna.actor); } diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h index 08d062e6c0..81b7bec9ba 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.h @@ -13,17 +13,17 @@ typedef struct BgIngate { /* 0x000 */ DynaPolyActor dyna; /* 0x15C */ BgIngateActionFunc actionFunc; /* 0x160 */ u16 unk160; - /* 0x164 */ Path* unk164; - /* 0x168 */ s16 unk168; + /* 0x164 */ Path* timePath; + /* 0x168 */ s16 timePathTimeSpeed; /* 0x16A */ s16 unk16A; /* 0x16C */ s16 unk16C; /* 0x16E */ s16 unk16E; - /* 0x170 */ Vec3f unk170; - /* 0x17C */ f32 unk17C; - /* 0x180 */ s32 unk180; - /* 0x184 */ s32 unk184; - /* 0x188 */ s32 unk188; - /* 0x18C */ s32 unk18C; + /* 0x170 */ Vec3f timePathTargetPos; + /* 0x17C */ f32 timePathProgress; + /* 0x180 */ s32 timePathTotalTime; + /* 0x184 */ s32 timePathWaypointTime; + /* 0x188 */ s32 timePathWaypoint; + /* 0x18C */ s32 timePathElapsedTime; } BgIngate; // size = 0x190 extern const ActorInit Bg_Ingate_InitVars; diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index e6dd15a32c..c10741fdf6 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -319,35 +319,35 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { } s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { - u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); + u16 sp26 = SCHEDULE_TIME_NOW; u16 temp; u8 sp23 = ENBABA_GET_3F00(&this->actor); if (D_80BAA4A8[arg2->result] >= 0) { - this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); } - if (this->unk_410 == NULL) { + if (this->timePath == NULL) { return false; } - if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { + if ((this->unk_434 != 0) && (this->timePathTimeSpeed >= 0)) { temp = sp26; } else { temp = arg2->time0; } if (arg2->time1 < temp) { - this->unk_424 = (temp - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (temp - arg2->time1) + 0xFFFF; } else { - this->unk_424 = arg2->time1 - temp; + this->timePathTotalTime = arg2->time1 - temp; } - this->unk_430 = sp26 - temp; - temp = this->unk_410->count - 2; - this->unk_428 = this->unk_424 / temp; + this->timePathElapsedTime = sp26 - temp; + temp = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / temp; this->unk_438 = 0; - this->unk_42C = (this->unk_430 / this->unk_428) + 2; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_43C = 0; return true; } @@ -372,52 +372,54 @@ s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) } s32 func_80BA9160(EnBaba* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_410->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (this->unk_438 == 0) { - sp58 = gZeroVec3f; + timePathTargetPos = gZeroVec3f; - func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &sp58, this->unk_436); - func_8013B878(globalCtx, this->unk_410, this->unk_42C, &sp58); - this->actor.world.pos.y = sp58.y; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_438 = 1; } else { - sp58 = this->unk_414; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_430; - sp50 = this->unk_42C; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_414 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_410, &this->unk_420, &this->unk_430, this->unk_428, this->unk_424, &this->unk_42C, sp7C, - &this->unk_414, this->unk_436)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_43C = 1; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_414; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_430 = sp54; - this->unk_42C = sp50; - this->unk_414 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return false; @@ -598,7 +600,7 @@ void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_436 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || ((this->unk_434 != sp20.result) && !func_80BA9110(this, globalCtx, &sp20))) { diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.h b/src/overlays/actors/ovl_En_Baba/z_en_baba.h index 6a21168b66..51a986bf02 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.h +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.h @@ -43,15 +43,15 @@ typedef struct EnBaba { /* 0x0406 */ UNK_TYPE1 unk406[4]; /* 0x040A */ u16 unk_40A; /* 0x040C */ s32 unk_40C; - /* 0x0410 */ Path* unk_410; - /* 0x0414 */ Vec3f unk_414; - /* 0x0420 */ f32 unk_420; - /* 0x0424 */ s32 unk_424; - /* 0x0428 */ s32 unk_428; - /* 0x042C */ s32 unk_42C; - /* 0x0430 */ s32 unk_430; + /* 0x0410 */ Path* timePath; + /* 0x0414 */ Vec3f timePathTargetPos; + /* 0x0420 */ f32 timePathProgress; + /* 0x0424 */ s32 timePathTotalTime; + /* 0x0428 */ s32 timePathWaypointTime; + /* 0x042C */ s32 timePathWaypoint; + /* 0x0430 */ s32 timePathElapsedTime; /* 0x0434 */ u8 unk_434; - /* 0x0436 */ s16 unk_436; + /* 0x0436 */ s16 timePathTimeSpeed; /* 0x0438 */ s32 unk_438; /* 0x043C */ s32 unk_43C; } EnBaba; // size = 0x440 diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 07699e7dee..8e43a095ae 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -979,18 +979,18 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; actor = func_8094DEE0(this, globalCtx, arg3, arg4); if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if ((actor != NULL) && (actor->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -1010,16 +1010,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; door = func_8094DF90(globalCtx, arg2->result); if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_278, &sp40); @@ -1053,32 +1053,33 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != NULL) { - if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { + if (this->timePath != NULL) { + if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3A4 &= ~0x8; this->unk_3A4 &= ~0x10; SubS_UpdateFlags(&this->unk_3A4, 3, 7); @@ -1154,16 +1155,16 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80951A0C[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); if (this->unk_258 == 0) { @@ -1444,7 +1445,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { f32 temp_f0; door = func_8094DF90(globalCtx, this->unk_258); - if (!SubS_InCsMode(globalCtx) && (this->unk_3C4 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; @@ -1459,7 +1460,7 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3BA * temp_f0; Lib_Vec3f_TranslateAndRotateY(&this->unk_278, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3BA += this->unk_3C4; + this->unk_3BA += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1469,51 +1470,53 @@ s32 func_80950804(EnGm* this, GlobalContext* globalCtx) { } s32 func_8095097C(EnGm* this, GlobalContext* globalCtx) { - f32 sp7C[0x109]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad2; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3A4 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_3C4); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3A4 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_3C4)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3A4 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -1576,7 +1579,7 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_3C4 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || ((this->unk_258 != sp20.result) && !func_80950280(this, globalCtx, &sp20))) { diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.h b/src/overlays/actors/ovl_En_Gm/z_en_gm.h index 63b6b8f570..1dd161757a 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.h +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.h @@ -18,13 +18,13 @@ typedef struct EnGm { /* 0x018C */ EnGmUnkFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 0x0234 */ Path* timePath; + /* 0x0238 */ Vec3f timePathTargetPos; + /* 0x0244 */ f32 timePathProgress; + /* 0x0248 */ s32 timePathTotalTime; + /* 0x024C */ s32 timePathWaypointTime; + /* 0x0250 */ s32 timePathWaypoint; + /* 0x0254 */ s32 timePathElapsedTime; /* 0x0258 */ u8 unk_258; /* 0x0259 */ u8 unk_259; /* 0x025C */ s32 unk_25C; @@ -54,7 +54,7 @@ typedef struct EnGm { /* 0x03BE */ s16 unk_3BE; /* 0x03C0 */ s16 unk_3C0; /* 0x03C2 */ s16 unk_3C2; - /* 0x03C4 */ s16 unk_3C4; + /* 0x03C4 */ s16 timePathTimeSpeed; /* 0x03C6 */ s16 unk_3C6; /* 0x03C8 */ s16 unk_3C8; /* 0x03CA */ s16 unk_3CA; diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index e687b770db..f15f15d59d 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -506,17 +506,17 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s3 s32 sp24 = false; sp2C = func_80BF1150(this, globalCtx, arg3, arg4); - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_274 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_274->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_274->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -549,16 +549,16 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; door = func_80BF1200(globalCtx, arg2->result); if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_274 != NULL) { - sp4C = Lib_SegmentedToVirtual(this->unk_274->points); + if (this->timePath != NULL) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_2B0, &sp40); @@ -588,39 +588,39 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); - s32 temp_t8; + s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); } - if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { - this->unk_274 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_274 != NULL) { - temp_t8 = this->scheduleResult; - if ((temp_t8 < 10) && (temp_t8 != 0) && (this->unk_3EC >= 0)) { + if (this->timePath != NULL) { + if ((this->scheduleResult < 10) && (this->scheduleResult != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_288 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_294 = sp2E - phi_v1; + this->timePathElapsedTime = sp2E - phi_v1; - phi_v1 = (this->unk_274->count - 2) & 0xFFFF; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); - this->unk_28C = this->unk_288 / phi_v1; - this->unk_290 = (this->unk_294 / this->unk_28C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3D0 &= ~0x8; this->unk_3D0 &= ~0x10; @@ -641,16 +641,16 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_274 = NULL; + this->timePath = NULL; if (D_80BF3318[arg2->result] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } - if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_274->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_274->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_274->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); @@ -733,7 +733,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { f32 temp; s32 pad; - if (!SubS_InCsMode(globalCtx) && (this->unk_3EC != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; @@ -747,7 +747,7 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_3E2 * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_2B0, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_3E2 += this->unk_3EC; + this->unk_3E2 += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -756,50 +756,52 @@ s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF25E8(EnIg* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk_274->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3D0 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &sp58, this->unk_3EC); - func_8013B878(globalCtx, this->unk_274, this->unk_290, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_3D0 |= 8; } else { - sp58 = this->unk_278; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_294; - sp50 = this->unk_290; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_278 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_274, &this->unk_284, &this->unk_294, this->unk_28C, this->unk_288, &this->unk_290, sp7C, - &this->unk_278, this->unk_3EC)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3D0 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_278; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_294 = sp54; - this->unk_290 = sp50; - this->unk_278 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if (Animation_OnFrame(&this->skelAnime, 0.0f) || Animation_OnFrame(&this->skelAnime, 13.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_PIRATE_WALK); } @@ -873,7 +875,7 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { ScheduleResult sp20; - this->unk_3EC = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || ((this->scheduleResult != sp20.result) && !func_80BF2368(this, globalCtx, &sp20))) { diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.h b/src/overlays/actors/ovl_En_Ig/z_en_ig.h index 21abb08ac8..9acf34ae94 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -19,13 +19,13 @@ typedef struct EnIg { /* 0x0190 */ MtxF unk_190; /* 0x01D0 */ ColliderCylinder collider1; /* 0x021C */ ColliderSphere collider2; - /* 0x0274 */ Path* unk_274; - /* 0x0278 */ Vec3f unk_278; - /* 0x0284 */ f32 unk_284; - /* 0x0288 */ s32 unk_288; - /* 0x028C */ s32 unk_28C; - /* 0x0290 */ s32 unk_290; - /* 0x0294 */ s32 unk_294; + /* 0x0274 */ Path* timePath; + /* 0x0278 */ Vec3f timePathTargetPos; + /* 0x0284 */ f32 timePathProgress; + /* 0x0288 */ s32 timePathTotalTime; + /* 0x028C */ s32 timePathWaypointTime; + /* 0x0290 */ s32 timePathWaypoint; + /* 0x0294 */ s32 timePathElapsedTime; /* 0x0298 */ u8 scheduleResult; /* 0x029C */ s32* unk_29C; /* 0x02A0 */ s32 unk_2A0; @@ -50,7 +50,7 @@ typedef struct EnIg { /* 0x03E6 */ s16 unk_3E6; /* 0x03E8 */ s16 unk_3E8; /* 0x03EA */ s16 unk_3EA; - /* 0x03EC */ s16 unk_3EC; + /* 0x03EC */ s16 timePathTimeSpeed; /* 0x03EE */ s16 unk_3EE; /* 0x03F0 */ s16 unk_3F0; /* 0x03F2 */ s16 unk_3F2; 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 bc41461d9b..43fb03da40 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1207,17 +1207,17 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { - if (this->unk_234 != NULL) { - sp48 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp3C, &sp48[this->unk_234->count - 2]); - Math_Vec3s_ToVec3f(&sp30, &sp48[this->unk_234->count - 1]); + if (this->timePath != NULL) { + sp48 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp3C, &sp48[this->timePath->count - 2]); + Math_Vec3s_ToVec3f(&sp30, &sp48[this->timePath->count - 1]); this->actor.shape.shadowDraw = NULL; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp3C, &sp30); Math_Vec3f_Copy(&this->actor.world.pos, &sp30); @@ -1238,15 +1238,15 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s16 temp; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; door = func_80AF7D60(globalCtx, arg2->result); if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { - if (this->unk_234 != 0) { - sp4C = Lib_SegmentedToVirtual(this->unk_234->points); + if (this->timePath != 0) { + sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); Math_Vec3s_ToVec3f(&sp34, &sp4C[1]); Math_Vec3f_Copy(&this->unk_26C, &sp40); @@ -1283,33 +1283,34 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); } - if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { - this->unk_234 = NULL; + if ((this->timePath != NULL) && (this->timePath->count < 3)) { + this->timePath = NULL; } - if (this->unk_234 != 0) { - if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { + if (this->timePath != 0) { + if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->timePathTimeSpeed >= 0)) { phi_v1 = sp2E; } else { phi_v1 = arg2->time0; } if (arg2->time1 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; + this->timePathTotalTime = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->time1 - phi_v1; + this->timePathTotalTime = arg2->time1 - phi_v1; } - this->unk_254 = sp2E - phi_v1; - phi_v1 = this->unk_234->count - 2; - this->unk_24C = this->unk_248 / phi_v1; - this->unk_250 = (this->unk_254 / this->unk_24C) + 2; + this->timePathElapsedTime = sp2E - phi_v1; + phi_v1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_v1; + this->timePathWaypoint = + (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_356 &= ~8; this->unk_356 &= ~0x10; if (this->unk_258 == 27) { @@ -1364,13 +1365,13 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; s32 ret = false; - this->unk_234 = NULL; + this->timePath = NULL; if (D_80AFB430[arg2->result] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_234->points); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp30[0]); Math_Vec3s_ToVec3f(&sp34, &sp30[1]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); @@ -1416,16 +1417,16 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { return ret; } - this->unk_234 = NULL; + this->timePath = NULL; phi_a3 = D_80AFB430[arg2->result]; if (phi_a3 >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } - if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { - sp30 = Lib_SegmentedToVirtual(this->unk_234->points); - Math_Vec3s_ToVec3f(&sp40, &sp30[this->unk_234->count - 1]); - Math_Vec3s_ToVec3f(&sp34, &sp30[this->unk_234->count - 2]); + if ((this->timePath != 0) && (this->timePath->count >= 2)) { + sp30 = Lib_SegmentedToVirtual(this->timePath->points); + Math_Vec3s_ToVec3f(&sp40, &sp30[this->timePath->count - 1]); + Math_Vec3s_ToVec3f(&sp34, &sp30[this->timePath->count - 2]); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp34, &sp40); Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); @@ -1703,7 +1704,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { Vec3f* sp28; f32 temp; - if (!SubS_InCsMode(globalCtx) && (this->unk_374 != 0)) { + if (!SubS_InCsMode(globalCtx) && (this->timePathTimeSpeed != 0)) { if ((door != NULL) && (door->dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; @@ -1717,7 +1718,7 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { sp38.y = 0.0f; sp38.z = this->unk_36E * temp; Lib_Vec3f_TranslateAndRotateY(&this->unk_26C, this->actor.world.rot.y, &sp38, &this->actor.world.pos); - this->unk_36E += this->unk_374; + this->unk_36E += this->timePathTimeSpeed; if (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); } @@ -1726,52 +1727,54 @@ s32 func_80AF9D04(EnPm* this, GlobalContext* globalCtx) { } s32 func_80AF9E7C(EnPm* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54; s32 sp50; sp50 = 0; sp54 = 0; - func_8013AF00(sp7C, 3, this->unk_234->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_356 & 8)) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &sp58, this->unk_374); - func_8013B878(globalCtx, this->unk_234, this->unk_250, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk_356 |= 8; } else { - sp58 = this->unk_238; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk_254; - sp50 = this->unk_250; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_238 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_234, &this->unk_244, &this->unk_254, this->unk_24C, this->unk_248, &this->unk_250, sp7C, - &this->unk_238, this->unk_374)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_356 |= 0x10; } else { sp70 = this->actor.world.pos; - sp64 = this->unk_238; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk_254 = sp54; - this->unk_250 = sp50; - this->unk_238 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } else if ((this->unk_258 != 91) && (Animation_OnFrame(&this->skelAnime, 3.0f) || Animation_OnFrame(&this->skelAnime, 8.0f))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK); @@ -1989,7 +1992,7 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { u16 sp3C = 0; ScheduleResult sp2C; - this->unk_374 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); if (this->unk_38C != 0) { time = gSaveContext.save.time - D_801F4E78; sp3C = gSaveContext.save.time; 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 6d545373b8..7a8c2be772 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.h +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.h @@ -16,13 +16,13 @@ typedef struct EnPm { /* 0x018C */ EnPmFunc2 unk_18C; /* 0x0190 */ ColliderCylinder colliderCylinder; /* 0x01DC */ ColliderSphere colliderSphere; - /* 0x0234 */ Path* unk_234; - /* 0x0238 */ Vec3f unk_238; - /* 0x0244 */ f32 unk_244; - /* 0x0248 */ s32 unk_248; - /* 0x024C */ s32 unk_24C; - /* 0x0250 */ s32 unk_250; - /* 0x0254 */ s32 unk_254; + /* 0x0234 */ Path* timePath; + /* 0x0238 */ Vec3f timePathTargetPos; + /* 0x0244 */ f32 timePathProgress; + /* 0x0248 */ s32 timePathTotalTime; + /* 0x024C */ s32 timePathWaypointTime; + /* 0x0250 */ s32 timePathWaypoint; + /* 0x0254 */ s32 timePathElapsedTime; /* 0x0258 */ u8 unk_258; /* 0x025C */ UNK_TYPE* unk_25C; /* 0x0260 */ s8 unk_260; @@ -44,7 +44,7 @@ typedef struct EnPm { /* 0x036E */ s16 unk_36E; /* 0x0370 */ s16 unk_370; /* 0x0372 */ s16 unk_372; - /* 0x0374 */ s16 unk_374; + /* 0x0374 */ s16 timePathTimeSpeed; /* 0x0376 */ s16 unk_376; /* 0x0378 */ s16 unk_378; /* 0x037C */ EnPmFunc unk_37C; 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 4a7e566829..21b0dd9a23 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -673,68 +673,66 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { u16 sp26 = SCHEDULE_TIME_NOW; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->result]; + s32 sp1C = D_80BAE8F8[scheduleResult->result]; u16 phi_a0; if (sp1C >= 0) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp23, sp1C); } - if (this->unk404 == NULL) { + if (this->timePath == NULL) { return 0; } - if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->unk42A >= 0)) { + if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->timePathTimeSpeed >= 0)) { phi_a0 = sp26; } else { - phi_a0 = unkStruct->time0; + phi_a0 = scheduleResult->time0; } - if (unkStruct->time1 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->time1) + 0xFFFF; + if (scheduleResult->time1 < phi_a0) { + this->timePathTotalTime = (phi_a0 - scheduleResult->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->time1 - phi_a0; + this->timePathTotalTime = scheduleResult->time1 - phi_a0; } - this->unk424 = sp26 - phi_a0; - phi_a0 = this->unk404->count - 2; + this->timePathElapsedTime = sp26 - phi_a0; + phi_a0 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); this->unk42C = 0; - this->unk41C = this->unk418 / phi_a0; - this->unk420 = (this->unk424 / this->unk41C) + 2; + this->timePathWaypointTime = this->timePathTotalTime / phi_a0; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk430 = 0; return 1; } -s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 pad; EnDoor* sp48; - u8 sp47; - u16 sp44; + u8 sp47 = ENSUTTARI_GET_PATH(&this->actor); + u16 sp44 = SCHEDULE_TIME_NOW; Vec3f sp38; Vec3f sp2C; Vec3s* sp28; - UNK_TYPE sp24; + s32 sp24; - sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = SCHEDULE_TIME_NOW; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[unkStruct->result]; + sp24 = D_80BAE8F8[scheduleResult->result]; if ((sp48 != NULL) && (sp24 >= 0)) { - this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); + this->timePath = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } - if ((sp48 == NULL) || (this->unk404 == NULL)) { + if ((sp48 == NULL) || (this->timePath == NULL)) { return 0; } - sp28 = Lib_SegmentedToVirtual(this->unk404->points); + sp28 = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - unkStruct->time0; - this->unk436 = unkStruct->time1 - unkStruct->time0; - if (unkStruct->result != 10 && unkStruct->result != 11) { + this->unk434 = sp44 - scheduleResult->time0; + this->unk436 = scheduleResult->time1 - scheduleResult->time0; + if (scheduleResult->result != 10 && scheduleResult->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -744,15 +742,15 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { +s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* scheduleResult) { s32 ret; - switch (unkStruct->result) { + switch (scheduleResult->result) { case 15: case 14: case 13: case 12: - ret = func_80BABC48(this, globalCtx, unkStruct); + ret = func_80BABC48(this, globalCtx, scheduleResult); break; case 11: case 10: @@ -760,7 +758,7 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk case 8: case 7: case 6: - ret = func_80BABDD8(this, globalCtx, unkStruct); + ret = func_80BABDD8(this, globalCtx, scheduleResult); break; case 5: case 4: @@ -777,45 +775,47 @@ s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unk } s32 func_80BABFD4(EnSuttari* this, GlobalContext* globalCtx) { - f32 sp7C[265]; + f32 knots[265]; Vec3f sp70; Vec3f sp64; - Vec3f sp58; + Vec3f timePathTargetPos; s32 sp54 = 0; s32 sp50 = 0; s32 pad; - func_8013AF00(sp7C, 3, this->unk404->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (this->unk42C == 0) { - sp58 = gZeroVec3f; - func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &sp58, this->unk42A); - func_8013B878(globalCtx, this->unk404, this->unk420, &sp58); - this->actor.world.pos.y = sp58.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; this->unk42C = 1; } else { - sp58 = this->unk408; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp58.x; - this->actor.world.pos.z = sp58.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (SubS_InCsMode(globalCtx)) { - sp54 = this->unk424; - sp50 = this->unk420; - sp58 = this->actor.world.pos; + sp54 = this->timePathElapsedTime; + sp50 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk408 = gZeroVec3f; - if (func_8013B6B0(this->unk404, &this->unk414, &this->unk424, this->unk41C, this->unk418, &this->unk420, sp7C, - &this->unk408, this->unk42A)) { + this->timePathTargetPos = gZeroVec3f; + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk430 = 1; } else { sp70 = this->actor.world.pos; - sp64 = this->unk408; + sp64 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp70, &sp64); } if (SubS_InCsMode(globalCtx)) { - this->unk424 = sp54; - this->unk420 = sp50; - this->unk408 = sp58; + this->timePathElapsedTime = sp54; + this->timePathWaypoint = sp50; + this->timePathTargetPos = timePathTargetPos; } return 0; } @@ -837,7 +837,7 @@ s32 func_80BAC220(EnSuttari* this, GlobalContext* globalCtx) { sp3C.z = this->unk434 * tmp; Lib_Vec3f_TranslateAndRotateY(&this->unk438, this->actor.world.rot.y, &sp3C, &sp30); this->actor.world.pos = sp30; - this->unk434 += this->unk42A; + this->unk434 += this->timePathTimeSpeed; return 0; } @@ -1099,17 +1099,17 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { @@ -1123,17 +1123,17 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); @@ -1244,7 +1244,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1252,22 +1252,22 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.result != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (scheduleResult.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1279,7 +1279,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - ScheduleResult unkStruct; + ScheduleResult scheduleResult; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1290,21 +1290,21 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->timePathTimeSpeed = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &scheduleResult) || + ((this->unk428 != scheduleResult.result) && !func_80BABF64(this, globalCtx, &scheduleResult))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.result = 0; + scheduleResult.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.result; + this->unk428 = scheduleResult.result; func_80BAC2FC(this, globalCtx); - if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { + if ((this->unk430 == 1) && (this->timePath->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.result != 9)) { + if ((this->flags1 & 0x20) && (scheduleResult.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; 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 2fbdff53b8..1fefc6f231 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.h @@ -39,16 +39,15 @@ typedef struct EnSuttari { /* 0x3F4 */ s16 unk3F4; /* 0x3F6 */ s16 unk3F6; /* 0x3F8 */ Vec3f unk3F8; - /* 0x404 */ Path* unk404; - /* 0x408 */ Vec3f unk408; - /* 0x414 */ f32 unk414; - /* 0x418 */ s32 unk418; - /* 0x41C */ s32 unk41C; - /* 0x420 */ s32 unk420; - /* 0x424 */ s32 unk424; + /* 0x404 */ Path* timePath; + /* 0x408 */ Vec3f timePathTargetPos; + /* 0x414 */ f32 timePathProgress; + /* 0x418 */ s32 timePathTotalTime; + /* 0x41C */ s32 timePathWaypointTime; + /* 0x420 */ s32 timePathWaypoint; + /* 0x424 */ s32 timePathElapsedTime; /* 0x428 */ u8 unk428; - /* 0x429 */ UNK_TYPE1 unk_429[0x1]; - /* 0x42A */ s16 unk42A; + /* 0x42A */ s16 timePathTimeSpeed; /* 0x42C */ s32 unk42C; /* 0x430 */ s32 unk430; /* 0x434 */ s16 unk434; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 4f61ac43f0..4dcea5b0dc 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -343,7 +343,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->unk_2DC += (REG(15) * sp44) - temp2; temp3 = this->unk_2DC; - this->unk_3D0 = temp2 + temp3; + this->timePathTimeSpeed = temp2 + temp3; this->unk_2DC -= temp3; this->unk_2E0 += REG(15); @@ -384,88 +384,89 @@ void func_80AECE0C(EnTk* this, GlobalContext* globalCtx) { s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { EnDoor* door; - f32 spA0[265]; + f32 knots[265]; Vec3f sp94; Vec3f sp88; - Vec3f sp7C; + Vec3f timePathTargetPos; s32 sp78; s32 sp74; - Actor* door2; - Actor* door1; - s32 pad2[1]; + s32 pad; - func_8013AF00(spA0, 3, this->unk_3C8->count + 3); + SubS_TimePathing_FillKnots(knots, SUBS_TIME_PATHING_ORDER, this->timePath->count + SUBS_TIME_PATHING_ORDER); if (!(this->unk_3CE & 4)) { - sp7C = gZeroVec3f; - func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &sp7C, this->unk_3D0); - func_8013B878(globalCtx, this->unk_3C8, this->unk_3EC, &sp7C); - this->actor.world.pos.y = sp7C.y; + timePathTargetPos = gZeroVec3f; + SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &timePathTargetPos, this->timePathTimeSpeed); + SubS_TimePathing_ComputeInitialY(globalCtx, this->timePath, this->timePathWaypoint, &timePathTargetPos); + this->actor.world.pos.y = timePathTargetPos.y; } else { - sp7C = this->unk_3D4; + timePathTargetPos = this->timePathTargetPos; } - this->actor.world.pos.x = sp7C.x; - this->actor.world.pos.z = sp7C.z; + this->actor.world.pos.x = timePathTargetPos.x; + this->actor.world.pos.z = timePathTargetPos.z; if (!(this->unk_3CE & 4)) { Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); this->unk_3CE |= 4; } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - sp78 = this->unk_3F0; - sp74 = this->unk_3EC; - sp7C = this->actor.world.pos; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + sp78 = this->timePathElapsedTime; + sp74 = this->timePathWaypoint; + timePathTargetPos = this->actor.world.pos; } - this->unk_3D4 = gZeroVec3f; + this->timePathTargetPos = gZeroVec3f; - if (func_8013B6B0(this->unk_3C8, &this->unk_3E0, &this->unk_3F0, this->unk_3E8, this->unk_3E4, &this->unk_3EC, spA0, - &this->unk_3D4, this->unk_3D0)) { + if (SubS_TimePathing_Update(this->timePath, &this->timePathProgress, &this->timePathElapsedTime, + this->timePathWaypointTime, this->timePathTotalTime, &this->timePathWaypoint, knots, + &this->timePathTargetPos, this->timePathTimeSpeed)) { this->unk_3CE |= 8; } else { sp94 = this->actor.world.pos; - sp88 = this->unk_3D4; + sp88 = this->timePathTargetPos; this->actor.world.rot.y = Math_Vec3f_Yaw(&sp94, &sp88); } - if ((globalCtx->unk_18B4A != 0) || (this->unk_3D0 == 0)) { - this->unk_3F0 = sp78; - this->unk_3EC = sp74; - this->unk_3D4 = sp7C; + if ((globalCtx->unk_18B4A != 0) || (this->timePathTimeSpeed == 0)) { + this->timePathElapsedTime = sp78; + this->timePathWaypoint = sp74; + this->timePathTargetPos = timePathTargetPos; } door = NULL; if (!(this->unk_2CA & 0xC00)) { - door1 = NULL; - label: + Actor* doorIter = NULL; + do { - door1 = SubS_FindActor(globalCtx, door1, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door1 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door1) <= 120.0f) { - if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &door1->world.pos), this->actor.shape.rot.y)) <= - 0x2000) { + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 120.0f) { + if (ABS(BINANG_SUB(Actor_YawToPoint(&this->actor, &doorIter->world.pos), + this->actor.shape.rot.y)) <= 0x2000) { this->unk_2CA |= 0x400; - door = (EnDoor*)door1; + door = (EnDoor*)doorIter; break; } } - door1 = door1->next; + doorIter = doorIter->next; } - } while (door1 != NULL); + } while (doorIter != NULL); } else { - door2 = NULL; + Actor* doorIter = NULL; + do { - door2 = SubS_FindActor(globalCtx, door2, ACTORCAT_DOOR, ACTOR_EN_DOOR); - if (door2 != NULL) { - if (Actor_XZDistanceBetweenActors(&this->actor, door2) <= 160.0f) { - door = (EnDoor*)door2; + doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); + if (doorIter != NULL) { + if (Actor_XZDistanceBetweenActors(&this->actor, doorIter) <= 160.0f) { + door = (EnDoor*)doorIter; break; } - door2 = door2->next; + doorIter = doorIter->next; } - } while (door2 != NULL); + } while (doorIter != NULL); } if ((door != NULL) && (this->unk_2CA & 0x400)) { @@ -507,22 +508,22 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 phi_a1; s32 idx = arg2->result - 1; - this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); - if (this->unk_3C8 == 0) { + this->timePath = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); + if (this->timePath == NULL) { return false; } - if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { + if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->timePathTimeSpeed >= 0)) { phi_a1 = sp1E; } else { phi_a1 = arg2->time0; } - this->unk_3E4 = arg2->time1 - phi_a1; - this->unk_3F0 = sp1E - phi_a1; - phi_a1 = this->unk_3C8->count - 2; - this->unk_3E8 = this->unk_3E4 / phi_a1; - this->unk_3EC = (this->unk_3F0 / this->unk_3E8) + 2; + this->timePathTotalTime = arg2->time1 - phi_a1; + this->timePathElapsedTime = sp1E - phi_a1; + phi_a1 = this->timePath->count - (SUBS_TIME_PATHING_ORDER - 1); + this->timePathWaypointTime = this->timePathTotalTime / phi_a1; + this->timePathWaypoint = (this->timePathElapsedTime / this->timePathWaypointTime) + (SUBS_TIME_PATHING_ORDER - 1); this->unk_3CE &= ~4; this->unk_3CE &= ~8; return true; diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.h b/src/overlays/actors/ovl_En_Tk/z_en_tk.h index 119ae2b2bb..ade05d6be3 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.h +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.h @@ -51,16 +51,16 @@ typedef struct EnTk { /* 0x0324 */ Vec3f unk_324[6]; /* 0x036C */ s32 unk_36C; /* 0x0370 */ UNK_TYPE1 unk370[0x58]; - /* 0x03C8 */ Path* unk_3C8; + /* 0x03C8 */ Path* timePath; /* 0x03CC */ u8 unk_3CC; /* 0x03CE */ u16 unk_3CE; - /* 0x03D0 */ s32 unk_3D0; - /* 0x03D4 */ Vec3f unk_3D4; - /* 0x03E0 */ f32 unk_3E0; - /* 0x03E4 */ s32 unk_3E4; - /* 0x03E8 */ s32 unk_3E8; - /* 0x03EC */ s32 unk_3EC; - /* 0x03F0 */ s32 unk_3F0; + /* 0x03D0 */ s32 timePathTimeSpeed; + /* 0x03D4 */ Vec3f timePathTargetPos; + /* 0x03E0 */ f32 timePathProgress; + /* 0x03E4 */ s32 timePathTotalTime; + /* 0x03E8 */ s32 timePathWaypointTime; + /* 0x03EC */ s32 timePathWaypoint; + /* 0x03F0 */ s32 timePathElapsedTime; } EnTk; // size = 0x3F4 extern const ActorInit En_Tk_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 2c74907d58..6c0b5d2d73 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2661,19 +2661,19 @@ 0x8013AD6C:("SubS_InCsMode",), 0x8013AD9C:("SubS_UpdateLimb",), 0x8013AED4:("SubS_UpdateFlags",), - 0x8013AF00:("func_8013AF00",), - 0x8013B010:("func_8013B010",), - 0x8013B0C8:("func_8013B0C8",), - 0x8013B350:("func_8013B350",), - 0x8013B6B0:("func_8013B6B0",), - 0x8013B878:("func_8013B878",), + 0x8013AF00:("SubS_TimePathing_FillKnots",), + 0x8013B010:("SubS_TimePathing_ComputeProgress",), + 0x8013B0C8:("SubS_TimePathing_ComputeWeights",), + 0x8013B350:("SubS_TimePathing_ComputeTargetPosXZ",), + 0x8013B6B0:("SubS_TimePathing_Update",), + 0x8013B878:("SubS_TimePathing_ComputeInitialY",), 0x8013BB34:("SubS_GetAdditionalPath",), 0x8013BB7C:("SubS_FindNearestActor",), 0x8013BC6C:("SubS_ChangeAnimationByInfoS",), 0x8013BD40:("SubS_HasReachedPoint",), 0x8013BEDC:("SubS_GetDayDependentPath",), - 0x8013C068:("func_8013C068",), - 0x8013C624:("func_8013C624",), + 0x8013C068:("SubS_WeightPathing_ComputePoint",), + 0x8013C624:("SubS_WeightPathing_Move",), 0x8013C8B8:("SubS_CopyPointFromPathCheckBounds",), 0x8013C964:("func_8013C964",), 0x8013CC2C:("SubS_FillShadowTex",), @@ -2693,7 +2693,7 @@ 0x8013D9C8:("SubS_FillLimbRotTables",), 0x8013DB90:("SubS_IsFloorAbove",), 0x8013DC40:("SubS_CopyPointFromPathList",), - 0x8013DCCC:("SubS_GetPathCount",), + 0x8013DCCC:("SubS_GetPathCountFromPathList",), 0x8013DCE0:("SubS_ActorPathing_Init",), 0x8013DE04:("SubS_ActorPathing_Update",), 0x8013DF3C:("SubS_ActorPathing_ComputePointInfo",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 336b844df8..602916a8e2 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -1971,8 +1971,8 @@ 0x801C5CD0:("sMtxFClear","MtxF","",0x40), 0x801C5D10:("D_801C5D10","UNK_TYPE1","",0x1), 0x801C5D20:("D_801C5D20","UNK_TYPE1","",0x1), - 0x801C5D60:("gShadowDL","UNK_TYPE1","",0x1), - 0x801C5D80:("gShadowVtxDL","UNK_TYPE1","",0x1), + 0x801C5D60:("gShadowMaterialDL","UNK_TYPE1","",0x1), + 0x801C5D80:("gShadowModelDL","UNK_TYPE1","",0x1), 0x801C5DB0:("gOneVec3f","UNK_TYPE1","",0x1), 0x801C5DD0:("D_801C5DD0","UNK_TYPE1","",0x1), 0x801C5DE0:("D_801C5DE0","UNK_TYPE1","",0x1), @@ -15954,8 +15954,7 @@ 0x80BD68A0:("D_80BD68A0","UNK_TYPE1","",0x1), 0x80BD68A4:("D_80BD68A4","UNK_TYPE1","",0x1), 0x80BD6DF0:("En_Sc_Ruppe_InitVars","UNK_TYPE1","",0x1), - 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x1), - 0x80BD6E14:("D_80BD6E14","UNK_TYPE1","",0x1), + 0x80BD6E10:("D_80BD6E10","UNK_TYPE1","",0x30), 0x80BD6E40:("D_80BD6E40","UNK_TYPE1","",0x1), 0x80BD6E70:("jtbl_80BD6E70","UNK_PTR","",0x4), 0x80BD6E88:("D_80BD6E88","f32","",0x4), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index bb57bb8a88..b3e5db1477 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2175,19 +2175,19 @@ asm/non_matchings/code/z_sub_s/SubS_DrawTransformFlex.s,SubS_DrawTransformFlex,0 asm/non_matchings/code/z_sub_s/SubS_InCsMode.s,SubS_InCsMode,0x8013AD6C,0xC asm/non_matchings/code/z_sub_s/SubS_UpdateLimb.s,SubS_UpdateLimb,0x8013AD9C,0x4E asm/non_matchings/code/z_sub_s/SubS_UpdateFlags.s,SubS_UpdateFlags,0x8013AED4,0xB -asm/non_matchings/code/z_sub_s/func_8013AF00.s,func_8013AF00,0x8013AF00,0x44 -asm/non_matchings/code/z_sub_s/func_8013B010.s,func_8013B010,0x8013B010,0x2E -asm/non_matchings/code/z_sub_s/func_8013B0C8.s,func_8013B0C8,0x8013B0C8,0xA2 -asm/non_matchings/code/z_sub_s/func_8013B350.s,func_8013B350,0x8013B350,0xD8 -asm/non_matchings/code/z_sub_s/func_8013B6B0.s,func_8013B6B0,0x8013B6B0,0x72 -asm/non_matchings/code/z_sub_s/func_8013B878.s,func_8013B878,0x8013B878,0xAF +asm/non_matchings/code/z_sub_s/SubS_TimePathing_FillKnots.s,SubS_TimePathing_FillKnots,0x8013AF00,0x44 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeProgress.s,SubS_TimePathing_ComputeProgress,0x8013B010,0x2E +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeWeights.s,SubS_TimePathing_ComputeWeights,0x8013B0C8,0xA2 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeTargetPosXZ.s,SubS_TimePathing_ComputeTargetPosXZ,0x8013B350,0xD8 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_Update.s,SubS_TimePathing_Update,0x8013B6B0,0x72 +asm/non_matchings/code/z_sub_s/SubS_TimePathing_ComputeInitialY.s,SubS_TimePathing_ComputeInitialY,0x8013B878,0xAF asm/non_matchings/code/z_sub_s/SubS_GetAdditionalPath.s,SubS_GetAdditionalPath,0x8013BB34,0x12 asm/non_matchings/code/z_sub_s/SubS_FindNearestActor.s,SubS_FindNearestActor,0x8013BB7C,0x3C asm/non_matchings/code/z_sub_s/SubS_ChangeAnimationByInfoS.s,SubS_ChangeAnimationByInfoS,0x8013BC6C,0x35 asm/non_matchings/code/z_sub_s/SubS_HasReachedPoint.s,SubS_HasReachedPoint,0x8013BD40,0x67 asm/non_matchings/code/z_sub_s/SubS_GetDayDependentPath.s,SubS_GetDayDependentPath,0x8013BEDC,0x63 -asm/non_matchings/code/z_sub_s/func_8013C068.s,func_8013C068,0x8013C068,0x16F -asm/non_matchings/code/z_sub_s/func_8013C624.s,func_8013C624,0x8013C624,0xA5 +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_ComputePoint.s,SubS_WeightPathing_ComputePoint,0x8013C068,0x16F +asm/non_matchings/code/z_sub_s/SubS_WeightPathing_Move.s,SubS_WeightPathing_Move,0x8013C624,0xA5 asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathCheckBounds.s,SubS_CopyPointFromPathCheckBounds,0x8013C8B8,0x2B asm/non_matchings/code/z_sub_s/func_8013C964.s,func_8013C964,0x8013C964,0xB2 asm/non_matchings/code/z_sub_s/SubS_FillShadowTex.s,SubS_FillShadowTex,0x8013CC2C,0x4E @@ -2207,7 +2207,7 @@ asm/non_matchings/code/z_sub_s/SubS_FindActor.s,SubS_FindActor,0x8013D960,0x1A asm/non_matchings/code/z_sub_s/SubS_FillLimbRotTables.s,SubS_FillLimbRotTables,0x8013D9C8,0x72 asm/non_matchings/code/z_sub_s/SubS_IsFloorAbove.s,SubS_IsFloorAbove,0x8013DB90,0x2C asm/non_matchings/code/z_sub_s/SubS_CopyPointFromPathList.s,SubS_CopyPointFromPathList,0x8013DC40,0x23 -asm/non_matchings/code/z_sub_s/SubS_GetPathCount.s,SubS_GetPathCount,0x8013DCCC,0x5 +asm/non_matchings/code/z_sub_s/SubS_GetPathCountFromPathList.s,SubS_GetPathCountFromPathList,0x8013DCCC,0x5 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