95#define G_RDPHALF_2 0xf1
96#define G_SETOTHERMODE_H 0xe3
97#define G_SETOTHERMODE_L 0xe2
98#define G_RDPHALF_1 0xe1
102#define G_LOAD_UCODE 0xdd
103#define G_MOVEMEM 0xdc
104#define G_MOVEWORD 0xdb
106#define G_GEOMETRYMODE 0xd9
108#define G_TEXTURE 0xd7
110#define G_SPECIAL_1 0xd5
111#define G_SPECIAL_2 0xd4
112#define G_SPECIAL_3 0xd3
115#define G_MODIFYVTX 0x02
117#define G_BRANCH_Z 0x04
134#define G_SPRITE2D_BASE 9
137#define G_IMMFIRST -65
138#define G_TRI1 (G_IMMFIRST - 0)
139#define G_CULLDL (G_IMMFIRST - 1)
140#define G_POPMTX (G_IMMFIRST - 2)
141#define G_MOVEWORD (G_IMMFIRST - 3)
142#define G_TEXTURE (G_IMMFIRST - 4)
143#define G_SETOTHERMODE_H (G_IMMFIRST - 5)
144#define G_SETOTHERMODE_L (G_IMMFIRST - 6)
145#define G_ENDDL (G_IMMFIRST - 7)
146#define G_SETGEOMETRYMODE (G_IMMFIRST - 8)
147#define G_CLEARGEOMETRYMODE (G_IMMFIRST - 9)
148#define G_LINE3D (G_IMMFIRST - 10)
149#define G_RDPHALF_1 (G_IMMFIRST - 11)
150#define G_RDPHALF_2 (G_IMMFIRST - 12)
151#define G_RDPHALF_CONT (G_IMMFIRST - 13)
152#if (defined(F3DEX_GBI) || defined(F3DLP_GBI))
154#define G_MODIFYVTX (G_IMMFIRST - 13)
156#define G_TRI2 (G_IMMFIRST - 14)
157#define G_BRANCH_Z (G_IMMFIRST - 15)
158#define G_LOAD_UCODE (G_IMMFIRST - 16)
159#define G_QUAD (G_IMMFIRST - 10)
165#define G_SPRITE2D_SCALEFLIP (G_IMMFIRST - 1)
166#define G_SPRITE2D_DRAW (G_IMMFIRST - 2)
174#define G_SETCIMG 0xff
175#define G_SETZIMG 0xfe
176#define G_SETTIMG 0xfd
177#define G_SETCOMBINE 0xfc
178#define G_SETENVCOLOR 0xfb
179#define G_SETPRIMCOLOR 0xfa
180#define G_SETBLENDCOLOR 0xf9
181#define G_SETFOGCOLOR 0xf8
182#define G_SETFILLCOLOR 0xf7
183#define G_FILLRECT 0xf6
184#define G_SETTILE 0xf5
185#define G_LOADTILE 0xf4
186#define G_LOADBLOCK 0xf3
187#define G_SETTILESIZE 0xf2
188#define G_LOADTLUT 0xf0
189#define G_RDPSETOTHERMODE 0xef
190#define G_SETPRIMDEPTH 0xee
191#define G_SETSCISSOR 0xed
192#define G_SETCONVERT 0xec
193#define G_SETKEYR 0xeb
194#define G_SETKEYGB 0xea
195#define G_RDPFULLSYNC 0xe9
196#define G_RDPTILESYNC 0xe8
197#define G_RDPPIPESYNC 0xe7
198#define G_RDPLOADSYNC 0xe6
199#define G_TEXRECTFLIP 0xe5
200#define G_TEXRECT 0xe4
210#define G_TRI_FILL 0xc8
211#define G_TRI_SHADE 0xcc
212#define G_TRI_TXTR 0xca
213#define G_TRI_SHADE_TXTR 0xce
214#define G_TRI_FILL_ZBUFF 0xc9
215#define G_TRI_SHADE_ZBUFF 0xcd
216#define G_TRI_TXTR_ZBUFF 0xcb
217#define G_TRI_SHADE_TXTR_ZBUFF 0xcf
233#define G_RDP_TRI_FILL_MASK 0x08
234#define G_RDP_TRI_SHADE_MASK 0x04
235#define G_RDP_TRI_TXTR_MASK 0x02
236#define G_RDP_TRI_ZBUFF_MASK 0x01
254#define G_RDP_ADDR_FIXUP 3
255#ifdef _LANGUAGE_ASSEMBLY
256#define G_RDP_TEXRECT_CHECK ((-1 * G_TEXRECTFLIP) & 0xff)
260#define GDMACMD(x) (x)
261#define GIMMCMD(x) (G_IMMFIRST - (x))
262#define GRDPCMD(x) (0xff - (x))
264#define G_DMACMDSIZ 128
265#define G_IMMCMDSIZ 64
266#define G_RDPCMDSIZ 64
271#define G_TEXTURE_IMAGE_FRAC 2
272#define G_TEXTURE_SCALE_FRAC 16
273#define G_SCALE_FRAC 8
274#define G_ROTATE_FRAC 16
289#define G_MAXFBZ 0x3fff
291#define GPACK_RGBA5551(r, g, b, a) ((((r) << 8) & 0xf800) | (((g) << 3) & 0x7c0) | (((b) >> 2) & 0x3e) | ((a) & 0x1))
292#define GPACK_ZDZ(z, dz) ((z) << 2 | (dz))
298#define G_MTX_MODELVIEW 0x00
299#define G_MTX_PROJECTION 0x04
300#define G_MTX_MUL 0x00
301#define G_MTX_LOAD 0x02
302#define G_MTX_NOPUSH 0x00
303#define G_MTX_PUSH 0x01
305#define G_MTX_MODELVIEW 0x00
306#define G_MTX_PROJECTION 0x01
307#define G_MTX_MUL 0x00
308#define G_MTX_LOAD 0x02
309#define G_MTX_NOPUSH 0x00
310#define G_MTX_PUSH 0x04
338#define G_ZBUFFER 0x00000001
339#define G_SHADE 0x00000004
342#define G_TEXTURE_ENABLE 0x00000000
343#define G_SHADING_SMOOTH 0x00200000
344#define G_CULL_FRONT 0x00000200
345#define G_CULL_BACK 0x00000400
346#define G_CULL_BOTH 0x00000600
348#define G_TEXTURE_ENABLE 0x00000002
349#define G_SHADING_SMOOTH 0x00000200
350#define G_CULL_FRONT 0x00001000
351#define G_CULL_BACK 0x00002000
352#define G_CULL_BOTH 0x00003000
354#define G_FOG 0x00010000
355#define G_LIGHTING 0x00020000
356#define G_TEXTURE_GEN 0x00040000
357#define G_TEXTURE_GEN_LINEAR 0x00080000
358#define G_LOD 0x00100000
359#if (defined(F3DEX_GBI) || defined(F3DLP_GBI))
360#define G_CLIPPING 0x00800000
362#define G_CLIPPING 0x00000000
365#ifdef _LANGUAGE_ASSEMBLY
366#define G_FOG_H (G_FOG / 0x10000)
367#define G_LIGHTING_H (G_LIGHTING / 0x10000)
368#define G_TEXTURE_GEN_H (G_TEXTURE_GEN / 0x10000)
369#define G_TEXTURE_GEN_LINEAR_H (G_TEXTURE_GEN_LINEAR / 0x10000)
370#define G_LOD_H (G_LOD / 0x10000)
371#if (defined(F3DEX_GBI) || defined(F3DLP_GBI))
372#define G_CLIPPING_H (G_CLIPPING / 0x10000)
377#ifdef _LANGUAGE_ASSEMBLY
378#define G_TX_LOADTILE 7
379#define G_TX_RENDERTILE 0
381#define G_TX_NOMIRROR 0
383#define G_TX_MIRROR 0x1
384#define G_TX_CLAMP 0x2
392#define G_IM_FMT_RGBA 0
393#define G_IM_FMT_YUV 1
403#define G_IM_SIZ_16b 2
404#define G_IM_SIZ_32b 3
407#define G_IM_SIZ_4b_BYTES 0
408#define G_IM_SIZ_4b_TILE_BYTES G_IM_SIZ_4b_BYTES
409#define G_IM_SIZ_4b_LINE_BYTES G_IM_SIZ_4b_BYTES
411#define G_IM_SIZ_8b_BYTES 1
412#define G_IM_SIZ_8b_TILE_BYTES G_IM_SIZ_8b_BYTES
413#define G_IM_SIZ_8b_LINE_BYTES G_IM_SIZ_8b_BYTES
415#define G_IM_SIZ_16b_BYTES 2
416#define G_IM_SIZ_16b_TILE_BYTES G_IM_SIZ_16b_BYTES
417#define G_IM_SIZ_16b_LINE_BYTES G_IM_SIZ_16b_BYTES
419#define G_IM_SIZ_32b_BYTES 4
420#define G_IM_SIZ_32b_TILE_BYTES 2
421#define G_IM_SIZ_32b_LINE_BYTES 2
423#define G_IM_SIZ_4b_LOAD_BLOCK G_IM_SIZ_16b
424#define G_IM_SIZ_8b_LOAD_BLOCK G_IM_SIZ_16b
425#define G_IM_SIZ_16b_LOAD_BLOCK G_IM_SIZ_16b
426#define G_IM_SIZ_32b_LOAD_BLOCK G_IM_SIZ_32b
428#define G_IM_SIZ_4b_SHIFT 2
429#define G_IM_SIZ_8b_SHIFT 1
430#define G_IM_SIZ_16b_SHIFT 0
431#define G_IM_SIZ_32b_SHIFT 0
433#define G_IM_SIZ_4b_INCR 3
434#define G_IM_SIZ_8b_INCR 1
435#define G_IM_SIZ_16b_INCR 0
436#define G_IM_SIZ_32b_INCR 0
442#define G_CCMUX_COMBINED 0
443#define G_CCMUX_TEXEL0 1
444#define G_CCMUX_TEXEL1 2
445#define G_CCMUX_PRIMITIVE 3
446#define G_CCMUX_SHADE 4
447#define G_CCMUX_ENVIRONMENT 5
448#define G_CCMUX_CENTER 6
449#define G_CCMUX_SCALE 6
450#define G_CCMUX_COMBINED_ALPHA 7
451#define G_CCMUX_TEXEL0_ALPHA 8
452#define G_CCMUX_TEXEL1_ALPHA 9
453#define G_CCMUX_PRIMITIVE_ALPHA 10
454#define G_CCMUX_SHADE_ALPHA 11
455#define G_CCMUX_ENV_ALPHA 12
456#define G_CCMUX_LOD_FRACTION 13
457#define G_CCMUX_PRIM_LOD_FRAC 14
458#define G_CCMUX_NOISE 7
465#define G_ACMUX_COMBINED 0
466#define G_ACMUX_TEXEL0 1
467#define G_ACMUX_TEXEL1 2
468#define G_ACMUX_PRIMITIVE 3
469#define G_ACMUX_SHADE 4
470#define G_ACMUX_ENVIRONMENT 5
471#define G_ACMUX_LOD_FRACTION 0
472#define G_ACMUX_PRIM_LOD_FRAC 6
477#define G_CC_PRIMITIVE 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE
478#define G_CC_SHADE 0, 0, 0, SHADE, 0, 0, 0, SHADE
480#define G_CC_MODULATEI TEXEL0, 0, SHADE, 0, 0, 0, 0, SHADE
481#define G_CC_MODULATEIDECALA TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0
482#define G_CC_MODULATEIFADE TEXEL0, 0, SHADE, 0, 0, 0, 0, ENVIRONMENT
484#define G_CC_MODULATERGB G_CC_MODULATEI
485#define G_CC_MODULATERGBDECALA G_CC_MODULATEIDECALA
486#define G_CC_MODULATERGBFADE G_CC_MODULATEIFADE
488#define G_CC_MODULATEIA TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0
489#define G_CC_MODULATEIFADEA TEXEL0, 0, SHADE, 0, TEXEL0, 0, ENVIRONMENT, 0
491#define G_CC_MODULATEFADE TEXEL0, 0, SHADE, 0, ENVIRONMENT, 0, TEXEL0, 0
493#define G_CC_MODULATERGBA G_CC_MODULATEIA
494#define G_CC_MODULATERGBFADEA G_CC_MODULATEIFADEA
496#define G_CC_MODULATEI_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE
497#define G_CC_MODULATEIA_PRIM TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0
498#define G_CC_MODULATEIDECALA_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0
500#define G_CC_MODULATERGB_PRIM G_CC_MODULATEI_PRIM
501#define G_CC_MODULATERGBA_PRIM G_CC_MODULATEIA_PRIM
502#define G_CC_MODULATERGBDECALA_PRIM G_CC_MODULATEIDECALA_PRIM
504#define G_CC_FADE SHADE, 0, ENVIRONMENT, 0, SHADE, 0, ENVIRONMENT, 0
505#define G_CC_FADEA TEXEL0, 0, ENVIRONMENT, 0, TEXEL0, 0, ENVIRONMENT, 0
507#define G_CC_DECALRGB 0, 0, 0, TEXEL0, 0, 0, 0, SHADE
508#define G_CC_DECALRGBA 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0
509#define G_CC_DECALFADE 0, 0, 0, TEXEL0, 0, 0, 0, ENVIRONMENT
511#define G_CC_DECALFADEA 0, 0, 0, TEXEL0, TEXEL0, 0, ENVIRONMENT, 0
513#define G_CC_BLENDI ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE
514#define G_CC_BLENDIA ENVIRONMENT, SHADE, TEXEL0, SHADE, TEXEL0, 0, SHADE, 0
515#define G_CC_BLENDIDECALA ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0
517#define G_CC_BLENDRGBA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, SHADE
518#define G_CC_BLENDRGBDECALA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, TEXEL0
519#define G_CC_BLENDRGBFADEA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, ENVIRONMENT
521#define G_CC_ADDRGB TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, SHADE
522#define G_CC_ADDRGBDECALA TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0
523#define G_CC_ADDRGBFADE TEXEL0, 0, TEXEL0, SHADE, 0, 0, 0, ENVIRONMENT
525#define G_CC_REFLECTRGB ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, SHADE
526#define G_CC_REFLECTRGBDECALA ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0
528#define G_CC_HILITERGB PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE
529#define G_CC_HILITERGBA PRIMITIVE, SHADE, TEXEL0, SHADE, PRIMITIVE, SHADE, TEXEL0, SHADE
530#define G_CC_HILITERGBDECALA PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0
532#define G_CC_SHADEDECALA 0, 0, 0, SHADE, 0, 0, 0, TEXEL0
533#define G_CC_SHADEFADEA 0, 0, 0, SHADE, 0, 0, 0, ENVIRONMENT
535#define G_CC_BLENDPE PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, SHADE, 0
536#define G_CC_BLENDPEDECALA PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL0
539#define _G_CC_BLENDPE ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, SHADE, 0
540#define _G_CC_BLENDPEDECALA ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, 0, 0, 0, TEXEL0
541#define _G_CC_TWOCOLORTEX PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE
543#define _G_CC_SPARSEST PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0, PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0
544#define G_CC_TEMPLERP TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0
547#define G_CC_TRILERP TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0, TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0
548#define G_CC_INTERFERENCE TEXEL0, 0, TEXEL1, 0, TEXEL0, 0, TEXEL1, 0
553#define G_CC_1CYUV2RGB TEXEL0, K4, K5, TEXEL0, 0, 0, 0, SHADE
559#define G_CC_YUV2RGB TEXEL1, K4, K5, TEXEL1, 0, 0, 0, 0
562#define G_CC_PASS2 0, 0, 0, COMBINED, 0, 0, 0, COMBINED
563#define G_CC_MODULATEI2 COMBINED, 0, SHADE, 0, 0, 0, 0, SHADE
564#define G_CC_MODULATEIA2 COMBINED, 0, SHADE, 0, COMBINED, 0, SHADE, 0
565#define G_CC_MODULATERGB2 G_CC_MODULATEI2
566#define G_CC_MODULATERGBA2 G_CC_MODULATEIA2
567#define G_CC_MODULATEI_PRIM2 COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE
568#define G_CC_MODULATEIA_PRIM2 COMBINED, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0
569#define G_CC_MODULATERGB_PRIM2 G_CC_MODULATEI_PRIM2
570#define G_CC_MODULATERGBA_PRIM2 G_CC_MODULATEIA_PRIM2
571#define G_CC_DECALRGB2 0, 0, 0, COMBINED, 0, 0, 0, SHADE
576#define G_CC_BLENDI2 ENVIRONMENT, SHADE, COMBINED, SHADE, 0, 0, 0, SHADE
577#define G_CC_BLENDIA2 ENVIRONMENT, SHADE, COMBINED, SHADE, COMBINED, 0, SHADE, 0
578#define G_CC_CHROMA_KEY2 TEXEL0, CENTER, SCALE, 0, 0, 0, 0, 0
579#define G_CC_HILITERGB2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, SHADE
580#define G_CC_HILITERGBA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, ENVIRONMENT, COMBINED, TEXEL0, COMBINED
581#define G_CC_HILITERGBDECALA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, TEXEL0
582#define G_CC_HILITERGBPASSA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, COMBINED
587#define G_MDSFT_ALPHACOMPARE 0
588#define G_MDSFT_ZSRCSEL 2
589#define G_MDSFT_RENDERMODE 3
590#define G_MDSFT_BLENDER 16
595#define G_MDSFT_BLENDMASK 0
596#define G_MDSFT_ALPHADITHER 4
597#define G_MDSFT_RGBDITHER 6
599#define G_MDSFT_COMBKEY 8
600#define G_MDSFT_TEXTCONV 9
601#define G_MDSFT_TEXTFILT 12
602#define G_MDSFT_TEXTLUT 14
603#define G_MDSFT_TEXTLOD 16
604#define G_MDSFT_TEXTDETAIL 17
605#define G_MDSFT_TEXTPERSP 19
606#define G_MDSFT_CYCLETYPE 20
607#define G_MDSFT_COLORDITHER 22
608#define G_MDSFT_PIPELINE 23
611#define G_PM_1PRIMITIVE (1 << G_MDSFT_PIPELINE)
612#define G_PM_NPRIMITIVE (0 << G_MDSFT_PIPELINE)
615#define G_CYC_1CYCLE (0 << G_MDSFT_CYCLETYPE)
616#define G_CYC_2CYCLE (1 << G_MDSFT_CYCLETYPE)
617#define G_CYC_COPY (2 << G_MDSFT_CYCLETYPE)
618#define G_CYC_FILL (3 << G_MDSFT_CYCLETYPE)
621#define G_TP_NONE (0 << G_MDSFT_TEXTPERSP)
622#define G_TP_PERSP (1 << G_MDSFT_TEXTPERSP)
625#define G_TD_CLAMP (0 << G_MDSFT_TEXTDETAIL)
626#define G_TD_SHARPEN (1 << G_MDSFT_TEXTDETAIL)
627#define G_TD_DETAIL (2 << G_MDSFT_TEXTDETAIL)
630#define G_TL_TILE (0 << G_MDSFT_TEXTLOD)
631#define G_TL_LOD (1 << G_MDSFT_TEXTLOD)
634#define G_TT_NONE (0 << G_MDSFT_TEXTLUT)
635#define G_TT_RGBA16 (2 << G_MDSFT_TEXTLUT)
636#define G_TT_IA16 (3 << G_MDSFT_TEXTLUT)
639#define G_TF_POINT (0 << G_MDSFT_TEXTFILT)
640#define G_TF_AVERAGE (3 << G_MDSFT_TEXTFILT)
641#define G_TF_BILERP (2 << G_MDSFT_TEXTFILT)
644#define G_TC_CONV (0 << G_MDSFT_TEXTCONV)
645#define G_TC_FILTCONV (5 << G_MDSFT_TEXTCONV)
646#define G_TC_FILT (6 << G_MDSFT_TEXTCONV)
649#define G_CK_NONE (0 << G_MDSFT_COMBKEY)
650#define G_CK_KEY (1 << G_MDSFT_COMBKEY)
653#define G_CD_MAGICSQ (0 << G_MDSFT_RGBDITHER)
654#define G_CD_BAYER (1 << G_MDSFT_RGBDITHER)
655#define G_CD_NOISE (2 << G_MDSFT_RGBDITHER)
658#define G_CD_DISABLE (3 << G_MDSFT_RGBDITHER)
659#define G_CD_ENABLE G_CD_NOISE
661#define G_CD_ENABLE (1 << G_MDSFT_COLORDITHER)
662#define G_CD_DISABLE (0 << G_MDSFT_COLORDITHER)
666#define G_AD_PATTERN (0 << G_MDSFT_ALPHADITHER)
667#define G_AD_NOTPATTERN (1 << G_MDSFT_ALPHADITHER)
668#define G_AD_NOISE (2 << G_MDSFT_ALPHADITHER)
669#define G_AD_DISABLE (3 << G_MDSFT_ALPHADITHER)
672#define G_AC_NONE (0 << G_MDSFT_ALPHACOMPARE)
673#define G_AC_THRESHOLD (1 << G_MDSFT_ALPHACOMPARE)
674#define G_AC_DITHER (3 << G_MDSFT_ALPHACOMPARE)
677#define G_ZS_PIXEL (0 << G_MDSFT_ZSRCSEL)
678#define G_ZS_PRIM (1 << G_MDSFT_ZSRCSEL)
685#define CLR_ON_CVG 0x80
686#define CVG_DST_CLAMP 0
687#define CVG_DST_WRAP 0x100
688#define CVG_DST_FULL 0x200
689#define CVG_DST_SAVE 0x300
691#define ZMODE_INTER 0x400
692#define ZMODE_XLU 0x800
693#define ZMODE_DEC 0xc00
694#define CVG_X_ALPHA 0x1000
695#define ALPHA_CVG_SEL 0x2000
696#define FORCE_BL 0x4000
697#define TEX_EDGE 0x0000
700#define G_BL_CLR_MEM 1
702#define G_BL_CLR_FOG 3
707#define G_BL_A_SHADE 2
711#define GBL_c1(m1a, m1b, m2a, m2b) (m1a) << 30 | (m1b) << 26 | (m2a) << 22 | (m2b) << 18
712#define GBL_c2(m1a, m1b, m2a, m2b) (m1a) << 28 | (m1b) << 24 | (m2a) << 20 | (m2b) << 16
714#define RM_AA_ZB_OPA_SURF(clk) \
715 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \
716 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
718#define RM_RA_ZB_OPA_SURF(clk) \
719 AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \
720 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
722#define RM_AA_ZB_XLU_SURF(clk) \
723 AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_XLU | \
724 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
726#define RM_AA_ZB_OPA_DECAL(clk) \
727 AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ALPHA_CVG_SEL | ZMODE_DEC | \
728 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
730#define RM_RA_ZB_OPA_DECAL(clk) \
731 AA_EN | Z_CMP | CVG_DST_WRAP | ALPHA_CVG_SEL | ZMODE_DEC | \
732 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
734#define RM_AA_ZB_XLU_DECAL(clk) \
735 AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_DEC | \
736 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
738#define RM_AA_ZB_OPA_INTER(clk) \
739 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ALPHA_CVG_SEL | ZMODE_INTER | \
740 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
742#define RM_RA_ZB_OPA_INTER(clk) \
743 AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | ALPHA_CVG_SEL | ZMODE_INTER | \
744 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
746#define RM_AA_ZB_XLU_INTER(clk) \
747 AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_INTER | \
748 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
750#define RM_AA_ZB_XLU_LINE(clk) \
751 AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_XLU | \
752 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
754#define RM_AA_ZB_DEC_LINE(clk) \
755 AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_DEC | \
756 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
758#define RM_AA_ZB_TEX_EDGE(clk) \
759 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \
760 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
762#define RM_AA_ZB_TEX_INTER(clk) \
763 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_INTER | TEX_EDGE | \
764 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
766#define RM_AA_ZB_SUB_SURF(clk) \
767 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \
768 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
770#define RM_AA_ZB_PCL_SURF(clk) \
771 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | G_AC_DITHER | \
772 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
774#define RM_AA_ZB_OPA_TERR(clk) \
775 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \
776 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
778#define RM_AA_ZB_TEX_TERR(clk) \
779 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \
780 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
782#define RM_AA_ZB_SUB_TERR(clk) \
783 AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \
784 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
786#define RM_AA_OPA_SURF(clk) \
787 AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \
788 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
790#define RM_RA_OPA_SURF(clk) \
791 AA_EN | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
793#define RM_AA_XLU_SURF(clk) \
794 AA_EN | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | ZMODE_OPA | \
795 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
797#define RM_AA_XLU_LINE(clk) \
798 AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \
799 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
801#define RM_AA_DEC_LINE(clk) \
802 AA_EN | IM_RD | CVG_DST_FULL | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \
803 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
805#define RM_AA_TEX_EDGE(clk) \
806 AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \
807 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
809#define RM_AA_SUB_SURF(clk) \
810 AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \
811 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
813#define RM_AA_PCL_SURF(clk) \
814 AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | G_AC_DITHER | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
816#define RM_AA_OPA_TERR(clk) \
817 AA_EN | IM_RD | CVG_DST_CLAMP | ZMODE_OPA | ALPHA_CVG_SEL | \
818 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
820#define RM_AA_TEX_TERR(clk) \
821 AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \
822 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
824#define RM_AA_SUB_TERR(clk) \
825 AA_EN | IM_RD | CVG_DST_FULL | ZMODE_OPA | ALPHA_CVG_SEL | \
826 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
828#define RM_ZB_OPA_SURF(clk) \
829 Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_OPA | \
830 GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
832#define RM_ZB_XLU_SURF(clk) \
833 Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
835#define RM_ZB_OPA_DECAL(clk) \
836 Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM)
838#define RM_ZB_XLU_DECAL(clk) \
839 Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
841#define RM_ZB_CLD_SURF(clk) \
842 Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
844#define RM_ZB_OVL_SURF(clk) \
845 Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
847#define RM_ZB_PCL_SURF(clk) \
848 Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | G_AC_DITHER | GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)
850#define RM_OPA_SURF(clk) CVG_DST_CLAMP | FORCE_BL | ZMODE_OPA | GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)
852#define RM_XLU_SURF(clk) \
853 IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_OPA | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
855#define RM_TEX_EDGE(clk) \
856 CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | TEX_EDGE | AA_EN | \
857 GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)
859#define RM_CLD_SURF(clk) \
860 IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)
862#define RM_PCL_SURF(clk) \
863 CVG_DST_FULL | FORCE_BL | ZMODE_OPA | G_AC_DITHER | GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)
866 IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | GBL_c##clk(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1)
868#define RM_NOOP(clk) GBL_c##clk(0, 0, 0, 0)
870#define RM_VISCVG(clk) IM_RD | FORCE_BL | GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM)
873#define RM_OPA_CI(clk) CVG_DST_CLAMP | ZMODE_OPA | GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)
876#define RM_CUSTOM_AA_ZB_XLU_SURF(clk) RM_AA_ZB_XLU_SURF(clk) | Z_UPD
878#define G_RM_AA_ZB_OPA_SURF RM_AA_ZB_OPA_SURF(1)
879#define G_RM_AA_ZB_OPA_SURF2 RM_AA_ZB_OPA_SURF(2)
880#define G_RM_AA_ZB_XLU_SURF RM_AA_ZB_XLU_SURF(1)
881#define G_RM_AA_ZB_XLU_SURF2 RM_AA_ZB_XLU_SURF(2)
882#define G_RM_AA_ZB_OPA_DECAL RM_AA_ZB_OPA_DECAL(1)
883#define G_RM_AA_ZB_OPA_DECAL2 RM_AA_ZB_OPA_DECAL(2)
884#define G_RM_AA_ZB_XLU_DECAL RM_AA_ZB_XLU_DECAL(1)
885#define G_RM_AA_ZB_XLU_DECAL2 RM_AA_ZB_XLU_DECAL(2)
886#define G_RM_AA_ZB_OPA_INTER RM_AA_ZB_OPA_INTER(1)
887#define G_RM_AA_ZB_OPA_INTER2 RM_AA_ZB_OPA_INTER(2)
888#define G_RM_AA_ZB_XLU_INTER RM_AA_ZB_XLU_INTER(1)
889#define G_RM_AA_ZB_XLU_INTER2 RM_AA_ZB_XLU_INTER(2)
890#define G_RM_AA_ZB_XLU_LINE RM_AA_ZB_XLU_LINE(1)
891#define G_RM_AA_ZB_XLU_LINE2 RM_AA_ZB_XLU_LINE(2)
892#define G_RM_AA_ZB_DEC_LINE RM_AA_ZB_DEC_LINE(1)
893#define G_RM_AA_ZB_DEC_LINE2 RM_AA_ZB_DEC_LINE(2)
894#define G_RM_AA_ZB_TEX_EDGE RM_AA_ZB_TEX_EDGE(1)
895#define G_RM_AA_ZB_TEX_EDGE2 RM_AA_ZB_TEX_EDGE(2)
896#define G_RM_AA_ZB_TEX_INTER RM_AA_ZB_TEX_INTER(1)
897#define G_RM_AA_ZB_TEX_INTER2 RM_AA_ZB_TEX_INTER(2)
898#define G_RM_AA_ZB_SUB_SURF RM_AA_ZB_SUB_SURF(1)
899#define G_RM_AA_ZB_SUB_SURF2 RM_AA_ZB_SUB_SURF(2)
900#define G_RM_AA_ZB_PCL_SURF RM_AA_ZB_PCL_SURF(1)
901#define G_RM_AA_ZB_PCL_SURF2 RM_AA_ZB_PCL_SURF(2)
902#define G_RM_AA_ZB_OPA_TERR RM_AA_ZB_OPA_TERR(1)
903#define G_RM_AA_ZB_OPA_TERR2 RM_AA_ZB_OPA_TERR(2)
904#define G_RM_AA_ZB_TEX_TERR RM_AA_ZB_TEX_TERR(1)
905#define G_RM_AA_ZB_TEX_TERR2 RM_AA_ZB_TEX_TERR(2)
906#define G_RM_AA_ZB_SUB_TERR RM_AA_ZB_SUB_TERR(1)
907#define G_RM_AA_ZB_SUB_TERR2 RM_AA_ZB_SUB_TERR(2)
909#define G_RM_RA_ZB_OPA_SURF RM_RA_ZB_OPA_SURF(1)
910#define G_RM_RA_ZB_OPA_SURF2 RM_RA_ZB_OPA_SURF(2)
911#define G_RM_RA_ZB_OPA_DECAL RM_RA_ZB_OPA_DECAL(1)
912#define G_RM_RA_ZB_OPA_DECAL2 RM_RA_ZB_OPA_DECAL(2)
913#define G_RM_RA_ZB_OPA_INTER RM_RA_ZB_OPA_INTER(1)
914#define G_RM_RA_ZB_OPA_INTER2 RM_RA_ZB_OPA_INTER(2)
916#define G_RM_AA_OPA_SURF RM_AA_OPA_SURF(1)
917#define G_RM_AA_OPA_SURF2 RM_AA_OPA_SURF(2)
918#define G_RM_AA_XLU_SURF RM_AA_XLU_SURF(1)
919#define G_RM_AA_XLU_SURF2 RM_AA_XLU_SURF(2)
920#define G_RM_AA_XLU_LINE RM_AA_XLU_LINE(1)
921#define G_RM_AA_XLU_LINE2 RM_AA_XLU_LINE(2)
922#define G_RM_AA_DEC_LINE RM_AA_DEC_LINE(1)
923#define G_RM_AA_DEC_LINE2 RM_AA_DEC_LINE(2)
924#define G_RM_AA_TEX_EDGE RM_AA_TEX_EDGE(1)
925#define G_RM_AA_TEX_EDGE2 RM_AA_TEX_EDGE(2)
926#define G_RM_AA_SUB_SURF RM_AA_SUB_SURF(1)
927#define G_RM_AA_SUB_SURF2 RM_AA_SUB_SURF(2)
928#define G_RM_AA_PCL_SURF RM_AA_PCL_SURF(1)
929#define G_RM_AA_PCL_SURF2 RM_AA_PCL_SURF(2)
930#define G_RM_AA_OPA_TERR RM_AA_OPA_TERR(1)
931#define G_RM_AA_OPA_TERR2 RM_AA_OPA_TERR(2)
932#define G_RM_AA_TEX_TERR RM_AA_TEX_TERR(1)
933#define G_RM_AA_TEX_TERR2 RM_AA_TEX_TERR(2)
934#define G_RM_AA_SUB_TERR RM_AA_SUB_TERR(1)
935#define G_RM_AA_SUB_TERR2 RM_AA_SUB_TERR(2)
937#define G_RM_RA_OPA_SURF RM_RA_OPA_SURF(1)
938#define G_RM_RA_OPA_SURF2 RM_RA_OPA_SURF(2)
940#define G_RM_ZB_OPA_SURF RM_ZB_OPA_SURF(1)
941#define G_RM_ZB_OPA_SURF2 RM_ZB_OPA_SURF(2)
942#define G_RM_ZB_XLU_SURF RM_ZB_XLU_SURF(1)
943#define G_RM_ZB_XLU_SURF2 RM_ZB_XLU_SURF(2)
944#define G_RM_ZB_OPA_DECAL RM_ZB_OPA_DECAL(1)
945#define G_RM_ZB_OPA_DECAL2 RM_ZB_OPA_DECAL(2)
946#define G_RM_ZB_XLU_DECAL RM_ZB_XLU_DECAL(1)
947#define G_RM_ZB_XLU_DECAL2 RM_ZB_XLU_DECAL(2)
948#define G_RM_ZB_CLD_SURF RM_ZB_CLD_SURF(1)
949#define G_RM_ZB_CLD_SURF2 RM_ZB_CLD_SURF(2)
950#define G_RM_ZB_OVL_SURF RM_ZB_OVL_SURF(1)
951#define G_RM_ZB_OVL_SURF2 RM_ZB_OVL_SURF(2)
952#define G_RM_ZB_PCL_SURF RM_ZB_PCL_SURF(1)
953#define G_RM_ZB_PCL_SURF2 RM_ZB_PCL_SURF(2)
955#define G_RM_OPA_SURF RM_OPA_SURF(1)
956#define G_RM_OPA_SURF2 RM_OPA_SURF(2)
957#define G_RM_XLU_SURF RM_XLU_SURF(1)
958#define G_RM_XLU_SURF2 RM_XLU_SURF(2)
959#define G_RM_CLD_SURF RM_CLD_SURF(1)
960#define G_RM_CLD_SURF2 RM_CLD_SURF(2)
961#define G_RM_TEX_EDGE RM_TEX_EDGE(1)
962#define G_RM_TEX_EDGE2 RM_TEX_EDGE(2)
963#define G_RM_PCL_SURF RM_PCL_SURF(1)
964#define G_RM_PCL_SURF2 RM_PCL_SURF(2)
965#define G_RM_ADD RM_ADD(1)
966#define G_RM_ADD2 RM_ADD(2)
967#define G_RM_NOOP RM_NOOP(1)
968#define G_RM_NOOP2 RM_NOOP(2)
969#define G_RM_VISCVG RM_VISCVG(1)
970#define G_RM_VISCVG2 RM_VISCVG(2)
971#define G_RM_OPA_CI RM_OPA_CI(1)
972#define G_RM_OPA_CI2 RM_OPA_CI(2)
974#define G_RM_CUSTOM_AA_ZB_XLU_SURF RM_CUSTOM_AA_ZB_XLU_SURF(1)
975#define G_RM_CUSTOM_AA_ZB_XLU_SURF2 RM_CUSTOM_AA_ZB_XLU_SURF(2)
977#define G_RM_FOG_SHADE_A GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA)
978#define G_RM_FOG_PRIM_A GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA)
979#define G_RM_PASS GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1)
994#define G_SC_NON_INTERLACE 0
995#define G_SC_ODD_INTERLACE 3
996#define G_SC_EVEN_INTERLACE 2
999#define G_DL_PUSH 0x00
1000#define G_DL_NOPUSH 0x01
1005#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
1045 unsigned short flag;
1047 unsigned char cn[4];
1055 unsigned short flag;
1064 long long int force_structure_alignment;
1072 void* SourceImagePointer;
1075 short SubImageWidth;
1076 short SubImageHeight;
1077 char SourceImageType;
1078 char SourceImageBitSize;
1079 short SourceImageOffsetS;
1080 short SourceImageOffsetT;
1092 long long int force_structure_allignment[3];
1108typedef s32 Mtx_t[4][4];
1112 long long int force_structure_alignment;
1136#define G_MAXZ 0x03ff
1157 long long int force_structure_alignment;
1172#define G_MV_VIEWPORT 8
1173#define G_MV_LIGHT 10
1174#define G_MV_POINT 12
1175#define G_MV_MATRIX 14
1176#define G_MVO_LOOKATX (0 * 24)
1177#define G_MVO_LOOKATY (1 * 24)
1178#define G_MVO_L0 (2 * 24)
1179#define G_MVO_L1 (3 * 24)
1180#define G_MVO_L2 (4 * 24)
1181#define G_MVO_L3 (5 * 24)
1182#define G_MVO_L4 (6 * 24)
1183#define G_MVO_L5 (7 * 24)
1184#define G_MVO_L6 (8 * 24)
1185#define G_MVO_L7 (9 * 24)
1187#define G_MV_VIEWPORT 0x80
1188#define G_MV_LOOKATY 0x82
1189#define G_MV_LOOKATX 0x84
1198#define G_MV_TXTATT 0x96
1199#define G_MV_MATRIX_1 0x9e
1200#define G_MV_MATRIX_2 0x98
1201#define G_MV_MATRIX_3 0x9a
1202#define G_MV_MATRIX_4 0x9c
1213#define G_MW_MATRIX 0x00
1214#define G_MW_NUMLIGHT 0x02
1215#define G_MW_CLIP 0x04
1216#define G_MW_SEGMENT 0x06
1217#define G_MW_FOG 0x08
1218#define G_MW_LIGHTCOL 0x0a
1220#define G_MW_FORCEMTX 0x0c
1222#define G_MW_POINTS 0x0c
1224#define G_MW_PERSPNORM 0x0e
1229#define G_MWO_NUMLIGHT 0x00
1230#define G_MWO_CLIP_RNX 0x04
1231#define G_MWO_CLIP_RNY 0x0c
1232#define G_MWO_CLIP_RPX 0x14
1233#define G_MWO_CLIP_RPY 0x1c
1234#define G_MWO_SEGMENT_0 0x00
1235#define G_MWO_SEGMENT_1 0x01
1236#define G_MWO_SEGMENT_2 0x02
1237#define G_MWO_SEGMENT_3 0x03
1238#define G_MWO_SEGMENT_4 0x04
1239#define G_MWO_SEGMENT_5 0x05
1240#define G_MWO_SEGMENT_6 0x06
1241#define G_MWO_SEGMENT_7 0x07
1242#define G_MWO_SEGMENT_8 0x08
1243#define G_MWO_SEGMENT_9 0x09
1244#define G_MWO_SEGMENT_A 0x0a
1245#define G_MWO_SEGMENT_B 0x0b
1246#define G_MWO_SEGMENT_C 0x0c
1247#define G_MWO_SEGMENT_D 0x0d
1248#define G_MWO_SEGMENT_E 0x0e
1249#define G_MWO_SEGMENT_F 0x0f
1250#define G_MWO_FOG 0x00
1251#define G_MWO_aLIGHT_1 0x00
1252#define G_MWO_bLIGHT_1 0x04
1254#define G_MWO_aLIGHT_2 0x18
1255#define G_MWO_bLIGHT_2 0x1c
1256#define G_MWO_aLIGHT_3 0x30
1257#define G_MWO_bLIGHT_3 0x34
1258#define G_MWO_aLIGHT_4 0x48
1259#define G_MWO_bLIGHT_4 0x4c
1260#define G_MWO_aLIGHT_5 0x60
1261#define G_MWO_bLIGHT_5 0x64
1262#define G_MWO_aLIGHT_6 0x78
1263#define G_MWO_bLIGHT_6 0x7c
1264#define G_MWO_aLIGHT_7 0x90
1265#define G_MWO_bLIGHT_7 0x94
1266#define G_MWO_aLIGHT_8 0xa8
1267#define G_MWO_bLIGHT_8 0xac
1269#define G_MWO_aLIGHT_2 0x20
1270#define G_MWO_bLIGHT_2 0x24
1271#define G_MWO_aLIGHT_3 0x40
1272#define G_MWO_bLIGHT_3 0x44
1273#define G_MWO_aLIGHT_4 0x60
1274#define G_MWO_bLIGHT_4 0x64
1275#define G_MWO_aLIGHT_5 0x80
1276#define G_MWO_bLIGHT_5 0x84
1277#define G_MWO_aLIGHT_6 0xa0
1278#define G_MWO_bLIGHT_6 0xa4
1279#define G_MWO_aLIGHT_7 0xc0
1280#define G_MWO_bLIGHT_7 0xc4
1281#define G_MWO_aLIGHT_8 0xe0
1282#define G_MWO_bLIGHT_8 0xe4
1284#define G_MWO_MATRIX_XX_XY_I 0x00
1285#define G_MWO_MATRIX_XZ_XW_I 0x04
1286#define G_MWO_MATRIX_YX_YY_I 0x08
1287#define G_MWO_MATRIX_YZ_YW_I 0x0c
1288#define G_MWO_MATRIX_ZX_ZY_I 0x10
1289#define G_MWO_MATRIX_ZZ_ZW_I 0x14
1290#define G_MWO_MATRIX_WX_WY_I 0x18
1291#define G_MWO_MATRIX_WZ_WW_I 0x1c
1292#define G_MWO_MATRIX_XX_XY_F 0x20
1293#define G_MWO_MATRIX_XZ_XW_F 0x24
1294#define G_MWO_MATRIX_YX_YY_F 0x28
1295#define G_MWO_MATRIX_YZ_YW_F 0x2c
1296#define G_MWO_MATRIX_ZX_ZY_F 0x30
1297#define G_MWO_MATRIX_ZZ_ZW_F 0x34
1298#define G_MWO_MATRIX_WX_WY_F 0x38
1299#define G_MWO_MATRIX_WZ_WW_F 0x3c
1300#define G_MWO_POINT_RGBA 0x10
1301#define G_MWO_POINT_ST 0x14
1302#define G_MWO_POINT_XYSCREEN 0x18
1303#define G_MWO_POINT_ZSCREEN 0x1c
1316 unsigned char col[3];
1318 unsigned char colc[3];
1325 unsigned char col[3];
1327 unsigned char colc[3];
1337 long long int force_structure_alignment[2];
1342 long long int force_structure_alignment[1];
1396 long int force_structure_alignment[4];
1399#define gdSPDefLights0(ar, ag, ab) \
1401 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1403 { { 0, 0, 0 }, 0, { 0, 0, 0 }, 0, { 0, 0, 0 }, 0 } \
1407#define gdSPDefLights1(ar, ag, ab, r1, g1, b1, x1, y1, z1) \
1409 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1411 { { r1, g1, b1 }, 0, { r1, g1, b1 }, 0, { x1, y1, z1 }, 0 } \
1415#define gdSPDefLights2(ar, ag, ab, r1, g1, b1, x1, y1, z1, r2, g2, b2, x2, y2, z2) \
1417 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1418 { { { r1, g1, b1 }, 0, { r1, g1, b1 }, 0, { x1, y1, z1 }, 0 } }, { \
1419 { { r2, g2, b2 }, 0, { r2, g2, b2 }, 0, { x2, y2, z2 }, 0 } \
1423#define gdSPDefLights3(ar, ag, ab, r1, g1, b1, x1, y1, z1, r2, g2, b2, x2, y2, z2, r3, g3, b3, x3, y3, z3) \
1425 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1426 { { { r1, g1, b1 }, 0, { r1, g1, b1 }, 0, { x1, y1, z1 }, 0 } }, \
1427 { { { r2, g2, b2 }, 0, { r2, g2, b2 }, 0, { x2, y2, z2 }, 0 } }, { \
1428 { { r3, g3, b3 }, 0, { r3, g3, b3 }, 0, { x3, y3, z3 }, 0 } \
1432#define gdSPDefLights4(ar, ag, ab, r1, g1, b1, x1, y1, z1, r2, g2, b2, x2, y2, z2, r3, g3, b3, x3, y3, z3, r4, g4, b4, \
1435 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1436 { { { r1, g1, b1 }, 0, { r1, g1, b1 }, 0, { x1, y1, z1 }, 0 } }, \
1437 { { { r2, g2, b2 }, 0, { r2, g2, b2 }, 0, { x2, y2, z2 }, 0 } }, \
1438 { { { r3, g3, b3 }, 0, { r3, g3, b3 }, 0, { x3, y3, z3 }, 0 } }, { \
1439 { { r4, g4, b4 }, 0, { r4, g4, b4 }, 0, { x4, y4, z4 }, 0 } \
1443#define gdSPDefLights5(ar, ag, ab, r1, g1, b1, x1, y1, z1, r2, g2, b2, x2, y2, z2, r3, g3, b3, x3, y3, z3, r4, g4, b4, \
1444 x4, y4, z4, r5, g5, b5, x5, y5, z5) \
1446 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1447 { { { r1, g1, b1 }, 0, { r1, g1, b1 }, 0, { x1, y1, z1 }, 0 } }, \
1448 { { { r2, g2, b2 }, 0, { r2, g2, b2 }, 0, { x2, y2, z2 }, 0 } }, \
1449 { { { r3, g3, b3 }, 0, { r3, g3, b3 }, 0, { x3, y3, z3 }, 0 } }, \
1450 { { { r4, g4, b4 }, 0, { r4, g4, b4 }, 0, { x4, y4, z4 }, 0 } }, { \
1451 { { r5, g5, b5 }, 0, { r5, g5, b5 }, 0, { x5, y5, z5 }, 0 } \
1456#define gdSPDefLights6(ar, ag, ab, r1, g1, b1, x1, y1, z1, r2, g2, b2, x2, y2, z2, r3, g3, b3, x3, y3, z3, r4, g4, b4, \
1457 x4, y4, z4, r5, g5, b5, x5, y5, z5, r6, g6, b6, x6, y6, z6) \
1459 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1460 { { { r1, g1, b1 }, 0, { r1, g1, b1 }, 0, { x1, y1, z1 }, 0 } }, \
1461 { { { r2, g2, b2 }, 0, { r2, g2, b2 }, 0, { x2, y2, z2 }, 0 } }, \
1462 { { { r3, g3, b3 }, 0, { r3, g3, b3 }, 0, { x3, y3, z3 }, 0 } }, \
1463 { { { r4, g4, b4 }, 0, { r4, g4, b4 }, 0, { x4, y4, z4 }, 0 } }, \
1464 { { { r5, g5, b5 }, 0, { r5, g5, b5 }, 0, { x5, y5, z5 }, 0 } }, { \
1465 { { r6, g6, b6 }, 0, { r6, g6, b6 }, 0, { x6, y6, z6 }, 0 } \
1470#define gdSPDefLights7(ar, ag, ab, r1, g1, b1, x1, y1, z1, r2, g2, b2, x2, y2, z2, r3, g3, b3, x3, y3, z3, r4, g4, b4, \
1471 x4, y4, z4, r5, g5, b5, x5, y5, z5, r6, g6, b6, x6, y6, z6, r7, g7, b7, x7, y7, z7) \
1473 { { { ar, ag, ab }, 0, { ar, ag, ab }, 0 } }, { \
1474 { { { r1, g1, b1 }, 0, { r1, g1, b1 }, 0, { x1, y1, z1 }, 0 } }, \
1475 { { { r2, g2, b2 }, 0, { r2, g2, b2 }, 0, { x2, y2, z2 }, 0 } }, \
1476 { { { r3, g3, b3 }, 0, { r3, g3, b3 }, 0, { x3, y3, z3 }, 0 } }, \
1477 { { { r4, g4, b4 }, 0, { r4, g4, b4 }, 0, { x4, y4, z4 }, 0 } }, \
1478 { { { r5, g5, b5 }, 0, { r5, g5, b5 }, 0, { x5, y5, z5 }, 0 } }, \
1479 { { { r6, g6, b6 }, 0, { r6, g6, b6 }, 0, { x6, y6, z6 }, 0 } }, { \
1480 { { r7, g7, b7 }, 0, { r7, g7, b7 }, 0, { x7, y7, z7 }, 0 } \
1485#define gdSPDefLookAt(rightx, righty, rightz, upx, upy, upz) \
1488 { { { 0, 0, 0 }, 0, { 0, 0, 0 }, 0, { rightx, righty, rightz }, 0 } }, { \
1489 { { 0, 0x80, 0 }, 0, { 0, 0x80, 0 }, 0, { upx, upy, upz }, 0 } \
1501 unsigned int par : 8;
1502 unsigned int len : 16;
1519 unsigned char param : 8;
1545 unsigned int data : 32;
1553 unsigned int data : 32;
1558 unsigned char lodscale;
1583 unsigned int fmt : 3;
1584 unsigned int siz : 2;
1585 unsigned int pad : 7;
1586 unsigned int wd : 12;
1592 unsigned int muxs0 : 24;
1593 unsigned int muxs1 : 32;
1599 unsigned char prim_min_level;
1600 unsigned char prim_level;
1601 unsigned long color;
1610 unsigned int pad : 8;
1619 unsigned int fmt : 3;
1620 unsigned int siz : 2;
1621 unsigned int pad0 : 1;
1622 unsigned int line : 9;
1623 unsigned int tmem : 9;
1624 unsigned int pad1 : 5;
1625 unsigned int tile : 3;
1626 unsigned int palette : 4;
1627 unsigned int ct : 1;
1628 unsigned int mt : 1;
1629 unsigned int maskt : 4;
1630 unsigned int shiftt : 4;
1631 unsigned int cs : 1;
1632 unsigned int ms : 1;
1633 unsigned int masks : 4;
1634 unsigned int shifts : 4;
1639 unsigned int sl : 12;
1640 unsigned int tl : 12;
1642 unsigned int tile : 3;
1643 unsigned int sh : 12;
1644 unsigned int th : 12;
1647typedef Gloadtile Gloadblock;
1649typedef Gloadtile Gsettilesize;
1651typedef Gloadtile Gloadtlut;
1654 unsigned int cmd : 8;
1655 unsigned int xl : 12;
1656 unsigned int yl : 12;
1657 unsigned int pad1 : 5;
1658 unsigned int tile : 3;
1659 unsigned int xh : 12;
1660 unsigned int yh : 12;
1661 unsigned int s : 16;
1662 unsigned int t : 16;
1663 unsigned int dsdx : 16;
1664 unsigned int dtdy : 16;
1678#define MakeTexRect(xh, yh, flip, tile, xl, yl, s, t, dsdx, dtdy) \
1679 G_TEXRECT, xh, yh, 0, flip, 0, tile, xl, yl, s, t, dsdx, dtdy
1700#if !defined(F3D_OLD) && IS_BIG_ENDIAN && !IS_64_BIT
1706 GsetothermodeH setothermodeH;
1707 GsetothermodeL setothermodeL;
1709 Gperspnorm perspnorm;
1711 Gsetcombine setcombine;
1716 Gsettilesize settilesize;
1719 long long int force_structure_alignment;
1729#define gDma0p(pkt, c, s, l) \
1731 Gfx* _g = (Gfx*) (pkt); \
1733 _g->words.w0 = _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24); \
1734 _g->words.w1 = (uintptr_t) (s); \
1737#define gsDma0p(c, s, l) \
1739 { _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24), (uintptr_t) (s) } \
1742#define gDma1p(pkt, c, s, l, p) \
1744 Gfx* _g = (Gfx*) (pkt); \
1746 _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | _SHIFTL((l), 0, 16)); \
1747 _g->words.w1 = (uintptr_t) (s); \
1750#define gsDma1p(c, s, l, p) \
1752 { (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | _SHIFTL((l), 0, 16)), (uintptr_t) (s) } \
1755#define gDma2p(pkt, c, adrs, len, idx, ofs) \
1757 Gfx* _g = (Gfx*) (pkt); \
1759 (_SHIFTL((c), 24, 8) | _SHIFTL(((len) - 1) / 8, 19, 5) | _SHIFTL((ofs) / 8, 8, 8) | _SHIFTL((idx), 0, 8)); \
1760 _g->words.w1 = (uintptr_t) (adrs); \
1762#define gsDma2p(c, adrs, len, idx, ofs) \
1765 (_SHIFTL((c), 24, 8) | _SHIFTL(((len) - 1) / 8, 19, 5) | _SHIFTL((ofs) / 8, 8, 8) | _SHIFTL((idx), 0, 8)), \
1766 (uintptr_t) (adrs) \
1770#define gSPNoOp(pkt) gDma0p(pkt, G_SPNOOP, 0, 0)
1771#define gsSPNoOp() gsDma0p(G_SPNOOP, 0, 0)
1774#define gSPMatrix(pkt, m, p) gDma2p((pkt), G_MTX, (m), sizeof(Mtx), (p) ^ G_MTX_PUSH, 0)
1775#define gsSPMatrix(m, p) gsDma2p(G_MTX, (m), sizeof(Mtx), (p) ^ G_MTX_PUSH, 0)
1777#define gSPMatrix(pkt, m, p) gDma1p(pkt, G_MTX, m, sizeof(Mtx), p)
1778#define gsSPMatrix(m, p) gsDma1p(G_MTX, m, sizeof(Mtx), p)
1781#if defined(F3DEX_GBI_2)
1791#define gSPVertex(pkt, v, n, v0) \
1793 Gfx* _g = (Gfx*) (pkt); \
1794 _g->words.w0 = _SHIFTL(G_VTX, 24, 8) | _SHIFTL((n), 12, 8) | _SHIFTL((v0) + (n), 1, 7); \
1795 _g->words.w1 = (uintptr_t) (v); \
1797#define gsSPVertex(v, n, v0) \
1799 { (_SHIFTL(G_VTX, 24, 8) | _SHIFTL((n), 12, 8) | _SHIFTL((v0) + (n), 1, 7)), (uintptr_t) (v) } \
1801#elif (defined(F3DEX_GBI) || defined(F3DLP_GBI))
1811#define gSPVertex(pkt, v, n, v0) gDma1p((pkt), G_VTX, (v), ((n) << 10) | (sizeof(Vtx) * (n) - 1), (v0) * 2)
1812#define gsSPVertex(v, n, v0) gsDma1p(G_VTX, (v), ((n) << 10) | (sizeof(Vtx) * (n) - 1), (v0) * 2)
1814#define gSPVertex(pkt, v, n, v0) gDma1p(pkt, G_VTX, v, sizeof(Vtx) * (n), ((n) - 1) << 4 | (v0))
1815#define gsSPVertex(v, n, v0) gsDma1p(G_VTX, v, sizeof(Vtx) * (n), ((n) - 1) << 4 | (v0))
1819#define gSPViewport(pkt, v) gDma2p((pkt), G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT, 0)
1820#define gsSPViewport(v) gsDma2p(G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT, 0)
1822#define gSPViewport(pkt, v) gDma1p((pkt), G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT)
1823#define gsSPViewport(v) gsDma1p(G_MOVEMEM, (v), sizeof(Vp), G_MV_VIEWPORT)
1826#define gSPDisplayList(pkt, dl) gDma1p(pkt, G_DL, dl, 0, G_DL_PUSH)
1827#define gsSPDisplayList(dl) gsDma1p(G_DL, dl, 0, G_DL_PUSH)
1829#define gSPBranchList(pkt, dl) gDma1p(pkt, G_DL, dl, 0, G_DL_NOPUSH)
1830#define gsSPBranchList(dl) gsDma1p(G_DL, dl, 0, G_DL_NOPUSH)
1832#define gSPSprite2DBase(pkt, s) gDma1p(pkt, G_SPRITE2D_BASE, s, sizeof(uSprite), 0)
1833#define gsSPSprite2DBase(s) gsDma1p(G_SPRITE2D_BASE, s, sizeof(uSprite), 0)
1838#define gImmp0(pkt, c) \
1840 Gfx* _g = (Gfx*) (pkt); \
1842 _g->words.w0 = _SHIFTL((c), 24, 8); \
1847 { _SHIFTL((c), 24, 8) } \
1850#define gImmp1(pkt, c, p0) \
1852 Gfx* _g = (Gfx*) (pkt); \
1854 _g->words.w0 = _SHIFTL((c), 24, 8); \
1855 _g->words.w1 = (uintptr_t) (p0); \
1858#define gsImmp1(c, p0) \
1860 { _SHIFTL((c), 24, 8), (uintptr_t) (p0) } \
1863#define gImmp2(pkt, c, p0, p1) \
1865 Gfx* _g = (Gfx*) (pkt); \
1867 _g->words.w0 = _SHIFTL((c), 24, 8); \
1868 _g->words.w1 = _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8); \
1871#define gsImmp2(c, p0, p1) \
1873 { _SHIFTL((c), 24, 8), _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8) } \
1876#define gImmp3(pkt, c, p0, p1, p2) \
1878 Gfx* _g = (Gfx*) (pkt); \
1880 _g->words.w0 = _SHIFTL((c), 24, 8); \
1881 _g->words.w1 = (_SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8) | _SHIFTL((p2), 0, 8)); \
1884#define gsImmp3(c, p0, p1, p2) \
1886 { _SHIFTL((c), 24, 8), (_SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8) | _SHIFTL((p2), 0, 8)) } \
1889#define gImmp21(pkt, c, p0, p1, dat) \
1891 Gfx* _g = (Gfx*) (pkt); \
1893 _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | _SHIFTL((p1), 0, 8)); \
1894 _g->words.w1 = (uintptr_t) (dat); \
1897#define gsImmp21(c, p0, p1, dat) \
1899 { _SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | _SHIFTL((p1), 0, 8), (uintptr_t) (dat) } \
1903#define gMoveWd(pkt, index, offset, data) gDma1p((pkt), G_MOVEWORD, data, offset, index)
1904#define gsMoveWd(index, offset, data) gsDma1p(G_MOVEWORD, data, offset, index)
1906#define gMoveWd(pkt, index, offset, data) gImmp21((pkt), G_MOVEWORD, offset, index, data)
1907#define gsMoveWd(index, offset, data) gsImmp21(G_MOVEWORD, offset, index, data)
1912#define gSPSprite2DScaleFlip(pkt, sx, sy, fx, fy) \
1914 Gfx* _g = (Gfx*) (pkt); \
1916 _g->words.w0 = (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | _SHIFTL((fx), 8, 8) | _SHIFTL((fy), 0, 8)); \
1917 _g->words.w1 = (_SHIFTL((sx), 16, 16) | _SHIFTL((sy), 0, 16)); \
1920#define gsSPSprite2DScaleFlip(sx, sy, fx, fy) \
1923 (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | _SHIFTL((fx), 8, 8) | _SHIFTL((fy), 0, 8)), \
1924 (_SHIFTL((sx), 16, 16) | _SHIFTL((sy), 0, 16)) \
1928#define gSPSprite2DDraw(pkt, px, py) \
1930 Gfx* _g = (Gfx*) (pkt); \
1932 _g->words.w0 = (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)); \
1933 _g->words.w1 = (_SHIFTL((px), 16, 16) | _SHIFTL((py), 0, 16)); \
1936#define gsSPSprite2DDraw(px, py) \
1938 { (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)), (_SHIFTL((px), 16, 16) | _SHIFTL((py), 0, 16)) } \
1945#if (defined(F3DLP_GBI) || defined(F3DEX_GBI))
1946#define __gsSP1Triangle_w1(v0, v1, v2) (_SHIFTL((v0) * 2, 16, 8) | _SHIFTL((v1) * 2, 8, 8) | _SHIFTL((v2) * 2, 0, 8))
1947#define __gsSP1Triangle_w1f(v0, v1, v2, flag) \
1948 (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2) \
1949 : ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v0) \
1950 : __gsSP1Triangle_w1(v2, v0, v1))
1951#define __gsSPLine3D_w1(v0, v1, wd) (_SHIFTL((v0) * 2, 16, 8) | _SHIFT((v1) * 2, 8, 8) | _SHIFT((wd), 0, 8))
1952#define __gsSPLine3D_w1f(v0, v1, wd, flag) (((flag) == 0) ? __gsSPLine3D_w1(v0, v1, wd) : __gsSPLine3D_w1(v1, v0, wd))
1955#define __gsSP1Quadrangle_w1(v0, v1, v2, v3) \
1956 (_SHIFTL((v3) * 2, 24, 8) | _SHIFTL((v0) * 2, 16, 8) | _SHIFTL((v1) * 2, 8, 8) | _SHIFTL((v2) * 2, 0, 8))
1958#define __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag) \
1959 (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2) \
1960 : ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v3) \
1961 : ((flag) == 2) ? __gsSP1Triangle_w1(v2, v3, v0) \
1962 : __gsSP1Triangle_w1(v3, v0, v1))
1963#define __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \
1964 (((flag) == 0) ? __gsSP1Triangle_w1(v0, v2, v3) \
1965 : ((flag) == 1) ? __gsSP1Triangle_w1(v1, v3, v0) \
1966 : ((flag) == 2) ? __gsSP1Triangle_w1(v2, v0, v1) \
1967 : __gsSP1Triangle_w1(v3, v1, v2))
1969#define __gsSP1Triangle_w1f(v0, v1, v2, flag) \
1970 (_SHIFTL((flag), 24, 8) | _SHIFTL((v0) * 10, 16, 8) | _SHIFTL((v1) * 10, 8, 8) | _SHIFTL((v2) * 10, 0, 8))
1971#define __gsSPLine3D_w1f(v0, v1, wd, flag) \
1972 (_SHIFTL((flag), 24, 8) | _SHIFTL((v0) * 10, 16, 8) | _SHIFTL((v1) * 10, 8, 8) | _SHIFTL((wd), 0, 8))
1979#define gSP1Triangle(pkt, v0, v1, v2, flag) \
1981 Gfx* _g = (Gfx*) (pkt); \
1983 _g->words.w0 = _SHIFTL(G_TRI1, 24, 8) | __gsSP1Triangle_w1f(v0, v1, v2, flag); \
1986#define gsSP1Triangle(v0, v1, v2, flag) \
1988 { _SHIFTL(G_TRI1, 24, 8) | __gsSP1Triangle_w1f(v0, v1, v2, flag), 0 } \
1994#define gSPLine3D(pkt, v0, v1, flag) \
1996 Gfx* _g = (Gfx*) (pkt); \
1998 _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8) | __gsSPLine3D_w1f(v0, v1, 0, flag); \
2001#define gsSPLine3D(v0, v1, flag) \
2003 { _SHIFTL(G_LINE3D, 24, 8) | __gsSPLine3D_w1f(v0, v1, 0, flag), 0 } \
2015#define gSPLineW3D(pkt, v0, v1, wd, flag) \
2017 Gfx* _g = (Gfx*) (pkt); \
2019 _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8) | __gsSPLine3D_w1f(v0, v1, wd, flag); \
2022#define gsSPLineW3D(v0, v1, wd, flag) \
2024 { _SHIFTL(G_LINE3D, 24, 8) | __gsSPLine3D_w1f(v0, v1, wd, flag), 0 } \
2030#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \
2032 Gfx* _g = (Gfx*) (pkt); \
2034 _g->words.w0 = (_SHIFTL(G_QUAD, 24, 8) | __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)); \
2035 _g->words.w1 = __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag); \
2038#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \
2041 (_SHIFTL(G_QUAD, 24, 8) | __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \
2042 __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \
2050#define gSP1Triangle(pkt, v0, v1, v2, flag) \
2052 Gfx* _g = (Gfx*) (pkt); \
2054 _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \
2055 _g->words.w1 = __gsSP1Triangle_w1f(v0, v1, v2, flag); \
2057#define gsSP1Triangle(v0, v1, v2, flag) \
2059 { _SHIFTL(G_TRI1, 24, 8), __gsSP1Triangle_w1f(v0, v1, v2, flag) } \
2065#define gSPLine3D(pkt, v0, v1, flag) \
2067 Gfx* _g = (Gfx*) (pkt); \
2069 _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \
2070 _g->words.w1 = __gsSPLine3D_w1f(v0, v1, 0, flag); \
2072#define gsSPLine3D(v0, v1, flag) \
2074 { _SHIFTL(G_LINE3D, 24, 8), __gsSPLine3D_w1f(v0, v1, 0, flag) } \
2086#define gSPLineW3D(pkt, v0, v1, wd, flag) \
2088 Gfx* _g = (Gfx*) (pkt); \
2090 _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \
2091 _g->words.w1 = __gsSPLine3D_w1f(v0, v1, wd, flag); \
2093#define gsSPLineW3D(v0, v1, wd, flag) \
2095 { _SHIFTL(G_LINE3D, 24, 8), __gsSPLine3D_w1f(v0, v1, wd, flag) } \
2105#define gSP1Quadrangle(v0, v1, v2, v3, flag) \
2108 Gfx* _g = (Gfx*) (pkt); \
2110 _g->words.w0 = _SHIFTL(G_QUAD, 24, 8); \
2111 _g->words.w1 = __gsSP1Quadrangle_w1(v0, v1, v2, v3); \
2115#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \
2117 { _SHIFTL(G_QUAD, 24, 8), __gsSP1Quadrangle_w1(v0, v1, v2, v3) } \
2123#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \
2125 Gfx* _g = (Gfx*) (pkt); \
2127 _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8) | __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)); \
2128 _g->words.w1 = __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag); \
2131#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \
2134 (_SHIFTL(G_TRI2, 24, 8) | __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \
2135 __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \
2141#if (defined(F3DLP_GBI) || defined(F3DEX_GBI))
2145#define gSP2Triangles(pkt, v00, v01, v02, flag0, v10, v11, v12, flag1) \
2147 Gfx* _g = (Gfx*) (pkt); \
2149 _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8) | __gsSP1Triangle_w1f(v00, v01, v02, flag0)); \
2150 _g->words.w1 = __gsSP1Triangle_w1f(v10, v11, v12, flag1); \
2153#define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \
2156 (_SHIFTL(G_TRI2, 24, 8) | __gsSP1Triangle_w1f(v00, v01, v02, flag0)), \
2157 __gsSP1Triangle_w1f(v10, v11, v12, flag1) \
2161#define gSP2Triangles(pkt, v00, v01, v02, flag0, v10, v11, v12, flag1) \
2163 gSP1Triangle(pkt, v00, v01, v02, flag0); \
2164 gSP1Triangle(pkt, v10, v11, v12, flag1); \
2166#define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \
2167 gsSP1Triangle(v00, v01, v02, flag0), gsSP1Triangle(v10, v11, v12, flag1)
2171#if (defined(F3DEX_GBI) || defined(F3DLP_GBI))
2172#define gSPCullDisplayList(pkt, vstart, vend) \
2174 Gfx* _g = (Gfx*) (pkt); \
2176 _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | _SHIFTL((vstart) * 2, 0, 16); \
2177 _g->words.w1 = _SHIFTL((vend) * 2, 0, 16); \
2180#define gsSPCullDisplayList(vstart, vend) \
2182 { _SHIFTL(G_CULLDL, 24, 8) | _SHIFTL((vstart) * 2, 0, 16), _SHIFTL((vend) * 2, 0, 16) } \
2186#define gSPCullDisplayList(pkt, vstart, vend) \
2188 Gfx* _g = (Gfx*) (pkt); \
2190 _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | ((0x0f & (vstart)) * 40); \
2191 _g->words.w1 = (unsigned int) ((0x0f & ((vend) + 1)) * 40); \
2194#define gsSPCullDisplayList(vstart, vend) \
2196 { _SHIFTL(G_CULLDL, 24, 8) | ((0x0f & (vstart)) * 40), ((0x0f & ((vend) + 1)) * 40) } \
2200#define gSPSegment(pkt, segment, base) gMoveWd(pkt, G_MW_SEGMENT, (segment) * 4, base)
2201#define gsSPSegment(segment, base) gsMoveWd(G_MW_SEGMENT, (segment) * 4, base)
2206#define FR_NEG_FRUSTRATIO_1 0x00000001
2207#define FR_POS_FRUSTRATIO_1 0x0000ffff
2208#define FR_NEG_FRUSTRATIO_2 0x00000002
2209#define FR_POS_FRUSTRATIO_2 0x0000fffe
2210#define FR_NEG_FRUSTRATIO_3 0x00000003
2211#define FR_POS_FRUSTRATIO_3 0x0000fffd
2212#define FR_NEG_FRUSTRATIO_4 0x00000004
2213#define FR_POS_FRUSTRATIO_4 0x0000fffc
2214#define FR_NEG_FRUSTRATIO_5 0x00000005
2215#define FR_POS_FRUSTRATIO_5 0x0000fffb
2216#define FR_NEG_FRUSTRATIO_6 0x00000006
2217#define FR_POS_FRUSTRATIO_6 0x0000fffa
2221#define gSPClipRatio(pkt, r) \
2223 gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r); \
2224 gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r); \
2225 gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r); \
2226 gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r); \
2229#define gsSPClipRatio(r) \
2230 gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r), gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r), \
2231 gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r), gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r)
2241#define gSPInsertMatrix(pkt, where, num) ERROR !!gSPInsertMatrix is no longer supported.
2242#define gsSPInsertMatrix(where, num) ERROR !!gsSPInsertMatrix is no longer supported.
2244#define gSPInsertMatrix(pkt, where, num) gMoveWd(pkt, G_MW_MATRIX, where, num)
2245#define gsSPInsertMatrix(where, num) gsMoveWd(G_MW_MATRIX, where, num)
2254#define gSPForceMatrix(pkt, mptr) \
2256 gDma2p((pkt), G_MOVEMEM, (mptr), sizeof(Mtx), G_MV_MATRIX, 0); \
2257 gMoveWd((pkt), G_MW_FORCEMTX, 0, 0x00010000); \
2259#define gsSPForceMatrix(mptr) \
2260 gsDma2p(G_MOVEMEM, (mptr), sizeof(Mtx), G_MV_MATRIX, 0), gsMoveWd(G_MW_FORCEMTX, 0, 0x00010000)
2263#define gSPForceMatrix(pkt, mptr) \
2265 gDma1p(pkt, G_MOVEMEM, mptr, 16, G_MV_MATRIX_1); \
2266 gDma1p(pkt, G_MOVEMEM, (char*) (mptr) + 16, 16, G_MV_MATRIX_2); \
2267 gDma1p(pkt, G_MOVEMEM, (char*) (mptr) + 32, 16, G_MV_MATRIX_3); \
2268 gDma1p(pkt, G_MOVEMEM, (char*) (mptr) + 48, 16, G_MV_MATRIX_4); \
2270#define gsSPForceMatrix(mptr) \
2271 gsDma1p(G_MOVEMEM, mptr, 16, G_MV_MATRIX_1), gsDma1p(G_MOVEMEM, (char*) (mptr) + 16, 16, G_MV_MATRIX_2), \
2272 gsDma1p(G_MOVEMEM, (char*) (mptr) + 32, 16, G_MV_MATRIX_3), \
2273 gsDma1p(G_MOVEMEM, (char*) (mptr) + 48, 16, G_MV_MATRIX_4)
2283#if (defined(F3DEX_GBI) || defined(F3DLP_GBI))
2284#define gSPModifyVertex(pkt, vtx, where, val) \
2286 Gfx* _g = (Gfx*) (pkt); \
2287 _g->words.w0 = (_SHIFTL(G_MODIFYVTX, 24, 8) | _SHIFTL((where), 16, 8) | _SHIFTL((vtx) * 2, 0, 16)); \
2288 _g->words.w1 = (unsigned int) (val); \
2290#define gsSPModifyVertex(vtx, where, val) \
2292 { _SHIFTL(G_MODIFYVTX, 24, 8) | _SHIFTL((where), 16, 8) | _SHIFTL((vtx) * 2, 0, 16), (unsigned int) (val) } \
2295#define gSPModifyVertex(pkt, vtx, where, val) gMoveWd(pkt, G_MW_POINTS, (vtx) * 40 + (where), val)
2296#define gsSPModifyVertex(vtx, where, val) gsMoveWd(G_MW_POINTS, (vtx) * 40 + (where), val)
2299#if (defined(F3DEX_GBI) || defined(F3DLP_GBI))
2314#define G_DEPTOZSrg(zval, near, far, flag, zmin, zmax) \
2315 (((unsigned int) FTOFIX32( \
2316 ((flag) == G_BZ_PERSP ? (1.0f - (float) (near) / (float) (zval)) / (1.0f - (float) (near) / (float) (far)) \
2317 : ((float) (zval) - (float) (near)) / ((float) (far) - (float) (near))))) * \
2318 (((int) ((zmax) - (zmin))) & ~1) + \
2319 (int) FTOFIX32(zmin))
2321#define G_DEPTOZS(zval, near, far, flag) G_DEPTOZSrg(zval, near, far, flag, 0, G_MAXZ)
2323#define gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, zmin, zmax) \
2325 Gfx* _g = (Gfx*) (pkt); \
2326 _g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \
2327 _g->words.w1 = (uintptr_t) (dl); \
2328 _g = (Gfx*) (pkt); \
2329 _g->words.w0 = (_SHIFTL(G_BRANCH_Z, 24, 8) | _SHIFTL((vtx) * 5, 12, 12) | _SHIFTL((vtx) * 2, 0, 12)); \
2330 _g->words.w1 = G_DEPTOZSrg(zval, near, far, flag, zmin, zmax); \
2333#define gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, zmin, zmax) \
2335 _SHIFTL(G_RDPHALF_1, 24, 8), \
2340 _SHIFTL(G_BRANCH_Z, 24, 8) | _SHIFTL((vtx) * 5, 12, 12) | _SHIFTL((vtx) * 2, 0, 12), \
2341 G_DEPTOZSrg(zval, near, far, flag, zmin, zmax), \
2345#define gSPBranchLessZ(pkt, dl, vtx, zval, near, far, flag) \
2346 gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, 0, G_MAXZ)
2347#define gsSPBranchLessZ(dl, vtx, zval, near, far, flag) gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, 0, G_MAXZ)
2356#define gSPBranchLessZraw(pkt, dl, vtx, zval) \
2358 Gfx* _g = (Gfx*) (pkt); \
2359 _g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \
2360 _g->words.w1 = (uintptr_t) (dl); \
2361 _g = (Gfx*) (pkt); \
2362 _g->words.w0 = (_SHIFTL(G_BRANCH_Z, 24, 8) | _SHIFTL((vtx) * 5, 12, 12) | _SHIFTL((vtx) * 2, 0, 12)); \
2363 _g->words.w1 = (unsigned int) (zval); \
2366#define gsSPBranchLessZraw(dl, vtx, zval) \
2368 _SHIFTL(G_RDPHALF_1, 24, 8), \
2373 _SHIFTL(G_BRANCH_Z, 24, 8) | _SHIFTL((vtx) * 5, 12, 12) | _SHIFTL((vtx) * 2, 0, 12), \
2374 (unsigned int) (zval), \
2384#define gSPLoadUcodeEx(pkt, uc_start, uc_dstart, uc_dsize) \
2386 Gfx* _g = (Gfx*) (pkt); \
2387 _g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \
2388 _g->words.w1 = (uintptr_t) (uc_dstart); \
2389 _g = (Gfx*) (pkt); \
2390 _g->words.w0 = (_SHIFTL(G_LOAD_UCODE, 24, 8) | _SHIFTL((int) (uc_dsize) - 1, 0, 16)); \
2391 _g->words.w1 = (uintptr_t) (uc_start); \
2394#define gsSPLoadUcodeEx(uc_start, uc_dstart, uc_dsize) \
2396 _SHIFTL(G_RDPHALF_1, 24, 8), \
2397 (uintptr_t) (uc_dstart), \
2400 { _SHIFTL(G_LOAD_UCODE, 24, 8) | _SHIFTL((int) (uc_dsize) - 1, 0, 16), (uintptr_t) (uc_start), } \
2403#define gSPLoadUcode(pkt, uc_start, uc_dstart) gSPLoadUcodeEx((pkt), (uc_start), (uc_dstart), SP_UCODE_DATA_SIZE)
2404#define gsSPLoadUcode(uc_start, uc_dstart) gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE)
2406#define gSPLoadUcodeL(pkt, ucode) \
2407 gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), OS_K0_TO_PHYSICAL(&##ucode##DataStart))
2408#define gsSPLoadUcodeL(ucode) \
2409 gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), OS_K0_TO_PHYSICAL(&##ucode##DataStart))
2416#define gSPDma_io(pkt, flag, dmem, dram, size) \
2418 Gfx* _g = (Gfx*) (pkt); \
2419 _g->words.w0 = _SHIFTL(G_DMA_IO, 24, 8) | _SHIFTL((flag), 23, 1) | _SHIFTL((dmem) / 8, 13, 10) | \
2420 _SHIFTL((size) - 1, 0, 12); \
2421 _g->words.w1 = (uintptr_t) (dram); \
2424#define gsSPDma_io(flag, dmem, dram, size) \
2427 _SHIFTL(G_DMA_IO, 24, 8) | _SHIFTL((flag), 23, 1) | _SHIFTL((dmem) / 8, 13, 10) | \
2428 _SHIFTL((size) - 1, 0, 12), \
2429 (uintptr_t) (dram) \
2433#define gSPDmaRead(pkt, dmem, dram, size) gSPDma_io((pkt), 0, (dmem), (dram), (size))
2434#define gsSPDmaRead(dmem, dram, size) gsSPDma_io(0, (dmem), (dram), (size))
2435#define gSPDmaWrite(pkt, dmem, dram, size) gSPDma_io((pkt), 1, (dmem), (dram), (size))
2436#define gsSPDmaWrite(dmem, dram, size) gsSPDma_io(1, (dmem), (dram), (size))
2443#define NUML(n) ((n) * 24)
2445#define NUML(n) (((n) + 1) * 32 + 0x80000000)
2447#define NUMLIGHTS_0 1
2448#define NUMLIGHTS_1 1
2449#define NUMLIGHTS_2 2
2450#define NUMLIGHTS_3 3
2451#define NUMLIGHTS_4 4
2452#define NUMLIGHTS_5 5
2453#define NUMLIGHTS_6 6
2454#define NUMLIGHTS_7 7
2460#define gSPNumLights(pkt, n) gMoveWd(pkt, G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n))
2461#define gsSPNumLights(n) gsMoveWd(G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n))
2480#define gSPLight(pkt, l, n) gDma2p((pkt), G_MOVEMEM, (l), sizeof(Light), G_MV_LIGHT, (n) * 24 + 24)
2481#define gsSPLight(l, n) gsDma2p(G_MOVEMEM, (l), sizeof(Light), G_MV_LIGHT, (n) * 24 + 24)
2483#define gSPLight(pkt, l, n) gDma1p(pkt, G_MOVEMEM, l, sizeof(Light), ((n) - 1) * 2 + G_MV_L0)
2484#define gsSPLight(l, n) gsDma1p(G_MOVEMEM, l, sizeof(Light), ((n) - 1) * 2 + G_MV_L0)
2492#define gSPLightColor(pkt, n, col) \
2494 gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_a##n, col); \
2495 gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_b##n, col); \
2497#define gsSPLightColor(n, col) gsMoveWd(G_MW_LIGHTCOL, G_MWO_a##n, col), gsMoveWd(G_MW_LIGHTCOL, G_MWO_b##n, col)
2501#define gSPSetLights0(pkt, name) \
2503 gSPNumLights(pkt, NUMLIGHTS_0); \
2504 gSPLight(pkt, &name.l[0], 1); \
2505 gSPLight(pkt, &name.a, 2); \
2507#define gsSPSetLights0(name) gsSPNumLights(NUMLIGHTS_0), gsSPLight(&name.l[0], 1), gsSPLight(&name.a, 2)
2509#define gSPSetLights1(pkt, name) \
2511 gSPNumLights(pkt, NUMLIGHTS_1); \
2512 gSPLight(pkt, &name.l[0], 1); \
2513 gSPLight(pkt, &name.a, 2); \
2515#define gsSPSetLights1(name) gsSPNumLights(NUMLIGHTS_1), gsSPLight(&name.l[0], 1), gsSPLight(&name.a, 2)
2517#define gSPSetLights2(pkt, name) \
2519 gSPNumLights(pkt, NUMLIGHTS_2); \
2520 gSPLight(pkt, &name.l[0], 1); \
2521 gSPLight(pkt, &name.l[1], 2); \
2522 gSPLight(pkt, &name.a, 3); \
2524#define gsSPSetLights2(name) \
2525 gsSPNumLights(NUMLIGHTS_2), gsSPLight(&name.l[0], 1), gsSPLight(&name.l[1], 2), gsSPLight(&name.a, 3)
2527#define gSPSetLights3(pkt, name) \
2529 gSPNumLights(pkt, NUMLIGHTS_3); \
2530 gSPLight(pkt, &name.l[0], 1); \
2531 gSPLight(pkt, &name.l[1], 2); \
2532 gSPLight(pkt, &name.l[2], 3); \
2533 gSPLight(pkt, &name.a, 4); \
2535#define gsSPSetLights3(name) \
2536 gsSPNumLights(NUMLIGHTS_3), gsSPLight(&name.l[0], 1), gsSPLight(&name.l[1], 2), gsSPLight(&name.l[2], 3), \
2537 gsSPLight(&name.a, 4)
2539#define gSPSetLights4(pkt, name) \
2541 gSPNumLights(pkt, NUMLIGHTS_4); \
2542 gSPLight(pkt, &name.l[0], 1); \
2543 gSPLight(pkt, &name.l[1], 2); \
2544 gSPLight(pkt, &name.l[2], 3); \
2545 gSPLight(pkt, &name.l[3], 4); \
2546 gSPLight(pkt, &name.a, 5); \
2548#define gsSPSetLights4(name) \
2549 gsSPNumLights(NUMLIGHTS_4), gsSPLight(&name.l[0], 1), gsSPLight(&name.l[1], 2), gsSPLight(&name.l[2], 3), \
2550 gsSPLight(&name.l[3], 4), gsSPLight(&name.a, 5)
2552#define gSPSetLights5(pkt, name) \
2554 gSPNumLights(pkt, NUMLIGHTS_5); \
2555 gSPLight(pkt, &name.l[0], 1); \
2556 gSPLight(pkt, &name.l[1], 2); \
2557 gSPLight(pkt, &name.l[2], 3); \
2558 gSPLight(pkt, &name.l[3], 4); \
2559 gSPLight(pkt, &name.l[4], 5); \
2560 gSPLight(pkt, &name.a, 6); \
2563#define gsSPSetLights5(name) \
2564 gsSPNumLights(NUMLIGHTS_5), gsSPLight(&name.l[0], 1), gsSPLight(&name.l[1], 2), gsSPLight(&name.l[2], 3), \
2565 gsSPLight(&name.l[3], 4), gsSPLight(&name.l[4], 5), gsSPLight(&name.a, 6)
2567#define gSPSetLights6(pkt, name) \
2569 gSPNumLights(pkt, NUMLIGHTS_6); \
2570 gSPLight(pkt, &name.l[0], 1); \
2571 gSPLight(pkt, &name.l[1], 2); \
2572 gSPLight(pkt, &name.l[2], 3); \
2573 gSPLight(pkt, &name.l[3], 4); \
2574 gSPLight(pkt, &name.l[4], 5); \
2575 gSPLight(pkt, &name.l[5], 6); \
2576 gSPLight(pkt, &name.a, 7); \
2579#define gsSPSetLights6(name) \
2580 gsSPNumLights(NUMLIGHTS_6), gsSPLight(&name.l[0], 1), gsSPLight(&name.l[1], 2), gsSPLight(&name.l[2], 3), \
2581 gsSPLight(&name.l[3], 4), gsSPLight(&name.l[4], 5), gsSPLight(&name.l[5], 6), gsSPLight(&name.a, 7)
2583#define gSPSetLights7(pkt, name) \
2585 gSPNumLights(pkt, NUMLIGHTS_7); \
2586 gSPLight(pkt, &name.l[0], 1); \
2587 gSPLight(pkt, &name.l[1], 2); \
2588 gSPLight(pkt, &name.l[2], 3); \
2589 gSPLight(pkt, &name.l[3], 4); \
2590 gSPLight(pkt, &name.l[4], 5); \
2591 gSPLight(pkt, &name.l[5], 6); \
2592 gSPLight(pkt, &name.l[6], 7); \
2593 gSPLight(pkt, &name.a, 8); \
2596#define gsSPSetLights7(name) \
2597 gsSPNumLights(NUMLIGHTS_7), gsSPLight(&name.l[0], 1), gsSPLight(&name.l[1], 2), gsSPLight(&name.l[2], 3), \
2598 gsSPLight(&name.l[3], 4), gsSPLight(&name.l[4], 5), gsSPLight(&name.l[5], 6), gsSPLight(&name.l[6], 7), \
2599 gsSPLight(&name.a, 8)
2605#define gSPLookAtX(pkt, l) gDma2p((pkt), G_MOVEMEM, (l), sizeof(Light), G_MV_LIGHT, G_MVO_LOOKATX)
2606#define gsSPLookAtX(l) gsDma2p(G_MOVEMEM, (l), sizeof(Light), G_MV_LIGHT, G_MVO_LOOKATX)
2607#define gSPLookAtY(pkt, l) gDma2p((pkt), G_MOVEMEM, (l), sizeof(Light), G_MV_LIGHT, G_MVO_LOOKATY)
2608#define gsSPLookAtY(l) gsDma2p(G_MOVEMEM, (l), sizeof(Light), G_MV_LIGHT, G_MVO_LOOKATY)
2610#define gSPLookAtX(pkt, l) gDma1p(pkt, G_MOVEMEM, l, sizeof(Light), G_MV_LOOKATX)
2611#define gsSPLookAtX(l) gsDma1p(G_MOVEMEM, l, sizeof(Light), G_MV_LOOKATX)
2612#define gSPLookAtY(pkt, l) gDma1p(pkt, G_MOVEMEM, l, sizeof(Light), G_MV_LOOKATY)
2613#define gsSPLookAtY(l) gsDma1p(G_MOVEMEM, l, sizeof(Light), G_MV_LOOKATY)
2616#define gSPLookAt(pkt, la) \
2617 { gSPLookAtX(pkt, la) gSPLookAtY(pkt, (char*) (la) + 16) }
2618#define gsSPLookAt(la) gsSPLookAtX(la), gsSPLookAtY((char*) (la) + 16)
2620#define gDPSetHilite1Tile(pkt, tile, hilite, width, height) \
2621 gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \
2622 ((((width) - 1) * 4) + (hilite)->h.x1) & 0xfff, ((((height) - 1) * 4) + (hilite)->h.y1) & 0xfff)
2624#define gDPSetHilite2Tile(pkt, tile, hilite, width, height) \
2625 gDPSetTileSize(pkt, tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \
2626 ((((width) - 1) * 4) + (hilite)->h.x2) & 0xfff, ((((height) - 1) * 4) + (hilite)->h.y2) & 0xfff)
2641#define gSPFogFactor(pkt, fm, fo) gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, (_SHIFTL(fm, 16, 16) | _SHIFTL(fo, 0, 16)))
2643#define gsSPFogFactor(fm, fo) gsMoveWd(G_MW_FOG, G_MWO_FOG, (_SHIFTL(fm, 16, 16) | _SHIFTL(fo, 0, 16)))
2645#define gSPFogPosition(pkt, min, max) \
2646 gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \
2647 (_SHIFTL((128000 / ((max) - (min))), 16, 16) | _SHIFTL(((500 - (min)) * 256 / ((max) - (min))), 0, 16)))
2649#define gsSPFogPosition(min, max) \
2650 gsMoveWd(G_MW_FOG, G_MWO_FOG, \
2651 (_SHIFTL((128000 / ((max) - (min))), 16, 16) | _SHIFTL(((500 - (min)) * 256 / ((max) - (min))), 0, 16)))
2657#define gSPTexture(pkt, s, t, level, tile, on) \
2659 Gfx* _g = (Gfx*) (pkt); \
2661 _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(BOWTIE_VAL, 16, 8) | _SHIFTL((level), 11, 3) | \
2662 _SHIFTL((tile), 8, 3) | _SHIFTL((on), 1, 7)); \
2663 _g->words.w1 = (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)); \
2665#define gsSPTexture(s, t, level, tile, on) \
2668 (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(BOWTIE_VAL, 16, 8) | _SHIFTL((level), 11, 3) | \
2669 _SHIFTL((tile), 8, 3) | _SHIFTL((on), 1, 7)), \
2670 (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)) \
2677#define gSPTextureL(pkt, s, t, level, xparam, tile, on) \
2679 Gfx* _g = (Gfx*) (pkt); \
2681 _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL((xparam), 16, 8) | _SHIFTL((level), 11, 3) | \
2682 _SHIFTL((tile), 8, 3) | _SHIFTL((on), 1, 7)); \
2683 _g->words.w1 = (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)); \
2685#define gsSPTextureL(s, t, level, xparam, tile, on) \
2688 (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL((xparam), 16, 8) | _SHIFTL((level), 11, 3) | _SHIFTL((tile), 8, 3) | \
2689 _SHIFTL((on), 1, 7)), \
2690 (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)) \
2697#define gSPTexture(pkt, s, t, level, tile, on) \
2699 Gfx* _g = (Gfx*) (pkt); \
2701 _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(BOWTIE_VAL, 16, 8) | _SHIFTL((level), 11, 3) | \
2702 _SHIFTL((tile), 8, 3) | _SHIFTL((on), 0, 8)); \
2703 _g->words.w1 = (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)); \
2705#define gsSPTexture(s, t, level, tile, on) \
2708 (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(BOWTIE_VAL, 16, 8) | _SHIFTL((level), 11, 3) | \
2709 _SHIFTL((tile), 8, 3) | _SHIFTL((on), 0, 8)), \
2710 (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)) \
2717#define gSPTextureL(pkt, s, t, level, xparam, tile, on) \
2719 Gfx* _g = (Gfx*) (pkt); \
2721 _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL((xparam), 16, 8) | _SHIFTL((level), 11, 3) | \
2722 _SHIFTL((tile), 8, 3) | _SHIFTL((on), 0, 8)); \
2723 _g->words.w1 = (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)); \
2725#define gsSPTextureL(s, t, level, xparam, tile, on) \
2728 (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL((xparam), 16, 8) | _SHIFTL((level), 11, 3) | _SHIFTL((tile), 8, 3) | \
2729 _SHIFTL((on), 0, 8)), \
2730 (_SHIFTL((s), 16, 16) | _SHIFTL((t), 0, 16)) \
2736#define gSPPerspNormalize(pkt, s) gMoveWd(pkt, G_MW_PERSPNORM, 0, (s))
2737#define gsSPPerspNormalize(s) gsMoveWd(G_MW_PERSPNORM, 0, (s))
2739#define gSPPerspNormalize(pkt, s) \
2741 Gfx* _g = (Gfx*) (pkt); \
2743 _g->words.w0 = _SHIFTL(G_RDPHALF_1, 24, 8); \
2744 _g->words.w1 = (s); \
2746#define gsSPPerspNormalize(s) \
2748 { _SHIFTL(G_RDPHALF_1, 24, 8), (s) } \
2753#define gSPPopMatrixN(pkt, n, num) gDma2p((pkt), G_POPMTX, (num) * 64, 64, 2, 0)
2754#define gsSPPopMatrixN(n, num) gsDma2p(G_POPMTX, (num) * 64, 64, 2, 0)
2755#define gSPPopMatrix(pkt, n) gSPPopMatrixN((pkt), (n), 1)
2756#define gsSPPopMatrix(n) gsSPPopMatrixN((n), 1)
2758#define gSPPopMatrix(pkt, n) gImmp1(pkt, G_POPMTX, n)
2759#define gsSPPopMatrix(n) gsImmp1(G_POPMTX, n)
2762#define gSPEndDisplayList(pkt) \
2764 Gfx* _g = (Gfx*) (pkt); \
2766 _g->words.w0 = _SHIFTL(G_ENDDL, 24, 8); \
2770#define gsSPEndDisplayList() \
2772 { _SHIFTL(G_ENDDL, 24, 8), 0 } \
2784#define gSPGeometryMode(pkt, c, s) \
2786 Gfx* _g = (Gfx*) (pkt); \
2787 _g->words.w0 = _SHIFTL(G_GEOMETRYMODE, 24, 8) | _SHIFTL(~(u32) (c), 0, 24); \
2788 _g->words.w1 = (u32) (s); \
2791#define gsSPGeometryMode(c, s) \
2793 { (_SHIFTL(G_GEOMETRYMODE, 24, 8) | _SHIFTL(~(u32) (c), 0, 24)), (u32) (s) } \
2795#define gSPSetGeometryMode(pkt, word) gSPGeometryMode((pkt), 0, (word))
2796#define gsSPSetGeometryMode(word) gsSPGeometryMode(0, (word))
2797#define gSPClearGeometryMode(pkt, word) gSPGeometryMode((pkt), (word), 0)
2798#define gsSPClearGeometryMode(word) gsSPGeometryMode((word), 0)
2799#define gSPLoadGeometryMode(pkt, word) gSPGeometryMode((pkt), -1, (word))
2800#define gsSPLoadGeometryMode(word) gsSPGeometryMode(-1, (word))
2801#define gsSPGeometryModeSetFirst(c, s) gsSPGeometryMode(c, s)
2803#define gSPSetGeometryMode(pkt, word) \
2805 Gfx* _g = (Gfx*) (pkt); \
2807 _g->words.w0 = _SHIFTL(G_SETGEOMETRYMODE, 24, 8); \
2808 _g->words.w1 = (unsigned int) (word); \
2811#define gsSPSetGeometryMode(word) \
2813 { _SHIFTL(G_SETGEOMETRYMODE, 24, 8), (unsigned int) (word) } \
2816#define gSPClearGeometryMode(pkt, word) \
2818 Gfx* _g = (Gfx*) (pkt); \
2820 _g->words.w0 = _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8); \
2821 _g->words.w1 = (unsigned int) (word); \
2824#define gsSPClearGeometryMode(word) \
2826 { _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8), (unsigned int) (word) } \
2834#define gsSPGeometryMode(c, s) gsSPClearGeometryMode(c), gsSPSetGeometryMode(s)
2835#define gsSPGeometryModeSetFirst(c, s) gsSPSetGeometryMode(s), gsSPClearGeometryMode(c)
2839#define gSPSetOtherMode(pkt, cmd, sft, len, data) \
2841 Gfx* _g = (Gfx*) (pkt); \
2842 _g->words.w0 = (_SHIFTL(cmd, 24, 8) | _SHIFTL(32 - (sft) - (len), 8, 8) | _SHIFTL((len) - 1, 0, 8)); \
2843 _g->words.w1 = (unsigned int) (data); \
2846#define gsSPSetOtherMode(cmd, sft, len, data) \
2848 { _SHIFTL(cmd, 24, 8) | _SHIFTL(32 - (sft) - (len), 8, 8) | _SHIFTL((len) - 1, 0, 8), (unsigned int) (data) } \
2851#define gSPSetOtherMode(pkt, cmd, sft, len, data) \
2853 Gfx* _g = (Gfx*) (pkt); \
2855 _g->words.w0 = (_SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | _SHIFTL(len, 0, 8)); \
2856 _g->words.w1 = (unsigned int) (data); \
2859#define gsSPSetOtherMode(cmd, sft, len, data) \
2861 { _SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | _SHIFTL(len, 0, 8), (unsigned int) (data) } \
2868#define gDPPipelineMode(pkt, mode) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode)
2869#define gsDPPipelineMode(mode) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode)
2871#define gDPSetCycleType(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type)
2872#define gsDPSetCycleType(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type)
2874#define gDPSetTexturePersp(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type)
2875#define gsDPSetTexturePersp(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type)
2877#define gDPSetTextureDetail(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type)
2878#define gsDPSetTextureDetail(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type)
2880#define gDPSetTextureLOD(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type)
2881#define gsDPSetTextureLOD(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type)
2883#define gDPSetTextureLUT(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type)
2884#define gsDPSetTextureLUT(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type)
2886#define gDPSetTextureFilter(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type)
2887#define gsDPSetTextureFilter(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type)
2889#define gDPSetTextureConvert(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type)
2890#define gsDPSetTextureConvert(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type)
2892#define gDPSetCombineKey(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type)
2893#define gsDPSetCombineKey(type) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type)
2895#ifndef _HW_VERSION_1
2896#define gDPSetColorDither(pkt, mode) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode)
2897#define gsDPSetColorDither(mode) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode)
2899#define gDPSetColorDither(pkt, mode) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode)
2900#define gsDPSetColorDither(mode) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode)
2903#ifndef _HW_VERSION_1
2904#define gDPSetAlphaDither(pkt, mode) gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode)
2905#define gsDPSetAlphaDither(mode) gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode)
2912#define gDPSetBlendMask(pkt, mask) gDPNoOp(pkt)
2913#define gsDPSetBlendMask(mask) gsDPNoOp()
2915#define gDPSetAlphaCompare(pkt, type) gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type)
2916#define gsDPSetAlphaCompare(type) gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type)
2918#define gDPSetDepthSource(pkt, src) gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src)
2919#define gsDPSetDepthSource(src) gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src)
2921#define gDPSetRenderMode(pkt, c0, c1) gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, (c0) | (c1))
2922#define gsDPSetRenderMode(c0, c1) gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, (c0) | (c1))
2924#define gSetImage(pkt, cmd, fmt, siz, width, i) \
2926 Gfx* _g = (Gfx*) (pkt); \
2928 _g->words.w0 = _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | _SHIFTL(siz, 19, 2) | _SHIFTL((width) - 1, 0, 12); \
2929 _g->words.w1 = (uintptr_t) (i); \
2932#define gsSetImage(cmd, fmt, siz, width, i) \
2935 _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | _SHIFTL(siz, 19, 2) | _SHIFTL((width) - 1, 0, 12), \
2940#define gDPSetColorImage(pkt, f, s, w, i) gSetImage(pkt, G_SETCIMG, f, s, w, i)
2941#define gsDPSetColorImage(f, s, w, i) gsSetImage(G_SETCIMG, f, s, w, i)
2944#define gDPSetDepthImage(pkt, i) gSetImage(pkt, G_SETZIMG, 0, 0, 1, i)
2945#define gsDPSetDepthImage(i) gsSetImage(G_SETZIMG, 0, 0, 1, i)
2947#define gDPSetMaskImage(pkt, i) gDPSetDepthImage(pkt, i)
2948#define gsDPSetMaskImage(i) gsDPSetDepthImage(i)
2950#define gDPSetTextureImage(pkt, f, s, w, i) gSetImage(pkt, G_SETTIMG, f, s, w, i)
2951#define gsDPSetTextureImage(f, s, w, i) gsSetImage(G_SETTIMG, f, s, w, i)
2957#define gDPSetCombine(pkt, muxs0, muxs1) \
2959 Gfx* _g = (Gfx*) (pkt); \
2961 _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24); \
2962 _g->words.w1 = (unsigned int) (muxs1); \
2965#define gsDPSetCombine(muxs0, muxs1) \
2967 { _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24), (unsigned int) (muxs1) } \
2970#define GCCc0w0(saRGB0, mRGB0, saA0, mA0) \
2971 (_SHIFTL((saRGB0), 20, 4) | _SHIFTL((mRGB0), 15, 5) | _SHIFTL((saA0), 12, 3) | _SHIFTL((mA0), 9, 3))
2973#define GCCc1w0(saRGB1, mRGB1) (_SHIFTL((saRGB1), 5, 4) | _SHIFTL((mRGB1), 0, 5))
2975#define GCCc0w1(sbRGB0, aRGB0, sbA0, aA0) \
2976 (_SHIFTL((sbRGB0), 28, 4) | _SHIFTL((aRGB0), 15, 3) | _SHIFTL((sbA0), 12, 3) | _SHIFTL((aA0), 9, 3))
2978#define GCCc1w1(sbRGB1, saA1, mA1, aRGB1, sbA1, aA1) \
2979 (_SHIFTL((sbRGB1), 24, 4) | _SHIFTL((saA1), 21, 3) | _SHIFTL((mA1), 18, 3) | _SHIFTL((aRGB1), 6, 3) | \
2980 _SHIFTL((sbA1), 3, 3) | _SHIFTL((aA1), 0, 3))
2982#define gDPSetCombineLERP(pkt, a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \
2984 Gfx* _g = (Gfx*) (pkt); \
2987 _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \
2988 GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), \
2990 _g->words.w1 = (unsigned int) (GCCc0w1(G_CCMUX_##b0, G_CCMUX_##d0, G_ACMUX_##Ab0, G_ACMUX_##Ad0) | \
2991 GCCc1w1(G_CCMUX_##b1, G_ACMUX_##Aa1, G_ACMUX_##Ac1, G_CCMUX_##d1, \
2992 G_ACMUX_##Ab1, G_ACMUX_##Ad1)); \
2995#define gsDPSetCombineLERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \
2998 _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \
2999 GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), \
3001 (unsigned int) (GCCc0w1(G_CCMUX_##b0, G_CCMUX_##d0, G_ACMUX_##Ab0, G_ACMUX_##Ad0) | \
3002 GCCc1w1(G_CCMUX_##b1, G_ACMUX_##Aa1, G_ACMUX_##Ac1, G_CCMUX_##d1, G_ACMUX_##Ab1, \
3017#define gDPSetCombineMode(pkt, a, b) gDPSetCombineLERP(pkt, a, b)
3018#define gsDPSetCombineMode(a, b) gsDPSetCombineLERP(a, b)
3020#define gDPSetColor(pkt, c, d) \
3022 Gfx* _g = (Gfx*) (pkt); \
3024 _g->words.w0 = _SHIFTL(c, 24, 8); \
3025 _g->words.w1 = (unsigned int) (d); \
3028#define gsDPSetColor(c, d) \
3030 { _SHIFTL(c, 24, 8), (unsigned int) (d) } \
3033#define DPRGBColor(pkt, cmd, r, g, b, a) \
3034 gDPSetColor(pkt, cmd, (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)))
3035#define sDPRGBColor(cmd, r, g, b, a) \
3036 gsDPSetColor(cmd, (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)))
3038#define gDPSetEnvColor(pkt, r, g, b, a) DPRGBColor(pkt, G_SETENVCOLOR, r, g, b, a)
3039#define gsDPSetEnvColor(r, g, b, a) sDPRGBColor(G_SETENVCOLOR, r, g, b, a)
3040#define gDPSetBlendColor(pkt, r, g, b, a) DPRGBColor(pkt, G_SETBLENDCOLOR, r, g, b, a)
3041#define gsDPSetBlendColor(r, g, b, a) sDPRGBColor(G_SETBLENDCOLOR, r, g, b, a)
3042#define gDPSetFogColor(pkt, r, g, b, a) DPRGBColor(pkt, G_SETFOGCOLOR, r, g, b, a)
3043#define gsDPSetFogColor(r, g, b, a) sDPRGBColor(G_SETFOGCOLOR, r, g, b, a)
3044#define gDPSetFillColor(pkt, d) gDPSetColor(pkt, G_SETFILLCOLOR, (d))
3045#define gsDPSetFillColor(d) gsDPSetColor(G_SETFILLCOLOR, (d))
3047#define gDPSetPrimDepth(pkt, z, dz) gDPSetColor(pkt, G_SETPRIMDEPTH, _SHIFTL(z, 16, 16) | _SHIFTL(dz, 0, 16))
3048#define gsDPSetPrimDepth(z, dz) gsDPSetColor(G_SETPRIMDEPTH, _SHIFTL(z, 16, 16) | _SHIFTL(dz, 0, 16))
3050#define gDPSetPrimColor(pkt, m, l, r, g, b, a) \
3052 Gfx* _g = (Gfx*) (pkt); \
3054 _g->words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \
3055 _g->words.w1 = (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)); \
3058#define gsDPSetPrimColor(m, l, r, g, b, a) \
3061 (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)), \
3062 (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)) \
3094#define gDPSetOtherMode(pkt, mode0, mode1) \
3096 Gfx* _g = (Gfx*) (pkt); \
3098 _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE, 24, 8) | _SHIFTL(mode0, 0, 24); \
3099 _g->words.w1 = (unsigned int) (mode1); \
3102#define gsDPSetOtherMode(mode0, mode1) \
3104 { _SHIFTL(G_RDPSETOTHERMODE, 24, 8) | _SHIFTL(mode0, 0, 24), (unsigned int) (mode1) } \
3113#define G_TX_LOADTILE 7
3114#define G_TX_RENDERTILE 0
3116#define G_TX_NOMIRROR 0
3118#define G_TX_MIRROR 0x1
3119#define G_TX_CLAMP 0x2
3120#define G_TX_NOMASK 0
3124#define MAX(a, b) ((a) > (b) ? (a) : (b))
3128#define MIN(a, b) ((a) < (b) ? (a) : (b))
3138#define G_TX_DXT_FRAC 11
3151#define G_TX_LDBLK_MAX_TXL 4095
3153#define G_TX_LDBLK_MAX_TXL 2047
3156#define TXL2WORDS(txls, b_txl) MAX(1, ((txls) * (b_txl) / 8))
3157#define CALC_DXT(width, b_txl) (((1 << G_TX_DXT_FRAC) + TXL2WORDS(width, b_txl) - 1) / TXL2WORDS(width, b_txl))
3159#define TXL2WORDS_4b(txls) MAX(1, ((txls) / 16))
3160#define CALC_DXT_4b(width) (((1 << G_TX_DXT_FRAC) + TXL2WORDS_4b(width) - 1) / TXL2WORDS_4b(width))
3162#define gDPLoadTileGeneric(pkt, c, tile, uls, ult, lrs, lrt) \
3164 Gfx* _g = (Gfx*) (pkt); \
3166 _g->words.w0 = _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12); \
3167 _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | _SHIFTL(lrt, 0, 12); \
3170#define gsDPLoadTileGeneric(c, tile, uls, ult, lrs, lrt) \
3173 _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12), \
3174 _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | _SHIFTL(lrt, 0, 12) \
3178#define gDPSetTileSize(pkt, t, uls, ult, lrs, lrt) gDPLoadTileGeneric(pkt, G_SETTILESIZE, t, uls, ult, lrs, lrt)
3179#define gsDPSetTileSize(t, uls, ult, lrs, lrt) gsDPLoadTileGeneric(G_SETTILESIZE, t, uls, ult, lrs, lrt)
3180#define gDPLoadTile(pkt, t, uls, ult, lrs, lrt) gDPLoadTileGeneric(pkt, G_LOADTILE, t, uls, ult, lrs, lrt)
3181#define gsDPLoadTile(t, uls, ult, lrs, lrt) gsDPLoadTileGeneric(G_LOADTILE, t, uls, ult, lrs, lrt)
3183#define gDPSetTile(pkt, fmt, siz, line, tmem, tile, palette, cmt, maskt, shiftt, cms, masks, shifts) \
3185 Gfx* _g = (Gfx*) (pkt); \
3187 _g->words.w0 = _SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) | _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | \
3188 _SHIFTL(tmem, 0, 9); \
3189 _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \
3190 _SHIFTL(shiftt, 10, 4) | _SHIFTL(cms, 8, 2) | _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4); \
3193#define gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmt, maskt, shiftt, cms, masks, shifts) \
3196 (_SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) | _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | \
3197 _SHIFTL(tmem, 0, 9)), \
3198 (_SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \
3199 _SHIFTL(shiftt, 10, 4) | _SHIFTL(cms, 8, 2) | _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4)) \
3213#define gDPLoadBlock(pkt, tile, uls, ult, lrs, dxt) \
3215 Gfx* _g = (Gfx*) (pkt); \
3217 _g->words.w0 = (_SHIFTL(G_LOADBLOCK, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12)); \
3218 _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL((MIN(lrs, G_TX_LDBLK_MAX_TXL)), 12, 12) | _SHIFTL(dxt, 0, 12)); \
3221#define gsDPLoadBlock(tile, uls, ult, lrs, dxt) \
3224 (_SHIFTL(G_LOADBLOCK, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12)), \
3225 (_SHIFTL(tile, 24, 3) | _SHIFTL((MIN(lrs, G_TX_LDBLK_MAX_TXL)), 12, 12) | _SHIFTL(dxt, 0, 12)) \
3229#define gDPLoadTLUTCmd(pkt, tile, count) \
3231 Gfx* _g = (Gfx*) pkt; \
3233 _g->words.w0 = _SHIFTL(G_LOADTLUT, 24, 8); \
3234 _g->words.w1 = _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10); \
3237#define gsDPLoadTLUTCmd(tile, count) \
3239 { _SHIFTL(G_LOADTLUT, 24, 8), _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10) } \
3242#define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3244 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3245 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3247 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3248 CALC_DXT(width, siz##_BYTES)); \
3250 gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES) + 7) >> 3, 0, G_TX_RENDERTILE, pal, cmt, maskt, \
3251 shiftt, cms, masks, shifts); \
3252 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3253 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3256#define gDPLoadTextureBlockYuv(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3258 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3259 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3261 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3262 CALC_DXT(width, siz##_BYTES)); \
3264 gDPSetTile(pkt, fmt, siz, (((width) * 1) + 7) >> 3, 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \
3266 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3267 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3273#define gDPLoadTextureBlockS(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3275 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3276 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3278 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, 0); \
3280 gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES) + 7) >> 3, 0, G_TX_RENDERTILE, pal, cmt, maskt, \
3281 shiftt, cms, masks, shifts); \
3282 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3283 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3290#define gDPLoadMultiBlockS(pkt, timg, tmem, rtile, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, \
3293 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3294 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3296 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, 0); \
3298 gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES) + 7) >> 3, tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3300 gDPSetTileSize(pkt, rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3301 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3304#define gDPLoadTextureBlockYuvS(pkt, timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3306 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3307 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3309 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, 0); \
3311 gDPSetTile(pkt, fmt, siz, (((width) * 1) + 7) >> 3, 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \
3313 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3314 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3320#define _gDPLoadTextureBlock(pkt, timg, tmem, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3322 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3323 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3325 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3326 CALC_DXT(width, siz##_BYTES)); \
3328 gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES) + 7) >> 3, tmem, G_TX_RENDERTILE, pal, cmt, maskt, \
3329 shiftt, cms, masks, shifts); \
3330 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3331 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3337#define _gDPLoadTextureBlockTile(pkt, timg, tmem, rtile, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, \
3340 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3341 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3343 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3344 CALC_DXT(width, siz##_BYTES)); \
3346 gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES) + 7) >> 3, tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3348 gDPSetTileSize(pkt, rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3349 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3355#define gDPLoadMultiBlock(pkt, timg, tmem, rtile, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, \
3358 gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \
3359 gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3361 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3362 CALC_DXT(width, siz##_BYTES)); \
3364 gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES) + 7) >> 3, tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3366 gDPSetTileSize(pkt, rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3367 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3370#define gsDPLoadTextureBlock(timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3372 gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \
3373 gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3375 gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3376 CALC_DXT(width, siz##_BYTES)), \
3378 gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \
3379 cms, masks, shifts), \
3380 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3381 ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3387#define gsDPLoadTextureBlockS(timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3389 gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \
3390 gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3391 gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, 0), \
3393 gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \
3394 cms, masks, shifts), \
3395 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3396 ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3401#define _gsDPLoadTextureBlock(timg, tmem, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3403 gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \
3404 gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3406 gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3407 CALC_DXT(width, siz##_BYTES)), \
3409 gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES) + 7) >> 3), tmem, G_TX_RENDERTILE, pal, cmt, maskt, \
3410 shiftt, cms, masks, shifts), \
3411 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3412 ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3417#define _gsDPLoadTextureBlockTile(timg, tmem, rtile, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, \
3420 gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \
3421 gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3423 gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3424 CALC_DXT(width, siz##_BYTES)), \
3426 gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3428 gsDPSetTileSize(rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3434#define gsDPLoadMultiBlock(timg, tmem, rtile, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3436 gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \
3437 gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3439 gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, \
3440 CALC_DXT(width, siz##_BYTES)), \
3442 gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3444 gsDPSetTileSize(rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3455#define gsDPLoadMultiBlockS(timg, tmem, rtile, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3457 gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \
3458 gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3459 gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + siz##_INCR) >> siz##_SHIFT) - 1, 0), \
3461 gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3463 gsDPSetTileSize(rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3465#define gDPLoadTextureBlock_4b(pkt, timg, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3467 gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \
3468 gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3470 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, CALC_DXT_4b(width)); \
3472 gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \
3473 cms, masks, shifts); \
3474 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3475 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3481#define gDPLoadTextureBlock_4bS(pkt, timg, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3483 gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \
3484 gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3486 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, 0); \
3488 gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \
3489 cms, masks, shifts); \
3490 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3491 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3497#define gDPLoadMultiBlock_4b(pkt, timg, tmem, rtile, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3499 gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \
3500 gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3502 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, CALC_DXT_4b(width)); \
3504 gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3506 gDPSetTileSize(pkt, rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3507 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3514#define gDPLoadMultiBlock_4bS(pkt, timg, tmem, rtile, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3516 gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \
3517 gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3519 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, 0); \
3521 gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, cms, \
3523 gDPSetTileSize(pkt, rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3524 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3527#define _gDPLoadTextureBlock_4b(pkt, timg, tmem, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3529 gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \
3530 gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts); \
3532 gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, CALC_DXT_4b(width)); \
3534 gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), tmem, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \
3535 cms, masks, shifts); \
3536 gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3537 ((height) - 1) << G_TEXTURE_IMAGE_FRAC) \
3540#define gsDPLoadTextureBlock_4b(timg, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3542 gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \
3543 gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3544 gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, CALC_DXT_4b(width)), \
3546 gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, \
3548 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3549 ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3551#define gsDPLoadTextureBlock_4bS(timg, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3553 gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \
3554 gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3555 gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, 0), gsDPPipeSync(), \
3556 gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, \
3558 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3559 ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3565#define gsDPLoadMultiBlock_4b(timg, tmem, rtile, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3567 gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \
3568 gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3569 gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, CALC_DXT_4b(width)), \
3571 gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \
3573 gsDPSetTileSize(rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3579#define gsDPLoadMultiBlock_4bS(timg, tmem, rtile, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3581 gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \
3582 gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3583 gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, 0), gsDPPipeSync(), \
3584 gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \
3586 gsDPSetTileSize(rtile, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3591#define _gsDPLoadTextureBlock_4b(timg, tmem, fmt, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \
3593 gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \
3594 gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, shifts), \
3595 gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width) * (height) + 3) >> 2) - 1, CALC_DXT_4b(width)), \
3597 gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width) >> 1) + 7) >> 3), tmem, G_TX_RENDERTILE, pal, cmt, maskt, shiftt, \
3598 cms, masks, shifts), \
3599 gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, ((width) - 1) << G_TEXTURE_IMAGE_FRAC, \
3600 ((height) - 1) << G_TEXTURE_IMAGE_FRAC)
3602#ifndef _HW_VERSION_1
3604#define gDPLoadTextureTile(pkt, timg, fmt, siz, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, \
3607 gDPSetTextureImage(pkt, fmt, siz, width, timg); \
3608 gDPSetTile(pkt, fmt, siz, (((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, G_TX_LOADTILE, 0, cmt, \
3609 maskt, shiftt, cms, masks, shifts); \
3611 gDPLoadTile(pkt, G_TX_LOADTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3612 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC); \
3614 gDPSetTile(pkt, fmt, siz, (((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, \
3615 maskt, shiftt, cms, masks, shifts); \
3616 gDPSetTileSize(pkt, G_TX_RENDERTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3617 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC) \
3622#define gDPLoadTextureTile(pkt, timg, fmt, siz, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, \
3626 int _loadtile_i, _loadtile_nw; \
3627 Gfx* _loadtile_temp = pkt; \
3628 guDPLoadTextureTile(_loadtile_temp, timg, fmt, siz, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, \
3629 maskt, shifts, shiftt); \
3630 _loadtile_nw = guGetDPLoadTextureTileSz(ult, lrt) - 1; \
3631 for (_loadtile_i = 0; _loadtile_i < _loadtile_nw; _loadtile_i++) \
3641#define gDPLoadMultiTile(pkt, timg, tmem, rtile, fmt, siz, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, \
3642 maskt, shifts, shiftt) \
3644 gDPSetTextureImage(pkt, fmt, siz, width, timg); \
3645 gDPSetTile(pkt, fmt, siz, (((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), tmem, G_TX_LOADTILE, 0, cmt, \
3646 maskt, shiftt, cms, masks, shifts); \
3648 gDPLoadTile(pkt, G_TX_LOADTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3649 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC); \
3651 gDPSetTile(pkt, fmt, siz, (((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), tmem, rtile, pal, cmt, maskt, \
3652 shiftt, cms, masks, shifts); \
3653 gDPSetTileSize(pkt, rtile, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3654 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC) \
3657#define gsDPLoadTextureTile(timg, fmt, siz, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, \
3660 gsDPSetTextureImage(fmt, siz, width, timg), \
3661 gsDPSetTile(fmt, siz, (((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, G_TX_LOADTILE, 0, cmt, maskt, \
3662 shiftt, cms, masks, shifts), \
3664 gsDPLoadTile(G_TX_LOADTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3665 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC), \
3667 gsDPSetTile(fmt, siz, (((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, \
3668 maskt, shiftt, cms, masks, shifts), \
3669 gsDPSetTileSize(G_TX_RENDERTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3670 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC)
3676#define gsDPLoadMultiTile(timg, tmem, rtile, fmt, siz, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, \
3679 gsDPSetTextureImage(fmt, siz, width, timg), \
3680 gsDPSetTile(fmt, siz, (((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), tmem, G_TX_LOADTILE, 0, cmt, \
3681 maskt, shiftt, cms, masks, shifts), \
3683 gsDPLoadTile(G_TX_LOADTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3684 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC), \
3686 gsDPSetTile(fmt, siz, (((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), tmem, rtile, pal, cmt, maskt, \
3687 shiftt, cms, masks, shifts), \
3688 gsDPSetTileSize(rtile, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3689 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC)
3691#define gDPLoadTextureTile_4b(pkt, timg, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, \
3694 gDPSetTextureImage(pkt, fmt, G_IM_SIZ_8b, ((width) >> 1), timg); \
3695 gDPSetTile(pkt, fmt, G_IM_SIZ_8b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), 0, G_TX_LOADTILE, 0, cmt, maskt, \
3696 shiftt, cms, masks, shifts); \
3698 gDPLoadTile(pkt, G_TX_LOADTILE, (uls) << (G_TEXTURE_IMAGE_FRAC - 1), (ult) << (G_TEXTURE_IMAGE_FRAC), \
3699 (lrs) << (G_TEXTURE_IMAGE_FRAC - 1), (lrt) << (G_TEXTURE_IMAGE_FRAC)); \
3701 gDPSetTile(pkt, fmt, G_IM_SIZ_4b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, \
3702 maskt, shiftt, cms, masks, shifts); \
3703 gDPSetTileSize(pkt, G_TX_RENDERTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3704 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC) \
3711#define gDPLoadMultiTile_4b(pkt, timg, tmem, rtile, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, \
3712 maskt, shifts, shiftt) \
3714 gDPSetTextureImage(pkt, fmt, G_IM_SIZ_8b, ((width) >> 1), timg); \
3715 gDPSetTile(pkt, fmt, G_IM_SIZ_8b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), tmem, G_TX_LOADTILE, 0, cmt, maskt, \
3716 shiftt, cms, masks, shifts); \
3718 gDPLoadTile(pkt, G_TX_LOADTILE, (uls) << (G_TEXTURE_IMAGE_FRAC - 1), (ult) << (G_TEXTURE_IMAGE_FRAC), \
3719 (lrs) << (G_TEXTURE_IMAGE_FRAC - 1), (lrt) << (G_TEXTURE_IMAGE_FRAC)); \
3721 gDPSetTile(pkt, fmt, G_IM_SIZ_4b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), tmem, rtile, pal, cmt, maskt, \
3722 shiftt, cms, masks, shifts); \
3723 gDPSetTileSize(pkt, rtile, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3724 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC) \
3727#define gsDPLoadTextureTile_4b(timg, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, shifts, \
3730 gsDPSetTextureImage(fmt, G_IM_SIZ_8b, ((width) >> 1), timg), \
3731 gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), 0, G_TX_LOADTILE, 0, cmt, maskt, \
3732 shiftt, cms, masks, shifts), \
3734 gsDPLoadTile(G_TX_LOADTILE, (uls) << (G_TEXTURE_IMAGE_FRAC - 1), (ult) << (G_TEXTURE_IMAGE_FRAC), \
3735 (lrs) << (G_TEXTURE_IMAGE_FRAC - 1), (lrt) << (G_TEXTURE_IMAGE_FRAC)), \
3737 gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), 0, G_TX_RENDERTILE, pal, cmt, maskt, \
3738 shiftt, cms, masks, shifts), \
3739 gsDPSetTileSize(G_TX_RENDERTILE, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3740 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC)
3746#define gsDPLoadMultiTile_4b(timg, tmem, rtile, fmt, width, height, uls, ult, lrs, lrt, pal, cms, cmt, masks, maskt, \
3749 gsDPSetTextureImage(fmt, G_IM_SIZ_8b, ((width) >> 1), timg), \
3750 gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), tmem, G_TX_LOADTILE, 0, cmt, maskt, \
3751 shiftt, cms, masks, shifts), \
3753 gsDPLoadTile(G_TX_LOADTILE, (uls) << (G_TEXTURE_IMAGE_FRAC - 1), (ult) << (G_TEXTURE_IMAGE_FRAC), \
3754 (lrs) << (G_TEXTURE_IMAGE_FRAC - 1), (lrt) << (G_TEXTURE_IMAGE_FRAC)), \
3756 gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs) - (uls) + 1) >> 1) + 7) >> 3), tmem, rtile, pal, cmt, maskt, shiftt, \
3757 cms, masks, shifts), \
3758 gsDPSetTileSize(rtile, (uls) << G_TEXTURE_IMAGE_FRAC, (ult) << G_TEXTURE_IMAGE_FRAC, \
3759 (lrs) << G_TEXTURE_IMAGE_FRAC, (lrt) << G_TEXTURE_IMAGE_FRAC)
3765#ifndef _HW_VERSION_1
3767#define gDPLoadTLUT_pal16(pkt, pal, dram) \
3769 gDPSetTextureImage(pkt, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram); \
3771 gDPSetTile(pkt, 0, 0, 0, (256 + (((pal) & 0xf) * 16)), G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0); \
3773 gDPLoadTLUTCmd(pkt, G_TX_LOADTILE, 15); \
3779#define gDPLoadTLUT_pal16(pkt, pal, dram) \
3781 _gDPLoadTextureBlock(pkt, dram, (256 + (((pal) & 0xf) * 16)), G_IM_FMT_RGBA, G_IM_SIZ_16b, 4 * 16, 1, pal, 0, 0, \
3790#ifndef _HW_VERSION_1
3792#define gsDPLoadTLUT_pal16(pal, dram) \
3794 gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram), gsDPTileSync(), \
3795 gsDPSetTile(0, 0, 0, (256 + (((pal) & 0xf) * 16)), G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0), gsDPLoadSync(), \
3796 gsDPLoadTLUTCmd(G_TX_LOADTILE, 15), gsDPPipeSync()
3800#define gsDPLoadTLUT_pal16(pal, dram) \
3802 _gsDPLoadTextureBlock(dram, (256 + (((pal) & 0xf) * 16)), G_IM_FMT_RGBA, G_IM_SIZ_16b, 4 * 16, 1, pal, 0, 0, 0, 0, \
3811#ifndef _HW_VERSION_1
3813#define gDPLoadTLUT_pal256(pkt, dram) \
3815 gDPSetTextureImage(pkt, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram); \
3817 gDPSetTile(pkt, 0, 0, 0, 256, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0); \
3819 gDPLoadTLUTCmd(pkt, G_TX_LOADTILE, 255); \
3825#define gDPLoadTLUT_pal256(pkt, dram) \
3827 _gDPLoadTextureBlock(pkt, dram, 256, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4 * 256, 1, 0, 0, 0, 0, 0, 0, 0)
3831#ifndef _HW_VERSION_1
3833#define gsDPLoadTLUT_pal256(dram) \
3835 gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram), gsDPTileSync(), \
3836 gsDPSetTile(0, 0, 0, 256, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0), gsDPLoadSync(), \
3837 gsDPLoadTLUTCmd(G_TX_LOADTILE, 255), gsDPPipeSync()
3841#define gsDPLoadTLUT_pal256(dram) \
3843 _gsDPLoadTextureBlock(dram, 256, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4 * 256, 1, 0, 0, 0, 0, 0, 0, 0)
3847#ifndef _HW_VERSION_1
3849#define gDPLoadTLUT(pkt, count, tmemaddr, dram) \
3851 gDPSetTextureImage(pkt, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram); \
3853 gDPSetTile(pkt, 0, 0, 0, tmemaddr, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0); \
3855 gDPLoadTLUTCmd(pkt, G_TX_LOADTILE, ((count) - 1)); \
3861#define gDPLoadTLUT(pkt, count, tmemaddr, dram) \
3863 _gDPLoadTextureBlock(pkt, dram, tmemaddr, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, count, 0, 0, 0, 0, 0, 0, 0)
3867#ifndef _HW_VERSION_1
3869#define gsDPLoadTLUT(count, tmemaddr, dram) \
3871 gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, dram), gsDPTileSync(), \
3872 gsDPSetTile(0, 0, 0, tmemaddr, G_TX_LOADTILE, 0, 0, 0, 0, 0, 0, 0), gsDPLoadSync(), \
3873 gsDPLoadTLUTCmd(G_TX_LOADTILE, ((count) - 1)), gsDPPipeSync()
3876#define gsDPLoadTLUT(count, tmemaddr, dram) \
3878 _gsDPLoadTextureBlock(dram, tmemaddr, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, count, 0, 0, 0, 0, 0, 0, 0)
3882#define gDPSetScissor(pkt, mode, ulx, uly, lrx, lry) \
3884 Gfx* _g = (Gfx*) pkt; \
3886 _g->words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | _SHIFTL((int) ((float) (ulx) * 4.0F), 12, 12) | \
3887 _SHIFTL((int) ((float) (uly) * 4.0F), 0, 12); \
3888 _g->words.w1 = _SHIFTL(mode, 24, 2) | _SHIFTL((int) ((float) (lrx) * 4.0F), 12, 12) | \
3889 _SHIFTL((int) ((float) (lry) * 4.0F), 0, 12); \
3892#define gDPSetScissorFrac(pkt, mode, ulx, uly, lrx, lry) \
3894 Gfx* _g = (Gfx*) pkt; \
3896 _g->words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | _SHIFTL((int) ((ulx)), 12, 12) | _SHIFTL((int) ((uly)), 0, 12); \
3897 _g->words.w1 = _SHIFTL(mode, 24, 2) | _SHIFTL((int) ((lrx)), 12, 12) | _SHIFTL((int) ((lry)), 0, 12); \
3900#define gsDPSetScissor(mode, ulx, uly, lrx, lry) \
3903 _SHIFTL(G_SETSCISSOR, 24, 8) | _SHIFTL((int) ((float) (ulx) * 4.0F), 12, 12) | \
3904 _SHIFTL((int) ((float) (uly) * 4.0F), 0, 12), \
3905 _SHIFTL(mode, 24, 2) | _SHIFTL((int) ((float) (lrx) * 4.0F), 12, 12) | \
3906 _SHIFTL((int) ((float) (lry) * 4.0F), 0, 12) \
3910#define gsDPSetScissorFrac(mode, ulx, uly, lrx, lry) \
3913 _SHIFTL(G_SETSCISSOR, 24, 8) | _SHIFTL((int) ((ulx)), 12, 12) | _SHIFTL((int) ((uly)), 0, 12), \
3914 _SHIFTL(mode, 24, 2) | _SHIFTL((int) (lrx), 12, 12) | _SHIFTL((int) (lry), 0, 12) \
3919#define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \
3921 Gfx* _g = (Gfx*) (pkt); \
3923 _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 14, 10) | _SHIFTL((lry), 2, 10)); \
3924 _g->words.w1 = (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10)); \
3927#define gsDPFillRectangle(ulx, uly, lrx, lry) \
3930 (_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 14, 10) | _SHIFTL((lry), 2, 10)), \
3931 (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10)) \
3936#define gDPScisFillRectangle(pkt, ulx, uly, lrx, lry) \
3938 Gfx* _g = (Gfx*) (pkt); \
3940 _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL(MAX((lrx), 0), 14, 10) | _SHIFTL(MAX((lry), 0), 2, 10)); \
3941 _g->words.w1 = (_SHIFTL(MAX((ulx), 0), 14, 10) | _SHIFTL(MAX((uly), 0), 2, 10)); \
3944#define gDPSetConvert(pkt, k0, k1, k2, k3, k4, k5) \
3946 Gfx* _g = (Gfx*) (pkt); \
3948 _g->words.w0 = (_SHIFTL(G_SETCONVERT, 24, 8) | _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | _SHIFTR(k2, 5, 4)); \
3949 _g->words.w1 = (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | _SHIFTL(k4, 9, 9) | _SHIFTL(k5, 0, 9)); \
3952#define gsDPSetConvert(k0, k1, k2, k3, k4, k5) \
3955 (_SHIFTL(G_SETCONVERT, 24, 8) | _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | _SHIFTR(k2, 5, 4)), \
3956 (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | _SHIFTL(k4, 9, 9) | _SHIFTL(k5, 0, 9)) \
3960#define gDPSetKeyR(pkt, cR, sR, wR) \
3962 Gfx* _g = (Gfx*) (pkt); \
3964 _g->words.w0 = _SHIFTL(G_SETKEYR, 24, 8); \
3965 _g->words.w1 = (_SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | _SHIFTL(sR, 0, 8)); \
3968#define gsDPSetKeyR(cR, sR, wR) \
3970 { _SHIFTL(G_SETKEYR, 24, 8), _SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | _SHIFTL(sR, 0, 8) } \
3973#define gDPSetKeyGB(pkt, cG, sG, wG, cB, sB, wB) \
3975 Gfx* _g = (Gfx*) (pkt); \
3977 _g->words.w0 = (_SHIFTL(G_SETKEYGB, 24, 8) | _SHIFTL(wG, 12, 12) | _SHIFTL(wB, 0, 12)); \
3978 _g->words.w1 = (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | _SHIFTL(cB, 8, 8) | _SHIFTL(sB, 0, 8)); \
3981#define gsDPSetKeyGB(cG, sG, wG, cB, sB, wB) \
3984 (_SHIFTL(G_SETKEYGB, 24, 8) | _SHIFTL(wG, 12, 12) | _SHIFTL(wB, 0, 12)), \
3985 (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | _SHIFTL(cB, 8, 8) | _SHIFTL(sB, 0, 8)) \
3989#define gDPNoParam(pkt, cmd) \
3991 Gfx* _g = (Gfx*) (pkt); \
3993 _g->words.w0 = _SHIFTL(cmd, 24, 8); \
3997#define gsDPNoParam(cmd) \
3999 { _SHIFTL(cmd, 24, 8), 0 } \
4002#define gDPParam(pkt, cmd, param) \
4004 Gfx* _g = (Gfx*) (pkt); \
4006 _g->words.w0 = _SHIFTL(cmd, 24, 8); \
4007 _g->words.w1 = (param); \
4010#define gsDPParam(cmd, param) \
4012 { _SHIFTL(cmd, 24, 8), (param) } \
4020#define gsDPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4022 (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)), \
4023 (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \
4026 { _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) } \
4029#define gDPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4031 Gfx* _g = (Gfx*) (pkt); \
4034 _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)); \
4035 _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)); \
4037 _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \
4038 _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \
4041#define gsDPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4043 (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)), \
4044 (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \
4047 { _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) } \
4050#define gDPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4052 Gfx* _g = (Gfx*) (pkt); \
4055 _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)); \
4056 _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)); \
4058 _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \
4059 _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \
4063#define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4065 Gfx* _g = (Gfx*) (pkt); \
4067 _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)); \
4068 _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)); \
4069 gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \
4070 gImmp1(pkt, G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \
4073#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4074 { { (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)), \
4075 (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)) } }, \
4076 gsImmp1(G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \
4077 gsImmp1(G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)))
4080#define gSPScisTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4082 Gfx* _g = (Gfx*) (pkt); \
4085 (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(MAX((s16) (xh), 0), 12, 12) | _SHIFTL(MAX((s16) (yh), 0), 0, 12)); \
4087 (_SHIFTL((tile), 24, 3) | _SHIFTL(MAX((s16) (xl), 0), 12, 12) | _SHIFTL(MAX((s16) (yl), 0), 0, 12)); \
4088 gImmp1(pkt, G_RDPHALF_2, \
4089 (_SHIFTL(((s) - (((s16) (xl) < 0) ? (((s16) (dsdx) < 0) ? (MAX((((s16) (xl) * (s16) (dsdx)) >> 7), 0)) \
4090 : (MIN((((s16) (xl) * (s16) (dsdx)) >> 7), 0))) \
4093 _SHIFTL(((t) - (((yl) < 0) ? (((s16) (dtdy) < 0) ? (MAX((((s16) (yl) * (s16) (dtdy)) >> 7), 0)) \
4094 : (MIN((((s16) (yl) * (s16) (dtdy)) >> 7), 0))) \
4097 gImmp1(pkt, G_RDPHALF_CONT, (_SHIFTL((dsdx), 16, 16) | _SHIFTL((dtdy), 0, 16))); \
4100#define gsSPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4101 { { (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)), \
4102 (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)) } }, \
4103 gsImmp1(G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \
4104 gsImmp1(G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)))
4106#define gSPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4108 Gfx* _g = (Gfx*) (pkt); \
4110 _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)); \
4111 _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)); \
4112 gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \
4113 gImmp1(pkt, G_RDPHALF_CONT, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \
4116#define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4118 Gfx* _g = (Gfx*) (pkt); \
4120 _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)); \
4121 _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)); \
4122 gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \
4123 gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \
4126#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4127 { { (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)), \
4128 (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)) } }, \
4129 gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \
4130 gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)))
4133#define gSPScisTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4135 Gfx* _g = (Gfx*) (pkt); \
4138 (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(MAX((s16) (xh), 0), 12, 12) | _SHIFTL(MAX((s16) (yh), 0), 0, 12)); \
4140 (_SHIFTL((tile), 24, 3) | _SHIFTL(MAX((s16) (xl), 0), 12, 12) | _SHIFTL(MAX((s16) (yl), 0), 0, 12)); \
4141 gImmp1(pkt, G_RDPHALF_1, \
4142 (_SHIFTL(((s) - (((s16) (xl) < 0) ? (((s16) (dsdx) < 0) ? (MAX((((s16) (xl) * (s16) (dsdx)) >> 7), 0)) \
4143 : (MIN((((s16) (xl) * (s16) (dsdx)) >> 7), 0))) \
4146 _SHIFTL(((t) - (((yl) < 0) ? (((s16) (dtdy) < 0) ? (MAX((((s16) (yl) * (s16) (dtdy)) >> 7), 0)) \
4147 : (MIN((((s16) (yl) * (s16) (dtdy)) >> 7), 0))) \
4150 gImmp1(pkt, G_RDPHALF_2, (_SHIFTL((dsdx), 16, 16) | _SHIFTL((dtdy), 0, 16))); \
4153#define gsSPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4154 { { (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)), \
4155 (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)) } }, \
4156 gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \
4157 gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)))
4159#define gSPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \
4161 Gfx* _g = (Gfx*) (pkt); \
4163 _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)); \
4164 _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)); \
4165 gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \
4166 gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \
4170#define gsDPWord(wordhi, wordlo) gsImmp1(G_RDPHALF_1, (uintptr_t) (wordhi)), gsImmp1(G_RDPHALF_2, (uintptr_t) (wordlo))
4172#define gDPWord(pkt, wordhi, wordlo) \
4174 Gfx* _g = (Gfx*) (pkt); \
4176 gImmp1(pkt, G_RDPHALF_1, (uintptr_t) (wordhi)); \
4177 gImmp1(pkt, G_RDPHALF_2, (uintptr_t) (wordlo)); \
4180#define gDPFullSync(pkt) gDPNoParam(pkt, G_RDPFULLSYNC)
4181#define gsDPFullSync() gsDPNoParam(G_RDPFULLSYNC)
4182#define gDPTileSync(pkt) gDPNoParam(pkt, G_RDPTILESYNC)
4183#define gsDPTileSync() gsDPNoParam(G_RDPTILESYNC)
4184#define gDPPipeSync(pkt) gDPNoParam(pkt, G_RDPPIPESYNC)
4185#define gsDPPipeSync() gsDPNoParam(G_RDPPIPESYNC)
4186#define gDPLoadSync(pkt) gDPNoParam(pkt, G_RDPLOADSYNC)
4187#define gsDPLoadSync() gsDPNoParam(G_RDPLOADSYNC)
4188#define gDPNoOp(pkt) gDPNoParam(pkt, G_NOOP)
4189#define gsDPNoOp() gsDPNoParam(G_NOOP)
4190#define gDPNoOpTag(pkt, tag) gDPParam(pkt, G_NOOP, tag)
4191#define gsDPNoOpTag(tag) gsDPParam(G_NOOP, tag)
signed int s32
Definition ultratypes.h:15