1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 23:14:37 +00:00

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>
This commit is contained in:
petrie911 2021-09-13 14:29:11 -05:00 committed by GitHub
parent baceca73b8
commit 30939ccd28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 82 additions and 343 deletions

View file

@ -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;
}

View file

@ -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 {

View file

@ -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);
}