From e2e880691dd43f3ac1158827a3cd4ceaf828461e Mon Sep 17 00:00:00 2001 From: HailSanta Date: Sun, 16 Jul 2023 14:55:23 -0400 Subject: [PATCH] RDP_MATRIX macro --- include/macros.h | 39 ++++++++++++++++++++++ src/draw_box.c | 26 ++++----------- src/entity/Chest.c | 4 +-- src/entity/model/ArrowSign.c | 18 ++++------ src/entity/model/BlueSwitch.c | 36 +++++++------------- src/entity/model/BlueWarpPipe.c | 18 ++++------ src/entity/model/Chest.c | 18 ++++------ src/entity/model/CymbalPlant_gfx.c | 52 +++++++++++------------------ src/entity/model/GreenStompSwitch.c | 18 ++++------ src/entity/model/Padlock.c | 18 ++++------ src/entity/model/PadlockBlueFace.c | 18 ++++------ src/entity/model/PadlockRedFace.c | 18 ++++------ src/entity/model/PadlockRedFrame.c | 18 ++++------ src/entity/model/PinkFlower_gfx.c | 18 ++++------ src/entity/model/PowBlock.c | 18 ++++------ src/entity/model/PushBlock.c | 18 ++++------ src/entity/model/RedSwitch.c | 37 ++++++++------------ src/entity/model/SaveBlock.c | 18 ++++------ src/entity/model/SpinningFlower.c | 18 ++++------ src/entity/model/StarBoxLauncher.c | 18 ++++------ src/entity/model/SuperBlock.c | 18 ++++------ src/entity/model/Tweester.c | 36 +++++++------------- src/entity/model/UltraBlock.c | 18 ++++------ src/entity/model/UnusedBlock.c | 18 ++++------ src/main_loop.c | 20 ++++------- src/model.c | 20 ++++------- 26 files changed, 218 insertions(+), 358 deletions(-) diff --git a/include/macros.h b/include/macros.h index ac30f1988a2..e325ba23e82 100644 --- a/include/macros.h +++ b/include/macros.h @@ -218,6 +218,45 @@ #define DMG_STATUS_ALWAYS(typeFlag, duration) (STATUS_FLAG_80000000 | STATUS_FLAG_RIGHT_ON | typeFlag | (duration << 8)) #define DMG_STATUS_IGNORE_RES(typeFlag, duration) (STATUS_KEY_IGNORE_RES | typeFlag | (duration << 8)) +#define _RDP_WHOLE(x) (((s32)(x * 65536.0) >> 16) & 0xFFFF) +#define _RDP_FRAC(x) ((s32)(x * 65536.0) & 0xFFFF) +#define _RDP_PACK_WHOLE(a, b) (_RDP_WHOLE(a) << 16) | _RDP_WHOLE(b) +#define _RDP_PACK_FRAC(a, b) (_RDP_FRAC(a) << 16) | _RDP_FRAC(b) + +#define RDP_MATRIX( \ + Ax, Bx, Cx, Dx, \ + Ay, By, Cy, Dy, \ + Az, Bz, Cz, Dz, \ + Aw, Bw, Cw, Dw ) \ +{ \ + .m = { \ + { \ + _RDP_PACK_WHOLE(Ax, Ay), \ + _RDP_PACK_WHOLE(Az, Aw), \ + _RDP_PACK_WHOLE(Bx, By), \ + _RDP_PACK_WHOLE(Bz, Bw), \ + }, \ + { \ + _RDP_PACK_WHOLE(Cx, Cy), \ + _RDP_PACK_WHOLE(Cz, Cw), \ + _RDP_PACK_WHOLE(Dx, Dy), \ + _RDP_PACK_WHOLE(Dz, Dw), \ + }, \ + { \ + _RDP_PACK_FRAC(Ax, Ay), \ + _RDP_PACK_FRAC(Az, Aw), \ + _RDP_PACK_FRAC(Bx, By), \ + _RDP_PACK_FRAC(Bz, Bw), \ + }, \ + { \ + _RDP_PACK_FRAC(Cx, Cy), \ + _RDP_PACK_FRAC(Cz, Cw), \ + _RDP_PACK_FRAC(Dx, Dy), \ + _RDP_PACK_FRAC(Dz, Dw), \ + } \ + } \ +}; + #define PM_CC_01 0, 0, 0, TEXEL0, PRIMITIVE, 0, TEXEL0, 0 #define PM_CC_02 0, 0, 0, TEXEL0, TEXEL0, 0, PRIMITIVE, 0 #define PM_CC_03 TEXEL0, 0, SHADE, 0, PRIMITIVE, 0, SHADE, 0 diff --git a/src/draw_box.c b/src/draw_box.c index e8f808dc4d3..f3c6c9e35e9 100644 --- a/src/draw_box.c +++ b/src/draw_box.c @@ -322,26 +322,12 @@ Vp gBoxViewport = { #include "vtx/drawbox1.vtx.inc.c" -/* -| 0.0 0.0 0.0 0.0| -| 0.0 0.0 0.0 0.0| -| 0.0 0.0 0.0 0.0| -|-6.0 0.0 0.0 0.0| -*/ -Mtx gBoxMatrix = { - .m = { - // integer portion - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0xFFFA0000, 0x00000000 }, - // fractional portion - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx gBoxMatrix = RDP_MATRIX( + 0.000000, 0.000000, 0.000000, -6.000000, + 0.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 0.000000 +); s32 draw_box(s32 flags, WindowStyle windowStyle, s32 posX, s32 posY, s32 posZ, s32 width, s32 height, u8 opacity, u8 darkening, f32 scaleX, f32 scaleY, f32 rotX, f32 rotY, f32 rotZ, void (*fpDrawContents)(s32, s32, s32, s32, s32, s32, s32), diff --git a/src/entity/Chest.c b/src/entity/Chest.c index ed6545a36d9..4ec4e50d8d2 100644 --- a/src/entity/Chest.c +++ b/src/entity/Chest.c @@ -8,7 +8,7 @@ extern EntityScript Entity_Chest_ScriptOpened; extern Gfx Entity_Chest_RenderBox[]; extern Gfx Entity_Chest_RenderLid[]; -extern Mtx Entity_Chest_lidMtx; +extern Mtx Entity_Chest_LidMtx; EvtScript Entity_Chest_AdjustCam_ISK = { EVT_THREAD @@ -98,7 +98,7 @@ void entity_Chest_setupGfx(s32 entityIndex) { Gfx* gfx; guRotateF(sp58, data->lidAngle, 1.0f, 0.0f, 0.0f); - guMtxL2F(sp18, ENTITY_ADDR(entity, Mtx*, &Entity_Chest_lidMtx)); + guMtxL2F(sp18, ENTITY_ADDR(entity, Mtx*, &Entity_Chest_LidMtx)); guMtxCatF(sp58, sp18, sp18); guMtxF2L(sp18, &gDisplayContext->matrixStack[gMatrixListPos]); gSPMatrix(gfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW); diff --git a/src/entity/model/ArrowSign.c b/src/entity/model/ArrowSign.c index f5dcedc6435..5678839b86b 100644 --- a/src/entity/model/ArrowSign.c +++ b/src/entity/model/ArrowSign.c @@ -28,18 +28,12 @@ Gfx Entity_ArrowSign_LoadTexture[] = { gsSPEndDisplayList(), }; -Mtx Entity_ArrowSign_mtxSign = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0xFFFF0014, 0x00010001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0xD1B40000, 0x00000000 } - } -}; +Mtx Entity_ArrowSign_mtxSign = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, -0.180848, + 0.000000, 1.000000, 0.000000, 20.000000, + 0.000000, 0.000000, 1.000000, 1.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_ArrowSign_RenderPole[] = { gsDPPipeSync(), diff --git a/src/entity/model/BlueSwitch.c b/src/entity/model/BlueSwitch.c index 458191dc955..8b976f96e9c 100644 --- a/src/entity/model/BlueSwitch.c +++ b/src/entity/model/BlueSwitch.c @@ -33,31 +33,19 @@ Gfx Entity_BlueSwitch_LoadExclMark[] = { gsSPEndDisplayList(), }; -Mtx Entity_BlueSwitch_mtxExclMark = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000006, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_BlueSwitch_mtxExclMark = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 6.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); -Mtx Entity_BlueSwitch_mtxBlueBubble = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0xFFFF0005, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0xF9310000, 0x9BEF0000 } - } -}; +Mtx Entity_BlueSwitch_mtxBlueBubble = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, -0.026597, + 0.000000, 1.000000, 0.000000, 5.000000, + 0.000000, 0.000000, 1.000000, 0.609116, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_BlueSwitch_RenderBlueBubble[] = { gsDPPipeSync(), diff --git a/src/entity/model/BlueWarpPipe.c b/src/entity/model/BlueWarpPipe.c index 492a1644eba..09edf471363 100644 --- a/src/entity/model/BlueWarpPipe.c +++ b/src/entity/model/BlueWarpPipe.c @@ -36,18 +36,12 @@ Gfx Entity_BlueWarpPipe_LoadTexturePipe[] = { gsSPEndDisplayList(), }; -Mtx Entity_BlueWarpPipe_mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x0000FFC9, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_BlueWarpPipe_mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, -55.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_BlueWarpPipe_RenderBase[] = { gsDPPipeSync(), diff --git a/src/entity/model/Chest.c b/src/entity/model/Chest.c index 14d5f92e9e5..8527e7dc299 100644 --- a/src/entity/model/Chest.c +++ b/src/entity/model/Chest.c @@ -54,18 +54,12 @@ Gfx Entity_Chest_LoadTextureLock[] = { gsSPEndDisplayList(), }; -Mtx Entity_Chest_lidMtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x0000001D, 0xFFE90001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_Chest_LidMtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 29.000000, + 0.000000, 0.000000, 1.000000, -23.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_Chest_RenderLidLock[] = { gsDPPipeSync(), diff --git a/src/entity/model/CymbalPlant_gfx.c b/src/entity/model/CymbalPlant_gfx.c index 86a31664cd9..cd158418ee1 100644 --- a/src/entity/model/CymbalPlant_gfx.c +++ b/src/entity/model/CymbalPlant_gfx.c @@ -24,35 +24,23 @@ Gfx Entity_CymbalPlant_LoadTexture[] = { #include "entity/model/CymbalPlant_7.vtx.inc.c" #include "entity/model/CymbalPlant_8.vtx.inc.c" -Mtx D_0A001078_E9A368 = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x0002001A, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0xAB15AB15, 0x00000000 } - } -}; +Mtx Entity_CymbalPlant_RightMtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 2.668290, + 0.000000, 1.000000, 0.000000, 26.668290, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); -Mtx D_0A0010B8_E9A3A8 = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0xFFFD001A, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0xAB15AB15, 0x00000000 } - } -}; +Mtx Entity_CymbalPlant_LeftMtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, -2.331711, + 0.000000, 1.000000, 0.000000, 26.668290, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_CymbalPlant_RenderNode3[] = { gsDPPipeSync(), - gsSPMatrix(&D_0A0010B8_E9A3A8, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_LeftMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), gsSPDisplayList(Entity_CymbalPlant_LoadTexture), @@ -80,7 +68,7 @@ Gfx Entity_CymbalPlant_RenderNode3[] = { Gfx Entity_CymbalPlant_RenderNode4[] = { gsDPPipeSync(), - gsSPMatrix(&D_0A0010B8_E9A3A8, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_LeftMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), gsSPDisplayList(Entity_CymbalPlant_LoadTexture), @@ -108,7 +96,7 @@ Gfx Entity_CymbalPlant_RenderNode4[] = { Gfx Entity_CymbalPlant_RenderNode5[] = { gsDPPipeSync(), - gsSPMatrix(&D_0A0010B8_E9A3A8, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_LeftMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), @@ -126,7 +114,7 @@ Gfx Entity_CymbalPlant_RenderNode5[] = { }; Gfx D_0A001308_E9A5F8[] = { - gsSPMatrix(&D_0A0010B8_E9A3A8, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_LeftMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsSPDisplayList(Entity_CymbalPlant_RenderNode5), gsSPDisplayList(Entity_CymbalPlant_RenderNode4), gsSPDisplayList(Entity_CymbalPlant_RenderNode3), @@ -136,7 +124,7 @@ Gfx D_0A001308_E9A5F8[] = { Gfx Entity_CymbalPlant_RenderNode7[] = { gsDPPipeSync(), - gsSPMatrix(&D_0A001078_E9A368, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_RightMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), gsSPDisplayList(Entity_CymbalPlant_LoadTexture), @@ -164,7 +152,7 @@ Gfx Entity_CymbalPlant_RenderNode7[] = { Gfx Entity_CymbalPlant_RenderNode9[] = { gsDPPipeSync(), - gsSPMatrix(&D_0A001078_E9A368, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_RightMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), gsSPDisplayList(Entity_CymbalPlant_LoadTexture), @@ -192,7 +180,7 @@ Gfx Entity_CymbalPlant_RenderNode9[] = { Gfx Entity_CymbalPlant_RenderNode8[] = { gsDPPipeSync(), - gsSPMatrix(&D_0A001078_E9A368, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_RightMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), @@ -209,7 +197,7 @@ Gfx Entity_CymbalPlant_RenderNode8[] = { }; Gfx D_0A001540_E9A830[] = { - gsSPMatrix(&D_0A001078_E9A368, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), + gsSPMatrix(&Entity_CymbalPlant_RightMtx, G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW), gsSPDisplayList(Entity_CymbalPlant_RenderNode8), gsSPDisplayList(Entity_CymbalPlant_RenderNode9), gsSPDisplayList(Entity_CymbalPlant_RenderNode7), diff --git a/src/entity/model/GreenStompSwitch.c b/src/entity/model/GreenStompSwitch.c index 26b21e01b6f..55d769b6a71 100644 --- a/src/entity/model/GreenStompSwitch.c +++ b/src/entity/model/GreenStompSwitch.c @@ -37,18 +37,12 @@ Gfx Entity_GreenStompSwitch_LoadExclMark[] = { gsSPEndDisplayList(), }; -Mtx Entity_GreenStompSwitch_mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_GreenStompSwitch_mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_GreenStompSwitch_RenderBase[] = { gsDPPipeSync(), diff --git a/src/entity/model/Padlock.c b/src/entity/model/Padlock.c index 4b8d9a66931..9c23685ea55 100644 --- a/src/entity/model/Padlock.c +++ b/src/entity/model/Padlock.c @@ -50,18 +50,12 @@ Gfx Entity_Padlock_LoadTextureBody[] = { gsSPEndDisplayList(), }; -Mtx Entity_Padlock_mtxShackle = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000016, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00008000, 0x00000000 } - } -}; +Mtx Entity_Padlock_mtxShackle = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 22.500000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_Padlock_RenderShackleMain[] = { gsDPPipeSync(), diff --git a/src/entity/model/PadlockBlueFace.c b/src/entity/model/PadlockBlueFace.c index f7d78a64977..3959bc40ed0 100644 --- a/src/entity/model/PadlockBlueFace.c +++ b/src/entity/model/PadlockBlueFace.c @@ -48,18 +48,12 @@ Gfx Entity_PadlockBlueFace_LoadTextureBody[] = { gsSPEndDisplayList(), }; -Mtx Entity_PadlockBlueFace_mtxShackle = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000016, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00008000, 0x00000000 } - } -}; +Mtx Entity_PadlockBlueFace_mtxShackle = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 22.500000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_PadlockBlueFace_RenderShackleMain[] = { gsDPPipeSync(), diff --git a/src/entity/model/PadlockRedFace.c b/src/entity/model/PadlockRedFace.c index e8d5369ca02..78f12dac257 100644 --- a/src/entity/model/PadlockRedFace.c +++ b/src/entity/model/PadlockRedFace.c @@ -48,18 +48,12 @@ Gfx Entity_PadlockRedFace_LoadTextureBody[] = { gsSPEndDisplayList(), }; -Mtx Entity_PadlockRedFace_mtxShackle = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000016, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00008000, 0x00000000 } - } -}; +Mtx Entity_PadlockRedFace_mtxShackle = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 22.500000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_PadlockRedFace_RenderShackleMain[] = { gsDPPipeSync(), diff --git a/src/entity/model/PadlockRedFrame.c b/src/entity/model/PadlockRedFrame.c index e743d65649a..45d81fe9216 100644 --- a/src/entity/model/PadlockRedFrame.c +++ b/src/entity/model/PadlockRedFrame.c @@ -35,18 +35,12 @@ Gfx Entity_PadlockRedFrame_LoadTextureFace[] = { gsSPEndDisplayList(), }; -Mtx Entity_PadlockRedFrame_mtxShackle = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_PadlockRedFrame_mtxShackle = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_PadlockRedFrame_RenderShackleMain[] = { gsDPPipeSync(), diff --git a/src/entity/model/PinkFlower_gfx.c b/src/entity/model/PinkFlower_gfx.c index c3f1ef3277a..bbeaae4d34d 100644 --- a/src/entity/model/PinkFlower_gfx.c +++ b/src/entity/model/PinkFlower_gfx.c @@ -31,18 +31,12 @@ Gfx D_0A001020_E9C520[] = { gsSPEndDisplayList(), }; -Mtx D_0A001098_E9C598 = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0xFFF60019, 0x000D0001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx D_0A001098_E9C598 = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, -10.000000, + 0.000000, 1.000000, 0.000000, 25.000000, + 0.000000, 0.000000, 1.000000, 13.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_PinkFlower_RenderNode3[] = { gsDPPipeSync(), diff --git a/src/entity/model/PowBlock.c b/src/entity/model/PowBlock.c index e69a40ead37..8bbd4874689 100644 --- a/src/entity/model/PowBlock.c +++ b/src/entity/model/PowBlock.c @@ -17,18 +17,12 @@ Gfx Entity_PowBlock_LoadTexture[] = { gsSPEndDisplayList(), }; -Mtx Entity_PowBlock_mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_PowBlock_mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_PowBlock_RenderTopBottom[] = { gsDPPipeSync(), diff --git a/src/entity/model/PushBlock.c b/src/entity/model/PushBlock.c index a3b792a27db..4e6e315a304 100644 --- a/src/entity/model/PushBlock.c +++ b/src/entity/model/PushBlock.c @@ -17,18 +17,12 @@ Gfx Entity_PushBlock_LoadTexture[] = { gsSPEndDisplayList(), }; -Mtx Entity_PushBlock_mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_PushBlock_mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_PushBlock_RenderFaces[] = { gsDPPipeSync(), diff --git a/src/entity/model/RedSwitch.c b/src/entity/model/RedSwitch.c index e59776c0e11..51c68d573d2 100644 --- a/src/entity/model/RedSwitch.c +++ b/src/entity/model/RedSwitch.c @@ -32,31 +32,20 @@ Gfx Entity_RedSwitch_LoadExclMark[] = { gsSPEndDisplayList(), }; -Mtx Entity_RedSwitch_mtxExclMark = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000006, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_RedSwitch_mtxExclMark = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 6.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); + +Mtx Entity_RedSwitch_mtxRedBubble = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, -0.026600, + 0.000000, 1.000000, 0.000000, 5.000000, + 0.000000, 0.000000, 1.000000, 0.609116, + 0.000000, 0.000000, 0.000000, 1.000000 +); -Mtx Entity_RedSwitch_mtxRedBubble = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0xFFFF0005, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0xF9310000, 0x9BEF0000 } - } -}; Gfx Entity_RedSwitch_RenderRedBubble[] = { gsDPPipeSync(), diff --git a/src/entity/model/SaveBlock.c b/src/entity/model/SaveBlock.c index f2681ac501b..995de26d762 100644 --- a/src/entity/model/SaveBlock.c +++ b/src/entity/model/SaveBlock.c @@ -42,18 +42,12 @@ Gfx Entity_SaveBlock_LoadTextureLetterS[] = { gsSPEndDisplayList(), }; -Mtx Entity_SaveBlock_Mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_SaveBlock_Mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_SaveBlock_RenderLetterS[] = { gsDPPipeSync(), diff --git a/src/entity/model/SpinningFlower.c b/src/entity/model/SpinningFlower.c index e7c4c3e971d..a7d1d72f924 100644 --- a/src/entity/model/SpinningFlower.c +++ b/src/entity/model/SpinningFlower.c @@ -31,18 +31,12 @@ Gfx D_0A000AF8_E9D3F8[] = { gsSPEndDisplayList(), }; -Mtx D_0A000B70_E9D470 = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000014, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx D_0A000B70_E9D470 = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 20.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx D_0A000BB0_E9D4B0[] = { gsDPPipeSync(), diff --git a/src/entity/model/StarBoxLauncher.c b/src/entity/model/StarBoxLauncher.c index 89cc41c3144..ef50d8bcb1f 100644 --- a/src/entity/model/StarBoxLauncher.c +++ b/src/entity/model/StarBoxLauncher.c @@ -48,18 +48,12 @@ Gfx Entity_StarBoxLauncher_LoadTextureBox[] = { gsSPEndDisplayList(), }; -Mtx Entity_StarBoxLauncher_mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_StarBoxLauncher_mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_StarBoxLauncher_RenderChain[] = { gsDPPipeSync(), diff --git a/src/entity/model/SuperBlock.c b/src/entity/model/SuperBlock.c index 7d89d79e04e..13e814501d5 100644 --- a/src/entity/model/SuperBlock.c +++ b/src/entity/model/SuperBlock.c @@ -17,18 +17,12 @@ Gfx Entity_SuperBlock_LoadTexture[] = { gsSPEndDisplayList(), }; -Mtx Entity_SuperBlock_mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_SuperBlock_mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_SuperBlock_RenderTop[] = { gsDPPipeSync(), diff --git a/src/entity/model/Tweester.c b/src/entity/model/Tweester.c index b9a574497f4..41d00dafc39 100644 --- a/src/entity/model/Tweester.c +++ b/src/entity/model/Tweester.c @@ -47,31 +47,19 @@ Gfx Entity_Tweester_LoadTextureFace[] = { gsSPEndDisplayList(), }; -Mtx Entity_Tweester_mtxInnerWhirl = { - .m = { - { 0x0000FFFF, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0xFFF6FB88, 0x00000000, - 0x0478FFF6, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_Tweester_mtxInnerWhirl = RDP_MATRIX( + 0.999848, 0.017457, 0.000000, 0.000000, + -0.01746, 0.999848, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); -Mtx Entity_Tweester_mtxOuterWhirl = { - .m = { - { 0x00010000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x33330000, 0x00000000, - 0x0000E666, 0x00000000 }, - { 0x00000000, 0x33330000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_Tweester_mtxOuterWhirl = RDP_MATRIX( + 1.199997, 0.000000, 0.000000, 0.000000, + 0.000000, 0.899994, 0.000000, 0.000000, + 0.000000, 0.000000, 1.199997, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx D_0A0019E8_E58848[] = { gsDPPipeSync(), diff --git a/src/entity/model/UltraBlock.c b/src/entity/model/UltraBlock.c index 9a051a542cb..b4bab0e0538 100644 --- a/src/entity/model/UltraBlock.c +++ b/src/entity/model/UltraBlock.c @@ -17,18 +17,12 @@ Gfx Entity_UltraBlock_LoadTexture[] = { gsSPEndDisplayList(), }; -Mtx Entity_UltraBlock_mtx = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx Entity_UltraBlock_mtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx Entity_UltraBlock_RenderTop[] = { gsDPPipeSync(), diff --git a/src/entity/model/UnusedBlock.c b/src/entity/model/UnusedBlock.c index b3d449b55a9..dea24301658 100644 --- a/src/entity/model/UnusedBlock.c +++ b/src/entity/model/UnusedBlock.c @@ -34,18 +34,12 @@ Gfx D_0A000968_E3D738[] = { gsSPEndDisplayList(), }; -Mtx D_0A000A20_E3D7F0 = { - .m = { - { 0x00010000, 0x00000000, - 0x00000001, 0x00000000 }, - { 0x00000000, 0x00010000, - 0x00000000, 0x00000001 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 }, - { 0x00000000, 0x00000000, - 0x00000000, 0x00000000 } - } -}; +Mtx D_0A000A20_E3D7F0 = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); Gfx D_0A000A60_E3D830[] = { gsDPPipeSync(), diff --git a/src/main_loop.c b/src/main_loop.c index 093e7299b7e..616ee78ba49 100644 --- a/src/main_loop.c +++ b/src/main_loop.c @@ -24,20 +24,12 @@ s16 D_800741A0 = 0; s16 D_800741A2 = 0; s32 D_800741A4 = 0; -Matrix4s MasterIdentityMtx = { - .whole = { - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {0, 0, 1, 0}, - {0, 0, 0, 1} - }, - .frac = { - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} - } -}; +Mtx MasterIdentityMtx = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); s32 D_800741E8[2] = {0, 0}; // padding? u16 gMatrixListPos = 0; diff --git a/src/model.c b/src/model.c index 83905cda1f8..565a40d7b30 100644 --- a/src/model.c +++ b/src/model.c @@ -470,20 +470,12 @@ s8 gRenderModelEnvR = 0; s8 gRenderModelEnvG = 0; s8 gRenderModelEnvB = 0; -Matrix4s mdl_RDPIdentity = { - .whole = { - {1, 0, 0, 0}, - {0, 1, 0, 0}, - {0, 0, 1, 0}, - {0, 0, 0, 1} - }, - .frac = { - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0} - } -}; +Mtx mdl_RDPIdentity = RDP_MATRIX( + 1.000000, 0.000000, 0.000000, 0.000000, + 0.000000, 1.000000, 0.000000, 0.000000, + 0.000000, 0.000000, 1.000000, 0.000000, + 0.000000, 0.000000, 0.000000, 1.000000 +); // The depth buffer contains values encoded in a custom 18-bit floating-point format. // There are 3 bits of exponent, 11 bits of mantissa, and 4 bits of "dz".