From 528871010a60a54b0539b0534ebe2977173aa5db Mon Sep 17 00:00:00 2001 From: MegaMech <7255464+MegaMech@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:30:09 -0700 Subject: [PATCH] Fix minimap karts --- src/math_util_2.c | 17 ++++++++++++++++- src/math_util_2.h | 1 + src/render_objects.c | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/math_util_2.c b/src/math_util_2.c index 33565e412..d378d9e42 100644 --- a/src/math_util_2.c +++ b/src/math_util_2.c @@ -722,7 +722,22 @@ void func_80042330_default(s32 x, s32 y, u16 angle, f32 scale) { Mat4 matrix; //printf("panel %d %d %d\n", x, (s32)OTRGetDimensionFromLeftEdge(x), (s32)OTRGetDimensionFromLeftEdge(0)); - printf("X %d Y %d\n", x, y); + mtxf_translation_x_y_rotate_z_scale_x_y(matrix, x, y, angle, scale); + // convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], matrix); + // gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxHud[gMatrixHudCount++]), + // G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + AddHudMatrix(matrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); +} + +// Centers in an area of the screen for 3P mode +void func_80042330_3P(s32 x, s32 y, u16 angle, f32 scale) { + Mat4 matrix; + + s32 offset = ((OTRGetDimensionFromRightEdge(SCREEN_WIDTH) - SCREEN_WIDTH) / 2); + // + 5 is just an alignment guess. + x += offset + 5; + mtxf_translation_x_y_rotate_z_scale_x_y(matrix, x, y, angle, scale); // convert_to_fixed_point_matrix(&gGfxPool->mtxHud[gMatrixHudCount], matrix); // gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxHud[gMatrixHudCount++]), diff --git a/src/math_util_2.h b/src/math_util_2.h index 842e417bd..c51b25066 100644 --- a/src/math_util_2.h +++ b/src/math_util_2.h @@ -71,6 +71,7 @@ void func_80041D34(void); void set_matrix_hud_screen(void); void func_80042330(s32, s32, u16, f32); void func_80042330_default(s32 x, s32 y, u16 angle, f32 scale); +void func_80042330_3P(s32 x, s32 y, u16 angle, f32 scale); void func_80042330_portrait(s32, s32, u16, f32, s16); void func_80042330_wide(s32, s32, u16, f32); void mtxf_set_matrix_transformation(Mat4, Vec3f, Vec3su, f32); diff --git a/src/render_objects.c b/src/render_objects.c index a97bef7fb..6044ba065 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -510,14 +510,43 @@ void func_800462A8(u8* texture, Vtx* arg1, s32 width, s32 arg3, s32 height) { void func_800463B0(s32 arg0, s32 arg1, u16 arg2, f32 arg3, u8* texture, Vtx* arg5, s32 arg6, s32 arg7, UNUSED s32 arg8, s32 arg9) { - func_80042330(arg0, arg1, arg2, arg3); + + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + func_80042330(arg0, arg1, arg2, arg3); + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + if (gPlayerCount == 3) { + func_80042330_3P(arg0, arg1, arg2, arg3); + } else { + func_80042330_default(arg0, arg1, arg2, arg3); + } + break; + } + gSPDisplayList(gDisplayListHead++, D_0D007928); func_80045D0C(texture, arg5, arg6, arg7, arg9); } void func_80046424(s32 arg0, s32 arg1, u16 arg2, f32 arg3, u8* texture, Vtx* arg5, s32 arg6, s32 arg7, UNUSED s32 arg8, s32 arg9) { - func_80042330(arg0, arg1, arg2, arg3); + switch(gScreenModeSelection) { + case SCREEN_MODE_1P: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + func_80042330(arg0, arg1, arg2, arg3); + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + if (gPlayerCount == 3) { + func_80042330_3P(arg0, arg1, arg2, arg3); + } else { + func_80042330_default(arg0, arg1, arg2, arg3); + } + break; + } + gSPDisplayList(gDisplayListHead++, D_0D007968); func_8004B614(D_801656C0, D_801656D0, D_801656E0, 128, 128, 128, 255); func_80045D0C(texture, arg5, arg6, arg7, arg9); @@ -1611,9 +1640,6 @@ void render_texture_rectangle_wide(s32 x, s32 y, s32 width, s32 height, s32 arg4 gSPTextureRectangle(gDisplayListHead++, xl << 2, yl, xh << 2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, 1 << 10); break; - case 999: - gSPTextureRectangle(gDisplayListHead++, xl << 2, yl, xh << 2, yh2, G_TX_RENDERTILE, arg4 << 5, (arg5 << 5), 1 << 10, - 1 << 10); break; } //OTRGetDimensionFromLeftEdge