1 // Emacs style mode select -*- C++ -*- 2 //----------------------------------------------------------------------------- 3 // 4 // $Id: r_defs.h 1558 2020-11-17 23:36:10Z wesleyjohnson $ 5 // 6 // Copyright (C) 1993-1996 by id Software, Inc. 7 // Portions Copyright (C) 1998-2015 by DooM Legacy Team. 8 // 9 // This program is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU General Public License 11 // as published by the Free Software Foundation; either version 2 12 // of the License, or (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // 20 // $Log: r_defs.h,v $ 21 // Revision 1.35 2003/05/04 04:14:08 sburke 22 // Prevent misaligned access on Solaris/Sparc. 23 // 24 // Revision 1.34 2002/07/20 03:23:20 mrousseau 25 // Added 'side' to seg_t 26 // 27 // Revision 1.33 2002/01/12 02:21:36 stroggonmeth 28 // Revision 1.32 2001/08/19 20:41:04 hurdler 29 // Revision 1.31 2001/08/13 22:53:40 stroggonmeth 30 // 31 // Revision 1.30 2001/08/12 17:57:15 hurdler 32 // Beter support of sector coloured lighting in hw mode 33 // 34 // Revision 1.29 2001/08/11 15:18:02 hurdler 35 // Add sector colormap in hw mode (first attempt) 36 // 37 // Revision 1.28 2001/08/09 21:35:17 hurdler 38 // Add translucent 3D water in hw mode 39 // 40 // Revision 1.27 2001/08/08 20:34:43 hurdler 41 // Big TANDL update 42 // 43 // Revision 1.26 2001/08/06 23:57:09 stroggonmeth 44 // Removed portal code, improved 3D floors in hardware mode. 45 // 46 // Revision 1.25 2001/05/30 04:00:52 stroggonmeth 47 // Fixed crashing bugs in software with 3D floors. 48 // 49 // Revision 1.24 2001/05/14 19:02:58 metzgermeister 50 // * Fixed floor not moving up with player on E3M1 51 // * Fixed crash due to oversized string in screen message ... bad bug! 52 // * Corrected some typos 53 // * fixed sound bug in SDL 54 // 55 // Revision 1.23 2001/04/30 17:19:24 stroggonmeth 56 // HW fix and misc. changes 57 // 58 // Revision 1.22 2001/03/30 17:12:51 bpereira 59 // Revision 1.21 2001/03/21 18:24:39 stroggonmeth 60 // 61 // Revision 1.20 2001/03/19 21:18:48 metzgermeister 62 // * missing textures in HW mode are replaced by default texture 63 // * fixed crash bug with P_SpawnMissile(.) returning NULL 64 // * deep water trick and other nasty thing work now in HW mode (tested with tnt/map02 eternal/map02) 65 // * added cvar gr_correcttricks 66 // 67 // Revision 1.19 2001/03/13 22:14:20 stroggonmeth 68 // Long time no commit. 3D floors, FraggleScript, portals, ect. 69 // 70 // Revision 1.18 2001/02/28 17:50:55 bpereira 71 // 72 // Revision 1.17 2001/01/25 22:15:44 bpereira 73 // added heretic support 74 // 75 // Revision 1.16 2000/11/21 21:13:17 stroggonmeth 76 // Optimised 3D floors and fixed crashing bug in high resolutions. 77 // 78 // Revision 1.15 2000/11/09 17:56:20 stroggonmeth 79 // 80 // Revision 1.14 2000/11/02 17:50:09 stroggonmeth 81 // Big 3Dfloors & FraggleScript commit!! 82 // 83 // Revision 1.13 2000/10/07 20:36:13 crashrl 84 // Added deathmatch team-start-sectors via sector/line-tag and linedef-type 1000-1031 85 // 86 // Revision 1.12 2000/10/04 16:19:24 hurdler 87 // Change all those "3dfx names" to more appropriate names 88 // 89 // Revision 1.11 2000/07/01 09:23:49 bpereira 90 // Revision 1.10 2000/04/18 17:39:39 stroggonmeth 91 // Revision 1.9 2000/04/18 12:55:39 hurdler 92 // Revision 1.7 2000/04/15 22:12:58 stroggonmeth 93 // 94 // Revision 1.6 2000/04/12 16:01:59 hurdler 95 // ready for T&L code and true static lighting 96 // 97 // Revision 1.5 2000/04/11 19:07:25 stroggonmeth 98 // 99 // Revision 1.4 2000/04/06 20:47:08 hurdler 100 // add Boris' changes for coronas in doom3.wad 101 // 102 // Revision 1.3 2000/04/04 00:32:47 stroggonmeth 103 // Initial Boom compatability plus few misc changes all around. 104 // 105 // Revision 1.2 2000/02/27 00:42:10 hurdler 106 // Revision 1.1.1.1 2000/02/22 20:32:32 hurdler 107 // Initial import into CVS (v1.29 pr3) 108 // 109 // 110 // DESCRIPTION: 111 // Refresh/rendering module, shared data struct definitions. 112 // 113 //----------------------------------------------------------------------------- 114 115 116 #ifndef R_DEFS_H 117 #define R_DEFS_H 118 119 #include "doomtype.h" 120 #include "m_fixed.h" 121 122 // We rely on the thinker data struct 123 // to handle sound origins in sectors. 124 #include "d_think.h" 125 // SECTORS do store MObjs anyway. 126 #include "p_mobj.h" 127 128 #include "screen.h" 129 // MAXVIDWIDTH, MAXVIDHEIGHT 130 131 132 // Max index (or -1). Used in line_t::sidenum and maplinedef_t::sidenum. 133 #define NULL_INDEX 0xFFFF 134 135 136 // Silhouette, needed for clipping Segs (mainly) 137 // and sprites representing things. 138 // OR bits for silhouette 139 typedef enum { 140 SIL_BOTTOM = 0x01, 141 SIL_TOP = 0x02 142 } Silhouette_e; 143 144 145 // SoM: Moved this here... 146 // This could be wider for >8 bit display. 147 // Indeed, true color support is possible 148 // precalculating 24bpp lightmap/colormap LUT. 149 // from darkening PLAYPAL to all black. 150 // Could even use more than 32 levels. 151 typedef byte lighttable_t; // light map table 152 // can be an array of map tables [256], or just one 153 // index a lighttable by mult by sizeof lighttable ( *256 => <<8 ) 154 #define LIGHTTABLE(t) ((t)<<8) 155 156 // right shift to convert 0..255 to 0..(NUM_RGBA_LEVELS-1) 157 //#define NUM_RGBA_LEVELS 4 158 //#define LIGHT_TO_RGBA_SHIFT 6 159 //#define NUM_RGBA_LEVELS 8 160 //#define LIGHT_TO_RGBA_SHIFT 5 161 #define NUM_RGBA_LEVELS 16 162 #define LIGHT_TO_RGBA_SHIFT 4 163 //#define NUM_RGBA_LEVELS 32 164 //#define LIGHT_TO_RGBA_SHIFT 3 165 166 167 // SoM: ExtraColormap type. Use for extra_colormaps from now on. 168 typedef struct 169 { 170 RGBA_t maskcolor; // 32 bit bright color 171 RGBA_t fadecolor; // 32 bit dark color 172 // [WDJ] maskalpha is in maskcolor.alpha 173 // double maskalpha; // 0.0 .. 1.0 174 uint16_t fadestart, fadeend; 175 int fog; 176 177 //Hurdler: rgba is used in hw mode for coloured sector lighting 178 // [WDJ] Separate rgba for light levels [0]=darkest, [NUM-1]=brightest 179 RGBA_t rgba[NUM_RGBA_LEVELS]; // similar to maskcolor in sw mode 180 // alpha=0..255, 0=black/white tint, 255=saturated color 181 // r,g,b are the saturated color, 0..255 182 183 lighttable_t* colormap; // colormap tables [32][256] 184 } extracolormap_t; 185 186 187 //========= 188 // INTERNAL MAP TYPES 189 // used by play and refresh 190 // 191 192 // 193 // Your plain vanilla vertex. 194 // Note: transformed values not buffered locally, 195 // like some DOOM-alikes ("wt", "WebView") did. 196 // 197 typedef struct 198 { 199 fixed_t x, y; 200 } vertex_t; 201 202 203 // Forward of LineDefs, for Sectors. 204 struct line_s; 205 206 // Each sector has an xyz_t in its center for sound origin purposes. 207 // [WDJ] This replaces degenmobj_t, which was prone to breakage. 208 // I suppose this does not handle sound from 209 // moving objects (doppler), because 210 // position is prolly just buffered, not updated. 211 212 //SoM: 3/23/2000: Store fake planes in a resizable array instead of just by 213 //heightsec field. Allows for multiple fake planes. 214 typedef enum 215 { 216 FF_EXISTS = 0x1, //MAKE SURE IT'S VALID 217 FF_SOLID = 0x2, //It clips things 218 FF_OUTER_SIDES = 0x4, //Render the outside view of sides 219 FF_OUTER_PLANES = 0x8, //Render the outside view of floor/ceiling 220 FF_SLAB_SHADOW = 0x10, //Make two lightlist entries to contain light 221 FF_NOSHADE = 0x20, //No light effect 222 // Cut instead of Occlude 223 FF_CUTSOLIDS = 0x40, //Must cut hidden solid pixels 224 FF_CUTEXTRA = 0x80, //Must cut hidden translucent pixels 225 FF_CUTSPRITES = 0x100, //Must cut sprites, Final Step in 3D water 226 FF_EXTRA = 0x200, //Translucent, water, and fog, 227 //It gets cut by FF_CUTEXTRAS 228 FF_FLUID = 0x400, //Fluid surface 229 FF_TRANSLUCENT = 0x800, //Translucent (see through) 230 FF_FOG = 0x1000, //Fog area 231 FF_INNER_PLANES = 0x2000, //Render the inside view of planes (FOG/WATER) 232 FF_INNER_SIDES = 0x4000, //Render the inside view of sides (FOG/WATER) 233 FF_JOIN_SIDES = 0x8000, //Render the join side between similar sectors 234 FF_FOGFACE = 0x10000,//Render a fogsheet in face 235 FF_SWIMMABLE = 0x20000,//Player can swim 236 // FF_unused = 0x40000,// 237 // FF_unused = 0x80000,// 238 } ffloortype_e; 239 240 241 // created by P_AddFakeFloor 242 typedef struct ffloor_s 243 { 244 // references to model sector, to pass through changes immediately 245 fixed_t *topheight; // model sector ceiling 246 short *toppic; 247 lightlev_t *toplightlevel; 248 fixed_t *topxoffs; 249 fixed_t *topyoffs; 250 251 fixed_t *bottomheight; // model sector floor 252 short *bottompic; 253 //lightlev_t *bottomlightlevel; 254 fixed_t *bottomxoffs; 255 fixed_t *bottomyoffs; 256 257 int model_secnum; // model sector num used in linedef 258 ffloortype_e flags; // draw and property flags set by special linedef 259 260 struct line_s * master; // the special linedef generating this floor 261 262 struct sector_s* taggedtarget; // tagged sector that is affected 263 264 // double linked list of ffloor_t in sector 265 struct ffloor_s* next; 266 struct ffloor_s* prev; 267 268 uint16_t fw_effect; // index to fweff, 0 is unused 269 // FF_FOG, FF_TRANSLUCENT, alpha 270 uint8_t alpha; 271 uint8_t lastlight; // light index, FF_SLAB_SHADOW 272 } ffloor_t; 273 274 275 // SoM: This struct holds information for shadows casted by 3D floors. 276 // This information is contained inside the sector_t and is used as the base 277 // information for casted shadows. 278 // The item for a fake-floor light list. 279 typedef struct lightlist_s { 280 fixed_t height; 281 uint32_t flags; 282 lightlev_t * lightlevel; 283 extracolormap_t* extra_colormap; 284 ffloor_t* caster; // ffloor that is source of light or shadow 285 } ff_light_t; 286 287 288 // SoM: This struct is used for rendering walls with shadows casted on them... 289 typedef struct r_lightlist_s { 290 fixed_t height; 291 fixed_t heightstep; 292 fixed_t botheight; 293 fixed_t botheightstep; 294 lightlev_t lightlevel; 295 // lightlev_t vlight; // visible light 0..255 296 lighttable_t** vlightmap; // scalelights 297 extracolormap_t* extra_colormap; // colormap tables 298 lighttable_t* rcolormap; // rendering colormap 299 uint32_t flags; 300 } r_lightlist_t; 301 302 303 typedef enum { 304 FLOOR_SOLID, 305 FLOOR_WATER, 306 FLOOR_LAVA, 307 FLOOR_SLUDGE, 308 FLOOR_ICE, 309 } floortype_e; 310 311 //========= 312 // ----- for special tricks with HW renderer ----- 313 314 // 315 // For creating a chain with the lines around a sector 316 // 317 typedef struct linechain_s 318 { 319 struct line_s *line; 320 struct linechain_s *next; 321 } linechain_t; 322 // ----- end special tricks ----- 323 324 //========= 325 // Sectors 326 327 // sector model [WDJ] 11/14/2009 328 typedef enum{ 329 SM_normal, // normal sector 330 SM_colormap, // Legacy colormap generation 331 SM_fluid, // start of fluid sectors 332 SM_Boom_deep_water, // special Boom sector 333 SM_Legacy_water, // special Legacy sector 334 // Legacy 3D floors are handled through FFloor list 335 } sector_model_e; 336 337 // The SECTORS record, at runtime. 338 // Stores things/mobjs. 339 typedef struct sector_s 340 { 341 fixed_t floorheight; 342 fixed_t ceilingheight; 343 short floorpic; 344 short ceilingpic; 345 lightlev_t lightlevel; 346 short special; // special type code (highly encoded with fields) 347 short oldspecial; //SoM: 3/6/2000: Remember if a sector was secret (for automap) 348 uint16_t tag; 349 // int nexttag,firsttag; //SoM: 3/6/2000: by killough: improves searches for tags. 350 int32_t nexttag; // linked list of sectors with that tag, improves searches for tags. 351 352 // 0 = untraversed, 1,2 = sndlines -1 353 byte soundtraversed; 354 byte floortype; // see floortype_e 355 356 // thing that made a sound (or null) 357 mobj_t* soundtarget; 358 359 // mapblock bounding box for height changes 360 int blockbox[4]; 361 362 // origin for any sounds played by the sector 363 xyz_t soundorg; 364 365 // if == validcount, already checked 366 int validcount; 367 368 // list of mobjs in sector 369 mobj_t* thinglist; 370 371 //SoM: 3/6/2000: Start boom extra stuff 372 // thinker_t for reversable actions 373 // make thinkers on floors, ceilings, lighting, independent of one another 374 void *floordata; 375 // ZMalloc PU_LEVSPEC, in EV_DoFloor 376 void *ceilingdata; 377 void *lightingdata; 378 379 // lockout machinery for stairbuilding 380 int stairlock; // -2 on first locked -1 after thinker done 0 normally 381 int prevsec; // -1 or number of sector for previous step 382 int nextsec; // -1 or number of next step sector 383 384 // floor and ceiling texture offsets 385 fixed_t floor_xoffs, floor_yoffs; 386 fixed_t ceiling_xoffs, ceiling_yoffs; 387 388 // [WDJ] 4/20/2010 modelsec is model sector for special linedefs. 389 // It will be valid when model != SM_normal. 390 // Testing modelsec for water is invalid, it is also used for colormap. 391 // Uses model and modelsec, instead of the PrBoom heightsec. 392 int modelsec; // other sector number, or -1 if no other sector 393 sector_model_e model; // Boom or Legacy special sector [WDJ] 11/14/2009 394 395 // [WDJ] 3/2011, (killough 8/28/98 Friction as sector property). 396 // friction=INT_MAX when unused 397 fixed_t friction; 398 int movefactor; 399 400 int floorlightsec, ceilinglightsec; 401 int teamstartsec; 402 403 int bottommap, midmap, topmap; // dynamic colormaps 404 // -1 is invalid, valid 0.. 405 406 // list of mobjs that are at least partially in the sector 407 // thinglist is a subset of touching_thinglist 408 struct msecnode_s *touching_thinglist; // phares 3/14/98 409 // nodes are ZMalloc PU_LEVEL, by P_GetSecnode 410 //SoM: 3/6/2000: end stuff... 411 412 // list of ptrs to lines that have this sector as a side 413 int linecount; 414 struct line_s** linelist; // [linecount] size 415 416 //SoM: 2/23/2000: Improved fake floor hack 417 ffloor_t * ffloors; // 3D floor list 418 // ZMalloc PU_LEVEL, in P_AddFakeFloor 419 int * attached; // list of control sectors (by secnum) 420 // realloc in P_AddFakeFloor 421 // [WDJ] 7/2010 deallocate in P_SetupLevel 422 int numattached; 423 ff_light_t * lightlist; // array of fake floor lights 424 // ZMalloc PU_LEVEL, in R_Prep3DFloors 425 int numlights; 426 boolean moved; // floor was moved 427 428 int validsort; //if == validsort already been sorted 429 boolean added; 430 431 // SoM: 4/3/2000: per-sector colormaps! 432 extracolormap_t* extra_colormap; // (ref) using colormap for this frame 433 // selected from bottommap,midmap,topmap, from special linedefs 434 435 // ----- for special tricks with HW renderer ----- 436 boolean pseudoSector; 437 boolean virtualFloor; 438 fixed_t virtualFloorheight; 439 boolean virtualCeiling; 440 fixed_t virtualCeilingheight; 441 linechain_t * sectorLines; 442 struct sector_s ** stackList; 443 #ifdef SOLARIS 444 // Until we get Z_MallocAlign sorted out, make this a float 445 // so that we don't get alignment problems. 446 float lineoutLength; 447 #else 448 double lineoutLength; 449 #endif 450 // ----- end special tricks ----- 451 } sector_t; 452 453 454 455 //========= 456 // SideDef. 457 458 typedef struct 459 { 460 // add this to the calculated texture column 461 fixed_t textureoffset; 462 463 // add this to the calculated texture top 464 fixed_t rowoffset; 465 466 // Texture indices. 467 // We do not maintain names here. 468 // 0= no-texture, will never have -1 469 short toptexture; 470 short bottomtexture; 471 short midtexture; 472 473 //SoM: 3/6/2000: This is the special of the linedef this side belongs to. 474 short linedef_special; 475 476 // Sector the SideDef is facing. 477 sector_t* sector; 478 } side_t; 479 480 481 482 // 483 // Move clipping aid for LineDefs. 484 // 485 typedef enum 486 { 487 ST_HORIZONTAL, 488 ST_VERTICAL, 489 ST_POSITIVE, 490 ST_NEGATIVE 491 492 } slopetype_t; 493 494 495 //========= 496 // LineDef 497 498 typedef struct line_s 499 { 500 // Vertices, from v1 to v2. 501 vertex_t* v1; // linedef start vertex 502 vertex_t* v2; // linedef end vertex 503 // side1 is right side when looking from v1 to v2 (start to end) 504 505 // Precalculated v2 - v1 for side checking. 506 fixed_t dx; 507 fixed_t dy; 508 509 // Animation related. 510 uint16_t flags; 511 // [WDJ] flags should be unsigned, but binary gets larger?? 512 // test shows that unsigned costs 4 more bytes per (flag & ML_bit) 513 short special; // special linedef code 514 uint16_t tag; // special affects sectors with same tag id 515 516 // Visual appearance: SideDefs. 517 uint16_t sidenum[2]; // sidenum[1] will be NULL_INDEX if one sided 518 // [smite] TODO actually they should be side_t pointers... 519 520 // Neat. Another bounding box, for the extent 521 // of the LineDef. 522 fixed_t bbox[4]; 523 524 // To aid move clipping. 525 slopetype_t slopetype; 526 527 // Front and back sector. 528 // Note: redundant? Can be retrieved from SideDefs. 529 sector_t* frontsector; // sidedef[0] sector (right side, required) 530 sector_t* backsector; // sidedef[1] sector (left side, optional) 531 532 // if == validcount, already checked 533 int validcount; 534 535 // thinker_t for reversable actions 536 void* specialdata; 537 538 // wallsplat_t list 539 void* splats; 540 541 //SoM: 3/6/2000 542 int translu_eff; // translucency effect table, 0 == none 543 // TRANSLU_med or (TRANSLU_ext + translu_store index) 544 // int firsttag,nexttag; // improves searches for tags. 545 int32_t nexttag; // linked list of lines with that tag value, improves searches for tags. 546 547 // int ecolormap; // SoM: Used for 282 linedefs 548 } line_t; 549 550 551 552 553 //========= 554 // SubSector 555 556 // 557 // A SubSector. 558 // References a Sector or portion of a sector. Is a convex polygon. 559 // When the original sector is not convex, the nodebuilder divides it into 560 // subsectors until it has convex polygons. 561 // Basically, this is a list of LineSegs, 562 // indicating the visible walls that define 563 // (all or some) sides of a convex BSP leaf. 564 // 565 typedef struct subsector_s 566 { 567 sector_t* sector; // (ref) part of this sector, from segs->sector of firstline 568 // numlines and firstline are from the subsectors lump (nodebuilder) 569 // [WDJ] some wad may be large enough to overflow signed short. 570 unsigned short numlines; // number of segs in this subsector 571 unsigned short firstline; // index into segs lump (loaded from wad) 572 // floorsplat_t list 573 void* splats; 574 //Hurdler: added for optimized mlook in hw mode 575 int validcount; 576 } subsector_t; 577 578 579 // SoM: 3/6/200 580 // 581 // Sector list node showing all sectors an object appears in. 582 // 583 // There are two threads that flow through these nodes. The first thread 584 // starts at touching_thinglist in a sector_t and flows through the m_snext 585 // links to find all mobjs that are entirely or partially in the sector. 586 // The second thread starts at touching_sectorlist in an mobj_t and flows 587 // through the m_tnext links to find all sectors a thing touches. This is 588 // useful when applying friction or push effects to sectors. These effects 589 // can be done as thinkers that act upon all objects touching their sectors. 590 // As an mobj moves through the world, these nodes are created and 591 // destroyed, with the links changed appropriately. 592 // 593 // For the links, NULL means top or end of list. 594 595 typedef struct msecnode_s 596 { 597 sector_t *m_sector; // a sector containing this object 598 struct mobj_s *m_thing; // this object 599 struct msecnode_s *m_tprev; // prev msecnode_t for this thing 600 struct msecnode_s *m_tnext; // next msecnode_t for this thing 601 struct msecnode_s *m_sprev; // prev msecnode_t for this sector 602 struct msecnode_s *m_snext; // next msecnode_t for this sector 603 boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms 604 } msecnode_t; 605 606 607 //========= 608 // Corona and Dynamic lights 609 610 // Defined constants for altering corona and dynamic lights from Fragglescript. 611 typedef enum { 612 LT_NOLIGHT = 0, 613 614 LT_PLASMA, LT_PLASMAEXP, 615 LT_ROCKET, LT_ROCKETEXP, 616 LT_BFG, LT_BFGEXP, 617 LT_BLUETALL, LT_GREENTALL, LT_REDTALL, 618 LT_BLUESMALL, LT_GREENSMALL, LT_REDSMALL, 619 LT_TECHLAMP, LT_TECHLAMP2, 620 LT_COLUMN, 621 LT_CANDLE, 622 LT_CANDLEABRE, 623 LT_REDBALL, LT_GREENBALL, 624 LT_ROCKET2, 625 // Heretic 626 LT_FX03, 627 LT_FX17, 628 LT_FX00, 629 LT_FX08, 630 LT_FX04, 631 LT_FX02, 632 LT_WTRH, 633 LT_SRTC, 634 LT_CHDL, 635 LT_KFR1, 636 637 NUMLIGHTS 638 } sprite_light_ind_e; 639 640 // [WDJ] Sprite light sources bit defines. 641 // The _SPR names are defined in legacy.wad for use in fragglescript scripts. 642 typedef enum { 643 // UNDEFINED_SPR = 0 644 SPLGT_none = 0x00, // actually just for testing 645 646 // Effect enables 647 // CORONA_SPR = 1 648 SPLGT_corona = 0x01, // emit a corona 649 // DYNLIGHT_SPR = 2 650 SPLGT_dynamic = 0x02, // emit dynamic lighting 651 652 // Type field, can create a light source 653 SPLT_type_field = 0xF0, 654 SPLT_unk = 0x00, // phobiata, newmaps default, plain corona 655 SPLT_rocket = 0x10, // flicker 656 SPLT_lamp = 0x20, 657 SPLT_fire = 0x30, // slow flicker, torch 658 //SPLT_monster = 0x40, 659 //SPLT_ammo = 0x50, 660 //SPLT_bonus = 0x60, 661 SPLT_light = 0xC0, // no fade 662 SPLT_firefly = 0xD0, // firefly flicker, un-synch 663 SPLT_random = 0xE0, // random LED, un-synch 664 SPLT_pulse = 0xF0, // slow pulsation, un-synch 665 666 // Standard Combinations 667 // LIGHT_SPR = 3 668 SPLGT_light = (SPLGT_dynamic|SPLGT_corona), 669 // ROCKET_SPR = 0x13 670 SPLGT_rocket = SPLT_rocket | (SPLGT_dynamic|SPLGT_corona), 671 } sprite_light_flags_e; 672 673 674 typedef enum { 675 // SPLT_type_field = 0xF0 // working type setting 676 SLI_type_set= 0x02, // the type was set, probably by fragglescript 677 SLI_corona_set= 0x04,// the corona was set, only by fragglescript 678 SLI_changed = 0x08, // the data was changed, probably by fragglescript 679 } sprite_light_impl_flags_e; 680 681 682 // Special sprite lighting. Optimized for Hardware, OpenGL. 683 typedef struct 684 { 685 uint16_t splgt_flags; // sprite_light_e, used in hwr_light.c 686 687 float light_xoffset; // unused 688 float light_yoffset; // y offset to adjust corona's height 689 690 RGBA_t corona_color; // color of the light for static lighting 691 float corona_radius; // radius of the coronas 692 693 RGBA_t dynamic_color; // color of the light for dynamic lighting 694 float dynamic_radius; // radius of the light ball 695 // implementation data, not in tables 696 float dynamic_sqrradius; // radius^2 of the light ball 697 uint16_t impl_flags; // implementation flags, sprite_light_impl_flags_e 698 } spr_light_t; 699 700 extern spr_light_t * corona_lsp; 701 extern float corona_size; 702 extern byte corona_alpha, corona_bright; 703 704 spr_light_t * Sprite_Corona_Light_lsp( int sprnum, state_t * sprstate ); 705 byte Sprite_Corona_Light_fade( spr_light_t * lsp, float cz, int objid ); 706 707 708 typedef struct lightmap_s 709 { 710 float s[2], t[2]; 711 spr_light_t * light; 712 struct lightmap_s * next; 713 } lightmap_t; 714 715 //========= 716 717 #ifdef HWRENDER 718 # include "hardware/hw_poly.h" 719 #endif 720 721 //========= 722 // BSP traverse 723 724 // 725 // The LineSeg. 726 // 727 typedef struct 728 { 729 // v1, v2, side, angle, offset, linedef are from wad segs lump 730 vertex_t* v1; // start vertex (derived from vertex index in wad) 731 vertex_t* v2; // end vertex 732 // side1 is right side when looking from v1 to v2 (start to end) 733 734 int side; 735 // 0= seg is on right side of linedef 736 // 1= seg is on left side of linedef (seg direction is opposite linedef) 737 738 fixed_t offset; 739 // offset from linedef start or end, to segment vertex v1 740 // when side=0, is offset from start of linedef to start of seg 741 // when side=1, is offset from end of linedef to start of seg 742 743 angle_t angle; // Binary Angle wad angle converted 744 // EAST = 0x00000000 745 // NORTH = 0x40000000 746 // WEST = 0x80000000 747 // SOUTH = 0xC0000000 748 749 line_t* linedef; // (derived from linedef index in wad) 750 side_t* sidedef; // segment sidedef (derived from linedef and side) 751 752 // Sector references. 753 // Could be retrieved from linedef, too. 754 // backsector is NULL for one sided lines 755 // (dervived from linedef and side) 756 sector_t* frontsector; // sidedef sector, the segment sector/subsector, required 757 sector_t* backsector; // side of linedef away from sector, optional 758 759 #ifdef HWRENDER 760 polyvertex_t *pv1, *pv2; // float polygon vertex 761 // length of the seg : used by the hardware renderer 762 float length; 763 764 //Hurdler: 04/12/2000: added for static lightmap 765 // hardware renderer 766 lightmap_t *lightmaps; 767 #endif 768 769 // SoM: Why slow things down by calculating lightlists for every 770 // thick side. 771 int numlights; 772 r_lightlist_t* rlights; 773 } seg_t; 774 775 776 777 // 778 // BSP node. 779 // 780 typedef struct 781 { 782 // Partition line from (x,y) to x+dx,y+dy) 783 fixed_t x, y; 784 fixed_t dx, dy; 785 786 // Bounding box for each child. 787 fixed_t bbox[2][4]; 788 // bbox[0]= right child, all segs of right must be within the box 789 // bbox[1]= left child, all segs of left must be within the box 790 791 // If NF_SUBSECTOR is set then rest of it is a subsector index, 792 // otherwise it is another node index. 793 uint16_t children[2]; 794 // children[0]= right 795 // children[1]= left 796 } node_t; 797 798 799 800 //========= 801 // OTHER TYPES 802 // 803 804 805 #ifndef MAXFFLOORS 806 #define MAXFFLOORS 40 807 #endif 808 809 // 810 // Drawseg for floor and 3D floor thickseg 811 // 812 typedef struct drawseg_s 813 { 814 seg_t* curline; 815 int x1, x2; // x1..x2 816 817 fixed_t scale1, scale2; // scale x1..x2 818 fixed_t scalestep; 819 820 // silhouette is where a drawseg can overlap a sprite 821 int silhouette; // bit flags, Silhouette_e 822 fixed_t sil_top_height; // do not clip sprites below this 823 fixed_t sil_bottom_height; // do not clip sprites above this 824 825 // Pointers to lists for sprite clipping, 826 // all three adjusted so [x1] is first value. 827 short* spr_topclip; // owned array [x1..x2] 828 short* spr_bottomclip; // owned array [x1..x2] 829 short* maskedtexturecol; // ref to array [x1..x2] 830 831 // 3D floors, only use what is needed, often none 832 struct visplane_s* ffloorplanes[MAXFFLOORS]; 833 int numffloorplanes; 834 struct ffloor_s* thicksides[MAXFFLOORS]; 835 short* thicksidecol; 836 int numthicksides; 837 838 // z check for sprite clipping 839 fixed_t * backscale_r; // ref to array [0..vid.width] 840 // fixed_t backscale[MAXVIDWIDTH]; // z check for sprite clipping 841 // fixed_t frontscale[MAXVIDWIDTH]; // z check for sprite clipping 842 } drawseg_t; 843 844 845 //========= 846 // Patch formats 847 // TM_patch 848 849 // Patches. 850 // A patch holds one or more columns. 851 // Patches are used for sprites and all masked pictures. 852 // We compose textures from the TEXTURE1 and TEXTURE2 lists 853 // of patches. 854 // 855 //WARNING: this structure is cloned in GlidePatch_t 856 // Derived from: pat_hdr_t; 857 // [WDJ] This is used for reading patches from wad. 858 typedef struct 859 { 860 // pat_hdr_t 861 uint16_t width; // bounding box size 862 uint16_t height; 863 int16_t leftoffset; // draw image at pixels to the left of origin 864 int16_t topoffset; // draw image at pixels above the origin 865 // patch fields 866 uint32_t columnofs[8]; // actually [width] 867 // offset of each column from start of patch header 868 // This is used as the head of a patch, and columnofs[8] provides 869 // access to an array that is usually [64], [128], or [256]. 870 // This would not work if the [8] was actually enforced. 871 } patch_t; 872 873 // The column data starts at offset read from columnofs[col]. 874 // Patch column is series of posts, terminated by 0xFF. 875 // The posts are drawn, the space between posts is transparent. 876 877 // Posts are runs of non-masked source pixels, drawn at the topdelta. 878 // Post format: (header post_t), 0, (pixels bytes[length]), 0 879 typedef struct 880 { 881 // unsigned test reads (topdelta = 0xFF) at column termination (which is not valid post_t) 882 byte topdelta; // y offset within patch of this post 883 byte length; // length data bytes follows 884 } post_t; 885 886 // Doom posts have a 0 pad before and after the post data. 887 // Example of Doom column data: 888 // (header post_t), 0, (pixels bytes[length]), 0, 889 // (header post_t), 0, (pixels bytes[length]), 0, 890 // (header post_t), 0, (pixels bytes[length]), 0, 891 // 0xFF 892 893 // column_t is a list of 0 or more post_t, (0xFF) terminated 894 typedef post_t column_t; 895 896 //========= 897 // Picture format 898 // TM_picture 899 // Has columnofs table, no column posts, columns are solid. 900 // Used to draw walls and sky, solid (no transparency). 901 // Draws can be tiled. 902 903 // header 904 typedef struct 905 { 906 uint32_t columnofs[8]; // actually [width] 907 // offset of each column from start of picture header 908 } picture_t; 909 // followed by TM_column_image 910 911 // Example of Doom TM_picture column data: 912 // (pixels bytes[length]) 913 914 915 //========= 916 // This is the Doom PIC format (not the Pictor PIC format). 917 typedef enum { 918 PALETTE = 0, // 1 byte is the index in the doom palette (as usual) 919 INTENSITY = 1, // 1 byte intensity 920 INTENSITY_ALPHA = 2, // 2 byte : alpha then intensity 921 RGB24 = 3, // 24 bit rgb 922 RGBA32 = 4, // 32 bit rgba 923 } pic_mode_t; 924 925 // a pic is an unmasked block of pixels, stored in horizontal way 926 // 927 typedef struct 928 { 929 uint16_t width; 930 byte zero; // set to 0 allow autodetection of pic_t 931 // mode instead of patch or raw 932 byte mode; // see pic_mode_t above 933 uint16_t height; 934 uint16_t reserved1; // set to 0 935 byte data[0]; // pixels (rows x columns), TM_row_image 936 } pic_t; 937 938 //========= 939 // Sprite 940 941 typedef enum 942 { 943 SC_NONE = 0, 944 SC_TOP = 1, 945 SC_BOTTOM = 2 946 } spritecut_e; 947 948 // A vissprite_t is a thing 949 // that will be drawn during a refresh. 950 // I.e. a sprite object that is partly visible. 951 typedef struct vissprite_s 952 { 953 // Doubly linked list. 954 struct vissprite_s* prev; 955 struct vissprite_s* next; 956 957 // Screen x range. 958 int x1, x2; 959 960 // global bottom / top for silhouette clipping, world coordinates 961 fixed_t gz_bot; 962 fixed_t gz_top; 963 964 fixed_t scale; 965 966 // texture 967 fixed_t tex_x1; // texture x at vis x1, fractional 968 fixed_t tex_x_iscale; // x texture step per pixel 969 // negative if flipped 970 971 fixed_t texturemid; 972 lumpnum_t patch_lumpnum; 973 974 // for color translation and shadow draw, 975 // maxbright frames as well 976 lighttable_t* colormap; 977 978 //Fab:29-04-98: for MF_SHADOW sprites, which translucency table to use 979 byte* translucentmap; 980 byte translucent_index; 981 982 byte dist_priority; // 0..255, when too many sprites 983 984 // SoM: 3/6/2000: sector for underwater/fake ceiling support 985 int modelsec; // -1 none 986 987 //SoM: 4/3/2000: Global colormaps! 988 extracolormap_t* extra_colormap; 989 fixed_t xscale; 990 991 sector_t * sector; // The sector containing the thing. 992 mobj_t * mobj; // The thing 993 994 // From mobj 995 uint32_t mobj_flags; // mobjflag_e, MF_, modified 996 // for line side calculation 997 fixed_t mobj_x, mobj_y; 998 // Physical bottom / top for sorting with 3D floors, world coordinates. 999 fixed_t mobj_top_z, mobj_bot_z; // modified by cuts 1000 //The actual height of the thing (for 3D floors) 1001 // fixed_t mobj_height; // unused 1002 1003 //SoM: Precalculated top and bottom screen coords for the sprite. 1004 // [WDJ] sz_ only used in r_things.c, as cut, used for clip tests. 1005 // Do not really need cut, just set sz_top, and sz_bot properly. 1006 int sz_bot; 1007 int sz_top; 1008 1009 uint8_t cut; //0 for none, bit 1 for top, bit 2 for bottom 1010 // OR of spritecut_e 1011 } vissprite_t; 1012 1013 1014 typedef enum { SRP_NULL, SRP_1, SRP_8, SRP_16 } sprite_rotation_pattern_e; 1015 1016 // 1017 // A sprite is a patch_t that is assumed to represent a three dimensional 1018 // object and may have multiple rotations pre-drawn. 1019 // Sprites are patches with a special naming convention so they can be 1020 // recognized by R_Init_Sprites. 1021 // The base name is combined with frame (F) and rotation (x) characters. 1022 // A sprite with only one patch for all views: NNNNF0. 1023 // With rotation it is named NNNNFx or NNNNFxFx, with 1024 // x = 1 .. 8, indicating the rotation. 1025 // The second frame uses Horizontal flipping (to save space), 1026 // thus NNNNF2F5 defines a mirrored patch with F2 normal and F5 flipped. 1027 // The sprite and frame specified by a thing_t 1028 // is range checked at run time. 1029 1030 // [WDJ] Tried to get better packing. 1031 // Having two levels of structure requires two levels of decoding, and 1032 // even more cache wasted due to field alignments. 1033 // This arrangement eliminates most conditional tests. 1034 // It allows storing 1-rotation sprites in a smaller allocation. 1035 // There may be enhancements later, so optimization of this structure 1036 // will be a waste of effort. Trying to put the rotation_pattern in 1037 // the structure just results in an irregular structure. 1038 1039 1040 // Per frame rotation 1041 // size 8 1042 typedef struct 1043 { 1044 lumpnum_t pat_lumpnum; // lump number of patch 1045 uint16_t spritelump_id; // into spritelumps[] 1046 byte flip; // Flip bit (1 = flip) 1047 } sprite_frot_t; 1048 1049 // Per frame, often has multiple rotations. 1050 typedef struct 1051 { 1052 byte rotation_pattern; // sprite_rotation_pattern_e 1053 } spriteframe_t; 1054 1055 1056 // 1057 // A sprite definition: a number of animation frames. 1058 // 1059 typedef struct 1060 { 1061 int numframes; 1062 byte frame_rot; // array indexing step 1063 spriteframe_t * spriteframe; // array[numframes] 1064 sprite_frot_t * framerotation; // array[numframes * frame_rot] 1065 } spritedef_t; 1066 1067 spriteframe_t * get_spriteframe( const spritedef_t * spritedef, int frame_num ); 1068 sprite_frot_t * get_framerotation( const spritedef_t * spritedef, 1069 int frame_num, byte rotation ); 1070 1071 extern const byte srp_to_num_rot[4]; 1072 1073 #endif 1074