summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpetrie911 <69443847+petrie911@users.noreply.github.com>2021-09-13 14:29:11 -0500
committerGitHub <noreply@github.com>2021-09-13 15:29:11 -0400
commit30939ccd28063726368e4caa455f94cd63c474bc (patch)
tree784f6e9d73132b809c7c65bb1b3248f93f803dba /src
parentbaceca73b8a9395bab282dd80e0572594ce59179 (diff)
code_800BB040 matched (#959)
* getting closer * match! * functions unnamed * Update include/functions.h Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * small changes Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain> Co-authored-by: fig02 <fig02srl@gmail.com> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/code/code_800BB0A0.c70
-rw-r--r--src/code/code_800EC960.c15
-rw-r--r--src/code/fault_drawer.c2
-rw-r--r--src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c2
-rw-r--r--src/overlays/actors/ovl_En_Horse/z_en_horse.c2
5 files changed, 81 insertions, 10 deletions
diff --git a/src/code/code_800BB0A0.c b/src/code/code_800BB0A0.c
index 8d9f37b4a..1c9223107 100644
--- a/src/code/code_800BB0A0.c
+++ b/src/code/code_800BB0A0.c
@@ -1,5 +1,71 @@
#include "global.h"
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_800BB0A0/func_800BB0A0.s")
+// The code in this file is very similar to a spline system used in Super Mario 64 for cutscene camera movement
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_800BB0A0/func_800BB2B4.s")
+void func_800BB0A0(f32 u, Vec3f* pos, f32* roll, f32* viewAngle, f32* point0, f32* point1, f32* point2, f32* point3) {
+ f32 coeff[4];
+
+ u = CLAMP_MAX(u, 1.0f);
+
+ coeff[0] = (1.0f - u) * (1.0f - u) * (1.0f - u) / 6.0f;
+ coeff[1] = u * u * u / 2.0f - u * u + 2.0f / 3.0f;
+ coeff[2] = -u * u * u / 2.0f + u * u / 2.0f + u / 2.0f + 1.0f / 6.0f;
+ coeff[3] = u * u * u / 6.0f;
+
+ pos->x = (coeff[0] * point0[0]) + (coeff[1] * point1[0]) + (coeff[2] * point2[0]) + (coeff[3] * point3[0]);
+ pos->y = (coeff[0] * point0[1]) + (coeff[1] * point1[1]) + (coeff[2] * point2[1]) + (coeff[3] * point3[1]);
+ pos->z = (coeff[0] * point0[2]) + (coeff[1] * point1[2]) + (coeff[2] * point2[2]) + (coeff[3] * point3[2]);
+ *roll = (coeff[0] * point0[3]) + (coeff[1] * point1[3]) + (coeff[2] * point2[3]) + (coeff[3] * point3[3]);
+ *viewAngle = (coeff[0] * point0[4]) + (coeff[1] * point1[4]) + (coeff[2] * point2[4]) + (coeff[3] * point3[4]);
+}
+
+s32 func_800BB2B4(Vec3f* pos, f32* roll, f32* fov, CutsceneCameraPoint* point, s16* keyFrame, f32* curFrame) {
+ s32 ret = false;
+ f32 pointData[4][5];
+ s32 i;
+ f32 progress = *curFrame;
+ s32 key = *keyFrame;
+ f32 speed1 = 0.0f;
+ f32 speed2 = 0.0f;
+ f32 advance;
+
+ if (key < 0) {
+ progress = 0.0f;
+ }
+
+ if ((point[key].continueFlag == -1) || (point[key + 1].continueFlag == -1) || (point[key + 2].continueFlag == -1)) {
+ return true;
+ }
+
+ for (i = 0; i < 4; i++) {
+ pointData[i][0] = point[key + i].pos.x;
+ pointData[i][1] = point[key + i].pos.y;
+ pointData[i][2] = point[key + i].pos.z;
+ pointData[i][3] = point[key + i].cameraRoll;
+ pointData[i][4] = point[key + i].viewAngle;
+ }
+
+ func_800BB0A0(progress, pos, roll, fov, &pointData[0], &pointData[1], &pointData[2], &pointData[3]);
+
+ if (point[*keyFrame + 1].nextPointFrame != 0) {
+ speed1 = 1.0f / point[*keyFrame + 1].nextPointFrame;
+ }
+
+ if (point[*keyFrame + 2].nextPointFrame != 0) {
+ speed2 = 1.0f / point[*keyFrame + 2].nextPointFrame;
+ }
+ advance = (*curFrame * (speed2 - speed1)) + speed1;
+ if (advance < 0.0f) {
+ advance = 0;
+ }
+ *curFrame += advance;
+ if (*curFrame >= 1) {
+ if (point[++*keyFrame + 3].continueFlag == -1) {
+ *keyFrame = 0;
+ ret = true;
+ }
+ *curFrame -= 1;
+ }
+
+ return ret;
+}
diff --git a/src/code/code_800EC960.c b/src/code/code_800EC960.c
index 5d928b539..d3ab8cda4 100644
--- a/src/code/code_800EC960.c
+++ b/src/code/code_800EC960.c
@@ -4,17 +4,22 @@
// TODO: can these macros be shared between files? code_800F9280 seems to use
// versions without any casts...
#define Audio_DisableSeq(seqIdx, fadeOut) Audio_QueueCmdS32(0x83000000 | ((u8)seqIdx << 16), fadeOut)
-#define Audio_StartSeq(seqIdx, fadeTimer, seqId) Audio_QueueSeqCmd(0x00000000 | ((u8)seqIdx << 24) | ((u8)(fadeTimer) << 0x10) | (u16)seqId)
+#define Audio_StartSeq(seqIdx, fadeTimer, seqId) \
+ Audio_QueueSeqCmd(0x00000000 | ((u8)seqIdx << 24) | ((u8)(fadeTimer) << 0x10) | (u16)seqId)
#define Audio_SeqCmd7(seqIdx, a, b) Audio_QueueSeqCmd(0x70000000 | ((u8)seqIdx << 0x18) | ((u8)a << 0x10) | (u8)(b))
-#define Audio_SeqCmdC(seqIdx, a, b, c) Audio_QueueSeqCmd(0xC0000000 | ((u8)seqIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)(c)))
+#define Audio_SeqCmdC(seqIdx, a, b, c) \
+ Audio_QueueSeqCmd(0xC0000000 | ((u8)seqIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)(c)))
#define Audio_SeqCmdA(seqIdx, a) Audio_QueueSeqCmd(0xA0000000 | ((u8)seqIdx << 24) | ((u16)(a)))
#define Audio_SeqCmd1(seqIdx, a) Audio_QueueSeqCmd(0x100000FF | ((u8)seqIdx << 24) | ((u8)(a) << 16))
-#define Audio_SeqCmdB(seqIdx, a, b, c) Audio_QueueSeqCmd(0xB0000000 | ((u8)seqIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c))
+#define Audio_SeqCmdB(seqIdx, a, b, c) \
+ Audio_QueueSeqCmd(0xB0000000 | ((u8)seqIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c))
#define Audio_SeqCmdB40(seqIdx, a, b) Audio_QueueSeqCmd(0xB0004000 | ((u8)seqIdx << 24) | ((u8)a << 16) | ((u8)b))
-#define Audio_SeqCmd6(seqIdx, a, b, c) Audio_QueueSeqCmd(0x60000000 | ((u8)seqIdx << 24) | ((u8)(a) << 16) | ((u8)b << 8) | ((u8)c))
+#define Audio_SeqCmd6(seqIdx, a, b, c) \
+ Audio_QueueSeqCmd(0x60000000 | ((u8)seqIdx << 24) | ((u8)(a) << 16) | ((u8)b << 8) | ((u8)c))
#define Audio_SeqCmdE0(seqIdx, a) Audio_QueueSeqCmd(0xE0000000 | ((u8)seqIdx << 24) | ((u8)a))
#define Audio_SeqCmdE01(seqIdx, a) Audio_QueueSeqCmd(0xE0000100 | ((u8)seqIdx << 24) | ((u16)a))
-#define Audio_SeqCmd8(seqIdx, a, b, c) Audio_QueueSeqCmd(0x80000000 | ((u8)seqIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c))
+#define Audio_SeqCmd8(seqIdx, a, b, c) \
+ Audio_QueueSeqCmd(0x80000000 | ((u8)seqIdx << 24) | ((u8)a << 16) | ((u8)b << 8) | ((u8)c))
#define Audio_SeqCmdF(seqIdx, a) Audio_QueueSeqCmd(0xF0000000 | ((u8)seqIdx << 24) | ((u8)a))
typedef struct {
diff --git a/src/code/fault_drawer.c b/src/code/fault_drawer.c
index 0885cacbd..036247d8a 100644
--- a/src/code/fault_drawer.c
+++ b/src/code/fault_drawer.c
@@ -282,7 +282,7 @@ void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...) {
FaultDrawer_SetCursor(x, y);
FaultDrawer_VPrintf(fmt, args);
-
+
va_end(args);
}
diff --git a/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c b/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c
index 4d248e10c..74ae488e3 100644
--- a/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c
+++ b/src/overlays/actors/ovl_En_Heishi1/z_en_heishi1.c
@@ -102,7 +102,7 @@ void EnHeishi1_Init(Actor* thisx, GlobalContext* globalCtx) {
// "(head) maximum turning angle speed"
osSyncPrintf(VT_FGCOL(PURPLE) " (頭)反転アングルスピード最大☆ %f\n" VT_RST, this->headTurnSpeedMax);
osSyncPrintf(VT_FGCOL(GREEN) " 今時間 %d\n" VT_RST, ((void)0, gSaveContext.dayTime)); // "current time"
- osSyncPrintf(VT_FGCOL(YELLOW) " チェック時間 %d\n" VT_RST, 0xBAAA); // "check time"
+ osSyncPrintf(VT_FGCOL(YELLOW) " チェック時間 %d\n" VT_RST, 0xBAAA); // "check time"
osSyncPrintf("\n\n");
if (this->path == 3) {
diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c
index 27facad22..5228f964e 100644
--- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c
+++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c
@@ -3784,7 +3784,7 @@ void EnHorse_SkinCallback1(Actor* thisx, GlobalContext* globalCtx, PSkinAwb* ski
}
//! @bug Setting colliders in a draw function allows for duplicate entries to be added to their respective lists
- //! under certain conditions, like when pausing and unpausing the game.
+ //! under certain conditions, like when pausing and unpausing the game.
//! Actors will draw for a couple of frames between the pauses, but some important logic updates will not occur.
//! In the case of OC, this can cause unwanted effects such as a very large amount of displacement being applied to
//! a colliding actor.