summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfig02 <fig02srl@gmail.com>2020-03-23 18:09:18 -0400
committerGitHub <noreply@github.com>2020-03-23 18:09:18 -0400
commit78a4684e3241f5c40cea8fb5437e6c36637df8ad (patch)
treea02167ae9ac063c8a44963b3d412cd3679f7bfc8 /src
parent8e316933d596204aa42fcfc2587fee480b4e114e (diff)
parent7fcc79fc4d506693c0da71c4c8a4bbf00f8dfb33 (diff)
Merge pull request #28 from Roman971/z_path.c
Rename/document some small files and Decompile z_path.c
Diffstat (limited to 'src')
-rw-r--r--src/code/code_80026B00.c26
-rw-r--r--src/code/z_effect.c26
-rw-r--r--src/code/z_face_reaction.c (renamed from src/code/code_8006C360.c)8
-rw-r--r--src/code/z_path.c46
-rw-r--r--src/overlays/actors/ovl_En_Dog/z_en_dog.c4
-rw-r--r--src/overlays/actors/ovl_En_Ms/z_en_ms.c6
-rw-r--r--src/overlays/actors/ovl_En_Tk/z_en_tk.c4
7 files changed, 83 insertions, 37 deletions
diff --git a/src/code/code_80026B00.c b/src/code/code_80026B00.c
deleted file mode 100644
index beb5006ee..000000000
--- a/src/code/code_80026B00.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <ultra64.h>
-#include <global.h>
-
-GlobalContext* func_80026B00(void) {
- return D_80157DA0;
-}
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80026B00/func_80026B0C.s")
-
-void func_80026C1C(u8* arg0) {
- arg0[0] = 0;
- arg0[1] = 0;
- arg0[2] = 0;
-}
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80026B00/func_80026C2C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80026B00/Effect_Add.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80026B00/func_80026E74.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80026B00/func_80026F70.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80026B00/func_8002709C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80026B00/func_800271A8.s")
diff --git a/src/code/z_effect.c b/src/code/z_effect.c
new file mode 100644
index 000000000..dfe367d13
--- /dev/null
+++ b/src/code/z_effect.c
@@ -0,0 +1,26 @@
+#include <ultra64.h>
+#include <global.h>
+
+GlobalContext* func_80026B00(void) {
+ return D_80157DA0;
+}
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026B0C.s")
+
+void func_80026C1C(u8* arg0) {
+ arg0[0] = 0;
+ arg0[1] = 0;
+ arg0[2] = 0;
+}
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026C2C.s")
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/Effect_Add.s")
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026E74.s")
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_80026F70.s")
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_8002709C.s")
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/z_effect/func_800271A8.s")
diff --git a/src/code/code_8006C360.c b/src/code/z_face_reaction.c
index 01cf89b4d..1bfe18b7c 100644
--- a/src/code/code_8006C360.c
+++ b/src/code/z_face_reaction.c
@@ -1,7 +1,7 @@
#include <ultra64.h>
#include <global.h>
-u16 D_8011F3F0[60][9] = {
+u16 sReactionTextIds[60][9] = {
{ 0x0000, 0x7124, 0x7127, 0x7126, 0x7125, 0x7127, 0x7124, 0x7125, 0x7127 },
{ 0x0000, 0x7128, 0x7129, 0x7128, 0x7128, 0x7128, 0x7128, 0x712A, 0x712B },
{ 0x0000, 0x7128, 0x712B, 0x7128, 0x7128, 0x7129, 0x7128, 0x712B, 0x7128 },
@@ -64,7 +64,7 @@ u16 D_8011F3F0[60][9] = {
{ 0x0000, 0x7104, 0x7105, 0x7107, 0x7105, 0x710C, 0x7105, 0x7107, 0x7107 },
};
-u16 func_8006C360(GlobalContext* globalCtx, u32 idx) {
- u8 mask = func_8008F080(globalCtx);
- return D_8011F3F0[idx][mask];
+u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet) {
+ u8 currentMask = func_8008F080(globalCtx);
+ return sReactionTextIds[reactionSet][currentMask];
}
diff --git a/src/code/z_path.c b/src/code/z_path.c
new file mode 100644
index 000000000..03dc6d6f6
--- /dev/null
+++ b/src/code/z_path.c
@@ -0,0 +1,46 @@
+#include <ultra64.h>
+#include <global.h>
+
+Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) {
+ Path* path;
+
+ if (index != max) {
+ path = &globalCtx->setupPathList[index];
+ } else {
+ path = NULL;
+ }
+
+ 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 = 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);
+}
+
+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;
+ }
+}
diff --git a/src/overlays/actors/ovl_En_Dog/z_en_dog.c b/src/overlays/actors/ovl_En_Dog/z_en_dog.c
index c9e1d06c2..c1f3ac053 100644
--- a/src/overlays/actors/ovl_En_Dog/z_en_dog.c
+++ b/src/overlays/actors/ovl_En_Dog/z_en_dog.c
@@ -224,7 +224,7 @@ static s32 EnDog_Orient(EnDog* this, GlobalContext* globalCtx) {
s16 targetYaw;
f32 waypointDistSq;
- waypointDistSq = func_8008E520(&this->actor, this->path, this->waypoint, &targetYaw);
+ waypointDistSq = Path_OrientAndGetDistSq(&this->actor, this->path, this->waypoint, &targetYaw);
Math_SmoothScaleMaxMinS(&this->actor.posRot.rot.y, targetYaw, 10, 1000, 1);
if ((waypointDistSq > 0.0f) && (waypointDistSq < 1000.0f)) {
@@ -261,7 +261,7 @@ static void EnDog_Init(EnDog* this, GlobalContext* globalCtx) {
Actor_SetScale(&this->actor, 0.0075f);
this->waypoint = 0;
this->actor.gravity = -1.0f;
- this->path = func_8008E4E0(globalCtx, (s16)((this->actor.params & 0x00F0) >> 4), 0xF);
+ this->path = Path_GetByIndex(globalCtx, (this->actor.params & 0x00F0) >> 4, 0xF);
switch (globalCtx->sceneNum) {
case SCENE_MARKET_NIGHT:
diff --git a/src/overlays/actors/ovl_En_Ms/z_en_ms.c b/src/overlays/actors/ovl_En_Ms/z_en_ms.c
index b8c98d055..fece576dd 100644
--- a/src/overlays/actors/ovl_En_Ms/z_en_ms.c
+++ b/src/overlays/actors/ovl_En_Ms/z_en_ms.c
@@ -67,13 +67,13 @@ extern D_060005EC;
extern D_06003DC0;
static void EnMs_SetOfferText(EnMs* this, GlobalContext* globalCtx) {
- this->actor.textId = func_8006C360(globalCtx, 0x1B);
+ this->actor.textId = Text_GetFaceReaction(globalCtx, 0x1B);
if (this->actor.textId == 0) {
if (BEANS_BOUGHT >= 10) {
this->actor.textId = 0x406B;
- return;
+ } else {
+ this->actor.textId = offerTextIds[BEANS_BOUGHT];
}
- this->actor.textId = offerTextIds[BEANS_BOUGHT];
}
}
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 954447e62..836c6a85d 100644
--- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c
+++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c
@@ -335,7 +335,7 @@ s32 EnTk_Orient(EnTk* this, GlobalContext* globalCtx) {
}
path = &globalCtx->setupPathList[0];
- point = SEGMENTED_TO_VIRTUAL(path->path);
+ point = SEGMENTED_TO_VIRTUAL(path->points);
point += this->currentWaypoint;
dx = point->x - this->actor.posRot.pos.x;
@@ -359,7 +359,7 @@ s32 EnTk_Orient(EnTk* this, GlobalContext* globalCtx) {
u16 func_80B1C54C(GlobalContext* globalCtx, Actor* a1) {
u16 ret;
- ret = func_8006C360(globalCtx, 14);
+ ret = Text_GetFaceReaction(globalCtx, 14);
if (ret != 0) {
return ret;
}