1 /* 2 Copyright (C) 2003 Rice1964 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 */ 19 20 #ifndef _TYPEDEFS_H_ 21 #define _TYPEDEFS_H_ 22 23 #include <stdint.h> 24 25 #include "osal_preproc.h" 26 #include "VectorMath.h" 27 28 typedef unsigned int COLOR; 29 typedef struct _COORDRECT 30 { 31 int x1,y1; 32 int x2,y2; 33 } COORDRECT; 34 #define COLOR_RGBA(r,g,b,a) (((r&0xFF)<<16) | ((g&0xFF)<<8) | ((b&0xFF)<<0) | ((a&0xFF)<<24)) 35 #define SURFFMT_A8R8G8B8 21 36 37 #define RGBA_GETALPHA(rgb) ((rgb) >> 24) 38 #define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff) 39 #define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff) 40 #define RGBA_GETBLUE(rgb) ((rgb) & 0xff) 41 42 typedef XMATRIX Matrix; 43 typedef void* LPRICETEXTURE ; 44 45 typedef struct 46 { 47 uint32_t dwRGBA, dwRGBACopy; 48 char x,y,z; // Direction 49 uint8_t pad; 50 } N64Light; 51 52 53 typedef struct 54 { 55 unsigned int dwFormat:3; 56 unsigned int dwSize:2; 57 unsigned int dwWidth:10; 58 uint32_t dwAddr; 59 uint32_t bpl; 60 } SetImgInfo; 61 62 typedef struct 63 { 64 int hilite_sl; 65 int hilite_tl; 66 int hilite_sh; 67 int hilite_th; 68 69 float fhilite_sl; 70 float fhilite_tl; 71 float fhilite_sh; 72 float fhilite_th; 73 74 uint32_t dwDXT; 75 76 uint32_t dwPitch; 77 78 float fShiftScaleS; 79 float fShiftScaleT; 80 81 uint32_t lastTileCmd; 82 bool bSizeIsValid; 83 84 bool bForceWrapS; 85 bool bForceWrapT; 86 bool bForceClampS; 87 bool bForceClampT; 88 89 } TileAdditionalInfo; 90 91 92 typedef struct 93 { 94 float u; 95 float v; 96 } TexCord; 97 98 typedef struct VECTOR2 99 { 100 float x; 101 float y; VECTOR2VECTOR2102 VECTOR2( float newx, float newy ) {x=newx; y=newy;} VECTOR2VECTOR2103 VECTOR2() {x=0; y=0;} 104 } VECTOR2; 105 106 typedef struct 107 { 108 short x; 109 short y; 110 } IVector2; 111 112 typedef struct 113 { 114 short x; 115 short y; 116 short z; 117 } IVector3; 118 119 typedef struct { 120 float x,y,z; 121 float rhw; 122 union { 123 COLOR dcDiffuse; 124 struct { 125 uint8_t b; 126 uint8_t g; 127 uint8_t r; 128 uint8_t a; 129 }; 130 }; 131 COLOR dcSpecular; 132 TexCord tcord[2]; 133 } TLITVERTEX, *LPTLITVERTEX; 134 135 typedef struct { 136 float x,y,z; 137 union { 138 COLOR dcDiffuse; 139 struct { 140 uint8_t b; 141 uint8_t g; 142 uint8_t r; 143 uint8_t a; 144 }; 145 }; 146 COLOR dcSpecular; 147 TexCord tcord[2]; 148 } UTLITVERTEX, *LPUTLITVERTEX; 149 150 typedef struct { 151 float x,y,z; 152 float rhw; 153 union { 154 COLOR dcDiffuse; 155 struct { 156 uint8_t b; 157 uint8_t g; 158 uint8_t r; 159 uint8_t a; 160 }; 161 }; 162 COLOR dcSpecular; 163 } LITVERTEX, *LPLITVERTEX; 164 165 166 167 typedef struct { 168 float x,y,z; 169 float rhw; 170 COLOR dcDiffuse; 171 } FILLRECTVERTEX, *LPFILLRECTVERTEX; 172 173 #include "COLOR.h" 174 #include "IColor.h" 175 176 typedef struct 177 { 178 float x,y,z; 179 float nx,ny,nz; 180 union { 181 COLOR dcDiffuse; 182 struct { 183 uint8_t b; 184 uint8_t g; 185 uint8_t r; 186 uint8_t a; 187 }; 188 }; 189 float u,v; 190 }EXTERNAL_VERTEX, *LPSHADERVERTEX; 191 192 193 typedef struct 194 { 195 union { 196 struct { 197 float x; 198 float y; 199 float z; 200 float range; // Range == 0 for directional light 201 // Range != 0 for point light, Zelda MM 202 }; 203 }; 204 205 union { 206 struct { 207 uint8_t r; 208 uint8_t g; 209 uint8_t b; 210 uint8_t a; 211 }; 212 uint32_t col; 213 }; 214 215 union { 216 struct { 217 float fr; 218 float fg; 219 float fb; 220 float fa; 221 }; 222 float fcolors[4]; 223 }; 224 225 union { 226 struct { 227 float tx; 228 float ty; 229 float tz; 230 float tdummy; 231 }; 232 }; 233 234 union { 235 struct { 236 float ox; 237 float oy; 238 float oz; 239 float odummy; 240 }; 241 }; 242 } Light; 243 244 typedef struct 245 { 246 char na; 247 char nz; // b 248 char ny; //g 249 char nx; //r 250 }NormalStruct; 251 252 typedef struct 253 { 254 short y; 255 short x; 256 257 short flag; 258 short z; 259 260 short tv; 261 short tu; 262 263 union { 264 struct { 265 uint8_t a; 266 uint8_t b; 267 uint8_t g; 268 uint8_t r; 269 } rgba; 270 NormalStruct norma; 271 }; 272 } FiddledVtx; 273 274 typedef struct 275 { 276 short y; 277 short x; 278 279 uint8_t a; 280 uint8_t b; 281 short z; 282 283 uint8_t g; 284 uint8_t r; 285 286 } FiddledVtxDKR; 287 288 typedef struct 289 { 290 short y; 291 short x; 292 uint16_t cidx; 293 short z; 294 short t; 295 short s; 296 } N64VtxPD; 297 298 class CTexture; 299 class COGLTexture; 300 class CDirectXTexture; 301 struct TxtrCacheEntry; 302 303 typedef struct { 304 LPRICETEXTURE m_lpsTexturePtr; 305 union { 306 CTexture * m_pCTexture; 307 CDirectXTexture * m_pCDirectXTexture; 308 COGLTexture * m_pCOGLTexture; 309 }; 310 311 uint32_t m_dwTileWidth; 312 uint32_t m_dwTileHeight; 313 float m_fTexWidth; 314 float m_fTexHeight; // Float to avoid converts when processing verts 315 TxtrCacheEntry *pTextureEntry; 316 } RenderTexture; 317 318 319 typedef struct 320 { 321 unsigned int dwFormat; 322 unsigned int dwSize; 323 unsigned int dwWidth; 324 unsigned int dwAddr; 325 326 unsigned int dwLastWidth; 327 unsigned int dwLastHeight; 328 329 unsigned int dwHeight; 330 unsigned int dwMemSize; 331 332 bool bCopied; 333 unsigned int dwCopiedAtFrame; 334 335 unsigned int dwCRC; 336 unsigned int lastUsedFrame; 337 unsigned int bUsedByVIAtFrame; 338 unsigned int lastSetAtUcode; 339 } RecentCIInfo; 340 341 typedef struct 342 { 343 uint32_t addr; 344 uint32_t FrameCount; 345 } RecentViOriginInfo; 346 347 typedef enum { 348 SHADE_DISABLED, 349 SHADE_FLAT, 350 SHADE_SMOOTH, 351 } RenderShadeMode; 352 353 typedef enum { 354 TEXTURE_UV_FLAG_WRAP, 355 TEXTURE_UV_FLAG_MIRROR, 356 TEXTURE_UV_FLAG_CLAMP, 357 } TextureUVFlag; 358 359 typedef struct 360 { 361 TextureUVFlag N64flag; 362 uint32_t realFlag; 363 } UVFlagMap; 364 365 366 typedef enum { 367 FILTER_POINT, 368 FILTER_LINEAR, 369 } TextureFilter; 370 371 typedef struct 372 { 373 TextureFilter N64filter; 374 uint32_t realFilter; 375 } TextureFilterMap; 376 377 typedef struct { 378 const char* description; 379 int number; 380 uint32_t setting; 381 } BufferSettingInfo; 382 383 typedef struct { 384 const char* description; 385 uint32_t setting; 386 } SettingInfo; 387 388 typedef union { 389 uint8_t g_Tmem8bit[0x1000]; 390 short g_Tmem16bit[0x800]; 391 uint32_t g_Tmem32bit[0x300]; 392 uint64_t g_Tmem64bit[0x200]; 393 } TmemType; 394 395 396 typedef struct { 397 uint32_t dwFormat; 398 uint32_t dwSize; 399 uint32_t bSetBy; 400 401 uint32_t dwLoadAddress; 402 uint32_t dwTotalWords; 403 uint32_t dxt; 404 bool bSwapped; 405 406 uint32_t dwWidth; 407 uint32_t dwLine; 408 409 int sl; 410 int sh; 411 int tl; 412 int th; 413 414 uint32_t dwTmem; 415 } TMEMLoadMapInfo; 416 417 #endif 418 419