Skip to content

Commit

Permalink
RDP_MATRIX macro
Browse files Browse the repository at this point in the history
  • Loading branch information
HailSanta authored and HailSanta committed Jul 16, 2023
1 parent b23fd21 commit e2e8806
Show file tree
Hide file tree
Showing 26 changed files with 218 additions and 358 deletions.
39 changes: 39 additions & 0 deletions include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 6 additions & 20 deletions src/draw_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/entity/Chest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 6 additions & 12 deletions src/entity/model/ArrowSign.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
36 changes: 12 additions & 24 deletions src/entity/model/BlueSwitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
18 changes: 6 additions & 12 deletions src/entity/model/BlueWarpPipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
18 changes: 6 additions & 12 deletions src/entity/model/Chest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
52 changes: 20 additions & 32 deletions src/entity/model/CymbalPlant_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand Down
18 changes: 6 additions & 12 deletions src/entity/model/GreenStompSwitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
18 changes: 6 additions & 12 deletions src/entity/model/Padlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading

0 comments on commit e2e8806

Please sign in to comment.