From 856de341ad35f03e36c45964a30a4c95f36f8098 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 6 Sep 2024 13:41:06 +0200 Subject: [PATCH 1/3] add sys_matrix.h, based on MM's --- include/functions.h | 37 +---------------------- include/sys_matrix.h | 72 ++++++++++++++++++++++++++++++++++++++++++++ include/variables.h | 2 -- include/z64.h | 6 +--- 4 files changed, 74 insertions(+), 43 deletions(-) create mode 100644 include/sys_matrix.h diff --git a/include/functions.h b/include/functions.h index a0156d314d1..79083ff4451 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1272,42 +1272,7 @@ void* SysCfb_GetFbEnd(void); void Math3D_DrawSphere(PlayState* play, Sphere16* sph); void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl); -void Matrix_Init(GameState* gameState); -void Matrix_Push(void); -void Matrix_Pop(void); -void Matrix_Get(MtxF* dest); -void Matrix_Put(MtxF* src); -void Matrix_Mult(MtxF* mf, u8 mode); -void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode); -void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode); -void Matrix_RotateX(f32 x, u8 mode); -void Matrix_RotateY(f32 y, u8 mode); -void Matrix_RotateZ(f32 z, u8 mode); -void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); -void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation); -void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot); -Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); -#if OOT_DEBUG -Mtx* Matrix_ToMtx(Mtx* dest, const char* file, int line); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, const char* file, int line); -#else -Mtx* Matrix_ToMtx(Mtx* dest); -Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx); -#endif -void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); -void Matrix_MtxFCopy(MtxF* dest, MtxF* src); -void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); -void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); -void Matrix_Transpose(MtxF* mf); -void Matrix_ReplaceRotation(MtxF* mf); -void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag); -void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag); -void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode); -#if OOT_DEBUG -MtxF* Matrix_CheckFloats(MtxF* mf, const char* file, int line); -#endif -void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, - f32 translateZ); + u64* SysUcode_GetUCodeBoot(void); size_t SysUcode_GetUCodeBootSize(void); u64* SysUcode_GetUCode(void); diff --git a/include/sys_matrix.h b/include/sys_matrix.h new file mode 100644 index 00000000000..5b8b473ad77 --- /dev/null +++ b/include/sys_matrix.h @@ -0,0 +1,72 @@ +#ifndef SYS_MATRIX_H +#define SYS_MATRIX_H + +#include "z64math.h" + +struct GraphicsContext; +struct GameState; + +typedef enum MatrixMode { + /* 0 */ MTXMODE_NEW, // generates a new matrix + /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix +} MatrixMode; + +extern Mtx gMtxClear; +extern MtxF gMtxFClear; + +/* Stack operations */ + +void Matrix_Init(struct GameState* gameState); +void Matrix_Push(void); +void Matrix_Pop(void); +void Matrix_Get(MtxF* dest); +void Matrix_Put(MtxF* src); + +/* Basic operations */ + +void Matrix_Mult(MtxF* mf, u8 mode); +void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode); +void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode); +void Matrix_RotateX(f32 x, u8 mode); +void Matrix_RotateY(f32 y, u8 mode); +void Matrix_RotateZ(f32 z, u8 mode); + +/* Compound operations */ + +void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode); +void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation); +void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot); +void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, + f32 translateZ); + +/* Conversion and allocation operations */ + +Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); +#if OOT_DEBUG +Mtx* Matrix_ToMtx(Mtx* dest, const char* file, int line); +Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx, const char* file, int line); +MtxF* Matrix_CheckFloats(MtxF* mf, const char* file, int line); +#else +Mtx* Matrix_ToMtx(Mtx* dest); +Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx); +#endif + +/* Vector operations */ + +void Matrix_MultVec3f(Vec3f* src, Vec3f* dest); +void Matrix_MultVec3fExt(Vec3f* src, Vec3f* dest, MtxF* mf); + +/* Copy and another conversion */ + +void Matrix_MtxFCopy(MtxF* dest, MtxF* src); +void Matrix_MtxToMtxF(Mtx* src, MtxF* dest); + +/* Miscellaneous */ + +void Matrix_Transpose(MtxF* mf); +void Matrix_ReplaceRotation(MtxF* mf); +void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag); +void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag); +void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode); + +#endif diff --git a/include/variables.h b/include/variables.h index fa09f0f54f1..9f966adee4e 100644 --- a/include/variables.h +++ b/include/variables.h @@ -104,8 +104,6 @@ extern u8 gBossMarkState; extern s32 gScreenWidth; extern s32 gScreenHeight; -extern Mtx gMtxClear; -extern MtxF gMtxFClear; #if OOT_DEBUG extern u32 gIsCtrlr2Valid; #endif diff --git a/include/z64.h b/include/z64.h index 0ee9f4f0808..7a6187a485b 100644 --- a/include/z64.h +++ b/include/z64.h @@ -66,6 +66,7 @@ #include "sys_math.h" #include "sys_math3d.h" #include "fp_math.h" +#include "sys_matrix.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -390,11 +391,6 @@ typedef struct DebugDispObject { /* 0x28 */ struct DebugDispObject* next; } DebugDispObject; // size = 0x2C -typedef enum MatrixMode { - /* 0 */ MTXMODE_NEW, // generates a new matrix - /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix -} MatrixMode; - typedef struct StackEntry { /* 0x00 */ struct StackEntry* next; /* 0x04 */ struct StackEntry* prev; From 7ff44faf587ab580b4bd349cde1cf8b69714a60d Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 6 Sep 2024 13:41:34 +0200 Subject: [PATCH 2/3] move matrix debug macros to sys_matrix.h --- include/macros.h | 6 ------ include/sys_matrix.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/macros.h b/include/macros.h index 50f8330282d..dab193146d2 100644 --- a/include/macros.h +++ b/include/macros.h @@ -189,9 +189,6 @@ extern struct GraphicsContext* __gfxCtx; (void)0 #define GRAPH_ALLOC(gfxCtx, size) Graph_Alloc(gfxCtx, size) -#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx, file, line) -#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx, file, line) -#define MATRIX_CHECK_FLOATS(mtx, file, line) Matrix_CheckFloats(mtx, file, line) #define DMA_REQUEST_SYNC(ram, vrom, size, file, line) DmaMgr_RequestSyncDebug(ram, vrom, size, file, line) #define DMA_REQUEST_ASYNC(req, ram, vrom, size, unk5, queue, msg, file, line) DmaMgr_RequestAsyncDebug(req, ram, vrom, size, unk5, queue, msg, file, line) #define GAME_STATE_ALLOC(gameState, size, file, line) GameState_Alloc(gameState, size, file, line) @@ -221,9 +218,6 @@ extern struct GraphicsContext* __gfxCtx; (void)0 #define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) -#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx) -#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx) -#define MATRIX_CHECK_FLOATS(mtx, file, line) (mtx) #define DMA_REQUEST_SYNC(ram, vrom, size, file, line) DmaMgr_RequestSync(ram, vrom, size) #define DMA_REQUEST_ASYNC(req, ram, vrom, size, unk5, queue, msg, file, line) DmaMgr_RequestAsync(req, ram, vrom, size, unk5, queue, msg) #define GAME_STATE_ALLOC(gameState, size, file, line) THA_AllocTailAlign16(&(gameState)->tha, size) diff --git a/include/sys_matrix.h b/include/sys_matrix.h index 5b8b473ad77..91a2285d775 100644 --- a/include/sys_matrix.h +++ b/include/sys_matrix.h @@ -42,13 +42,26 @@ void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, /* Conversion and allocation operations */ Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); + #if OOT_DEBUG + Mtx* Matrix_ToMtx(Mtx* dest, const char* file, int line); Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx, const char* file, int line); MtxF* Matrix_CheckFloats(MtxF* mf, const char* file, int line); + +#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx, file, line) +#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx, file, line) +#define MATRIX_CHECK_FLOATS(mtx, file, line) Matrix_CheckFloats(mtx, file, line) + #else + Mtx* Matrix_ToMtx(Mtx* dest); Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx); + +#define MATRIX_TO_MTX(gfxCtx, file, line) Matrix_ToMtx(gfxCtx) +#define MATRIX_NEW(gfxCtx, file, line) Matrix_NewMtx(gfxCtx) +#define MATRIX_CHECK_FLOATS(mtx, file, line) (mtx) + #endif /* Vector operations */ From af9788d78ddeab599c18d460b26656889362af35 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Fri, 6 Sep 2024 15:26:11 +0200 Subject: [PATCH 3/3] bss --- src/overlays/actors/ovl_Fishing/z_fishing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 802ed831abd..bc45197ab2f 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -14,7 +14,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:157 gc-eu-mq:157 gc-jp:159 gc-jp-ce:159 gc-jp-mq:159 gc-us:159 gc-us-mq:159" +#pragma increment_block_number "gc-eu:156 gc-eu-mq:156 gc-jp:158 gc-jp-ce:158 gc-jp-mq:158 gc-us:158 gc-us-mq:158" #define FLAGS ACTOR_FLAG_4