From 9fe391a2a4617cdb6ce3b2ab743183756f2ca9bd Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 15 Jun 2025 22:17:24 -0600 Subject: Fix More Interpolation (#220) * Fix SetTextMatrix Interpolation (flashing text) * Interpolate pause menu item box * Interp mtxf_translation_x_y_rotate_z_scale_x_y * Fix billboarding for freecam * Fix menus battle mode back to grand prix bug * Fix snow interp * interp star clouds --- src/engine/Matrix.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/engine/Matrix.cpp') diff --git a/src/engine/Matrix.cpp b/src/engine/Matrix.cpp index 671489413..b55a9b89f 100644 --- a/src/engine/Matrix.cpp +++ b/src/engine/Matrix.cpp @@ -35,8 +35,8 @@ void AddMatrixFixed(std::vector& stack, s32 flags) { } // Used in func_80095BD0 -Mtx* SetTextMatrix(f32 arg1, f32 arg2, f32 arg3, f32 arg4) { - Mat4 mf; +void SetTextMatrix(Mat4 mf, f32 x, f32 y, f32 arg3, f32 arg4) { + FrameInterpolation_Record_SetTextMatrix((Mat4*)&mf, x, y, arg3, arg4); mf[0][0] = arg3; mf[0][1] = 0.0f; mf[0][2] = 0.0f; @@ -49,15 +49,25 @@ Mtx* SetTextMatrix(f32 arg1, f32 arg2, f32 arg3, f32 arg4) { mf[2][1] = 0.0f; mf[2][2] = 1.0f; mf[2][3] = 0.0f; - mf[3][0] = arg1; - mf[3][1] = arg2; + mf[3][0] = x; + mf[3][1] = y; mf[3][2] = 0.0f; mf[3][3] = 1.0f; - Mtx* mtx = GetMatrix(gWorldInstance.Mtx.Effects); - FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)mf, mtx); - guMtxF2L(mf, mtx); +} + +// AddMatrix but with custom gfx ptr arg and flags are predefined +Gfx* AddTextMatrix(Gfx* displayListHead, Mat4 mtx) { + // Push a new matrix to the stack + gWorldInstance.Mtx.Effects.emplace_back(); + + // Convert to a fixed-point matrix + FrameInterpolation_RecordMatrixMtxFToMtx((MtxF*)mtx, &gWorldInstance.Mtx.Effects.back()); + guMtxF2L(mtx, &gWorldInstance.Mtx.Effects.back()); + + // Load the matrix + gSPMatrix(displayListHead++, &gWorldInstance.Mtx.Effects.back(), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - return mtx; + return displayListHead; } void ApplyMatrixTransformations(Mat4 mtx, FVector pos, IRotator rot, FVector scale) { -- cgit v1.2.3