| 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 "osal_preproc.h" |
| 24 | #include "VectorMath.h" |
| 25 | |
| 26 | #define uchar unsigned char |
| 27 | #define uint16 unsigned short |
| 28 | #define uint32 unsigned int |
| 29 | #define uint64 unsigned long long |
| 30 | |
| 31 | typedef unsigned char uint8; |
| 32 | |
| 33 | typedef signed char s8; |
| 34 | typedef int s32; |
| 35 | typedef unsigned int u32; |
| 36 | typedef unsigned char u8; |
| 37 | |
| 38 | typedef unsigned int COLOR; |
| 39 | typedef struct _COORDRECT |
| 40 | { |
| 41 | int x1,y1; |
| 42 | int x2,y2; |
| 43 | } COORDRECT; |
| 44 | #define COLOR_RGBA(r,g,b,a) (((r&0xFF)<<16) | ((g&0xFF)<<8) | ((b&0xFF)<<0) | ((a&0xFF)<<24)) |
| 45 | #define SURFFMT_A8R8G8B8 21 |
| 46 | |
| 47 | #define RGBA_GETALPHA(rgb) ((rgb) >> 24) |
| 48 | #define RGBA_GETRED(rgb) (((rgb) >> 16) & 0xff) |
| 49 | #define RGBA_GETGREEN(rgb) (((rgb) >> 8) & 0xff) |
| 50 | #define RGBA_GETBLUE(rgb) ((rgb) & 0xff) |
| 51 | |
| 52 | typedef XMATRIX Matrix; |
| 53 | typedef void* LPRICETEXTURE ; |
| 54 | |
| 55 | typedef struct |
| 56 | { |
| 57 | uint32 dwRGBA, dwRGBACopy; |
| 58 | char x,y,z; // Direction |
| 59 | uint8 pad; |
| 60 | } N64Light; |
| 61 | |
| 62 | |
| 63 | typedef struct |
| 64 | { |
| 65 | unsigned int dwFormat:3; |
| 66 | unsigned int dwSize:2; |
| 67 | unsigned int dwWidth:10; |
| 68 | uint32 dwAddr; |
| 69 | uint32 bpl; |
| 70 | } SetImgInfo; |
| 71 | |
| 72 | typedef struct |
| 73 | { |
| 74 | // Set by RDP_SetTile |
| 75 | unsigned int dwFormat :3; // e.g. RGBA, YUV etc |
| 76 | unsigned int dwSize :2; // e.g 4/8/16/32bpp |
| 77 | unsigned int dwLine :9; // Ummm... |
| 78 | unsigned int dwPalette :4; // 0..15 - a palette index? |
| 79 | uint32 dwTMem; // Texture memory location |
| 80 | |
| 81 | unsigned int bClampS :1; |
| 82 | unsigned int bClampT :1; |
| 83 | unsigned int bMirrorS :1; |
| 84 | unsigned int bMirrorT :1; |
| 85 | |
| 86 | unsigned int dwMaskS :4; |
| 87 | unsigned int dwMaskT :4; |
| 88 | unsigned int dwShiftS :4; |
| 89 | unsigned int dwShiftT :4; |
| 90 | |
| 91 | // Set by RDP_SetTileSize |
| 92 | int sl; // Upper left S - 8:3 |
| 93 | int tl; // Upper Left T - 8:3 |
| 94 | int sh; // Lower Right S |
| 95 | int th; // Lower Right T |
| 96 | |
| 97 | int hilite_sl; |
| 98 | int hilite_tl; |
| 99 | int hilite_sh; |
| 100 | int hilite_th; |
| 101 | |
| 102 | float fsl; // Upper left S - 8:3 |
| 103 | float ftl; // Upper Left T - 8:3 |
| 104 | float fsh; // Lower Right S |
| 105 | float fth; // Lower Right T |
| 106 | |
| 107 | float fhilite_sl; |
| 108 | float fhilite_tl; |
| 109 | float fhilite_sh; |
| 110 | float fhilite_th; |
| 111 | |
| 112 | uint32 dwDXT; |
| 113 | |
| 114 | uint32 dwPitch; |
| 115 | |
| 116 | uint32 dwWidth; |
| 117 | uint32 dwHeight; |
| 118 | |
| 119 | float fShiftScaleS; |
| 120 | float fShiftScaleT; |
| 121 | |
| 122 | uint32 lastTileCmd; |
| 123 | bool bSizeIsValid; |
| 124 | |
| 125 | bool bForceWrapS; |
| 126 | bool bForceWrapT; |
| 127 | bool bForceClampS; |
| 128 | bool bForceClampT; |
| 129 | |
| 130 | } Tile; |
| 131 | |
| 132 | |
| 133 | typedef struct |
| 134 | { |
| 135 | float u; |
| 136 | float v; |
| 137 | } TexCord; |
| 138 | |
| 139 | typedef struct VECTOR2 |
| 140 | { |
| 141 | float x; |
| 142 | float y; |
| 143 | VECTOR2( float newx, float newy ) {x=newx; y=newy;} |
| 144 | VECTOR2() {x=0; y=0;} |
| 145 | } VECTOR2; |
| 146 | |
| 147 | typedef struct |
| 148 | { |
| 149 | short x; |
| 150 | short y; |
| 151 | } IVector2; |
| 152 | |
| 153 | typedef struct |
| 154 | { |
| 155 | short x; |
| 156 | short y; |
| 157 | short z; |
| 158 | } IVector3; |
| 159 | |
| 160 | typedef struct { |
| 161 | float x,y,z; |
| 162 | float rhw; |
| 163 | union { |
| 164 | COLOR dcDiffuse; |
| 165 | struct { |
| 166 | uint8 b; |
| 167 | uint8 g; |
| 168 | uint8 r; |
| 169 | uint8 a; |
| 170 | }; |
| 171 | }; |
| 172 | COLOR dcSpecular; |
| 173 | TexCord tcord[2]; |
| 174 | } TLITVERTEX, *LPTLITVERTEX; |
| 175 | |
| 176 | typedef struct { |
| 177 | float x,y,z; |
| 178 | union { |
| 179 | COLOR dcDiffuse; |
| 180 | struct { |
| 181 | uint8 b; |
| 182 | uint8 g; |
| 183 | uint8 r; |
| 184 | uint8 a; |
| 185 | }; |
| 186 | }; |
| 187 | COLOR dcSpecular; |
| 188 | TexCord tcord[2]; |
| 189 | } UTLITVERTEX, *LPUTLITVERTEX; |
| 190 | |
| 191 | typedef struct { |
| 192 | float x,y,z; |
| 193 | float rhw; |
| 194 | union { |
| 195 | COLOR dcDiffuse; |
| 196 | struct { |
| 197 | uint8 b; |
| 198 | uint8 g; |
| 199 | uint8 r; |
| 200 | uint8 a; |
| 201 | }; |
| 202 | }; |
| 203 | COLOR dcSpecular; |
| 204 | } LITVERTEX, *LPLITVERTEX; |
| 205 | |
| 206 | |
| 207 | |
| 208 | typedef struct { |
| 209 | float x,y,z; |
| 210 | float rhw; |
| 211 | COLOR dcDiffuse; |
| 212 | } FILLRECTVERTEX, *LPFILLRECTVERTEX; |
| 213 | |
| 214 | #include "COLOR.h" |
| 215 | #include "IColor.h" |
| 216 | |
| 217 | typedef struct |
| 218 | { |
| 219 | float x,y,z; |
| 220 | float nx,ny,nz; |
| 221 | union { |
| 222 | COLOR dcDiffuse; |
| 223 | struct { |
| 224 | uint8 b; |
| 225 | uint8 g; |
| 226 | uint8 r; |
| 227 | uint8 a; |
| 228 | }; |
| 229 | }; |
| 230 | float u,v; |
| 231 | }EXTERNAL_VERTEX, *LPSHADERVERTEX; |
| 232 | |
| 233 | |
| 234 | typedef struct |
| 235 | { |
| 236 | union { |
| 237 | struct { |
| 238 | float x; |
| 239 | float y; |
| 240 | float z; |
| 241 | float range; // Range == 0 for directional light |
| 242 | // Range != 0 for point light, Zelda MM |
| 243 | }; |
| 244 | }; |
| 245 | |
| 246 | union { |
| 247 | struct { |
| 248 | uint8 r; |
| 249 | uint8 g; |
| 250 | uint8 b; |
| 251 | uint8 a; |
| 252 | }; |
| 253 | uint32 col; |
| 254 | }; |
| 255 | |
| 256 | union { |
| 257 | struct { |
| 258 | float fr; |
| 259 | float fg; |
| 260 | float fb; |
| 261 | float fa; |
| 262 | }; |
| 263 | float fcolors[4]; |
| 264 | }; |
| 265 | |
| 266 | union { |
| 267 | struct { |
| 268 | float tx; |
| 269 | float ty; |
| 270 | float tz; |
| 271 | float tdummy; |
| 272 | }; |
| 273 | }; |
| 274 | |
| 275 | union { |
| 276 | struct { |
| 277 | float ox; |
| 278 | float oy; |
| 279 | float oz; |
| 280 | float odummy; |
| 281 | }; |
| 282 | }; |
| 283 | } Light; |
| 284 | |
| 285 | typedef struct |
| 286 | { |
| 287 | char na; |
| 288 | char nz; // b |
| 289 | char ny; //g |
| 290 | char nx; //r |
| 291 | }NormalStruct; |
| 292 | |
| 293 | typedef struct |
| 294 | { |
| 295 | short y; |
| 296 | short x; |
| 297 | |
| 298 | short flag; |
| 299 | short z; |
| 300 | |
| 301 | short tv; |
| 302 | short tu; |
| 303 | |
| 304 | union { |
| 305 | struct { |
| 306 | uint8 a; |
| 307 | uint8 b; |
| 308 | uint8 g; |
| 309 | uint8 r; |
| 310 | } rgba; |
| 311 | NormalStruct norma; |
| 312 | }; |
| 313 | } FiddledVtx; |
| 314 | |
| 315 | typedef struct |
| 316 | { |
| 317 | short y; |
| 318 | short x; |
| 319 | |
| 320 | uint8 a; |
| 321 | uint8 b; |
| 322 | short z; |
| 323 | |
| 324 | uint8 g; |
| 325 | uint8 r; |
| 326 | |
| 327 | } FiddledVtxDKR; |
| 328 | |
| 329 | typedef struct |
| 330 | { |
| 331 | short y; |
| 332 | short x; |
| 333 | uint16 cidx; |
| 334 | short z; |
| 335 | short t; |
| 336 | short s; |
| 337 | } N64VtxPD; |
| 338 | |
| 339 | class CTexture; |
| 340 | class COGLTexture; |
| 341 | class CDirectXTexture; |
| 342 | struct TxtrCacheEntry; |
| 343 | |
| 344 | typedef struct { |
| 345 | LPRICETEXTURE m_lpsTexturePtr; |
| 346 | union { |
| 347 | CTexture * m_pCTexture; |
| 348 | CDirectXTexture * m_pCDirectXTexture; |
| 349 | COGLTexture * m_pCOGLTexture; |
| 350 | }; |
| 351 | |
| 352 | uint32 m_dwTileWidth; |
| 353 | uint32 m_dwTileHeight; |
| 354 | float m_fTexWidth; |
| 355 | float m_fTexHeight; // Float to avoid converts when processing verts |
| 356 | TxtrCacheEntry *pTextureEntry; |
| 357 | } RenderTexture; |
| 358 | |
| 359 | |
| 360 | typedef struct |
| 361 | { |
| 362 | unsigned int dwFormat; |
| 363 | unsigned int dwSize; |
| 364 | unsigned int dwWidth; |
| 365 | unsigned int dwAddr; |
| 366 | |
| 367 | unsigned int dwLastWidth; |
| 368 | unsigned int dwLastHeight; |
| 369 | |
| 370 | unsigned int dwHeight; |
| 371 | unsigned int dwMemSize; |
| 372 | |
| 373 | bool bCopied; |
| 374 | unsigned int dwCopiedAtFrame; |
| 375 | |
| 376 | unsigned int dwCRC; |
| 377 | unsigned int lastUsedFrame; |
| 378 | unsigned int bUsedByVIAtFrame; |
| 379 | unsigned int lastSetAtUcode; |
| 380 | } RecentCIInfo; |
| 381 | |
| 382 | typedef struct |
| 383 | { |
| 384 | uint32 addr; |
| 385 | uint32 FrameCount; |
| 386 | } RecentViOriginInfo; |
| 387 | |
| 388 | typedef enum { |
| 389 | SHADE_DISABLED, |
| 390 | SHADE_FLAT, |
| 391 | SHADE_SMOOTH, |
| 392 | } RenderShadeMode; |
| 393 | |
| 394 | typedef enum { |
| 395 | TEXTURE_UV_FLAG_WRAP, |
| 396 | TEXTURE_UV_FLAG_MIRROR, |
| 397 | TEXTURE_UV_FLAG_CLAMP, |
| 398 | } TextureUVFlag; |
| 399 | |
| 400 | typedef struct |
| 401 | { |
| 402 | TextureUVFlag N64flag; |
| 403 | uint32 realFlag; |
| 404 | } UVFlagMap; |
| 405 | |
| 406 | |
| 407 | typedef enum { |
| 408 | FILTER_POINT, |
| 409 | FILTER_LINEAR, |
| 410 | } TextureFilter; |
| 411 | |
| 412 | typedef struct |
| 413 | { |
| 414 | TextureFilter N64filter; |
| 415 | uint32 realFilter; |
| 416 | } TextureFilterMap; |
| 417 | |
| 418 | typedef struct { |
| 419 | const char* description; |
| 420 | int number; |
| 421 | uint32 setting; |
| 422 | } BufferSettingInfo; |
| 423 | |
| 424 | typedef struct { |
| 425 | const char* description; |
| 426 | uint32 setting; |
| 427 | } SettingInfo; |
| 428 | |
| 429 | typedef union { |
| 430 | uint8 g_Tmem8bit[0x1000]; |
| 431 | short g_Tmem16bit[0x800]; |
| 432 | uint32 g_Tmem32bit[0x300]; |
| 433 | uint64 g_Tmem64bit[0x200]; |
| 434 | } TmemType; |
| 435 | |
| 436 | |
| 437 | typedef struct { |
| 438 | uint32 dwFormat; |
| 439 | uint32 dwSize; |
| 440 | BOOL bSetBy; |
| 441 | |
| 442 | uint32 dwLoadAddress; |
| 443 | uint32 dwTotalWords; |
| 444 | uint32 dxt; |
| 445 | BOOL bSwapped; |
| 446 | |
| 447 | uint32 dwWidth; |
| 448 | uint32 dwLine; |
| 449 | |
| 450 | int sl; |
| 451 | int sh; |
| 452 | int tl; |
| 453 | int th; |
| 454 | |
| 455 | uint32 dwTmem; |
| 456 | } TMEMLoadMapInfo; |
| 457 | |
| 458 | #endif |
| 459 | |