Torch
Loading...
Searching...
No Matches
gbi-otr.h
1#pragma once
2
3// CUSTOM OTR COMMANDS
4#define G_SETTIMG_OTR_HASH 0x20
5#define G_SETFB 0x21
6#define G_RESETFB 0x22
7#define G_SETTIMG_FB 0x23
8#define G_VTX_OTR_FILEPATH 0x24
9#define G_SETTIMG_OTR_FILEPATH 0x25
10#define G_TRI1_OTR 0x26
11#define G_DL_OTR_FILEPATH 0x27
12#define G_PUSHCD 0x28
13#define G_MTX_OTR2 0x29
14#define G_DL_OTR_HASH 0x31
15#define G_VTX_OTR_HASH 0x32
16#define G_MARKER 0x33
17#define G_INVALTEXCACHE 0x34
18#define G_BRANCH_Z_OTR 0x35
19#define G_MTX_OTR 0x36
20#define G_TEXRECT_WIDE 0x37
21#define G_FILLWIDERECT 0x38
22#define G_DL_OTR_INDEX 0x3D
23#define G_MOVEMEM_OTR_HASH 0x42
24
25// DL FLAGS
26#define G_DL_PUSH 0x00
27#define G_DL_NO_PUSH 0x01
28
29/* GFX Effects */
30#define G_SETGRAYSCALE 0x39
31#define G_EXTRAGEOMETRYMODE 0x3a
32#define G_SETINTENSITY 0x40
33#define G_SETFILTERING 0x41
34
35#define gDPFillWideRectangle(pkt, ulx, uly, lrx, lry) \
36{ \
37 N64Gfx *_g0 = (N64Gfx*)(pkt), *_g1 = (N64Gfx*)(pkt); \
38 _g0->words.w0 = _SHIFTL(G_FILLWIDERECT, 24, 8) | _SHIFTL((lrx), 2, 22); \
39 _g0->words.w1 = _SHIFTL((lry), 2, 22); \
40 _g1->words.w0 = _SHIFTL((ulx), 2, 22); \
41 _g1->words.w1 = _SHIFTL((uly), 2, 22); \
42}
43
44#define gSPWideTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
45{ \
46 N64Gfx *_g0 = (N64Gfx*)(pkt), *_g1 = (N64Gfx*)(pkt), *_g2 = (N64Gfx*)(pkt); \
47 \
48 _g0->words.w0 = _SHIFTL(G_TEXRECT_WIDE, 24, 8) | _SHIFTL((xh), 0, 24); \
49 _g0->words.w1 = _SHIFTL((yh), 0, 24); \
50 _g1->words.w0 = (_SHIFTL(tile, 24, 3) | _SHIFTL((xl), 0, 24)); \
51 _g1->words.w1 = _SHIFTL((yl), 0, 24); \
52 _g2->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \
53 _g2->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \
54}
55
56#define gsSPWideTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
57{ { \
58 (_SHIFTL(G_TEXRECT_WIDE, 24, 8) | _SHIFTL((xh), 0, 24)), \
59 _SHIFTL((yh), 0, 24), \
60} }, \
61 { { \
62 (_SHIFTL((tile), 24, 3) | _SHIFTL((xl), 0, 24)), \
63 _SHIFTL((yl), 0, 24), \
64 } }, \
65{ \
66 { _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) } \
67}
68
69#define gSPExtraGeometryMode(pkt, c, s) \
70_DW({ \
71 N64Gfx* _g = (N64Gfx*)(pkt); \
72 \
73 _g->words.w0 = _SHIFTL(G_EXTRAGEOMETRYMODE, 24, 8) | _SHIFTL(~(u32)(c), 0, 24); \
74 _g->words.w1 = (u32)(s); \
75})
76
77#define gSPSetExtraGeometryMode(pkt, word) gSPExtraGeometryMode((pkt), 0, word)
78#define gSPClearExtraGeometryMode(pkt, word) gSPExtraGeometryMode((pkt), word, 0)
79
80#define __gSPInvalidateTexCache(pkt, addr) \
81 _DW({ \
82 N64Gfx* _g = (N64Gfx*)(pkt); \
83 \
84 _g->words.w0 = _SHIFTL(G_INVALTEXCACHE, 24, 8); \
85 _g->words.w1 = addr; \
86 })
87
88#define gsSPInvalidateTexCache() \
89 { _SHIFTL(G_INVALTEXCACHE, 24, 8), 0 }
90
91#define gsSPSetFB(pkt, fb) \
92 { \
93 N64Gfx* _g = (N64Gfx*)(pkt); \
94 \
95 _g->words.w0 = _SHIFTL(G_SETFB, 24, 8); \
96 _g->words.w1 = fb; \
97 }
98
99#define gsSPResetFB(pkt) \
100 { \
101 N64Gfx* _g = (N64Gfx*)(pkt); \
102 \
103 _g->words.w0 = _SHIFTL(G_RESETFB, 24, 8); \
104 _g->words.w1 = 0; \
105 }
106
107#define gSPGrayscale(pkt, state) \
108 { \
109 N64Gfx* _g = (N64Gfx*)(pkt); \
110 \
111 _g->words.w0 = _SHIFTL(G_SETGRAYSCALE, 24, 8); \
112 _g->words.w1 = state; \
113 }
114
115#define gsSPGrayscale(state) \
116 { (_SHIFTL(G_SETGRAYSCALE, 24, 8)), (state) }
117
118#define gSPDisableFiltering(pkt, state) \
119 { \
120 N64Gfx* _g = (N64Gfx*)(pkt); \
121 \
122 _g->words.w0 = _SHIFTL(G_SETFILTERING, 24, 8); \
123 _g->words.w1 = state; \
124 }
125
126#define gsSPDisableFiltering(state) \
127 { (_SHIFTL(G_SETFILTERING, 24, 8)), (state) }
128
129#define gsSP1TriangleOTR(v0, v1, v2, flag) \
130 { _SHIFTL(G_TRI1_OTR, 24, 8) | __gsSP1Triangle_w1f(v0, v1, v2, flag), 0 }
131
132#define gsSPVertexOTR(v, n, v0) \
133 { (_SHIFTL(G_VTX_OTR_HASH, 24, 8) | _SHIFTL((n), 12, 8) | _SHIFTL((v0) + (n), 1, 7)), (uint32_t)(v) }
134
135#define gsSPRawOpcode(opcode) \
136 { _SHIFTL(opcode, 24, 8), 0 }
137
138#define gsDPSetTextureOTRImage(fmt, siz, width, i) \
139 {{ \
140 _SHIFTL(G_SETTIMG_OTR_HASH, 24, 8) | _SHIFTL(fmt, 21, 3) | \
141 _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12), \
142 (uint32_t)(i) \
143 }}
144
145#define gsSPBranchListOTRHash(dl) \
146 {{ \
147 (_SHIFTL((G_DL_OTR_HASH), 24, 8) | _SHIFTL((0x01), 16, 8) | \
148 _SHIFTL((0), 1, 16)), \
149 (uint32_t)(dl) \
150 }}
151
152#define gsSPBranchListOTRFilePath(dl) \
153 {{ \
154 (_SHIFTL((G_DL_OTR_FILEPATH), 24, 8) | _SHIFTL((0x01), 16, 8) | \
155 _SHIFTL((0), 0, 16)), \
156 (uint32_t)(dl) \
157 }}
158
159#define gsSPDisplayListOTRHash(dl) \
160 {{ \
161 (_SHIFTL((G_DL_OTR_HASH), 24, 8) | _SHIFTL((0x00), 16, 8) | \
162 _SHIFTL((0), 0, 16)), \
163 (uint32_t)(dl) \
164 }}
165
166#define gsSPDisplayListOTRIndex(dl) \
167 {{ \
168 (_SHIFTL((G_DL_OTR_INDEX), 24, 8) | _SHIFTL((0x00), 16, 8) | \
169 _SHIFTL((0), 0, 16)), \
170 (uint32_t)((SEGMENT_NUMBER(dl) << 24) | ((SEGMENT_OFFSET(dl) / 8) & 0x00FFFFFF)) \
171 }}
172
173#define gsSPDisplayListOTRFilePath(dl) \
174 {{ \
175 (_SHIFTL((G_DL_OTR_FILEPATH), 24, 8) | _SHIFTL((0x00), 16, 8) | \
176 _SHIFTL((0), 0, 16)), \
177 (uint32_t)(dl) \
178 }}
179#define gDPSetGrayscaleColor(pkt, r, g, b, lerp) DPRGBColor(pkt, G_SETINTENSITY, r, g, b, lerp)
180#define gsDPSetGrayscaleColor(r, g, b, a) sDPRGBColor(G_SETINTENSITY, r, g, b, a)
181
182#define gsDPSetCombineLERP_NoMacros(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \
183 { \
184 _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(GCCc0w0(a0, c0, Aa0, Ac0) | GCCc1w0(a1, c1), 0, 24), \
185 (unsigned int)(GCCc0w1(b0, d0, Ab0, Ad0) | GCCc1w1(b1, Aa1, Ac1, d1, Ab1, Ad1)) \
186 }