24#define GS_PERSISTENT 0x00
26#define GS_ONESHOT 0x01
29#define GS_RENDER_QUEUE_PER_POOLSIZE 1024 * 256
31#define GS_RENDER_QUEUE_OS_POOLSIZE 1024 * 1024
39#define GS_NONINTERLACED 0x00
41#define GS_INTERLACED 0x01
49#define GS_FIELD_NORMAL 0x00
51#define GS_FIELD_ODD 0x02
53#define GS_FIELD_EVEN 0x03
56#define GS_ASPECT_4_3 0x0
58#define GS_ASPECT_16_9 0x1
61#define GS_MODE_NTSC 0x02
63#define GS_MODE_PAL 0x03
65#define GS_MODE_VGA_640_60 0x1A
67#define GS_MODE_VGA_640_72 0x1B
69#define GS_MODE_VGA_640_75 0x1C
71#define GS_MODE_VGA_640_85 0x1D
74#define GS_MODE_VGA_800_56 0x2A
76#define GS_MODE_VGA_800_60 0x2B
78#define GS_MODE_VGA_800_72 0x2C
80#define GS_MODE_VGA_800_75 0x2D
82#define GS_MODE_VGA_800_85 0x2E
85#define GS_MODE_VGA_1024_60 0x3B
87#define GS_MODE_VGA_1024_70 0x3C
89#define GS_MODE_VGA_1024_75 0x3D
91#define GS_MODE_VGA_1024_85 0x3E
94#define GS_MODE_VGA_1280_60 0x4A
96#define GS_MODE_VGA_1280_75 0x4B
99#define GS_MODE_DTV_480P 0x50
101#define GS_MODE_DTV_576P 0x53
103#define GS_MODE_DTV_1080I 0x51
105#define GS_MODE_DTV_720P 0x52
108#define GS_MODE_DVD_NTSC 0x72
110#define GS_MODE_DVD_PAL 0x73
112#define GS_MODE_DVD_480P 0x74
115#define GS_PSM_CT32 0x00
117#define GS_PSM_CT24 0x01
119#define GS_PSM_CT16 0x02
121#define GS_PSM_CT16S 0x0A
123#define GS_PSM_T8 0x13
125#define GS_PSM_T8H 0x1B
127#define GS_PSM_T4 0x14
129#define GS_PSM_T4HL 0x24
131#define GS_PSM_T4HH 0x2C
134#define GS_PSMZ_32 0x00
136#define GS_PSMZ_24 0x01
138#define GS_PSMZ_16 0x02
140#define GS_PSMZ_16S 0x0A
143#define GS_BLEND_FRONT2BACK 0x12
145#define GS_BLEND_BACK2FRONT 0x01
148#define GS_SETTING_OFF 0x00
151#define GS_SETTING_ON 0x01
168#define GS_TEX0_1 0x06
170#define GS_TEX0_2 0x07
172#define GS_CLAMP_1 0x08
174#define GS_CLAMP_2 0x09
182#define GS_TEX1_1 0x14
184#define GS_TEX1_2 0x15
186#define GS_TEX2_1 0x16
188#define GS_TEX2_2 0x17
190#define GS_XYOFFSET_1 0x18
192#define GS_XYOFFSET_2 0x19
194#define GS_PRMODECONT 0x1a
196#define GS_PRMODE 0x1b
198#define GS_TEXCLUT 0x1c
200#define GS_SCANMSK 0x22
202#define GS_MIPTBP1_1 0x34
204#define GS_MIPTBP1_2 0x35
206#define GS_MIPTBP2_1 0x36
208#define GS_MIPTBP2_2 0x37
212#define GS_FOGCOL 0x3d
214#define GS_TEXFLUSH 0x3f
216#define GS_SCISSOR_1 0x40
218#define GS_SCISSOR_2 0x41
220#define GS_ALPHA_1 0x42
222#define GS_ALPHA_2 0x43
228#define GS_COLCLAMP 0x46
230#define GS_TEST_1 0x47
232#define GS_TEST_2 0x48
240#define GS_FRAME_1 0x4c
242#define GS_FRAME_2 0x4d
244#define GS_ZBUF_1 0x4e
246#define GS_ZBUF_2 0x4f
248#define GS_BITBLTBUF 0x50
250#define GS_TRXPOS 0x51
252#define GS_TRXREG 0x52
254#define GS_TRXDIR 0x53
258#define GS_SIGNAL 0x60
260#define GS_FINISH 0x61
267#define GS_PRIM_PRIM_POINT 0x00
269#define GS_PRIM_PRIM_LINE 0x01
271#define GS_PRIM_PRIM_LINESTRIP 0x02
273#define GS_PRIM_PRIM_TRIANGLE 0x03
275#define GS_PRIM_PRIM_TRISTRIP 0x04
277#define GS_PRIM_PRIM_TRIFAN 0x05
279#define GS_PRIM_PRIM_SPRITE 0x06
282#define GSKIT_GIF_PRIM_POINT 0x1000
283#define GSKIT_GIF_PRIM_LINE 0x1100
284#define GSKIT_GIF_PRIM_LINESTRIP 0x1200
285#define GSKIT_GIF_PRIM_TRIANGLE 0x1300
286#define GSKIT_GIF_PRIM_TRISTRIP 0x1400
287#define GSKIT_GIF_PRIM_TRIFAN 0x1500
288#define GSKIT_GIF_PRIM_SPRITE 0x1600
289#define GSKIT_GIF_PRIM_QUAD 0x1700
290#define GSKIT_GIF_PRIM_TRIANGLE_GOURAUD 0x1800
291#define GSKIT_GIF_PRIM_QUAD_GOURAUD 0x1900
292#define GSKIT_GIF_PRIM_SPRITE_TEXTURED 0x1A00
293#define GSKIT_GIF_PRIM_TRIANGLE_TEXTURED 0x1B00
294#define GSKIT_GIF_PRIM_TRISTRIP_TEXTURED 0x1C00
295#define GSKIT_GIF_PRIM_TRIFAN_TEXTURED 0x1D00
296#define GSKIT_GIF_PRIM_QUAD_TEXTURED 0x1E00
299#define GSKIT_GIF_FLG_PACKED 0
300#define GSKIT_GIF_FLG_REGLIST 1
301#define GSKIT_GIF_FLG_IMAGE 2
308#define GIF_TAG_AD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_PACKED,1)
311#define GIF_TAG_POINT(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,4)
313#define GIF_TAG_POINT_REGS \
314 ((u64)(GS_PRIM) << 0) | \
315 ((u64)(GS_RGBAQ) << 4) | \
316 ((u64)(GS_XYZ2) << 8) | \
317 ((u64)(GIF_NOP) << 12);
321#define GIF_TAG_LINE(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,4)
323#define GIF_TAG_LINE_REGS \
324 ((u64)(GS_PRIM) << 0) | \
325 ((u64)(GS_RGBAQ) << 4) | \
326 ((u64)(GS_XYZ2) << 8) | \
327 ((u64)(GS_XYZ2) << 12);
331#define GIF_TAG_LINE_GORAUD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,6)
333#define GIF_TAG_LINE_GORAUD_REGS \
334 ((u64)(GS_PRIM) << 0) | \
335 ((u64)(GS_RGBAQ) << 4) | \
336 ((u64)(GS_XYZ2) << 8) | \
337 ((u64)(GS_RGBAQ) << 12) | \
338 ((u64)(GS_XYZ2) << 16) | \
339 ((u64)(GIF_NOP) << 20);
343#define GIF_TAG_TRIANGLE(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,6)
345#define GIF_TAG_TRIANGLE_REGS \
346 ((u64)(GS_PRIM) << 0) | \
347 ((u64)(GS_RGBAQ) << 4) | \
348 ((u64)(GS_XYZ2) << 8) | \
349 ((u64)(GS_XYZ2) << 12) | \
350 ((u64)(GS_XYZ2) << 16) | \
351 ((u64)(GIF_NOP) << 20);
355#define GIF_TAG_SPRITE(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,4)
357#define GIF_TAG_SPRITE_REGS \
358 ((u64)(GS_PRIM) << 0) | \
359 ((u64)(GS_RGBAQ) << 4) | \
360 ((u64)(GS_XYZ2) << 8) | \
361 ((u64)(GS_XYZ2) << 12);
365#define GIF_TAG_QUAD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,6)
367#define GIF_TAG_QUAD_REGS \
368 ((u64)(GS_PRIM) << 0) | \
369 ((u64)(GS_RGBAQ) << 4) | \
370 ((u64)(GS_XYZ2) << 8) | \
371 ((u64)(GS_XYZ2) << 12) | \
372 ((u64)(GS_XYZ2) << 16) | \
373 ((u64)(GS_XYZ2) << 20);
377#define GIF_TAG_TRIANGLE_GOURAUD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,8)
379#define GIF_TAG_TRIANGLE_GOURAUD_REGS \
380 ((u64)(GS_PRIM) << 0) | \
381 ((u64)(GS_RGBAQ) << 4) | \
382 ((u64)(GS_XYZ2) << 8) | \
383 ((u64)(GS_RGBAQ) << 12) | \
384 ((u64)(GS_XYZ2) << 16) | \
385 ((u64)(GS_RGBAQ) << 20) | \
386 ((u64)(GS_XYZ2) << 24) | \
387 ((u64)(GIF_NOP) << 28);
391#define GIF_TAG_QUAD_GOURAUD(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,10)
393#define GIF_TAG_QUAD_GOURAUD_REGS \
394 ((u64)(GS_PRIM) << 0) | \
395 ((u64)(GS_RGBAQ) << 4) | \
396 ((u64)(GS_XYZ2) << 8) | \
397 ((u64)(GS_RGBAQ) << 12) | \
398 ((u64)(GS_XYZ2) << 16) | \
399 ((u64)(GS_RGBAQ) << 20) | \
400 ((u64)(GS_XYZ2) << 24) | \
401 ((u64)(GS_RGBAQ) << 28) | \
402 ((u64)(GS_XYZ2) << 32) | \
403 ((u64)(GS_RGBAQ) << 36);
407#define GIF_TAG_SPRITE_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,8)
409#define GIF_TAG_SPRITE_TEXTURED_REGS(ctx) \
410 ((u64)(GS_TEX0_1 + ctx) << 0) | \
411 ((u64)(GS_PRIM) << 4) | \
412 ((u64)(GS_RGBAQ) << 8) | \
413 ((u64)(GS_UV) << 12) | \
414 ((u64)(GS_XYZ2) << 16) | \
415 ((u64)(GS_UV) << 20) | \
416 ((u64)(GS_XYZ2) << 24) | \
417 ((u64)(GIF_NOP) << 28);
421#define GIF_TAG_TRIANGLE_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,10)
423#define GIF_TAG_TRIANGLE_TEXTURED_REGS(ctx) \
424 ((u64)(GS_TEX0_1 + ctx) << 0) | \
425 ((u64)(GS_PRIM) << 4) | \
426 ((u64)(GS_RGBAQ) << 8) | \
427 ((u64)(GS_UV) << 12) | \
428 ((u64)(GS_XYZ2) << 16) | \
429 ((u64)(GS_UV) << 20) | \
430 ((u64)(GS_XYZ2) << 24) | \
431 ((u64)(GS_UV) << 28) | \
432 ((u64)(GS_XYZ2) << 32) | \
433 ((u64)(GIF_NOP) << 36);
437#define GIF_TAG_QUAD_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,12)
439#define GIF_TAG_QUAD_TEXTURED_REGS(ctx) \
440 ((u64)(GS_TEX0_1 + ctx) << 0) | \
441 ((u64)(GS_PRIM) << 4) | \
442 ((u64)(GS_RGBAQ) << 8) | \
443 ((u64)(GS_UV) << 12) | \
444 ((u64)(GS_XYZ2) << 16) | \
445 ((u64)(GS_UV) << 20) | \
446 ((u64)(GS_XYZ2) << 24) | \
447 ((u64)(GS_UV) << 28) | \
448 ((u64)(GS_XYZ2) << 32) | \
449 ((u64)(GS_UV) << 36) | \
450 ((u64)(GS_XYZ2) << 40) | \
451 ((u64)(GIF_NOP) << 44);
455#define GIF_TAG_TRIANGLE_GORAUD_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,12)
457#define GIF_TAG_TRIANGLE_GORAUD_TEXTURED_REGS(ctx) \
458 ((u64)(GS_TEX0_1 + ctx) << 0) | \
459 ((u64)(GS_PRIM) << 4) | \
460 ((u64)(GS_RGBAQ) << 8) | \
461 ((u64)(GS_UV) << 12) | \
462 ((u64)(GS_XYZ2) << 16) | \
463 ((u64)(GS_RGBAQ) << 20) | \
464 ((u64)(GS_UV) << 24) | \
465 ((u64)(GS_XYZ2) << 28) | \
466 ((u64)(GS_RGBAQ) << 32) | \
467 ((u64)(GS_UV) << 36) | \
468 ((u64)(GS_XYZ2) << 40) | \
469 ((u64)(GIF_NOP) << 44);
473#define GIF_TAG_QUAD_GORAUD_TEXTURED(NLOOP) GIF_TAG(NLOOP,1,0,0,GSKIT_GIF_FLG_REGLIST,14)
475#define GIF_TAG_QUAD_GORAUD_TEXTURED_REGS(ctx) \
476 ((u64)(GS_TEX0_1 + ctx) << 0) | \
477 ((u64)(GS_PRIM) << 4) | \
478 ((u64)(GS_RGBAQ) << 8) | \
479 ((u64)(GS_UV) << 12) | \
480 ((u64)(GS_XYZ2) << 16) | \
481 ((u64)(GS_RGBAQ) << 20) | \
482 ((u64)(GS_UV) << 24) | \
483 ((u64)(GS_XYZ2) << 28) | \
484 ((u64)(GS_RGBAQ) << 32) | \
485 ((u64)(GS_UV) << 36) | \
486 ((u64)(GS_XYZ2) << 40) | \
487 ((u64)(GS_RGBAQ) << 44) | \
488 ((u64)(GS_UV) << 48) | \
489 ((u64)(GS_XYZ2) << 52);
492#define GIF_RESERVED 0x0B
499#define GSKIT_PREFETCH(address) asm __volatile__("pref 0, 0(%0)" : : "r" (address));
502#define GS_RESET() *GS_CSR = ((u64)(1) << 9)
505#define GIF_CTRL (volatile u32*)0x10003000
508#define GIF_MODE (volatile u32*)0x10003010
511#define GIF_STAT (volatile u32*)0x10003020
514#define GIF_SETREG_CTRL(RST, PSE) \
516 ((u32)(RST) << 0) | \
520#define GIF_SETREG_MODE(M3R, IMT) \
522 ((u32)(M3R) << 0) | \
526#define GIF_STAT_M3R *GIF_STAT >> 0
527#define GIF_STAT_M3P *GIF_STAT >> 1
528#define GIF_STAT_IMT *GIF_STAT >> 2
529#define GIF_STAT_PSE *GIF_STAT >> 3
530#define GIF_STAT_IP3 *GIF_STAT >> 5
531#define GIF_STAT_P3Q *GIF_STAT >> 6
532#define GIF_STAT_P2Q *GIF_STAT >> 7
533#define GIF_STAT_P1Q *GIF_STAT >> 8
534#define GIF_STAT_OPH *GIF_STAT >> 9
535#define GIF_STAT_APATH *GIF_STAT >> 10
536#define GIF_STAT_DIR *GIF_STAT >> 12
537#define GIF_STAT_FQC *GIF_STAT >> 24
540#define GS_CSR (volatile u64 *)0x12001000
543#define GS_CSR_FINISH ((*GS_CSR) >> 1)&1
546#define GS_SETREG_CSR_FINISH(A) *GS_CSR = ((u64)(A) << 1)
549#define GS_BUSDIR ((volatile u64 *)(0x12001040))
552#define GS_SETREG_BUSDIR(A) *GS_BUSDIR = ((u64)(A))
555#define GS_IMR ((volatile u64 *)(0x12001010))
558#define GS_SIGNALID ((volatile u64 *)(0x12001080))
561#define GS_SETREG_CSR(A,B,C,D,E,F,G,H,I,J,K,L) \
562 (u64)(A & 0x00000001) << 0 | (u64)(B & 0x00000001) << 1 | \
563 (u64)(C & 0x00000001) << 2 | (u64)(D & 0x00000001) << 3 | \
564 (u64)(E & 0x00000001) << 4 | (u64)(F & 0x00000001) << 8 | \
565 (u64)(G & 0x00000001) << 9 | (u64)(H & 0x00000001) << 12 | \
566 (u64)(I & 0x00000001) << 13 | (u64)(J & 0x00000003) << 14 | \
567 (u64)(K & 0x000000FF) << 16 | (u64)(L & 0x000000FF) << 24
570#define GIF_TAG(NLOOP,EOP,PRE,PRIM,FLG,NREG) \
571 ((u64)(NLOOP) << 0) | \
572 ((u64)(EOP) << 15) | \
573 ((u64)(PRE) << 46) | \
574 ((u64)(PRIM) << 47) | \
575 ((u64)(FLG) << 58) | \
579#define GS_SETREG_RGBAQ(r, g, b, a, q) \
580 ((u64)(r) | ((u64)(g) << 8) | ((u64)(b) << 16) | \
581 ((u64)(a) << 24) | ((u64)(q) << 32))
584#define GS_SETREG_RGBA(r, g, b, a) \
585 ((u64)(r) | ((u64)(g) << 8) | ((u64)(b) << 16) | ((u64)(a) << 24))
588#define GS_SETREG_XYZ3 GS_SETREG_XYZ
590#define GS_SETREG_XYZ2 GS_SETREG_XYZ
592#define GS_SETREG_XYZ(x, y, z) \
593 ((u64)(x) | ((u64)(y) << 16) | ((u64)(z) << 32))
596#define GS_SETREG_XYZF3 GS_SETREG_XYZF
598#define GS_SETREG_XYZF2 GS_SETREG_XYZF
600#define GS_SETREG_XYZF(x, y, z, f) \
601 ((u64)(x) | ((u64)(y) << 16) | ((u64)(z) << 32) | \
605#define GS_PMODE ((volatile u64 *)(0x12000000))
606#define GS_SMODE1 ((volatile u64 *)(0x12000010))
607#define GS_SMODE2 ((volatile u64 *)(0x12000020))
608#define GS_SRFSH ((volatile u64 *)(0x12000030))
609#define GS_SYNCH1 ((volatile u64 *)(0x12000040))
610#define GS_SYNCH2 ((volatile u64 *)(0x12000050))
611#define GS_SYNCV ((volatile u64 *)(0x12000060))
612#define GS_EXTBUF ((volatile u64 *)(0x120000B0))
613#define GS_EXTDATA ((volatile u64 *)(0x120000C0))
614#define GS_EXTWRITE ((volatile u64 *)(0x120000D0))
617#define GS_DISPFB1 ((volatile u64 *)(0x12000070))
620#define GS_DISPFB2 ((volatile u64 *)(0x12000090))
623#define GS_SET_PMODE(EN1,EN2,MMOD,AMOD,SLBG,ALP) \
625 ((u64)(EN1) << 0) | \
626 ((u64)(EN2) << 1) | \
627 ((u64)(001) << 2) | \
628 ((u64)(MMOD) << 5) | \
629 ((u64)(AMOD) << 6) | \
630 ((u64)(SLBG) << 7) | \
634#define GS_SET_SMODE2(INT, FFMD, DPMS) \
636 ((u64)(INT) << 0) | \
637 ((u64)(FFMD) << 1) | \
641#define GS_SET_PMODE_EXT(EN1,EN2,CRTMD,MMOD,AMOD,SLBG,ALP, NFLD, EXVWINS, EXVWINE, EVSYNCMD) \
643 ((u64)(EN1) << 0) | \
644 ((u64)(EN2) << 1) | \
645 ((u64)(CRTMD) << 2) | \
646 ((u64)(MMOD) << 5) | \
647 ((u64)(AMOD) << 6) | \
648 ((u64)(SLBG) << 7) | \
649 ((u64)(ALP) << 8) | \
650 ((u64)(NFLD) << 16) | \
651 ((u64)(EXVWINS) << 32) | \
652 ((u64)(EXVWINE) << 42) | \
653 ((u64)(EVSYNCMD) << 52)
656#define GS_SET_EXTBUF(EXBP,EXBW,FBIN,WFFMD,EMODA,EMODC,WDX,WDY) \
658 ((u64)(EXBP) << 0) | \
659 ((u64)(EXBW) << 14) | \
660 ((u64)(FBIN) << 20) | \
661 ((u64)(WFFMD) << 22) | \
662 ((u64)(EMODA) << 23) | \
663 ((u64)(EMODC) << 25) | \
664 ((u64)(WDX) << 32) | \
668#define GS_SET_EXTDATA(SX,SY,SMPH,SMPV,WW,WH) \
671 ((u64)(SY) << 12) | \
672 ((u64)(SMPH) << 23) | \
673 ((u64)(SMPV) << 27) | \
674 ((u64)(WW) << 32) | \
678#define GS_SET_EXTWRITE(WRITE) \
684#define GS_SET_DISPFB1(FBP,FBW,PSM,DBX,DBY) \
686 ((u64)(FBP) << 0) | \
687 ((u64)(FBW) << 9) | \
688 ((u64)(PSM) << 15) | \
689 ((u64)(DBX) << 32) | \
693#define GS_SET_DISPFB2(FBP,FBW,PSM,DBX,DBY) \
695 ((u64)(FBP) << 0) | \
696 ((u64)(FBW) << 9) | \
697 ((u64)(PSM) << 15) | \
698 ((u64)(DBX) << 32) | \
702#define GS_DISPLAY1 ((volatile u64 *)(0x12000080))
705#define GS_SET_DISPLAY1(DX,DY,MAGH,MAGV,DW,DH) \
708 ((u64)(DY) << 12) | \
709 ((u64)(MAGH) << 23) | \
710 ((u64)(MAGV) << 27) | \
711 ((u64)(DW) << 32) | \
715#define GS_DISPLAY2 ((volatile u64 *)(0x120000a0))
718#define GS_SET_DISPLAY2(DX,DY,MAGH,MAGV,DW,DH) \
721 ((u64)(DY) << 12) | \
722 ((u64)(MAGH) << 23) | \
723 ((u64)(MAGV) << 27) | \
724 ((u64)(DW) << 32) | \
728#define GS_BGCOLOR ((volatile u64 *)(0x120000e0))
731#define GS_SET_BGCOLOR(R,G,B) \
738#define GS_SETREG_XYOFFSET_1 GS_SETREG_XYOFFSET
740#define GS_SETREG_XYOFFSET_2 GS_SETREG_XYOFFSET
742#define GS_SETREG_XYOFFSET(ofx, ofy) ((u64)(ofx) | ((u64)(ofy) << 32))
745#define GS_SETREG_ZBUF_1 GS_SETREG_ZBUF
747#define GS_SETREG_ZBUF_2 GS_SETREG_ZBUF
749#define GS_SETREG_ZBUF(zbp, psm, zmsk) \
750 ((u64)(zbp) | ((u64)(psm) << 24) | \
754#define GS_SETREG_TEST_1 GS_SETREG_TEST
756#define GS_SETREG_TEST_2 GS_SETREG_TEST
758#define GS_SETREG_TEST(ate, atst, aref, afail, date, datm, zte, ztst) \
759 ((u64)(ate) | ((u64)(atst) << 1) | \
760 ((u64)(aref) << 4) | ((u64)(afail) << 12) | \
761 ((u64)(date) << 14) | ((u64)(datm) << 15) | \
762 ((u64)(zte) << 16) | ((u64)(ztst) << 17))
765#define GS_SETREG_COLCLAMP(clamp) ((u64)(clamp))
768#define GS_SETREG_FRAME_1 GS_SETREG_FRAME
770#define GS_SETREG_FRAME_2 GS_SETREG_FRAME
772#define GS_SETREG_FRAME(fbp, fbw, psm, fbmask) \
773 ((u64)(fbp) | ((u64)(fbw) << 16) | \
774 ((u64)(psm) << 24) | ((u64)(fbmask) << 32))
777#define GS_SETREG_SCISSOR_1 GS_SETREG_SCISSOR
779#define GS_SETREG_SCISSOR_2 GS_SETREG_SCISSOR
781#define GS_SETREG_SCISSOR(scax0, scax1, scay0, scay1) \
782 ((u64)(scax0) | ((u64)(scax1) << 16) | \
783 ((u64)(scay0) << 32) | ((u64)(scay1) << 48))
786#define GS_SETREG_CLAMP_1 GS_SET_CLAMP
788#define GS_SETREG_CLAMP_2 GS_SET_CLAMP
790#define GS_SETREG_CLAMP(wms, wmt, minu, maxu, minv, maxv) \
791 ((u64)(wms) | ((u64)(wmt) << 2) | \
792 ((u64)(minu) << 4) | ((u64)(maxu) << 14) | \
793 ((u64)(minv) << 24) | ((u64)(maxv) << 34))
796#define GS_SETREG_ALPHA(A, B, C, D, FIX) \
808 #define GS_SETREG_DIMX(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P) \
809((u64)(A) << 0) | ((u64)(B) << 4) | ((u64)(C) << 8) | ((u64)(D) << 12) | \
810((u64)(E) << 16) | ((u64)(F) << 20) | ((u64)(G) << 24) | ((u64)(H) << 28) | \
811((u64)(I) << 32) | ((u64)(J) << 36) | ((u64)(K) << 40) | ((u64)(L) << 44) | \
812((u64)(M) << 48) | ((u64)(N) << 52) | ((u64)(0) << 56) | ((u64)(P) << 60)
835typedef struct gsTest GSTEST;
993 gs_rgba_t components;
1053 u32 unused_bits: 10;
1061 gs_textclut_t specification;
1126#define gsKit_detect_signal() gsKit_check_rom()
1135#define gsKit_reset_screen(gsGlobal) \
1136 gsKit_init_screen(gsGlobal);
1138#define gsKit_init_global() \
1139 gsKit_init_global_custom(GS_RENDER_QUEUE_OS_POOLSIZE, GS_RENDER_QUEUE_PER_POOLSIZE);
1141void gsKit_deinit_global(GSGLOBAL *
gsGlobal);
GSGLOBAL * gsKit_init_global_custom(int Os_AllocSize, int Per_AllocSize)
Initialize gsGlobal (With Specified Sizes (In Bytes) for the Persistent and Oneshot drawbuffers).
void gsKit_init_screen(GSGLOBAL *gsGlobal)
Initialize Screen and GS Registers.
void gsKit_set_display_offset(GSGLOBAL *gsGlobal, int x, int y)
Position the framebuffer onto the display.
short int gsKit_check_rom(void)
Checks the console's capabilities based on the ROM version (returns default video format: GS_MODE_NTS...
Background Color Structure.
CLAMP Register Settings Structure.
int MAXU
Maximum Horizontal Clamp Value.
int MINV
Minimum Vertical Clamp Value.
u8 WMS
Wrap Mode Horizontal.
u8 WMT
Wrap Mode Vertical.
int MAXV
Maximum Vertical Clamp Value.
int MINU
Minimum Horizontal Clamp Value.
u8 ActiveBuffer
Active Framebuffer.
int PrimAlphaEnable
Primitive Alpha Blending Enable.
u8 EvenOrOdd
Is ((GSREG*)CSR)->FIELD (Used for Interlace Correction).
u8 ZBuffering
Enable/Disable Z Buffering.
int Width
Framebuffer Width (the mode's DW is a multiple of this value).
u32 CurrentPointer
Current VRAM Pointer.
void *dma_misc __attribute__((aligned(64)))
Misc 512 byte DMA Transfer Buffer (so we don't malloc at runtime).
int MagH
X Magnification Value (MAGH = DW / Width - 1).
int Per_AllocSize
Persistent Drawbuffer Size (Per Buffer).
GSBGCOLOR * BGColor
Background Color Structure Pointer.
int Os_AllocSize
Oneshot Drawbuffer Size (Per Buffer).
u8 Dithering
Dithering (On/Off).
GSTEST * Test
TEST Register Value Structure Pointer.
int PrimContext
Primitive Context.
GSQUEUE * CurQueue
Draw Queue (Current).
int Aspect
Framebuffer Aspect Ratio (GS_ASPECT_4_3/GS_ASPECT_16_9).
int PSMZ
ZBuffer Pixel Storage Method.
u32 TexturePointer
Pointer to beginning of Texture Buffer.
u8 DoubleBuffering
Enable/Disable Double Buffering.
u8 DrawField
Field to draw (GS_FIELD_NORMAL/GS_FIELD_ODD/GS_FIELD_EVEN).
int StartYOffset
Y Starting Coordinate (Used for Placement Correction) Additional correction.
int StartXOffset
X Starting Coordinate (Used for Placement Correction) Additional correction.
GSQUEUE * Os_Queue
Draw Queue (Oneshot).
int OffsetX
X Window Offset.
int DW
Total Display Area Width (DW = Width * (MAGH + 1)).
u32 ScreenBuffer[2]
Screenbuffer Pointer Array.
int StartX
X Starting Coordinate (Used for Placement Correction) Default value.
int PSM
Pixel Storage Method (Color Mode).
u8 DrawOrder
Drawing Order (GS_PER_OS/GS_OS_PER) (GS_PER_OS = Persitant objects always drawn first).
int MagV
Y Magnification Value (MAGV = DH / Height - 1).
int Height
Framebuffer Height (the mode's DH is a multiple of this value).
u64 PrimAlpha
Primitive Alpha Value.
int PrimFogEnable
Primitive Fog Enable.
GSCLAMP * Clamp
CLAMP Register Value Structure Pointer.
int PrimAAEnable
Primitive AntiAlaising Enable.
int OffsetY
Y Window Offset.
u32 ZBuffer
ZBuffer Pointer.
u8 PABE
Choose if to do Alpha Blend on a Per-Pixel Basis.
s8 DitherMatrix[16]
Dithering Matrix.
u8 FirstFrame
Have we executed a frame yet?
int DH
Total Display Area Height (DH = Height * (MAGH + 1)).
s16 Interlace
Interlace (On/Off).
int StartY
Y Starting Coordinate (Used for Placement Correction) Default value.
GSQUEUE * Per_Queue
Draw Queue (Persistent).
volatile u8 LockBuffer
Used to lock the buffer so it doesn't switch.
void * dma_tag
Pointer to last DMA_TAG.
int same_obj
Number of times in a row the same REGLIST enabled object has been added (Used for NLOOP fixup later).
void * pool_max[2]
Pool Maximum Address (Used for bounds checking).
void * pool_cur
Current Pool Address (Offset from Base).
u8 mode
Mode of the draw queue (NOT USED RIGHT NOW).
void *pool[2] __attribute__((aligned(64)))
Pool Base Address (Two of these, since we doublebuffer).
void * last_tag
Pointer to the GIF_TAG of the last object in this draw queue.
int dbuf
Which of the pool[2] buffers we are using.
int last_type
Last type of object in this draw queue.
u32 tag_size
Quadwords in current DMA_TAG.
Alternative Access Method to the GS CSR Register.
TEST Register Settings Structure.
u8 ATST
Alpha Test Method.
u8 ZTE
Depth Test Enable (DO NOT USE THIS - IT IS BUGGED IN PARTICULAR GS REV - SET TO 1 ALWAYS).
u8 DATE
Destination Alpha Enable.
u8 DATM
Destination Alpha Mode.
u8 ZTST
Depth Test Method.
u8 AREF
Alpha Reference Value.
u8 AFAIL
Alpha Failure Action.
u32 * Clut
EE CLUT Memory Pointer.
u32 TBW
Texture Base Width.
u32 * Mem
EE Memory Pointer.
u8 ClutStorageMode
CLUT Storage Mode.
u32 Vram
GS VRAM Memory Pointer.
u32 VramClut
GS VRAM CLUT Memory Pointer.
u8 Delayed
Delay Texture Upload To VRAM.
u8 ClutPSM
CLUT Pixel Storage Method (Color Format).
u8 PSM
Pixel Storage Method (Color Format).
u32 Height
Height of the Texture.
u32 Width
Width of the Texture.
u32 Filter
NEAREST or LINEAR.