| 1 | #ifndef GDP_H |
| 2 | #define GDP_H |
| 3 | |
| 4 | #include "Types.h" |
| 5 | |
| 6 | #define CHANGED_RENDERMODE 0x0001 |
| 7 | #define CHANGED_CYCLETYPE 0x0002 |
| 8 | #define CHANGED_SCISSOR 0x0004 |
| 9 | #define CHANGED_TMEM 0x0008 |
| 10 | #define CHANGED_TILE 0x0010 |
| 11 | #define CHANGED_COMBINE_COLORS 0x0020 |
| 12 | #define CHANGED_COMBINE 0x0040 |
| 13 | #define CHANGED_ALPHACOMPARE 0x0080 |
| 14 | #define CHANGED_FOGCOLOR 0x0100 |
| 15 | #define CHANGED_DEPTHSOURCE 0x0200 |
| 16 | #define CHANGED_PRIMITIVEZ 0x0400 |
| 17 | #define CHANGED_ENV_COLOR 0x0800 |
| 18 | #define CHANGED_PRIM_COLOR 0x1000 |
| 19 | #define CHANGED_BLENDCOLOR 0x2000 |
| 20 | #define CHANGED_CONVERT 0x4000 |
| 21 | |
| 22 | #define TEXTUREMODE_NORMAL 0 |
| 23 | #define TEXTUREMODE_TEXRECT 1 |
| 24 | #define TEXTUREMODE_BGIMAGE 2 |
| 25 | #define TEXTUREMODE_FRAMEBUFFER 3 |
| 26 | |
| 27 | #define LOADTYPE_BLOCK 0 |
| 28 | #define LOADTYPE_TILE 1 |
| 29 | |
| 30 | struct gDPCombine |
| 31 | { |
| 32 | union |
| 33 | { |
| 34 | struct |
| 35 | { |
| 36 | // muxs1 |
| 37 | unsigned aA1 : 3; |
| 38 | unsigned sbA1 : 3; |
| 39 | unsigned aRGB1 : 3; |
| 40 | unsigned aA0 : 3; |
| 41 | unsigned sbA0 : 3; |
| 42 | unsigned aRGB0 : 3; |
| 43 | unsigned mA1 : 3; |
| 44 | unsigned saA1 : 3; |
| 45 | unsigned sbRGB1 : 4; |
| 46 | unsigned sbRGB0 : 4; |
| 47 | |
| 48 | // muxs0 |
| 49 | unsigned mRGB1 : 5; |
| 50 | unsigned saRGB1 : 4; |
| 51 | unsigned mA0 : 3; |
| 52 | unsigned saA0 : 3; |
| 53 | unsigned mRGB0 : 5; |
| 54 | unsigned saRGB0 : 4; |
| 55 | }; |
| 56 | |
| 57 | struct |
| 58 | { |
| 59 | u32 muxs1, muxs0; |
| 60 | }; |
| 61 | |
| 62 | u64 mux; |
| 63 | }; |
| 64 | }; |
| 65 | |
| 66 | struct gDPTile |
| 67 | { |
| 68 | u32 format, size, line, tmem, palette; |
| 69 | |
| 70 | union |
| 71 | { |
| 72 | struct |
| 73 | { |
| 74 | unsigned mirrort : 1; |
| 75 | unsigned clampt : 1; |
| 76 | unsigned pad0 : 30; |
| 77 | |
| 78 | unsigned mirrors : 1; |
| 79 | unsigned clamps : 1; |
| 80 | unsigned pad1 : 30; |
| 81 | }; |
| 82 | |
| 83 | struct |
| 84 | { |
| 85 | u32 cmt, cms; |
| 86 | }; |
| 87 | }; |
| 88 | |
| 89 | //FrameBuffer *frameBuffer; |
| 90 | u32 maskt, masks; |
| 91 | u32 shiftt, shifts; |
| 92 | f32 fuls, fult, flrs, flrt; |
| 93 | u32 uls, ult, lrs, lrt; |
| 94 | }; |
| 95 | |
| 96 | struct gDPInfo |
| 97 | { |
| 98 | struct |
| 99 | { |
| 100 | union |
| 101 | { |
| 102 | struct |
| 103 | { |
| 104 | unsigned int alphaCompare : 2; |
| 105 | unsigned int depthSource : 1; |
| 106 | |
| 107 | // struct |
| 108 | // { |
| 109 | unsigned int AAEnable : 1; |
| 110 | unsigned int depthCompare : 1; |
| 111 | unsigned int depthUpdate : 1; |
| 112 | unsigned int imageRead : 1; |
| 113 | unsigned int clearOnCvg : 1; |
| 114 | |
| 115 | unsigned int cvgDest : 2; |
| 116 | unsigned int depthMode : 2; |
| 117 | |
| 118 | unsigned int cvgXAlpha : 1; |
| 119 | unsigned int alphaCvgSel : 1; |
| 120 | unsigned int forceBlender : 1; |
| 121 | unsigned int textureEdge : 1; |
| 122 | // } renderMode; |
| 123 | |
| 124 | //struct |
| 125 | //{ |
| 126 | unsigned int c2_m2b : 2; |
| 127 | unsigned int c1_m2b : 2; |
| 128 | unsigned int c2_m2a : 2; |
| 129 | unsigned int c1_m2a : 2; |
| 130 | unsigned int c2_m1b : 2; |
| 131 | unsigned int c1_m1b : 2; |
| 132 | unsigned int c2_m1a : 2; |
| 133 | unsigned int c1_m1a : 2; |
| 134 | //} blender; |
| 135 | |
| 136 | unsigned int blendMask : 4; |
| 137 | unsigned int alphaDither : 2; |
| 138 | unsigned int colorDither : 2; |
| 139 | |
| 140 | unsigned int combineKey : 1; |
| 141 | unsigned int textureConvert : 3; |
| 142 | unsigned int textureFilter : 2; |
| 143 | unsigned int textureLUT : 2; |
| 144 | |
| 145 | unsigned int textureLOD : 1; |
| 146 | unsigned int textureDetail : 2; |
| 147 | unsigned int texturePersp : 1; |
| 148 | unsigned int cycleType : 2; |
| 149 | unsigned int unusedColorDither : 1; // unsupported |
| 150 | unsigned int pipelineMode : 1; |
| 151 | |
| 152 | unsigned int pad : 8; |
| 153 | |
| 154 | }; |
| 155 | |
| 156 | u64 _u64; |
| 157 | |
| 158 | struct |
| 159 | { |
| 160 | u32 l, h; |
| 161 | }; |
| 162 | }; |
| 163 | } otherMode; |
| 164 | |
| 165 | gDPCombine combine; |
| 166 | |
| 167 | gDPTile tiles[8], *loadTile; |
| 168 | |
| 169 | struct |
| 170 | { |
| 171 | f32 r, g, b, a; |
| 172 | } fogColor, blendColor, envColor; |
| 173 | |
| 174 | struct |
| 175 | { |
| 176 | unsigned int i; |
| 177 | f32 r, g, b, a; |
| 178 | f32 z, dz; |
| 179 | } fillColor; |
| 180 | |
| 181 | struct |
| 182 | { |
| 183 | u32 m; |
| 184 | f32 l, r, g, b, a; |
| 185 | } primColor; |
| 186 | |
| 187 | struct |
| 188 | { |
| 189 | f32 z, deltaZ; |
| 190 | } primDepth; |
| 191 | |
| 192 | struct |
| 193 | { |
| 194 | u32 format, size, width, bpl; |
| 195 | u32 address; |
| 196 | } textureImage; |
| 197 | |
| 198 | struct |
| 199 | { |
| 200 | u32 format, size, width, height, bpl; |
| 201 | u32 address, changed; |
| 202 | u32 depthImage; |
| 203 | } colorImage; |
| 204 | |
| 205 | u32 depthImageAddress; |
| 206 | |
| 207 | struct |
| 208 | { |
| 209 | u32 mode; |
| 210 | f32 ulx, uly, lrx, lry; |
| 211 | } scissor; |
| 212 | |
| 213 | struct |
| 214 | { |
| 215 | f32 k0, k1, k2, k3, k4, k5; |
| 216 | } convert; |
| 217 | |
| 218 | struct |
| 219 | { |
| 220 | struct |
| 221 | { |
| 222 | f32 r, g, b, a; |
| 223 | } center, scale, width; |
| 224 | } key; |
| 225 | |
| 226 | struct |
| 227 | { |
| 228 | u32 width, height; |
| 229 | } texRect; |
| 230 | |
| 231 | u32 changed; |
| 232 | |
| 233 | //u16 palette[256]; |
| 234 | u32 paletteCRC16[16]; |
| 235 | u32 paletteCRC256; |
| 236 | u32 half_1, half_2; |
| 237 | u32 textureMode; |
| 238 | u32 loadType; |
| 239 | }; |
| 240 | |
| 241 | extern gDPInfo gDP; |
| 242 | |
| 243 | void gDPSetOtherMode( u32 mode0, u32 mode1 ); |
| 244 | void gDPSetPrimDepth( u16 z, u16 dz ); |
| 245 | void gDPPipelineMode( u32 mode ); |
| 246 | void gDPSetCycleType( u32 type ); |
| 247 | void gDPSetTexturePersp( u32 enable ); |
| 248 | void gDPSetTextureDetail( u32 type ); |
| 249 | void gDPSetTextureLOD( u32 mode ); |
| 250 | void gDPSetTextureLUT( u32 mode ); |
| 251 | void gDPSetTextureFilter( u32 type ); |
| 252 | void gDPSetTextureConvert( u32 type ); |
| 253 | void gDPSetCombineKey( u32 type ); |
| 254 | void gDPSetColorDither( u32 type ); |
| 255 | void gDPSetAlphaDither( u32 type ); |
| 256 | void gDPSetAlphaCompare( u32 mode ); |
| 257 | void gDPSetDepthSource( u32 source ); |
| 258 | void gDPSetRenderMode( u32 mode1, u32 mode2 ); |
| 259 | void gDPSetCombine( s32 muxs0, s32 muxs1 ); |
| 260 | void gDPSetColorImage( u32 format, u32 size, u32 width, u32 address ); |
| 261 | void gDPSetTextureImage( u32 format, u32 size, u32 width, u32 address ); |
| 262 | void gDPSetDepthImage( u32 address ); |
| 263 | void gDPSetEnvColor( u32 r, u32 g, u32 b, u32 a ); |
| 264 | void gDPSetBlendColor( u32 r, u32 g, u32 b, u32 a ); |
| 265 | void gDPSetFogColor( u32 r, u32 g, u32 b, u32 a ); |
| 266 | void gDPSetFillColor( u32 c ); |
| 267 | void gDPSetPrimColor( u32 m, u32 l, u32 r, u32 g, u32 b, u32 a ); |
| 268 | void gDPSetTile(u32 format, const u32 size, const u32 line, const u32 tmem, u32 tile, |
| 269 | const u32 palette, const u32 cmt, const u32 cms, const u32 maskt, const u32 masks, |
| 270 | const u32 shiftt, const u32 shifts ); |
| 271 | void gDPSetTileSize( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt ); |
| 272 | void gDPLoadTile( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt ); |
| 273 | void gDPLoadBlock( u32 tile, u32 uls, u32 ult, u32 lrs, u32 dxt ); |
| 274 | void gDPLoadTLUT( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt ); |
| 275 | void gDPSetScissor( u32 mode, f32 ulx, f32 uly, f32 lrx, f32 lry ); |
| 276 | void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry ); |
| 277 | void gDPSetConvert( s32 k0, s32 k1, s32 k2, s32 k3, s32 k4, s32 k5 ); |
| 278 | void gDPSetKeyR( u32 cR, u32 sR, u32 wR ); |
| 279 | void gDPSetKeyGB(u32 cG, u32 sG, u32 wG, u32 cB, u32 sB, u32 wB ); |
| 280 | void gDPTextureRectangle( f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, f32 s, f32 t, f32 dsdx, f32 dtdy ); |
| 281 | void gDPTextureRectangleFlip( f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, f32 s, f32 t, f32 dsdx, f32 dtdy ); |
| 282 | void gDPFullSync(); |
| 283 | void gDPTileSync(); |
| 284 | void gDPPipeSync(); |
| 285 | void gDPLoadSync(); |
| 286 | void gDPNoOp(); |
| 287 | |
| 288 | #endif |
| 289 | |