#ifndef DEFINES_H /* VERSION 0.1 */ #define DEFINES_H typedef unsigned int u_long128 __attribute__ ((mode(TI))); typedef unsigned int u_long64 __attribute__ ((mode(DI))); //GIFtag builder #define GIF_SET_TAG(nloop, eop, pre, prim, flg, nreg) \ ((u_long128)(nloop) | ((u_long128)(eop)<<15) | ((u_long128)(pre)<<46) | \ ((u_long128)(prim)<<47) | ((u_long128)(flg)<<58) | ((u_long128)(nreg)<<60)) #define GOURAUD(x) (x) #define TEXTURED(x) (x) #define FOG(x) (x) #define ABE(x) (x) #define ALPHA(x) (x) #define AA(x) (x) #define CTXT(x) (x) #define FIX(x) (x) #define EOP(x) (x) #define PRE(x) (x) #define NREG(x) (x) #define NLOOP(x) (x) //Prim register redefines for compatibility with basic sample #define GS_PRIM_POINT PRIM_POINT #define GS_PRIM_LINE PRIM_LINE #define GS_PRIM_LINESTRIP PRIM_LINE_STRIP #define GS_PRIM_TRI PRIM_TRI #define GS_PRIM_TRISTRIP PRIM_TRI_STRIP #define GS_PRIM_TRIFAN PRIM_TRI_FAN #define GS_PRIM_SPRITE PRIM_SPRITE #define GIF_PACKED 0 #define GIF_REGLIST 1 #define GIF_IMAGE 2 // GS Registers (in address order) #define PRIM_REG 0x00 // Select and configure current drawing primitive #define RGBAQ_REG 0x01 // Setup current vertex color #define ST_REG 0x02 // Specify Texture Co-ordinates #define UV_REG 0x03 // Specify Texture Coordinates #define XYZF2_REG 0x04 // Set vertex coordinate (with fog) #define XYZ2_REG 0x05 // Set vertex coordinate and 'kick' drawing #define TEX0_1_REG 0x06 // Texture Buffer Setup (Context 1) #define TEX0_2_REG 0x07 // Texture Buffer Setup (Context 2) #define CLAMP_1_REG 0x08 // ... #define CLAMP_2_REG 0x09 // ... #define FOG_REG 0x0a // ... #define XYZF3_REG 0x0c // Set vertex coordinate with fog without vertex kick #define XYZ3_REG 0x0d // Set vertex coordinate witout vertex kick #define AD_REG 0x0e // Not really a register - the postman in PACKED mode #define TEX1_1_REG 0x14 // More texture buffer setup (context 1) #define TEX1_2_REG 0x15 // More texture buffer setup (context 2) #define TEX2_1_REG 0x16 // Yet More texture buffer setup (context 1) #define TEX2_2_REG 0x17 // Yet More texture buffer setup (context 2) #define XYOFFSET_1_REG 0x18 // Mapping from Primitive to Window coordinate system (Context 1) #define XYOFFSET_2_REG 0x19 // Mapping from Primitive to Window coordinate system (Context 2) #define PRMODECONT_REG 0x1a // ... #define PRMODE_REG 0x1b // ... #define TEXCLUT_REG 0x1c // ... #define SCANMSK_REG 0x22 // ... #define MIPTBP1_1_REG 0x34 // ... #define MIPTBP1_2_REG 0x35 // ... #define MIPTBP2_1_REG 0x36 // ... #define MIPTBP2_2_REG 0x37 // ... #define TEXA_REG 0x3b // ... #define FOGCOL_REG 0x3d // ... #define TEXFLUSH_REG 0x3f // Write to this register before using newly loaded texture #define SCISSOR_1_REG 0x40 // Setup clipping rectangle (Context 1) #define SCISSOR_2_REG 0x41 // Setup clipping rectangle (Context 2) #define ALPHA_1_REG 0x42 // Setup Alpha Blending Parameters (Context 1) #define ALPHA_2_REG 0x43 // Setup Alpha Blending Parameters (Context 2) #define DIMX_REG 0x44 // ... #define DTHE_REG 0x45 // ... #define COLCLAMP_REG 0x46 // ... #define TEST_1_REG 0x47 // ... #define TEST_2_REG 0x48 // ... #define PABE_REG 0x49 // ... #define FBA_1_REG 0x4a // ... #define FBA_2_REG 0x4b // ... #define FRAME_1_REG 0x4c // Frame buffer settings (Context 1) #define FRAME_2_REG 0x4d // Frame buffer settings (Context 2) #define ZBUF_1_REG 0x4e // ... #define ZBUF_2_REG 0x4f // ... #define BITBLTBUF_REG 0x50 // Setup Image Transfer Between host and GS #define TRXPOS_REG 0x51 // Setup Image Transfer Coordinates #define TRXREG_REG 0x52 // Setup Image Transfer Size #define TRXDIR_REG 0x53 // Set Image Transfer Directon + Start Transfer #define HWREG_REG 0x54 // ... #define SIGNAL_REG 0x60 // ... #define FINISH_REG 0x61 // ... #define LABEL_REG 0x62 // ... #define NOP_REG 0x7f // No Operation // GS pixel format #define PSMCT32 0 #define PSMCT24 1 #define PSMCT16 2 #define PSMCT16S 10 #define PSMT8 19 #define PSMT4 20 #define PSMT8H 27 #define PSMT4HL 36 #define PSMT4HH 44 #define PSMZ32 48 #define PSMZ24 49 #define PSMZ16 50 #define PSMZ16S 58 //=========================================================================== // General Purpose Register Macros //=========================================================================== #define CLEAR_GSREG(p) *(u_long64 *)(p) = 0 //--------------------------------------------------------------------------- // ALPHA_x Registers - Setup Alpha Blending Parameters // Alpha Formula is: Cv = (A-B)*C>>7 + D // For A,B,D - (0=texture, 1=frame buffer, 2=0) // For C - (0=texture, 1=frame buffer, 2=use FIX field for Alpha) //--------------------------------------------------------------------------- #define ALPHA_A_CS 0 #define ALPHA_A_CD 1 #define ALPHA_A_ZERO 2 #define ALPHA_B_CS 0 #define ALPHA_B_CD 1 #define ALPHA_B_ZERO 2 #define ALPHA_C_AS 0 #define ALPHA_C_AD 1 #define ALPHA_C_FIX 2 #define ALPHA_D_CS 0 #define ALPHA_D_CD 1 #define ALPHA_D_ZERO 2 #define GS_SET_ALPHA_1 GS_SET_ALPHA #define GS_SET_ALPHA_2 GS_SET_ALPHA #define GS_SET_ALPHA(A,B,C,D,FIX) \ (((u_long64)(A) << 0) | \ ((u_long64)(B) << 2) | \ ((u_long64)(C) << 4) | \ ((u_long64)(D) << 6) | \ ((u_long64)(FIX) << 32)) typedef struct { u_long64 A: 2 __attribute__((packed)); u_long64 B: 2 __attribute__((packed)); u_long64 C: 2 __attribute__((packed)); u_long64 D: 2 __attribute__((packed)); u_long64 pad8: 24 __attribute__((packed)); u_long64 FIX: 8 __attribute__((packed)); u_long64 pad40: 24 __attribute__((packed)); } gs_alpha __attribute__((packed)); //--------------------------------------------------------------------------- // BITBLTBUF Register - Setup Image Transfer Between EE and GS // SBP - Source buffer address (Address/256) // SBW - Source buffer width (Pixels/64) // SPSM - Source pixel format (0 = 32bit RGBA) // DBP - Destination buffer address (Address/256) // DBW - Destination buffer width (Pixels/64) // DPSM - Destination pixel format (0 = 32bit RGBA) // // - When transferring from host to GS, only the Destination fields // need to be set. (Only Source fields for GS->host, and all for GS->GS). //--------------------------------------------------------------------------- #define GS_SET_BITBLTBUF(SBP,SBW,SPSM,DBP,DBW,DPSM) \ (((u_long64)(SBP) << 0) | \ ((u_long64)(SBW) << 16) | \ ((u_long64)(SPSM) << 24) | \ ((u_long64)(DBP) << 32) | \ ((u_long64)(DBW) << 48) | \ ((u_long64)(DPSM) << 56)) typedef struct { u_long64 SBP: 14 __attribute__((packed)); u_long64 pad14: 2 __attribute__((packed)); u_long64 SBW: 6 __attribute__((packed)); u_long64 pad22: 2 __attribute__((packed)); u_long64 SPSM: 6 __attribute__((packed)); u_long64 pad30: 2 __attribute__((packed)); u_long64 DBP: 14 __attribute__((packed)); u_long64 pad46: 2 __attribute__((packed)); u_long64 DBW: 6 __attribute__((packed)); u_long64 pad54: 2 __attribute__((packed)); u_long64 DPSM: 6 __attribute__((packed)); u_long64 pad62: 2 __attribute__((packed)); } gs_bitbltbuf __attribute__((packed)); //--------------------------------------------------------------------------- // CLAMP_x Registers //--------------------------------------------------------------------------- #define CLAMP_REPEAT 0 #define CLAMP_CLAMP 1 #define CLAMP_REGION_CLAMP 2 #define CLAMP_REGION_REPEAT 3 #define GS_SET_CLAMP_1 GS_SET_CLAMP #define GS_SET_CLAMP_2 GS_SET_CLAMP #define GS_SET_CLAMP(WMS, WMT, MINU, MAXU, MINV, MAXV) \ (((u_long64)(WMS) << 0) | \ ((u_long64)(WMT) << 2) | \ ((u_long64)(MINU) << 4) | \ ((u_long64)(MAXU) << 14) | \ ((u_long64)(MINV) << 24) | \ ((u_long64)(MAXV) << 34)) typedef struct { u_long64 WMS: 2 __attribute__((packed)); u_long64 WMT: 2 __attribute__((packed)); u_long64 MINU: 10 __attribute__((packed)); u_long64 MAXU: 10 __attribute__((packed)); u_long64 MINV: 10 __attribute__((packed)); u_long64 MAXV: 10 __attribute__((packed)); u_long64 pad44: 20 __attribute__((packed)); } gs_clamp __attribute__((packed)); //--------------------------------------------------------------------------- // COLCLAMP Register //--------------------------------------------------------------------------- #define COLCLAMP_MASK 0 #define COLCLAMP_CLAMP 1 #define GS_SET_COLCLAMP(CLAMP) ((u_long64)(CLAMP)) typedef struct { u_long64 CLAMP: 1 __attribute__((packed)); u_long64 pad01: 63 __attribute__((packed)); } gs_colclamp __attribute__((packed)); //--------------------------------------------------------------------------- // DIMX Register //--------------------------------------------------------------------------- #define GS_SET_DIMX(dm00, dm01, dm02, dm03, dm10, dm11, dm12, dm13, \ dm20, dm21, dm22, dm23, dm30, dm31, dm32, dm33) \ ((u_long64)(dm00) | ((u_long64)(dm01) << 4) | \ ((u_long64)(dm02) << 8) | ((u_long64)(dm03) << 12) | \ ((u_long64)(dm10) << 16) | ((u_long64)(dm11) << 20) | \ ((u_long64)(dm12) << 24) | ((u_long64)(dm13) << 28) | \ ((u_long64)(dm20) << 32) | ((u_long64)(dm21) << 36) | \ ((u_long64)(dm22) << 40) | ((u_long64)(dm23) << 44) | \ ((u_long64)(dm30) << 48) | ((u_long64)(dm31) << 52) | \ ((u_long64)(dm32) << 56) | ((u_long64)(dm33) << 60)) typedef struct { u_long64 DM00: 3 __attribute__((packed)); u_long64 pad03: 1 __attribute__((packed)); u_long64 DM01: 3 __attribute__((packed)); u_long64 pad07: 1 __attribute__((packed)); u_long64 DM02: 3 __attribute__((packed)); u_long64 pad11: 1 __attribute__((packed)); u_long64 DM03: 3 __attribute__((packed)); u_long64 pad15: 1 __attribute__((packed)); u_long64 DM10: 3 __attribute__((packed)); u_long64 pad19: 1 __attribute__((packed)); u_long64 DM11: 3 __attribute__((packed)); u_long64 pad23: 1 __attribute__((packed)); u_long64 DM12: 3 __attribute__((packed)); u_long64 pad27: 1 __attribute__((packed)); u_long64 DM13: 3 __attribute__((packed)); u_long64 pad31: 1 __attribute__((packed)); u_long64 DM20: 3 __attribute__((packed)); u_long64 pad35: 1 __attribute__((packed)); u_long64 DM21: 3 __attribute__((packed)); u_long64 pad39: 1 __attribute__((packed)); u_long64 DM22: 3 __attribute__((packed)); u_long64 pad43: 1 __attribute__((packed)); u_long64 DM23: 3 __attribute__((packed)); u_long64 pad47: 1 __attribute__((packed)); u_long64 DM30: 3 __attribute__((packed)); u_long64 pad51: 1 __attribute__((packed)); u_long64 DM31: 3 __attribute__((packed)); u_long64 pad55: 1 __attribute__((packed)); u_long64 DM32: 3 __attribute__((packed)); u_long64 pad59: 1 __attribute__((packed)); u_long64 DM33: 3 __attribute__((packed)); u_long64 pad63: 1 __attribute__((packed)); } gs_dimx __attribute__((packed)); //--------------------------------------------------------------------------- // DTHE Register //--------------------------------------------------------------------------- #define DTHE_OFF 0 #define DTHE_ON 1 #define GS_SET_DTHE(DTHE) ((u_long64)(DTHE)) typedef struct { u_long64 DTHE: 1 __attribute__((packed)); u_long64 pad01: 63 __attribute__((packed)); } gs_dthe __attribute__((packed)); //--------------------------------------------------------------------------- // FBA_x Registers //--------------------------------------------------------------------------- #define GS_SET_FBA_1 GS_SET_FBA #define GS_SET_FBA_2 GS_SET_FBA #define GS_SET_FBA(FBA) ((u_long64)(FBA)) typedef struct { u_long64 FBA: 1 __attribute__((packed)); u_long64 pad01: 63 __attribute__((packed)); } gs_fba __attribute__((packed)); //--------------------------------------------------------------------------- // FINISH Register //--------------------------------------------------------------------------- typedef struct { u_long64 pad00: 64 __attribute__((packed)); } gs_finish __attribute__((packed)); //--------------------------------------------------------------------------- // FOG Register //--------------------------------------------------------------------------- #define GS_SET_FOG(F) ((u_long64)(F) << 56) typedef struct { u_long64 pad00: 56 __attribute__((packed)); u_long64 F: 8 __attribute__((packed)); } gs_fog __attribute__((packed)); //--------------------------------------------------------------------------- // FOGCOL Register //--------------------------------------------------------------------------- #define GS_SET_FOGCOL(FCR, FCG, FCB) \ ((u_long64)(FCR) | ((u_long64)(FCG) << 8) | ((u_long64)(FCB) << 16)) typedef struct { u_long64 FCR: 8 __attribute__((packed)); u_long64 FCG: 8 __attribute__((packed)); u_long64 FCB: 8 __attribute__((packed)); u_long64 pad24: 40 __attribute__((packed)); } gs_fogcol __attribute__((packed)); //--------------------------------------------------------------------------- // FRAME_x Register //--------------------------------------------------------------------------- #define GS_SET_FRAME(FBP,FBW,PSM,FBMSK) \ (((u_long64)(FBP) << 0) | \ ((u_long64)(FBW) << 16) | \ ((u_long64)(PSM) << 24) | \ ((u_long64)(FBMSK) << 32)) typedef struct { u_long64 FBP: 9 __attribute__((packed)); u_long64 pad09: 7 __attribute__((packed)); u_long64 FBW: 6 __attribute__((packed)); u_long64 pad22: 2 __attribute__((packed)); u_long64 PSM: 6 __attribute__((packed)); u_long64 pad30: 2 __attribute__((packed)); u_long64 FBMSK: 32 __attribute__((packed)); } gs_frame __attribute__((packed)); //--------------------------------------------------------------------------- // HWREG Register //--------------------------------------------------------------------------- typedef struct { u_long64 DATA: 64 __attribute__((packed)); } gs_hwreg __attribute__((packed)); //--------------------------------------------------------------------------- // LABEL Register //--------------------------------------------------------------------------- #define GS_SET_LABEL(ID, IDMSK) \ ((u_long64)(ID) | ((u_long64)(IDMSK) << 32)) typedef struct { u_long64 ID: 32 __attribute__((packed)); u_long64 IDMSK: 32 __attribute__((packed)); } gs_label __attribute__((packed)); //--------------------------------------------------------------------------- // MIPTBP1_x Registers //--------------------------------------------------------------------------- #define GS_SET_MIPTBP1_1 GS_SET_MIPTBP1 #define GS_SET_MIPTBP1_2 GS_SET_MIPTBP1 #define GS_SET_MIPTBP1(TBP1, TBW1, TBP2, TBW2, TBP3, TBW3) \ ((u_long64)(TBP1) | ((u_long64)(TBW1) << 14) | \ ((u_long64)(TBP2) << 20) | ((u_long64)(TBW2) << 34) | \ ((u_long64)(TBP3) << 40) | ((u_long64)(TBW3) << 54)) typedef struct { u_long64 TBP1: 14 __attribute__((packed)); u_long64 TBW1: 6 __attribute__((packed)); u_long64 TBP2: 14 __attribute__((packed)); u_long64 TBW2: 6 __attribute__((packed)); u_long64 TBP3: 14 __attribute__((packed)); u_long64 TBW3: 6 __attribute__((packed)); u_long64 pad60: 4 __attribute__((packed)); } gs_miptbp1 __attribute__((packed)); //--------------------------------------------------------------------------- // MIPTBP2_x Registers //--------------------------------------------------------------------------- #define GS_SET_MIPTBP2_1 GS_SET_MIPTBP2 #define GS_SET_MIPTBP2_2 GS_SET_MIPTBP2 #define GS_SET_MIPTBP2(TBP4, TBW4, TBP5, TBW5, TBP6, TBW6) \ ((u_long64)(TBP4) | ((u_long64)(TBW4) << 14) | \ ((u_long64)(TBP5) << 20) | ((u_long64)(TBW5) << 34) | \ ((u_long64)(TBP6) << 40) | ((u_long64)(TBW6) << 54)) typedef struct { u_long64 TBP4: 14 __attribute__((packed)); u_long64 TBW4: 6 __attribute__((packed)); u_long64 TBP5: 14 __attribute__((packed)); u_long64 TBW5: 6 __attribute__((packed)); u_long64 TBP6: 14 __attribute__((packed)); u_long64 TBW6: 6 __attribute__((packed)); u_long64 pad60: 4 __attribute__((packed)); } gs_miptbp2 __attribute__((packed)); //--------------------------------------------------------------------------- // PABE Register //--------------------------------------------------------------------------- #define PABE_OFF 0 #define PABE_ON 1 #define GS_SET_PABE(PABE) ((u_long64)(PABE)) typedef struct { u_long64 PABE: 1 __attribute__((packed)); u_long64 pad01: 63 __attribute__((packed)); } gs_pabe __attribute__((packed)); //--------------------------------------------------------------------------- // PRIM Register - Setup Drawing Primitive // PRI - Primitive type // IIP - Shading method (0=flat, 1=gouraud) // TME - Texture mapping (0=off, 1=on) // FGE - Fog (0=off, 1=on) // ABE - Alpha Blending (0=off, 1=on) // AA1 - Antialiasing (0=off,1=on) // FST - Texture coordinate specification (0=use ST/RGBAQ register, 1=use UV register) // (UV means no perspective correction, good for 2D) // CTXT - Drawing context (0=1, 1=2) // FIX - ?? Fragment value control (use 0) //--------------------------------------------------------------------------- #define PRIM_POINT 0 #define PRIM_LINE 1 #define PRIM_LINE_STRIP 2 #define PRIM_TRI 3 #define PRIM_TRI_STRIP 4 #define PRIM_TRI_FAN 5 #define PRIM_SPRITE 6 #define PRIM_IIP_FLAT 0 #define PRIM_IIP_GOURAUD 1 #define PRIM_TME_OFF 0 #define PRIM_TME_ON 1 #define PRIM_FGE_OFF 0 #define PRIM_FGE_ON 1 #define PRIM_ABE_OFF 0 #define PRIM_ABE_ON 1 #define PRIM_AA1_OFF 0 #define PRIM_AA1_ON 1 #define PRIM_FST_STQ 0 #define PRIM_FST_UV 1 #define PRIM_CTXT_CONTEXT1 0 #define PRIM_CTXT_CONTEXT2 1 #define PRIM_FIX_NOFIXDDA 0 #define PRIM_FIX_FIXDDA 1 #define GS_SET_PRIM(PRI,IIP,TME,FGE,ABE,AA1,FST,CTXT,FIX) \ (((u_long64)(PRI) << 0) | \ ((u_long64)(IIP) << 3) | \ ((u_long64)(TME) << 4) | \ ((u_long64)(FGE) << 5) | \ ((u_long64)(ABE) << 6) | \ ((u_long64)(AA1) << 7) | \ ((u_long64)(FST) << 8) | \ ((u_long64)(CTXT) << 9) | \ ((u_long64)(FIX) << 10)) typedef struct { u_long64 PRIM: 3 __attribute__((packed)); u_long64 IIP: 1 __attribute__((packed)); u_long64 TME: 1 __attribute__((packed)); u_long64 FGE: 1 __attribute__((packed)); u_long64 ABE: 1 __attribute__((packed)); u_long64 AA1: 1 __attribute__((packed)); u_long64 FST: 1 __attribute__((packed)); u_long64 CTXT: 1 __attribute__((packed)); u_long64 FIX: 1 __attribute__((packed)); u_long64 pad11: 53 __attribute__((packed)); } gs_prim __attribute__((packed)); //--------------------------------------------------------------------------- // PRMODE Register //--------------------------------------------------------------------------- #define PRMODE_IIP_FLAT PRIM_IIP_FLAT #define PRMODE_IIP_GOURAUD PRIM_IIP_GOURAUD #define PRMODE_TME_OFF PRIM_TME_OFF #define PRMODE_TME_ON PRIM_TME_ON #define PRMODE_FGE_OFF PRIM_FGE_OFF #define PRMODE_FGE_ON PRIM_FGE_ON #define PRMODE_ABE_OFF PRIM_ABE_OFF #define PRMODE_ABE_ON PRIM_ABE_ON #define PRMODE_AA1_OFF PRIM_AA1_OFF #define PRMODE_AA1_ON PRIM_AA1_ON #define PRMODE_FST_STQ PRIM_FST_STQ #define PRMODE_FST_UV PRIM_FST_UV #define PRMODE_CTXT_CONTEXT1 PRIM_CTXT_CONTEXT1 #define PRMODE_CTXT_CONTEXT2 PRIM_CTXT_CONTEXT2 #define PRMODE_FIX_NOFIXDDA PRIM_FIX_NOFIXDDA #define PRMODE_FIX_FIXDDA PRIM_FIX_FIXDDA #define GS_SET_PRMODE(IIP, TME, FGE, ABE, AA1, FST, CTXT, FIX) \ (((u_long64)(IIP) << 3) | ((u_long64)(TME) << 4) | \ ((u_long64)(FGE) << 5) | ((u_long64)(ABE) << 6) | ((u_long64)(AA1) << 7) | \ ((u_long64)(FST) << 8) | ((u_long64)(CTXT) << 9) | ((u_long64)(FIX) << 10)) typedef struct { u_long64 pad00: 3 __attribute__((packed)); u_long64 IIP: 1 __attribute__((packed)); u_long64 TME: 1 __attribute__((packed)); u_long64 FGE: 1 __attribute__((packed)); u_long64 ABE: 1 __attribute__((packed)); u_long64 AA1: 1 __attribute__((packed)); u_long64 FST: 1 __attribute__((packed)); u_long64 CTXT: 1 __attribute__((packed)); u_long64 FIX: 1 __attribute__((packed)); u_long64 pad11: 53 __attribute__((packed)); } gs_prmode __attribute__((packed)); //--------------------------------------------------------------------------- // PRMODECONT Register //--------------------------------------------------------------------------- #define PRMODECONT_REFPRMODE 0 #define PRMODECONT_REFPRIM 1 #define GS_SET_PRMODECONT(AC) ((u_long64)(AC)) typedef struct { u_long64 AC: 1 __attribute__((packed)); u_long64 pad01: 63 __attribute__((packed)); } gs_prmodecont __attribute__((packed)); //--------------------------------------------------------------------------- // RGBAQ Register //--------------------------------------------------------------------------- #define GS_SET_RGBAQ(R,G,B,A,Q) \ (((u_long64)(R) << 0) | \ ((u_long64)(G) << 8) | \ ((u_long64)(B) << 16) | \ ((u_long64)(A) << 24) | \ ((u_long64)(Q) << 32)) typedef struct { u_long64 R: 8 __attribute__((packed)); u_long64 G: 8 __attribute__((packed)); u_long64 B: 8 __attribute__((packed)); u_long64 A: 8 __attribute__((packed)); float Q __attribute__((packed)); } gs_rgbaq __attribute__((packed)); //--------------------------------------------------------------------------- // SCANMSK Register //--------------------------------------------------------------------------- #define SCANMSK_NOMASK 0 #define SCANMSK_MASKEVEN 2 #define SCANMSK_MASKODD 3 #define GS_SET_SCANMSK(MSK) ((u_long64)(MSK)) typedef struct { u_long64 MSK: 2 __attribute__((packed)); u_long64 pad02: 62 __attribute__((packed)); } gs_scanmsk __attribute__((packed)); //--------------------------------------------------------------------------- // SCISSOR_x Register //--------------------------------------------------------------------------- #define GS_SET_SCISSOR(X0,X1,Y0,Y1) \ (((u_long64)(X0) << 0) | \ ((u_long64)(X1) << 16) | \ ((u_long64)(Y0) << 32) | \ ((u_long64)(Y1) << 48)) typedef struct { u_long64 SCAX0: 11 __attribute__((packed)); u_long64 pad11: 5 __attribute__((packed)); u_long64 SCAX1: 11 __attribute__((packed)); u_long64 pad27: 5 __attribute__((packed)); u_long64 SCAY0: 11 __attribute__((packed)); u_long64 pad43: 5 __attribute__((packed)); u_long64 SCAY1: 11 __attribute__((packed)); u_long64 pad59: 5 __attribute__((packed)); } gs_scissor __attribute__((packed)); //--------------------------------------------------------------------------- // SIGNAL Register //--------------------------------------------------------------------------- #define GS_SET_SIGNAL(ID, IDMSK) \ ((u_long64)(ID) | ((u_long64)(IDMSK) << 32)) typedef struct { u_long64 ID: 32 __attribute__((packed)); u_long64 IDMSK: 32 __attribute__((packed)); } gs_signal __attribute__((packed)); //--------------------------------------------------------------------------- // ST Register //--------------------------------------------------------------------------- #define GS_SET_ST(S, T) ((u_long64)(S) | ((u_long64)(T) << 32)) typedef struct { float S __attribute__((packed)); float T __attribute__((packed)); } gs_st __attribute__((packed)); //--------------------------------------------------------------------------- // TEST_x Register - Pixel Test Settings // ATE - Alpha Test (0=off, 1=on) // ATST - Alpha Test Method // 0=NEVER: All pixels fail. // 1=ALWAYS: All pixels pass. // 2=LESS: Pixels with A less than AREF pass. // 3=LEQUAL, 4=EQUAL, 5=GEQUAL, 6=GREATER, 7=NOTEQUAL // AREF - Alpha value compared to. // AFAIL - What to do when a pixel fails a test. // 0=KEEP: Don't update anything. // 1=FBONLY: Update frame buffer only. // 2=ZBONLY: Update z-buffer only. // 3=RGBONLY: Update only the frame buffer RGB. // DATE - Destination Alpha Test (0=off, 1=on) // DATM - DAT Mode (0=pass pixels whose destination alpha is 0) // ZTE - Depth Test (0=off, 1=on) // ZTST - Depth Test Method. // 0=NEVER, 1=ALWAYS, 2=GEQUAL, 3=GREATER //--------------------------------------------------------------------------- #define ATST_NEVER 0 #define ATST_ALWAYS 1 #define ATST_LESS 2 #define ATST_LEQUAL 3 #define ATST_EQUAL 4 #define ATST_GEQUAL 5 #define ATST_GREATER 6 #define ATST_NOTEQUAL 7 #define AFAIL_KEEP 0 #define AFAIL_FBONLY 1 #define AFAIL_ZBONLY 2 #define AFAIL_RGBONLY 3 #define ZTST_NEVER 0 #define ZTST_ALWAYS 1 #define ZTST_GEQUAL 2 #define ZTST_GREATER 3 #define TEST_ATE_OFF 0 #define TEST_ATE_ON 1 #define TEST_ATST_NEVER 0 #define TEST_ATST_ALWAYS 1 #define TEST_ATST_LESS 2 #define TEST_ATST_LEQUAL 3 #define TEST_ATST_EQUAL 4 #define TEST_ATST_GEQUAL 5 #define TEST_ATST_GREATER 6 #define TEST_ATST_NOTEQUAL 7 #define TEST_AFAIL_KEEP 0 #define TEST_AFAIL_FB_ONLY 1 #define TEST_AFAIL_ZB_ONLY 2 #define TEST_AFAIL_RGB_ONLY 3 #define TEST_DATE_OFF 0 #define TEST_DATE_ON 1 #define TEST_DATM_PASS0 0 #define TEST_DATM_PASS1 1 #define TEST_ZTE_OFF 0 #define TEST_ZTE_ON 1 #define TEST_ZTST_NEVER 0 #define TEST_ZTST_ALWAYS 1 #define TEST_ZTST_GEQUAL 2 #define TEST_ZTST_GREATER 3 #define ZNEVER TEST_ZTST_NEVER #define ZALWAYS TEST_ZTST_ALWAYS #define ZGEQUAL TEST_ZTST_GEQUAL #define ZGREATER TEST_ZTST_GREATER #define GS_SET_TEST(ATE,ATST,AREF,AFAIL,DATE,DATM,ZTE,ZTST) \ (((u_long64)(ATE) << 0) | \ ((u_long64)(ATST) << 1) | \ ((u_long64)(AREF) << 4) | \ ((u_long64)(AFAIL) << 12) | \ ((u_long64)(DATE) << 14) | \ ((u_long64)(DATM) << 15) | \ ((u_long64)(ZTE) << 16) | \ ((u_long64)(ZTST) << 17)) typedef struct { u_long64 ATE: 1 __attribute__((packed)); u_long64 ATST: 3 __attribute__((packed)); u_long64 AREF: 8 __attribute__((packed)); u_long64 AFAIL: 2 __attribute__((packed)); u_long64 DATE: 1 __attribute__((packed)); u_long64 DATM: 1 __attribute__((packed)); u_long64 ZTE: 1 __attribute__((packed)); u_long64 ZTST: 2 __attribute__((packed)); u_long64 pad19: 45 __attribute__((packed)); } gs_test __attribute__((packed)); //--------------------------------------------------------------------------- // TEX0_x Register - Set Texture Buffer Information // TBP0 - Texture Buffer Base Pointer (Address/256) // TBW - Texture Buffer Width (Texels/64) // PSM - Pixel Storage Format (0 = 32bit RGBA) // TW - Texture Width (Width = 2^TW) // TH - Texture Height (Height = 2^TH) // TCC - Tecture Color Component // 0=RGB, // 1=RGBA, use Alpha from TEXA reg when not in PSM // TFX - Texture Function (0=modulate, 1=decal, 2=hilight, 3=hilight2) //--------------------------------------------------------------------------- #define TEX_TCC_RGB 0 #define TEX_TCC_RGBA 1 #define TEX_TFX_MODULATE 0 #define TEX_TFX_DECAL 1 #define TEX_TFX_HIGHLIGHT 2 #define TEX_TFX_HIGHLIGHT2 3 #define TEX_CSM_CSM1 0 #define TEX_CSM_CSM2 1 #define TEX_CLD_NOUPDATE 0 #define TEX_CLD_LOAD 1 #define TEX_CLD_LOAD_COPY0 2 #define TEX_CLD_LOAD_COPY1 3 #define TEX_CLD_TEST0_LOAD_COPY0 4 #define TEX_CLD_TEST1_LOAD_COPY1 5 #define TEX0_TCC_RGB TEX_TCC_RGB #define TEX0_TCC_RGBA TEX_TCC_RGBA #define TEX0_TFX_MODULATE TEX_TFX_MODULATE #define TEX0_TFX_DECAL TEX_TFX_DECAL #define TEX0_TFX_HIGHLIGHT TEX_TFX_HIGHLIGHT #define TEX0_TFX_HIGHLIGHT2 TEX_TFX_HIGHLIGHT2 #define TEX0_CSM_CSM1 TEX_CSM_CSM1 #define TEX0_CSM_CSM2 TEX_CSM_CSM2 #define TEX0_CLD_NOUPDATE TEX_CLD_NOUPDATE #define TEX0_CLD_LOAD TEX_CLD_LOAD #define TEX0_CLD_LOAD_COPY0 TEX_CLD_LOAD_COPY0 #define TEX0_CLD_LOAD_COPY1 TEX_CLD_LOAD_COPY1 #define TEX0_CLD_TEST0_LOAD_COPY0 TEX_CLD_TEST0_LOAD_COPY0 #define TEX0_CLD_TEST1_LOAD_COPY1 TEX_CLD_TEST1_LOAD_COPY1 #define GS_SET_TEX0(TBP0,TBW,PSM,TW,TH,TCC,TFX,CBP,CPSM,CSM,CSA,CLD) \ (((u_long64)(TBP0) << 0) | \ ((u_long64)(TBW) << 14) | \ ((u_long64)(PSM) << 20) | \ ((u_long64)(TW) << 26) | \ ((u_long64)(TH) << 30) | \ ((u_long64)(TCC) << 34) | \ ((u_long64)(TFX) << 35) | \ ((u_long64)(CBP) << 37) | \ ((u_long64)(CPSM) << 51) | \ ((u_long64)(CSM) << 55) | \ ((u_long64)(CSA) << 56) | \ ((u_long64)(CLD) << 61)) typedef struct { u_long64 TBP0: 14 __attribute__((packed)); u_long64 TBW: 6 __attribute__((packed)); u_long64 PSM: 6 __attribute__((packed)); u_long64 TW: 4 __attribute__((packed)); u_long64 TH: 4 __attribute__((packed)); u_long64 TCC: 1 __attribute__((packed)); u_long64 TFX: 2 __attribute__((packed)); u_long64 CBP: 14 __attribute__((packed)); u_long64 CPSM: 4 __attribute__((packed)); u_long64 CSM: 1 __attribute__((packed)); u_long64 CSA: 5 __attribute__((packed)); u_long64 CLD: 3 __attribute__((packed)); } gs_tex0 __attribute__((packed)); //--------------------------------------------------------------------------- // TEX1_x Register - Set Texture Information // LCM - LOD calculation method // MXL - Maximum MIP level (0-6) // MMAG - Filter when expanding (0=NEAREST, 1=LINEAR) // MMIN - Filter when reducing (0=NEAREST, 1=LINEAR) // MTBA - MIP Base specified by (0=MIPTBP1&2, 1=Automatic) // L - LOD parameter L // K - LOD parameter K //--------------------------------------------------------------------------- #define TEX1_LCM_CALC 0 #define TEX1_LCM_K 1 #define TEX1_MMAG_NEAREST 0 #define TEX1_MMAG_LINEAR 1 #define TEX1_MMIN_NEAREST 0 #define TEX1_MMIN_LINEAR 1 #define TEX1_MMIN_NEAREST_MIPMAP_NEAREST 2 #define TEX1_MMIN_NEAREST_MIPMAP_LINEAR 3 #define TEX1_MMIN_LINEAR_MIPMAP_NEAREST 4 #define TEX1_MMIN_LINEAR_MIPMAP_LINEAR 5 #define TEX1_MTBA_NOAUTO 0 #define TEX1_MTBA_AUTO 1 #define GS_SET_TEX1(LCM,MXL,MMAG,MMIN,MTBA,L,K) \ (((u_long64)(LCM) << 0) | \ ((u_long64)(MXL) << 2) | \ ((u_long64)(MMAG) << 5) | \ ((u_long64)(MMIN) << 6) | \ ((u_long64)(MTBA) << 9) | \ ((u_long64)(L) << 19) | \ ((u_long64)(K) << 32)) typedef struct { u_long64 LCM: 1 __attribute__((packed)); u_long64 pad01: 1 __attribute__((packed)); u_long64 MXL: 3 __attribute__((packed)); u_long64 MMAG: 1 __attribute__((packed)); u_long64 MMIN: 3 __attribute__((packed)); u_long64 MTBA: 1 __attribute__((packed)); u_long64 pad10: 9 __attribute__((packed)); u_long64 L: 2 __attribute__((packed)); u_long64 pad21: 11 __attribute__((packed)); u_long64 K: 12 __attribute__((packed)); u_long64 pad44: 20 __attribute__((packed)); } gs_tex1 __attribute__((packed)); //--------------------------------------------------------------------------- // TEX2_x Registers //--------------------------------------------------------------------------- #define TEX2_CSM_CSM1 TEX_CSM_CSM1 #define TEX2_CSM_CSM2 TEX_CSM_CSM2 #define TEX2_CLD_NOUPDATE TEX_CLD_NOUPDATE #define TEX2_CLD_LOAD TEX_CLD_LOAD #define TEX2_CLD_LOAD_COPY0 TEX_CLD_LOAD_COPY0 #define TEX2_CLD_LOAD_COPY1 TEX_CLD_LOAD_COPY1 #define TEX2_CLD_TEST0_LOAD_COPY0 TEX_CLD_TEST0_LOAD_COPY0 #define TEX2_CLD_TEST1_LOAD_COPY1 TEX_CLD_TEST1_LOAD_COPY1 #define GS_SET_TEX2_1 GS_SET_TEX2 #define GS_SET_TEX2_2 GS_SET_TEX2 #define GS_SET_TEX2(PSM, CBP, CPSM, CSM, CSA, CLD) \ (((u_long64)(PSM) << 20) | ((u_long64)(CBP) << 37) | \ ((u_long64)(CPSM) << 51) | ((u_long64)(CSM) << 55) | \ ((u_long64)(CSA) << 56) | ((u_long64)(CLD) << 61)) typedef struct { u_long64 pad00: 20 __attribute__((packed)); u_long64 PSM: 6 __attribute__((packed)); u_long64 pad26: 11 __attribute__((packed)); u_long64 CBP: 14 __attribute__((packed)); u_long64 CPSM: 4 __attribute__((packed)); u_long64 CSM: 1 __attribute__((packed)); u_long64 CSA: 5 __attribute__((packed)); u_long64 CLD: 3 __attribute__((packed)); } gs_tex2 __attribute__((packed)); //--------------------------------------------------------------------------- // TEXA Register //--------------------------------------------------------------------------- #define TEXA_AEM_NORMAL 0 #define TEXA_AEM_BLACKTHRU 1 #define GS_SET_TEXA(TA0, AEM, TA1) \ ((u_long64)(TA0) | ((u_long64)(AEM) << 15) | ((u_long64)(TA1) << 32)) typedef struct { u_long64 TA0: 8 __attribute__((packed)); u_long64 pad08: 7 __attribute__((packed)); u_long64 AEM: 1 __attribute__((packed)); u_long64 pad16: 16 __attribute__((packed)); u_long64 TA1: 8 __attribute__((packed)); u_long64 pad40: 24 __attribute__((packed)); } gs_texa __attribute__((packed)); //--------------------------------------------------------------------------- // TEXCLUT Register //--------------------------------------------------------------------------- #define GS_SET_TEXCLUT(CBW, COU, COV) \ ((u_long64)(CBW) | ((u_long64)(COU) << 6) | ((u_long64)(COV) << 12)) typedef struct { u_long64 CBW: 6 __attribute__((packed)); u_long64 COU: 6 __attribute__((packed)); u_long64 COV: 10 __attribute__((packed)); u_long64 pad22: 42 __attribute__((packed)); } gs_texclut __attribute__((packed)); //--------------------------------------------------------------------------- // TEXFLUSH Register //--------------------------------------------------------------------------- #define GS_SET_TEXFLUSH() (u_long64)(0); typedef struct { u_long64 pad00: 64 __attribute__((packed)); } gs_texflush __attribute__((packed)); //--------------------------------------------------------------------------- // TRXDIR Register - Set Image Transfer Directon, and Start Transfer // XDIR - (0=EE->GS, 1=GS->EE, 2=GS->GS, 3=Transmission is deactivated) //--------------------------------------------------------------------------- #define TRXDIR_TO_GS 0 #define TRXDIR_FROM_GS 1 #define TRXDIR_IN_GS 2 #define TRXDIR_DEACTIVATE 3 #define GS_SET_TRXDIR(XDIR) \ ((u_long64)(XDIR)) typedef struct { u_long64 XDR: 2 __attribute__((packed)); u_long64 pad02: 62 __attribute__((packed)); } gs_trxdir __attribute__((packed)); //--------------------------------------------------------------------------- // TRXPOS Register - Setup Image Transfer Coordinates // SSAX - Source Upper Left X // SSAY - Source Upper Left Y // DSAX - Destionation Upper Left X // DSAY - Destionation Upper Left Y // DIR - Pixel Transmission Order (00 = top left -> bottom right) // // - When transferring from host to GS, only the Detination fields // need to be set. (Only Source fields for GS->host, and all for GS->GS). //--------------------------------------------------------------------------- #define TRXPOS_DIR_LR_UD 0 #define TRXPOS_DIR_LR_DU 1 #define TRXPOS_DIR_RL_UD 2 #define TRXPOS_DIR_RL_DU 3 #define GS_SET_TRXPOS(SSAX,SSAY,DSAX,DSAY,DIR) \ (((u_long64)(SSAX) << 0) | \ ((u_long64)(SSAY) << 16) | \ ((u_long64)(DSAX) << 32) | \ ((u_long64)(DSAY) << 48) | \ ((u_long64)(DIR) << 59)) typedef struct { u_long64 SSAX: 11 __attribute__((packed)); u_long64 pad11: 5 __attribute__((packed)); u_long64 SSAY: 11 __attribute__((packed)); u_long64 pad27: 5 __attribute__((packed)); u_long64 DSAX: 11 __attribute__((packed)); u_long64 pad43: 5 __attribute__((packed)); u_long64 DSAY: 11 __attribute__((packed)); u_long64 DIR: 2 __attribute__((packed)); u_long64 pad61: 3 __attribute__((packed)); } gs_trxpos __attribute__((packed)); //--------------------------------------------------------------------------- // TRXREG Register - Setup Image Transfer Size // RRW - Image Width // RRH - Image Height //--------------------------------------------------------------------------- #define GS_SET_TRXREG(RRW,RRH) \ (((u_long64)(RRW) << 0) | \ ((u_long64)(RRH) << 32)) typedef struct { u_long64 RRW: 12 __attribute__((packed)); u_long64 pad12: 20 __attribute__((packed)); u_long64 RRH: 12 __attribute__((packed)); u_long64 pad44: 20 __attribute__((packed)); } gs_trxreg __attribute__((packed)); //--------------------------------------------------------------------------- // UV Register - Specify Texture Coordinates //--------------------------------------------------------------------------- #define GS_SET_UV(U,V) \ (((u_long64)(U) << 0) | \ ((u_long64)(V) << 16)) typedef struct { u_long64 U: 14 __attribute__((packed)); u_long64 pad14: 2 __attribute__((packed)); u_long64 V: 14 __attribute__((packed)); u_long64 pad30: 34 __attribute__((packed)); } gs_uv __attribute__((packed)); //--------------------------------------------------------------------------- // XYOFFSET_x Register //--------------------------------------------------------------------------- #define GS_SET_XYOFFSET_1 GS_SET_XYOFFSET #define GS_SET_XYOFFSET_2 GS_SET_XYOFFSET #define GS_SET_XYOFFSET(OFX,OFY) \ (((u_long64)(OFX) << 0) | \ ((u_long64)(OFY) << 32)) typedef struct { u_long64 OFX: 16 __attribute__((packed)); u_long64 pad16: 16 __attribute__((packed)); u_long64 OFY: 16 __attribute__((packed)); u_long64 pad48: 16 __attribute__((packed)); } gs_xyoffset __attribute__((packed)); //--------------------------------------------------------------------------- // XYZ2 Register //--------------------------------------------------------------------------- #define gs_xyz2 gs_xyz #define GS_SET_XYZ2 GS_SET_XYZ #define GS_SET_XYZ(X,Y,Z) \ (((u_long64)(X) << 0) | \ ((u_long64)(Y) << 16) | \ ((u_long64)(Z) << 32)) typedef struct { u_long64 X: 16 __attribute__((packed)); u_long64 Y: 16 __attribute__((packed)); u_long64 Z: 32 __attribute__((packed)); } gs_xyz __attribute__((packed)); //--------------------------------------------------------------------------- // XYZ3 Register //--------------------------------------------------------------------------- #define gs_xyz3 gs_xyz #define GS_SET_XYZ3 GS_SET_XYZ //--------------------------------------------------------------------------- // XYZF2 Register //--------------------------------------------------------------------------- #define gs_xyzf2 gs_xyzf #define GS_SET_XYZF2 GS_SET_XYZF #define GS_SET_XYZF(x, y, z, f) \ ((u_long64)(x) | ((u_long64)(y) << 16) | ((u_long64)(z) << 32) | \ ((u_long64)(f) << 56)) typedef struct { u_long64 X: 16 __attribute__((packed)); u_long64 Y: 16 __attribute__((packed)); u_long64 Z: 24 __attribute__((packed)); u_long64 F: 8 __attribute__((packed)); } gs_xyzf __attribute__((packed)); //--------------------------------------------------------------------------- // XYZF3 Register //--------------------------------------------------------------------------- #define GS_SET_XYZF3 GS_SET_XYZF #define gs_xyzf3 gs_xyzf //--------------------------------------------------------------------------- // ZBUF_x Register //--------------------------------------------------------------------------- #define ZBUF_ZMSK_NOMASK 0 #define ZBUF_ZMSK_MASK 1 #define GS_SET_ZBUF(ZBP,PSM,ZMSK) \ (((u_long64)(ZBP) << 0) | \ ((u_long64)(PSM) << 24) | \ ((u_long64)(ZMSK) << 32)) typedef struct { u_long64 ZBP: 9 __attribute__((packed)); u_long64 pad09: 15 __attribute__((packed)); u_long64 PSM: 4 __attribute__((packed)); u_long64 pad28: 4 __attribute__((packed)); u_long64 ZMSK: 1 __attribute__((packed)); u_long64 pad33: 31 __attribute__((packed)); } gs_zbuf __attribute__((packed)); #endif // DEFINES_H