From d2729f9d88b8bdb63397338e4979d619304a2b1e Mon Sep 17 00:00:00 2001 From: Roman971 Date: Mon, 23 Mar 2020 21:18:53 +0100 Subject: Split z_path.c and Rename some small files and functions --- src/code/z_path.c | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/code/z_path.c (limited to 'src/code/z_path.c') diff --git a/src/code/z_path.c b/src/code/z_path.c new file mode 100644 index 000000000..7b54d58c2 --- /dev/null +++ b/src/code/z_path.c @@ -0,0 +1,8 @@ +#include +#include + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_GetByIndex.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_OrientAndGetDistSq.s") + +#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_CopyLastPoint.s") -- cgit v1.2.3 From a9d4fec1134990b3df70fe82e68013af07927d84 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Mon, 23 Mar 2020 21:19:24 +0100 Subject: Decompile Path_GetByIndex --- src/code/z_path.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/code/z_path.c') diff --git a/src/code/z_path.c b/src/code/z_path.c index 7b54d58c2..011421bd6 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -1,7 +1,17 @@ #include #include -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_GetByIndex.s") +Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { + Path* path; + + if (index != max) { + path = &globalCtx->setupPathList[index]; + } else { + path = NULL; + } + + return path; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_OrientAndGetDistSq.s") -- cgit v1.2.3 From e88ea64835d97a4ead14ec0b8028e1ecff211471 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Mon, 23 Mar 2020 21:19:54 +0100 Subject: Decompile Path_OrientAndGetDistSq --- src/code/z_path.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/code/z_path.c') diff --git a/src/code/z_path.c b/src/code/z_path.c index 011421bd6..d1d81286d 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -13,6 +13,24 @@ Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { return path; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_OrientAndGetDistSq.s") +f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) { + f32 dx; + f32 dz; + Vec3s* pointPos; + + if (path == NULL) { + return -1.0; + } + + pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos = &pointPos[waypoint]; + + dx = pointPos->x - actor->posRot.pos.x; + dz = pointPos->z - actor->posRot.pos.z; + + *yaw = Math_atan2f(dx, dz) * (32768 / M_PI); + + return SQ(dx) + SQ(dz); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_CopyLastPoint.s") -- cgit v1.2.3 From 7fcc79fc4d506693c0da71c4c8a4bbf00f8dfb33 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Mon, 23 Mar 2020 21:20:30 +0100 Subject: Decompile Path_CopyLastPoint --- src/code/z_path.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/code/z_path.c') diff --git a/src/code/z_path.c b/src/code/z_path.c index d1d81286d..03dc6d6f6 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -33,4 +33,14 @@ f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) { return SQ(dx) + SQ(dz); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_CopyLastPoint.s") +void Path_CopyLastPoint(Path* path, Vec3f* dest) { + Vec3s* pointPos; + + if (path != NULL) { + pointPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[path->count - 1]; + + dest->x = pointPos->x; + dest->y = pointPos->y; + dest->z = pointPos->z; + } +} -- cgit v1.2.3