diff --git a/include/functions.h b/include/functions.h index fedeaf0f57..0b9685639d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2193,9 +2193,9 @@ void func_8011C808(GlobalContext* globalCtx); // void func_801210E0(void); // void func_80121F94(void); void func_80121FC4(GlobalContext* globalCtx); -s32 func_801224E0(s32 param_1, s16 param_2, s16 param_3); -f32 func_80122524(Actor* actor, Path* path, s16 arg2, s16* arg3); -// void func_801225CC(void); +Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max); +f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw); +void Path_CopyLastPoint(Path* path, Vec3f* dest); // void func_80122660(void); // UNK_TYPE4 func_80122670(s32* param_1, Input* input); // void func_801226E0(void); diff --git a/src/code/z_path.c b/src/code/z_path.c index 15d9409237..0462a40cd9 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -1,7 +1,45 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/func_801224E0.s") +Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { + Path* path; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/func_80122524.s") + if (index != max) { + path = &globalCtx->setupPathList[index]; + } else { + path = NULL; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/func_801225CC.s") + return path; +} + +f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) { + f32 dx; + f32 dz; + Vec3s* pointPos; + + if (path == NULL) { + return -1.0; + } + + pointPos = Lib_SegmentedToVirtual(path->points); + pointPos = &pointPos[waypoint]; + + dx = pointPos->x - actor->world.pos.x; + dz = pointPos->z - actor->world.pos.z; + + *yaw = Math_Atan2S(dx, dz); + + return SQ(dx) + SQ(dz); +} + +void Path_CopyLastPoint(Path* path, Vec3f* dest) { + Vec3s* pointPos; + + if (path != NULL) { + pointPos = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[path->count - 1]; + + dest->x = pointPos->x; + dest->y = pointPos->y; + dest->z = pointPos->z; + } +} diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index f0a2327fdc..c325a2b073 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -545,7 +545,7 @@ void func_8095B6C8(EnOwl* this, GlobalContext* globalCtx) { void func_8095B76C(EnOwl* this, GlobalContext* globalCtx) { s32 pad; s16 sp4A; - f32 sp44 = func_80122524(&this->actor, this->path, this->unk_3F8, &sp4A); + f32 sp44 = Path_OrientAndGetDistSq(&this->actor, this->path, this->unk_3F8, &sp4A); Vec3s* points; Math_SmoothStepToS(&this->actor.world.rot.y, sp4A, 6, 0x800, 0x200); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 4348bf5b58..d859d90578 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2167,9 +2167,9 @@ 0x801210E0:("func_801210E0",), 0x80121F94:("func_80121F94",), 0x80121FC4:("func_80121FC4",), - 0x801224E0:("func_801224E0",), - 0x80122524:("func_80122524",), - 0x801225CC:("func_801225CC",), + 0x801224E0:("Path_GetByIndex",), + 0x80122524:("Path_OrientAndGetDistSq",), + 0x801225CC:("Path_CopyLastPoint",), 0x80122660:("func_80122660",), 0x80122670:("func_80122670",), 0x801226E0:("func_801226E0",),