summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoco875 <59367621+coco875@users.noreply.github.com>2025-02-07 22:30:36 +0100
committerGitHub <noreply@github.com>2025-02-07 14:30:36 -0700
commit6f8cbc0279004a39635c922b824e8561f5355bc5 (patch)
tree29d8a03c17fa458f329dac7ea58e59eb8b68164d
parent8e0e95d7d16e1d3e362b8e7eeef5fc8ff386150d (diff)
fix a matrix (#185)
* fix a matrix * remove LOAD_ASSET
-rw-r--r--src/enhancements/collision_viewer.c3
-rw-r--r--src/gbiMacro.c4
-rw-r--r--src/racing/framebuffer_effects.c5
-rw-r--r--src/racing/math_util.c4
-rw-r--r--src/racing/math_util.h1
-rw-r--r--src/racing/skybox_and_splitscreen.c9
6 files changed, 18 insertions, 8 deletions
diff --git a/src/enhancements/collision_viewer.c b/src/enhancements/collision_viewer.c
index 577cdd9cf..fd7c542e0 100644
--- a/src/enhancements/collision_viewer.c
+++ b/src/enhancements/collision_viewer.c
@@ -6,6 +6,7 @@
#include "main.h"
#include "collision_viewer.h"
+#include "math_util.h"
#include "assets/other_textures.h"
#include "assets/common_data.h"
@@ -25,7 +26,7 @@ void render_collision(void) {
gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE);
// Set matrix
- gSPMatrix(gDisplayListHead++, LOAD_ASSET(D_0D008E98), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
+ gSPMatrix(gDisplayListHead++, &gIdentityMatrix, G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
for (size_t i = 0; i < gCollisionMeshCount; i++) {
// Load vertices for this tri
diff --git a/src/gbiMacro.c b/src/gbiMacro.c
index b215c9cfe..5fa0ab171 100644
--- a/src/gbiMacro.c
+++ b/src/gbiMacro.c
@@ -4,6 +4,8 @@
#include <mk64.h>
#include <assets/common_data.h>
+#include "math_util.h"
+
extern s16 D_800E43A8;
// rsp init
@@ -16,5 +18,5 @@ UNUSED void gfx_func_80040D00(void) {
guOrtho(&gGfxPool->mtxScreen, 0.0f, SCREEN_WIDTH, 0.0f, SCREEN_HEIGHT, -1.0f, 1.0f, 1.0f);
gSPPerspNormalize(gDisplayListHead++, 0xFFFF);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(gGfxPool), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
- gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(D_0D008E98), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gIdentityMatrix), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
}
diff --git a/src/racing/framebuffer_effects.c b/src/racing/framebuffer_effects.c
index 5e6fd394f..4406ca787 100644
--- a/src/racing/framebuffer_effects.c
+++ b/src/racing/framebuffer_effects.c
@@ -3,6 +3,7 @@
#include "mk64.h"
#include <assets/common_data.h>
#include "port/Engine.h"
+#include "math_util.h"
#include <stdio.h>
int gfx_create_framebuffer(uint32_t width, uint32_t height, uint32_t native_width, uint32_t native_height,
@@ -36,7 +37,7 @@ void FB_CreateFramebuffers(void) {
void FB_CopyToFramebuffer(Gfx** gfxP, s32 fb_src, s32 fb_dest, u8 oncePerFrame, u8* hasCopied) {
Gfx* gfx = *gfxP;
- gSPMatrix(gfx++, LOAD_ASSET(D_0D008E98), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(gfx++, &gIdentityMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gDPSetOtherMode(gfx++,
G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE |
@@ -110,7 +111,7 @@ void FB_WriteFramebufferSliceToCPU(Gfx** gfxP, void* buffer, u8 byteSwap) {
void FB_DrawFromFramebuffer(Gfx** gfxP, s32 fb, u8 alpha) {
Gfx* gfx = *gfxP;
- gSPMatrix(gfx++, LOAD_ASSET(D_0D008E98), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(gfx++, &gIdentityMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gDPSetEnvColor(gfx++, 255, 255, 255, alpha);
diff --git a/src/racing/math_util.c b/src/racing/math_util.c
index 54b6aa412..1e9241528 100644
--- a/src/racing/math_util.c
+++ b/src/racing/math_util.c
@@ -14,6 +14,10 @@
s32 D_802B91C0[2] = { 13, 13 };
Vec3f D_802B91C8 = { 0.0f, 0.0f, 0.0f };
+Mtx gIdentityMatrix = {
+ toFixedPointMatrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0),
+};
+
// This functions looks similar to a segment of code from func_802A4A0C in skybox_and_splitscreen.c
UNUSED s32 func_802B4F60(UNUSED s32 arg0, Vec3f arg1, UNUSED s32 arg2, UNUSED f32 arg3, UNUSED f32 arg4) {
Mat4 sp30;
diff --git a/src/racing/math_util.h b/src/racing/math_util.h
index 71a203b62..bd4ce5759 100644
--- a/src/racing/math_util.h
+++ b/src/racing/math_util.h
@@ -70,5 +70,6 @@ f32 is_within_render_distance(Vec3f, Vec3f, u16, f32, f32, f32);
extern s32 D_802B91C0[];
extern Vec3f D_802B91C8;
+extern Mtx gIdentityMatrix;
#endif // MATH_UTIL_H
diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c
index 916a97e23..d0d52f77e 100644
--- a/src/racing/skybox_and_splitscreen.c
+++ b/src/racing/skybox_and_splitscreen.c
@@ -20,6 +20,7 @@
#include "port/Engine.h"
#include "engine/courses/Course.h"
#include "port/Game.h"
+#include "math_util.h"
Vp D_802B8880[] = {
{ { { 640, 480, 511, 0 }, { 640, 480, 511, 0 } } },
@@ -408,7 +409,7 @@ void func_802A487C(Vtx* arg0, UNUSED struct UnkStruct_800DC5EC* arg1, UNUSED s32
gSPPerspNormalize(gDisplayListHead++, 0xFFFF);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxScreen),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
- gSPMatrix(gDisplayListHead++, LOAD_ASSET(D_0D008E98), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(gDisplayListHead++, &gIdentityMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPVertex(gDisplayListHead++, &arg0[4], 4, 0);
gSP2Triangles(gDisplayListHead++, 0, 3, 1, 0, 1, 3, 2, 0);
}
@@ -444,8 +445,8 @@ void func_802A4A0C(Vtx* vtx, struct UnkStruct_800DC5EC* arg1, UNUSED s32 arg2, U
sp5C[0] = 0.0f;
sp5C[1] = 0.0f;
sp5C[2] = 30000.0f;
- func_802B5564(matrix1, &sp128, camera->unk_B4, gScreenAspect, CM_GetProps()->NearPersp,
- CM_GetProps()->FarPersp, 1.0f);
+ func_802B5564(matrix1, &sp128, camera->unk_B4, gScreenAspect, CM_GetProps()->NearPersp, CM_GetProps()->FarPersp,
+ 1.0f);
func_802B5794(matrix2, camera->pos, camera->lookAt);
mtxf_multiplication(matrix3, matrix1, matrix2);
@@ -475,7 +476,7 @@ void func_802A4A0C(Vtx* vtx, struct UnkStruct_800DC5EC* arg1, UNUSED s32 arg2, U
gSPPerspNormalize(gDisplayListHead++, 0xFFFF);
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxScreen),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
- gSPMatrix(gDisplayListHead++, LOAD_ASSET(D_0D008E98), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(gDisplayListHead++, &gIdentityMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPVertex(gDisplayListHead++, &vtx[0], 4, 0);
gSP2Triangles(gDisplayListHead++, 0, 3, 1, 0, 1, 3, 2, 0);
if (GetCourse() == GetRainbowRoad()) {