diff --git a/src/engine/Matrix.cpp b/src/engine/Matrix.cpp index 15cc00f17..c84eaefab 100644 --- a/src/engine/Matrix.cpp +++ b/src/engine/Matrix.cpp @@ -35,7 +35,7 @@ void AddMatrixFixed(std::vector& stack, s32 flags) { } // Used in func_80095BD0 -Mtx* SetTextMatrix(Mat4 matrix, f32 x, f32 y, f32 arg3, f32 arg4) { +void SetTextMatrix(Mat4 matrix, f32 x, f32 y, f32 arg3, f32 arg4) { FrameInterpolation_Record_SetTextMatrix((Mat4*)&matrix, x, y, arg3, arg4); matrix[0][0] = arg3; matrix[0][1] = 0.0f; @@ -53,11 +53,6 @@ Mtx* SetTextMatrix(Mat4 matrix, f32 x, f32 y, f32 arg3, f32 arg4) { matrix[3][1] = y; matrix[3][2] = 0.0f; matrix[3][3] = 1.0f; - Mtx* mtx = GetMatrix(gWorldInstance.Mtx.Effects); - FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)matrix, mtx); - guMtxF2L(matrix, mtx); - - return mtx; } void ApplyMatrixTransformations(Mat4 mtx, FVector pos, IRotator rot, FVector scale) { diff --git a/src/engine/Matrix.h b/src/engine/Matrix.h index cada8c267..7e8f91e55 100644 --- a/src/engine/Matrix.h +++ b/src/engine/Matrix.h @@ -17,7 +17,7 @@ void AddObjectMatrix(Mat4 mtx, s32 flags); void AddEffectMatrix(Mat4 mtx, s32 flags); void AddEffectMatrixOrtho(void); void AddEffectMatrixFixed(s32 flags); -Mtx* SetTextMatrix(Mat4 mtx, f32 x, f32 y, f32 arg3, f32 arg4); +void SetTextMatrix(Mat4 mtx, f32 x, f32 y, f32 arg3, f32 arg4); Mtx* GetEffectMatrix(void); Mtx* GetObjectMatrix(void); void ClearHudMatrixPool(void); diff --git a/src/main.c b/src/main.c index c3f6f27d7..960521639 100644 --- a/src/main.c +++ b/src/main.c @@ -1264,10 +1264,13 @@ void thread5_game_loop(void) { read_controllers(); func_800C5CB8(); } - +extern size_t gTextMatrixCount; +extern size_t gTextMatrixCount_wide_right; void thread5_iteration(void) { func_800CB2C4(); calculate_delta_time(); + gTextMatrixCount = 0; + gTextMatrixCount_wide_right = 0; #ifdef TARGET_N64 while (true) { func_800CB2C4(); diff --git a/src/menu_items.c b/src/menu_items.c index c0ca438a5..5dcf4a314 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -48,6 +48,8 @@ #include "engine/Matrix.h" #include "src/engine/HM_Intro.h" +#include "src/port/interpolation/FrameInterpolation.h" + const char* GetCupName(void); void guMtxCatL(Mtx* m, Mtx* n, Mtx* res); @@ -2216,23 +2218,18 @@ void func_800942D0(void) { s32 i; s32 alpha; -// FrameInterpolation_RecordOpenChild("logo", 0); gSPMatrix(gDisplayListHead++, &gGfxPool->mtxScreen, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPMatrix(gDisplayListHead++, &gGfxPool->mtxLookAt[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); guRotate(mtx, gIntroModelRotX, 1.0f, 0.0f, 0.0f); guRotate(mtx + 1, gIntroModelRotY, 0.0f, 1.0f, 0.0f); guScale(mtx + 2, 1.0f, 1.0f, gIntroModelScale); -// FrameInterpolation_RecordMatrixToMtx(mtx); gSPMatrix(gDisplayListHead++, mtx++, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); -// FrameInterpolation_RecordMatrixToMtx(mtx); gSPMatrix(gDisplayListHead++, mtx++, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); -// FrameInterpolation_RecordMatrixToMtx(mtx); gSPMatrix(gDisplayListHead++, mtx++, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); gDPSetEnvColor(gDisplayListHead++, 0x00, 0x00, 0x00, 0x00); gSPDisplayList(gDisplayListHead++, D_02007F60); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); -// FrameInterpolation_RecordCloseChild(); if (sIntroModelMotionSpeed > 0) { introModelSpeed = sIntroModelSpeed; @@ -2241,22 +2238,16 @@ void func_800942D0(void) { } for (i = 0, alpha = 192; i < 12; i++, alpha -= 16) { -// FrameInterpolation_RecordOpenChild("logo", i + 1); guRotate(mtx, 0.0f, 1.0f, 0.0f, 0.0f); guRotate(mtx + 1, (i + 1) * sIntroModelMotionSpeed * introModelSpeed, 0.0f, 1.0f, 0.0f); guScale(mtx + 2, 1.0f, 1.0f, 2.0f); -// FrameInterpolation_RecordMatrixToMtx(mtx); gSPMatrix(gDisplayListHead++, mtx++, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); -// FrameInterpolation_RecordMatrixToMtx(mtx); gSPMatrix(gDisplayListHead++, mtx++, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); -// FrameInterpolation_RecordMatrixToMtx(mtx); gSPMatrix(gDisplayListHead++, mtx++, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gDPSetRenderMode(gDisplayListHead++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2); gDPSetEnvColor(gDisplayListHead++, 0x00, 0x00, 0x00, alpha); gSPDisplayList(gDisplayListHead++, startup_texture_dl4); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - -// FrameInterpolation_RecordCloseChild(); } } } @@ -2279,7 +2270,7 @@ void render_checkered_flag(struct GfxPool* arg0, UNUSED s32 arg1) { u16 perspNorm; FrameInterpolation_RecordOpenChild("start_flag", 0); - move_segment_table_to_dmem(); + //move_segment_table_to_dmem(); guPerspective(&arg0->mtxPersp[0], &perspNorm, 45.0f, 1.3333334f, 100.0f, 12800.0f, 1.0f); gSPPerspNormalize(gDisplayListHead++, perspNorm); guLookAt(&arg0->mtxLookAt[1], 0.0f, 0.0f, (f32) gIntroModelZEye, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); @@ -2288,19 +2279,12 @@ void render_checkered_flag(struct GfxPool* arg0, UNUSED s32 arg1) { guRotate(&arg0->mtxObject[2], gIntroModelRotZ, 0, 0, 1.0f); guScale(&arg0->mtxObject[3], gIntroModelScale, gIntroModelScale, gIntroModelScale); guTranslate(&arg0->mtxObject[4], gIntroModelPosX, gIntroModelPosY, gIntroModelPosZ); - FrameInterpolation_RecordMatrixToMtx(arg0->mtxPersp[0]); gSPMatrix(gDisplayListHead++, &arg0->mtxPersp[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); - FrameInterpolation_RecordMatrixToMtx(arg0->mtxLookAt[1]); gSPMatrix(gDisplayListHead++, &arg0->mtxLookAt[1], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - FrameInterpolation_RecordMatrixToMtx(arg0->mtxObject[0]); gSPMatrix(gDisplayListHead++, &arg0->mtxObject[0], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - FrameInterpolation_RecordMatrixToMtx(arg0->mtxObject[1]); gSPMatrix(gDisplayListHead++, &arg0->mtxObject[1], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - FrameInterpolation_RecordMatrixToMtx(arg0->mtxObject[2]); gSPMatrix(gDisplayListHead++, &arg0->mtxObject[2], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - FrameInterpolation_RecordMatrixToMtx(arg0->mtxObject[3]); gSPMatrix(gDisplayListHead++, &arg0->mtxObject[3], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); - FrameInterpolation_RecordMatrixToMtx(arg0->mtxObject[4]); gSPMatrix(gDisplayListHead++, &arg0->mtxObject[4], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, D_02007FC8); func_800B0004(); @@ -2725,7 +2709,7 @@ void func_80095AE0(MTX_TYPE* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { } #undef MTX_TYPE - +size_t gTextMatrixCount = 0; Gfx* func_80095BD0(Gfx* displayListHead, u8* arg1, f32 x, f32 y, u32 arg4, u32 arg5, f32 arg6, f32 arg7) { Vtx* var_a1; // A match is a match, but why are goto's required here? @@ -2738,9 +2722,16 @@ Gfx* func_80095BD0(Gfx* displayListHead, u8* arg1, f32 x, f32 y, u32 arg4, u32 a } // func_80095AE0(&gGfxPool->mtxEffect[gMatrixEffectCount], arg2, arg3, arg6, arg7); - FrameInterpolation_RecordOpenChild("flashing_text", ((s32)x) | ((s32)y) | arg4 | arg5); + FrameInterpolation_RecordOpenChild("flashing_text", TAG_LETTER(gTextMatrixCount << 8)); + gTextMatrixCount += 1; Mat4 matrix; - Mtx* mtx = SetTextMatrix(matrix, x, y, arg6, arg7); + SetTextMatrix(matrix, x, y, arg6, arg7); + //AddEffectMatrix(matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + //AddObjectMatrix(matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + Mtx* mtx = GetEffectMatrix(); + FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)matrix, mtx); + guMtxF2L(matrix, mtx); + gSPMatrix(displayListHead++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gMKLoadTextureTile_4b(displayListHead++, arg1, G_IM_FMT_I, arg4, 0, 0, 0, arg4, arg5, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -2758,28 +2749,35 @@ Gfx* func_80095BD0(Gfx* displayListHead, u8* arg1, f32 x, f32 y, u32 arg4, u32 a var_a1 = D_02007DF8; break; } - Gfx* gfx = func_800959F8(displayListHead, var_a1); FrameInterpolation_RecordCloseChild(); - return gfx; + //Gfx* gfx = func_800959F8(displayListHead, var_a1); + return func_800959F8(displayListHead, var_a1); } -Gfx* func_80095BD0_wide_right(Gfx* displayListHead, u8* arg1, f32 arg2, f32 arg3, u32 arg4, u32 arg5, f32 arg6, +size_t gTextMatrixCount_wide_right = 0; +Gfx* func_80095BD0_wide_right(Gfx* displayListHead, u8* arg1, f32 x, f32 y, u32 arg4, u32 arg5, f32 arg6, f32 arg7) { Vtx* var_a1; // A match is a match, but why are goto's required here? if (gMatrixEffectCount >= 0x2F7) { - goto func_80095BD0_label1; + rmonPrintf("MAX effectcount(760) over!!!!(kawano)\n"); + return displayListHead; } if (gMatrixEffectCount < 0) { rmonPrintf("effectcount < 0 !!!!!!(kawano)\n"); } - goto func_80095BD0_label2; -func_80095BD0_label1: - rmonPrintf("MAX effectcount(760) over!!!!(kawano)\n"); - return displayListHead; -func_80095BD0_label2: - func_80095AE0(&gGfxPool->mtxEffect[gMatrixEffectCount], OTRGetDimensionFromRightEdge(arg2), arg3, arg6, arg7); - gSPMatrix(displayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxEffect[gMatrixEffectCount++]), + //func_80095AE0(&gGfxPool->mtxEffect[gMatrixEffectCount], OTRGetDimensionFromRightEdge(arg2), arg3, arg6, arg7); + FrameInterpolation_RecordOpenChild("flashing_text2", gTextMatrixCount_wide_right); + gTextMatrixCount_wide_right += 1; + Mat4 matrix; + SetTextMatrix(matrix, x, y, arg6, arg7); + //AddEffectMatrix(matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + Mtx* mtx = GetEffectMatrix(); + FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)matrix, mtx); + guMtxF2L(matrix, mtx); + + gSPMatrix(displayListHead++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gMKLoadTextureTile_4b(displayListHead++, arg1, G_IM_FMT_I, arg4, 0, 0, 0, arg4, arg5, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); @@ -2797,6 +2795,7 @@ func_80095BD0_label2: var_a1 = D_02007DF8; break; } + FrameInterpolation_RecordCloseChild(); return func_800959F8(displayListHead, var_a1); } diff --git a/src/os/guLookAtF.c b/src/os/guLookAtF.c index 3163b89b4..bebd1b204 100644 --- a/src/os/guLookAtF.c +++ b/src/os/guLookAtF.c @@ -17,6 +17,7 @@ void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, float xAt, fl float yUp, float zUp) { float len, xLook, yLook, zLook, xRight, yRight, zRight; + FrameInterpolation_Record_guLookAt(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp); guMtxIdentF(mf); xLook = xAt - xEye; @@ -74,8 +75,8 @@ void guLookAt(Mtx* m, float xEye, float yEye, float zEye, float xAt, float yAt, float zUp) { float mf[4][4]; + //FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)mf, m); guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp); - - guMtxF2L(mf, m); FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)mf, m); + guMtxF2L(mf, m); } diff --git a/src/os/guOrthoF.c b/src/os/guOrthoF.c index f38376b72..41271223d 100644 --- a/src/os/guOrthoF.c +++ b/src/os/guOrthoF.c @@ -1,8 +1,10 @@ #include "libultra_internal.h" +#include "src/port/interpolation/FrameInterpolation.h" void guOrthoF(float m[4][4], float left, float right, float bottom, float top, float near, float far, float scale) { int row; int col; + FrameInterpolation_Record_guOrtho(m, left, right, bottom, top, near, far, scale); guMtxIdentF(m); m[0][0] = 2 / (right - left); m[1][1] = 2 / (top - bottom); @@ -19,7 +21,8 @@ void guOrthoF(float m[4][4], float left, float right, float bottom, float top, f } void guOrtho(Mtx* m, float left, float right, float bottom, float top, float near, float far, float scale) { - float sp28[4][4]; - guOrthoF(sp28, left, right, bottom, top, near, far, scale); - guMtxF2L(sp28, m); + float mtxF[4][4]; + guOrthoF(mtxF, left, right, bottom, top, near, far, scale); + FrameInterpolation_RecordMatrixMtxFToMtx(mtxF, m); + guMtxF2L(mtxF, m); } diff --git a/src/os/guPerspectiveF.c b/src/os/guPerspectiveF.c index fc65c6e80..745432c35 100644 --- a/src/os/guPerspectiveF.c +++ b/src/os/guPerspectiveF.c @@ -36,7 +36,8 @@ void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, fl void guPerspective(Mtx* m, u16* perspNorm, float fovy, float aspect, float near, float far, float scale) { float mat[4][4]; + //FrameInterpolation_Record_guPerspective(mat, perspNorm, fovy, aspect, near, far, scale); guPerspectiveF(mat, perspNorm, fovy, aspect, near, far, scale); - guMtxF2L(mat, m); FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)mat, m); + guMtxF2L(mat, m); } diff --git a/src/os/guRotateF.c b/src/os/guRotateF.c index 0bdfad841..a731c94ad 100644 --- a/src/os/guRotateF.c +++ b/src/os/guRotateF.c @@ -39,7 +39,7 @@ void guRotateF(float m[4][4], float a, float x, float y, float z) { void guRotate(Mtx* m, float a, float x, float y, float z) { float mf[4][4]; guRotateF(mf, a, x, y, z); - FrameInterpolation_Record_guRotate(mf, a, x, y, z); + //FrameInterpolation_Record_guRotate(mf, a, x, y, z); FrameInterpolation_RecordMatrixMtxFToMtx(mf, m); guMtxF2L(mf, m); } diff --git a/src/os/guScaleF.c b/src/os/guScaleF.c index 51aa4dfa4..f8334889e 100644 --- a/src/os/guScaleF.c +++ b/src/os/guScaleF.c @@ -12,7 +12,7 @@ void guScaleF(float mf[4][4], float x, float y, float z) { void guScale(Mtx* m, float x, float y, float z) { float mf[4][4]; guScaleF(mf, x, y, z); - FrameInterpolation_Record_guScale(mf, x, y, z); + //FrameInterpolation_Record_guScale(mf, x, y, z); FrameInterpolation_RecordMatrixMtxFToMtx(mf, m); guMtxF2L(mf, m); } diff --git a/src/os/guTranslateF.c b/src/os/guTranslateF.c index d54af9165..f021087f9 100644 --- a/src/os/guTranslateF.c +++ b/src/os/guTranslateF.c @@ -1,4 +1,5 @@ #include "libultra_internal.h" +#include "src/port/interpolation/FrameInterpolation.h" void guTranslateF(float m[4][4], float x, float y, float z) { guMtxIdentF(m); @@ -10,5 +11,7 @@ void guTranslateF(float m[4][4], float x, float y, float z) { void guTranslate(Mtx* m, float x, float y, float z) { float mf[4][4]; guTranslateF(mf, x, y, z); + //FrameInterpolation_RecordMatrixTranslate(m, (Vec3f){x, y, z}); + FrameInterpolation_RecordMatrixMtxFToMtx(mf, m); guMtxF2L(mf, m); } diff --git a/src/port/interpolation/FrameInterpolation.cpp b/src/port/interpolation/FrameInterpolation.cpp index c1f4a67b6..29a788046 100644 --- a/src/port/interpolation/FrameInterpolation.cpp +++ b/src/port/interpolation/FrameInterpolation.cpp @@ -49,6 +49,10 @@ given a specific interpolation factor (0=old frame, 0.5=average of frames, 1.0=new frame). */ +// These are defined in windows +#undef far +#undef near + static bool invert_matrix(const float m[16], float invOut[16]); using namespace std; @@ -85,7 +89,11 @@ enum class Op { SetTranslateRotate, guRotate, guScale, + guOrtho, SetTextMatrix, + guTranslate, + guPersp, + guLookAt, }; typedef pair label; @@ -119,6 +127,29 @@ union Data { f32 scale; } matrix_scale; + struct { + Mat4* matrix; + u16* perspNorm; + f32 fovy; + f32 aspect; + f32 near; + f32 far; + f32 scale; + } matrix_gu_persp; + + struct { + Mat4* matrix; + f32 xEye; + f32 yEye; + f32 zEye; + f32 xAt; + f32 yAt; + f32 zAt; + f32 xUp; + f32 yUp; + f32 zUp; + } matrix_gu_lookAt; + struct { Mat4* matrix; f32 a; @@ -127,6 +158,17 @@ union Data { f32 z; } matrix_gu_rotate; + struct { + Mat4* matrix; + f32 left; + f32 right; + f32 bottom; + f32 top; + f32 near; + f32 far; + f32 scale; + } matrix_gu_ortho; + struct { Mat4* matrix; f32 x; @@ -280,7 +322,7 @@ struct InterpolateCtx { unordered_map mtx_replacements; MtxF tmp_mtxf, tmp_mtxf2; Mat3 tmp_mat3; - Vec3f tmp_vec3f, tmp_vec3f2; + Vec3f tmp_vec3f, tmp_vec3f2, tmp_vec3f3; Vec3s tmp_vec3s; MtxF actor_mtx; @@ -561,6 +603,36 @@ struct InterpolateCtx { mtxf_translate_rotate(*gInterpolationMatrix, tmp_vec3f, tmp_vec3s); break; } + case Op::guPersp: { + + tmp_vec3f[0] = lerp(old_op.matrix_gu_persp.fovy, new_op.matrix_gu_persp.fovy); + tmp_vec3f[1] = lerp(old_op.matrix_gu_persp.aspect, new_op.matrix_gu_persp.aspect); + tmp_vec3f[2] = lerp(old_op.matrix_gu_persp.near, new_op.matrix_gu_persp.near); + tmp_vec3f2[0] = lerp(old_op.matrix_gu_persp.far, new_op.matrix_gu_persp.far); + tmp_vec3f2[1] = lerp(old_op.matrix_gu_persp.scale, new_op.matrix_gu_persp.scale); + + tmp_vec3s[0] = *old_op.matrix_gu_persp.perspNorm; + + guPerspectiveF(*gInterpolationMatrix, (uint16_t*)&tmp_vec3s[0], tmp_vec3f[0], tmp_vec3f[1], tmp_vec3f[2], tmp_vec3f2[0], tmp_vec3f2[1]); + break; + } + case Op::guLookAt: { + + tmp_vec3f[0] = lerp(old_op.matrix_gu_lookAt.xEye, new_op.matrix_gu_lookAt.xEye); + tmp_vec3f[1] = lerp(old_op.matrix_gu_lookAt.yEye, new_op.matrix_gu_lookAt.yEye); + tmp_vec3f[2] = lerp(old_op.matrix_gu_lookAt.zEye, new_op.matrix_gu_lookAt.zEye); + + tmp_vec3f2[0] = lerp(old_op.matrix_gu_lookAt.xAt, new_op.matrix_gu_lookAt.xAt); + tmp_vec3f2[1] = lerp(old_op.matrix_gu_lookAt.yAt, new_op.matrix_gu_lookAt.yAt); + tmp_vec3f2[2] = lerp(old_op.matrix_gu_lookAt.zAt, new_op.matrix_gu_lookAt.zAt); + + tmp_vec3f3[0] = lerp(old_op.matrix_gu_lookAt.xUp, new_op.matrix_gu_lookAt.xUp); + tmp_vec3f3[1] = lerp(old_op.matrix_gu_lookAt.yUp, new_op.matrix_gu_lookAt.yUp); + tmp_vec3f3[2] = lerp(old_op.matrix_gu_lookAt.zUp, new_op.matrix_gu_lookAt.zUp); + + guLookAtF(*gInterpolationMatrix, tmp_vec3f[0], tmp_vec3f[1], tmp_vec3f[2], tmp_vec3f2[0], tmp_vec3f2[1], tmp_vec3f2[2], tmp_vec3f3[0], tmp_vec3f3[1], tmp_vec3f3[2]); + break; + } case Op::guRotate: { tmp_f = lerp(old_op.matrix_gu_rotate.a, new_op.matrix_gu_rotate.a); @@ -578,6 +650,20 @@ struct InterpolateCtx { guScaleF(*gInterpolationMatrix, tmp_vec3f[0], tmp_vec3f[1], tmp_vec3f[2]); break; } + case Op::guOrtho: { + tmp_vec3f[0] = lerp(old_op.matrix_gu_ortho.left, new_op.matrix_gu_ortho.left); + tmp_vec3f[1] = lerp(old_op.matrix_gu_ortho.right, new_op.matrix_gu_ortho.right); + tmp_vec3f[2] = lerp(old_op.matrix_gu_ortho.bottom, new_op.matrix_gu_ortho.bottom); + + tmp_vec3f2[0] = lerp(old_op.matrix_gu_ortho.top, new_op.matrix_gu_ortho.top); + tmp_vec3f2[1] = lerp(old_op.matrix_gu_ortho.near, new_op.matrix_gu_ortho.near); + tmp_vec3f2[2] = lerp(old_op.matrix_gu_ortho.far, new_op.matrix_gu_ortho.far); + + tmp_f = lerp(old_op.matrix_gu_ortho.scale, new_op.matrix_gu_ortho.scale); + + guOrthoF(*gInterpolationMatrix, tmp_vec3f[0], tmp_vec3f[1], tmp_vec3f[2], tmp_vec3f2[0], tmp_vec3f2[1], tmp_vec3f2[2], tmp_f); + break; + } case Op::SetTextMatrix: { tmp_vec3f[0] = lerp(old_op.matrix_text.x, new_op.matrix_text.x); @@ -711,6 +797,18 @@ void FrameInterpolation_RecordMatrixScale(Mat4* matrix, f32 scale) { append(Op::MatrixScale).matrix_scale = { matrix, scale }; } +void FrameInterpolation_Record_guPerspective(Mat4* matrix, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale) { + if (!is_recording) + return; + append(Op::guPersp).matrix_gu_persp = {matrix, perspNorm, fovy, aspect, near, far, scale}; +} + +void FrameInterpolation_Record_guLookAt(Mat4* matrix, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp) { + if (!is_recording) + return; + append(Op::guLookAt).matrix_gu_lookAt = {matrix, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp}; +} + void FrameInterpolation_Record_guRotate(Mat4* matrix, f32 a, f32 x, f32 y, f32 z) { if (!is_recording) return; @@ -723,6 +821,12 @@ void FrameInterpolation_Record_guScale(Mat4* matrix, f32 x, f32 y, f32 z) { append(Op::guScale).matrix_scale_xyz = {matrix, x, y, z}; } +void FrameInterpolation_Record_guOrtho(Mat4* matrix, f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far, f32 scale) { + if (!is_recording) + return; + append(Op::guOrtho).matrix_gu_ortho = {matrix, left, right, bottom, top, near, far, scale}; +} + void FrameInterpolation_Record_SetTextMatrix(Mat4* matrix, f32 x, f32 y, f32 arg3, f32 arg4) { if (!is_recording) return; diff --git a/src/port/interpolation/FrameInterpolation.h b/src/port/interpolation/FrameInterpolation.h index 742dec470..aaf977600 100644 --- a/src/port/interpolation/FrameInterpolation.h +++ b/src/port/interpolation/FrameInterpolation.h @@ -51,10 +51,16 @@ void FrameInterpolation_RecordMatrixTranslate(Mat4* matrix, Vec3f b); void FrameInterpolation_RecordMatrixScale(Mat4* matrix, f32 scale); +void FrameInterpolation_Record_guPerspective(Mat4* matrix, u16* perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); + +void FrameInterpolation_Record_guLookAt(Mat4* matrix, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp); + void FrameInterpolation_Record_guRotate(Mat4* matrix, f32 a, f32 x, f32 y, f32 z); void FrameInterpolation_Record_guScale(Mat4* matrix, f32 x, f32 y, f32 z); +void FrameInterpolation_Record_guOrtho(Mat4* matrix, f32 left, f32 right, f32 bottom, f32 top, f32 near, f32 far, f32 scale); + void FrameInterpolation_Record_SetTextMatrix(Mat4* matrix, f32 x, f32 y, f32 arg3, f32 arg4); void FrameInterpolation_RecordMatrixRotate1Coord(Mat4* matrix, u32 coord, s16 value);