summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_0x800E8EA0.c110
-rw-r--r--src/code/code_0x800E8EA0.c.ignore44
-rw-r--r--src/code/z_lib.c4
3 files changed, 112 insertions, 46 deletions
diff --git a/src/code/code_0x800E8EA0.c b/src/code/code_0x800E8EA0.c
new file mode 100644
index 000000000..74ebbcb70
--- /dev/null
+++ b/src/code/code_0x800E8EA0.c
@@ -0,0 +1,110 @@
+#include <ultra64.h>
+#include <global.h>
+
+void func_800E8EA0(GlobalContext* ctxt, Actor* actor, u16 param_3) {
+ func_80151938(ctxt, param_3);
+ actor->textId = param_3;
+}
+
+s32 nop_800E8ED0(UNK_TYPE4 param_1) {
+ return 0;
+}
+
+void nop_800E8EE0(UNK_TYPE4 param_1) {}
+
+s32 nop_800E8EEC(UNK_TYPE4 param_1) {
+ return 0;
+}
+
+void nop_800E8EFC(UNK_TYPE4 param_1) {}
+
+s32 func_800E8F08(Vector3s* param_1, Vector3s* param_2) {
+ Lib_ScaleMaxMin_s(&param_1->y, 0, 6, 6200, 100);
+ Lib_ScaleMaxMin_s(&param_1->x, 0, 6, 6200, 100);
+ Lib_ScaleMaxMin_s(&param_2->y, 0, 6, 6200, 100);
+ Lib_ScaleMaxMin_s(&param_2->x, 0, 6, 6200, 100);
+ return 1;
+}
+
+s32 func_800E8FA4(Actor* actor, Vector3f* param_2, Vector3s* param_3, Vector3s* param_4) {
+ s16 targetPitch;
+ s16 targetYaw;
+ s16 yawDiffFromTarget;
+
+ targetPitch = Lib_PitchVec3f(&actor->unk3C.pos,param_2);
+ targetYaw = Lib_YawVec3f(&actor->unk3C.pos,param_2) - actor->unk24.rot.y;
+
+ Lib_ScaleMaxMin_s(&param_3->x, targetPitch, 6, 2000, 1);
+ param_3->x = (param_3->x < -6000)? -6000 : ((6000 < param_3->x)? 6000 : param_3->x);
+
+ yawDiffFromTarget = Lib_ScaleMaxMin_s(&param_3->y, targetYaw, 6, 2000, 1);
+ param_3->y = (param_3->y < -8000)? -8000 : ((8000 < param_3->y)? 8000 : param_3->y);
+
+ if (yawDiffFromTarget != 0) {
+ if ((param_3->y < 0? -param_3->y : param_3->y) < 8000) {
+ return 0;
+ }
+ }
+
+ Lib_ScaleMaxMin_s(&param_4->y, targetYaw - param_3->y, 4, 2000, 1);
+ param_4->y = (param_4->y < -12000)? -12000 : ((12000 < param_4->y)? 12000 : param_4->y);
+
+ return 1;
+}
+
+s32 func_800E9138(GlobalContext* ctxt, Actor* actor, Vector3s* param_3, Vector3s* param_4, f32 param_5) {
+ s16 sVar3;
+ Actor *player;
+ Vector3f local_14;
+
+ player = (ctxt->actorContext).actorTypeLists[2].head;
+ actor->unk3C.pos = actor->unk24.pos;
+ actor->unk3C.pos.y += param_5;
+
+ if (((ctxt->cutsceneContext).state == 0) && (D_801D0D50 == 0)) {
+ sVar3 = actor->unk92 - actor->postDrawParams.rotation.y;
+ // TODO is this shifting because of a missing cast?
+ if (0x42ff < (sVar3 < 0? ((-sVar3 << 0x10) >> 0x10) : ((sVar3 << 0x10) >> 0x10))) {
+ func_800E8F08(param_3,param_4);
+ return 0;
+ }
+ }
+
+ if (((ctxt->cutsceneContext).state != 0) || (D_801D0D50 != 0)) {
+ local_14 = ctxt->view.eye;
+ } else {
+ local_14 = player->unk3C.pos;
+ }
+
+ func_800E8FA4(actor,&local_14,param_3,param_4);
+
+ return 1;
+}
+s32 func_800E9250(GlobalContext* ctxt, Actor* actor, Vector3s* param_3, Vector3s* param_4, Vector3f param_5) {
+ s16 sVar3;
+ Actor *player;
+ Vector3f local_14;
+
+ player = (ctxt->actorContext).actorTypeLists[2].head;
+ actor->unk3C.pos = param_5;
+
+ if (((ctxt->cutsceneContext).state == 0) && (D_801D0D50 == 0)) {
+ sVar3 = actor->unk92 - actor->postDrawParams.rotation.y;
+ // TODO is this shifting because of a missing cast?
+ if (0x42ff < (sVar3 < 0? ((-sVar3 << 0x10) >> 0x10) : ((sVar3 << 0x10) >> 0x10))) {
+ func_800E8F08(param_3,param_4);
+ return 0;
+ }
+ }
+
+ if (((ctxt->cutsceneContext).state != 0) || (D_801D0D50 != 0)) {
+ local_14 = ctxt->view.eye;
+ } else {
+ local_14 = player->unk3C.pos;
+ }
+
+ func_800E8FA4(actor,&local_14,param_3,param_4);
+
+ return 1;
+}
+
diff --git a/src/code/code_0x800E8EA0.c.ignore b/src/code/code_0x800E8EA0.c.ignore
deleted file mode 100644
index 1bc5b38f8..000000000
--- a/src/code/code_0x800E8EA0.c.ignore
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <ultra64.h>
-#include <global.h>
-
-void func_800E8EA0(z_GlobalContext* a0, z_Actor* a1, u16 a2) {
- func_80151938(a0, a2);
- a1->unk116 = a2;
-}
-
-UNK_TYPE func_800E8ED0(UNK_TYPE a0) {
- return 0;
-}
-
-void func_800E8EE0(UNK_TYPE a0) {
- return;
-}
-
-UNK_TYPE func_800E8EEC(UNK_TYPE a0) {
- return 0;
-}
-
-void func_800E8EFC(UNK_TYPE a0) {
- return;
-}
-
-UNK_TYPE func_800E8F08(s16* a0, s16* a1) {
- func_800FFEBC(a0 + 1, 0, 6, 6200, 100);
- func_800FFEBC(a1 , 0, 6, 6200, 100);
- func_800FFEBC(a0 + 1, 0, 6, 6200, 100);
- func_800FFEBC(a1 , 0, 6, 6200, 100);
-
- return 1;
-}
-
-UNK_RET func_800E8FA4(UNK_TYPE a0, UNK_TYPE a1, UNK_TYPE a2, UNK_TYPE a3) {
-
-}
-
-UNK_RET func_800E9138(UNK_ARGS) {
-
-}
-
-UNK_RET func_800E9250(UNK_ARGS) {
-
-}
diff --git a/src/code/z_lib.c b/src/code/z_lib.c
index f8124709b..a3695dc9e 100644
--- a/src/code/z_lib.c
+++ b/src/code/z_lib.c
@@ -409,13 +409,13 @@ f32 Lib_DistanceYVec3f(Vector3f* a, Vector3f* b) {
return b->y - a->y;
}
-s32 Lib_YawVec3f(Vector3f* from, Vector3f* to) {
+s16 Lib_YawVec3f(Vector3f* from, Vector3f* to) {
f32 f14 = to->x - from->x;
f32 f12 = to->z - from->z;
return atans_flip(f12, f14);
}
-s32 Lib_PitchVec3f(Vector3f* from, Vector3f* to) {
+s16 Lib_PitchVec3f(Vector3f* from, Vector3f* to) {
return atans_flip(Lib_DistanceXZVec3f(from, to), from->y - to->y);
}