1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#include <revolution/gd.h>
#include <revolution/os.h>
void GDLoadPosMtxImm(const Mtx mtx, u32 id) {
GDWriteXFCmdHdr(4 * id, 12);
GDWrite_f32(mtx[0][0]);
GDWrite_f32(mtx[0][1]);
GDWrite_f32(mtx[0][2]);
GDWrite_f32(mtx[0][3]);
GDWrite_f32(mtx[1][0]);
GDWrite_f32(mtx[1][1]);
GDWrite_f32(mtx[1][2]);
GDWrite_f32(mtx[1][3]);
GDWrite_f32(mtx[2][0]);
GDWrite_f32(mtx[2][1]);
GDWrite_f32(mtx[2][2]);
GDWrite_f32(mtx[2][3]);
}
void GDLoadPosMtxIndx(u16 mtx_indx, u32 id) {
GDWriteXFIndxACmd(4 * id, 12, mtx_indx);
}
void GDLoadNrmMtxImm(const Mtx mtx, u32 id) {
GDWriteXFCmdHdr(id * 3 + 0x400, 9);
GDWrite_f32(mtx[0][0]);
GDWrite_f32(mtx[0][1]);
GDWrite_f32(mtx[0][2]);
GDWrite_f32(mtx[1][0]);
GDWrite_f32(mtx[1][1]);
GDWrite_f32(mtx[1][2]);
GDWrite_f32(mtx[2][0]);
GDWrite_f32(mtx[2][1]);
GDWrite_f32(mtx[2][2]);
}
void GDLoadNrmMtxImm3x3(const f32 mtx[3][3], u32 id) {
GDWriteXFCmdHdr(id * 3 + 0x400, 9);
GDWrite_f32(mtx[0][0]);
GDWrite_f32(mtx[0][1]);
GDWrite_f32(mtx[0][2]);
GDWrite_f32(mtx[1][0]);
GDWrite_f32(mtx[1][1]);
GDWrite_f32(mtx[1][2]);
GDWrite_f32(mtx[2][0]);
GDWrite_f32(mtx[2][1]);
GDWrite_f32(mtx[2][2]);
}
void GDLoadNrmMtxIndx3x3(u16 mtx_indx, u32 id) {
GDWriteXFIndxBCmd(id * 3 + 0x400, 9, mtx_indx);
}
void GDLoadTexMtxImm(const Mtx mtx, u32 id, GXTexMtxType type) {
u16 addr;
u8 count;
if (id >= 0x40) {
ASSERTMSGLINE(178, type == GX_MTX3x4, "GDLoadTexMtxImm: invalid matrix type");
addr = ((id - 0x40) << 2) + 0x500;
count = 12;
} else {
addr = 4 * id;
count = type == GX_MTX2x4 ? 8 : 12;
}
GDWriteXFCmdHdr(addr,count);
GDWrite_f32(mtx[0][0]);
GDWrite_f32(mtx[0][1]);
GDWrite_f32(mtx[0][2]);
GDWrite_f32(mtx[0][3]);
GDWrite_f32(mtx[1][0]);
GDWrite_f32(mtx[1][1]);
GDWrite_f32(mtx[1][2]);
GDWrite_f32(mtx[1][3]);
if (type == GX_MTX3x4) {
GDWrite_f32(mtx[2][0]);
GDWrite_f32(mtx[2][1]);
GDWrite_f32(mtx[2][2]);
GDWrite_f32(mtx[2][3]);
}
}
void GDLoadTexMtxIndx(u16 mtx_indx, u32 id, GXTexMtxType type) {
u16 addr;
u8 count;
if (id >= 0x40) {
ASSERTMSGLINE(227, type == GX_MTX3x4, "GDLoadTexMtxIndx: invalid matrix type");
addr = ((id - 0x40) << 2) + 0x500;
count = 12;
} else {
addr = 4 * id;
count = type == GX_MTX2x4 ? 8 : 12;
}
GDWriteXFIndxCCmd(addr, count, mtx_indx);
}
void GDSetCurrentMtx(u32 pn, u32 t0, u32 t1, u32 t2, u32 t3, u32 t4, u32 t5, u32 t6, u32 t7) {
u32 regA;
u32 regB;
regA = CP_MTX_REG_A(pn, t0, t1, t2, t3);
regB = CP_MTX_REG_B(t4, t5, t6, t7);
GDWriteCPCmd(CP_MTX_REG_A_ID, regA);
GDWriteCPCmd(CP_MTX_REG_B_ID, regB);
GDWriteXFCmdHdr(XF_REG_MATRIXINDEX0_ID, 2);
GDWrite_u32(regA);
GDWrite_u32(regB);
}
void GDSetProjection(const Mtx44 mtx, GXProjectionType type) {
u32 c;
c = type == GX_ORTHOGRAPHIC ? 3 : 2;
GDWriteXFCmdHdr(XF_REG_PROJECTIONA_ID, 7);
GDWrite_f32(mtx[0][0]);
GDWrite_f32(mtx[0][c]);
GDWrite_f32(mtx[1][1]);
GDWrite_f32(mtx[1][c]);
GDWrite_f32(mtx[2][2]);
GDWrite_f32(mtx[2][3]);
GDWrite_u32(type);
}
|