1 // 2 // Copyright(C) 1993-1996 Id Software, Inc. 3 // Copyright(C) 2005-2014 Simon Howard 4 // 5 // This program is free software; you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License 7 // as published by the Free Software Foundation; either version 2 8 // of the License, or (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // DESCRIPTION: 16 // Refresh/rendering module, shared data struct definitions. 17 // 18 19 20 #ifndef __R_DEFS__ 21 #define __R_DEFS__ 22 23 24 // Screenwidth. 25 #include "doomdef.h" 26 27 // Some more or less basic data types 28 // we depend on. 29 #include "m_fixed.h" 30 31 // We rely on the thinker data struct 32 // to handle sound origins in sectors. 33 #include "d_think.h" 34 // SECTORS do store MObjs anyway. 35 #include "p_mobj.h" 36 37 #include "i_video.h" 38 39 #include "v_patch.h" 40 41 42 43 44 // Silhouette, needed for clipping Segs (mainly) 45 // and sprites representing things. 46 #define SIL_NONE 0 47 #define SIL_BOTTOM 1 48 #define SIL_TOP 2 49 #define SIL_BOTH 3 50 51 #define MAXDRAWSEGS 256 52 53 54 55 56 57 // 58 // INTERNAL MAP TYPES 59 // used by play and refresh 60 // 61 62 // 63 // Your plain vanilla vertex. 64 // Note: transformed values not buffered locally, 65 // like some DOOM-alikes ("wt", "WebView") did. 66 // 67 typedef struct 68 { 69 fixed_t x; 70 fixed_t y; 71 72 // [crispy] remove slime trails 73 // vertex coordinates *only* used in rendering that have been 74 // moved towards the linedef associated with their seg by projecting them 75 // using the law of cosines in p_setup.c:P_RemoveSlimeTrails(); 76 fixed_t r_x; 77 fixed_t r_y; 78 boolean moved; 79 } vertex_t; 80 81 82 // Forward of LineDefs, for Sectors. 83 struct line_s; 84 85 // Each sector has a degenmobj_t in its center 86 // for sound origin purposes. 87 // I suppose this does not handle sound from 88 // moving objects (doppler), because 89 // position is prolly just buffered, not 90 // updated. 91 typedef struct 92 { 93 thinker_t thinker; // not used for anything 94 fixed_t x; 95 fixed_t y; 96 fixed_t z; 97 98 } degenmobj_t; 99 100 // 101 // The SECTORS record, at runtime. 102 // Stores things/mobjs. 103 // 104 typedef struct 105 { 106 fixed_t floorheight; 107 fixed_t ceilingheight; 108 short floorpic; 109 short ceilingpic; 110 short lightlevel; 111 short special; 112 short tag; 113 114 // 0 = untraversed, 1,2 = sndlines -1 115 int soundtraversed; 116 117 // thing that made a sound (or null) 118 mobj_t* soundtarget; 119 120 // mapblock bounding box for height changes 121 int blockbox[4]; 122 123 // origin for any sounds played by the sector 124 degenmobj_t soundorg; 125 126 // if == validcount, already checked 127 int validcount; 128 129 // list of mobjs in sector 130 mobj_t* thinglist; 131 132 // thinker_t for reversable actions 133 void* specialdata; 134 135 int linecount; 136 struct line_s** lines; // [linecount] size 137 138 // [crispy] WiggleFix: [kb] for R_FixWiggle() 139 int cachedheight; 140 int scaleindex; 141 142 // [crispy] add support for MBF sky tranfers 143 int sky; 144 145 // [AM] Previous position of floor and ceiling before 146 // think. Used to interpolate between positions. 147 fixed_t oldfloorheight; 148 fixed_t oldceilingheight; 149 150 // [AM] Gametic when the old positions were recorded. 151 // Has a dual purpose; it prevents movement thinkers 152 // from storing old positions twice in a tic, and 153 // prevents the renderer from attempting to interpolate 154 // if old values were not updated recently. 155 int oldgametic; 156 157 // [AM] Interpolated floor and ceiling height. 158 // Calculated once per tic and used inside 159 // the renderer. 160 fixed_t interpfloorheight; 161 fixed_t interpceilingheight; 162 163 // [crispy] revealed secrets 164 short oldspecial; 165 166 // [crispy] A11Y light level used for rendering 167 short rlightlevel; 168 } sector_t; 169 170 171 172 173 // 174 // The SideDef. 175 // 176 177 typedef struct 178 { 179 // add this to the calculated texture column 180 fixed_t textureoffset; 181 182 // add this to the calculated texture top 183 fixed_t rowoffset; 184 185 // Texture indices. 186 // We do not maintain names here. 187 short toptexture; 188 short bottomtexture; 189 short midtexture; 190 191 // Sector the SideDef is facing. 192 sector_t* sector; 193 194 // [crispy] smooth texture scrolling 195 fixed_t basetextureoffset; 196 } side_t; 197 198 199 200 // 201 // Move clipping aid for LineDefs. 202 // 203 typedef enum 204 { 205 ST_HORIZONTAL, 206 ST_VERTICAL, 207 ST_POSITIVE, 208 ST_NEGATIVE 209 210 } slopetype_t; 211 212 213 214 typedef struct line_s 215 { 216 // Vertices, from v1 to v2. 217 vertex_t* v1; 218 vertex_t* v2; 219 220 // Precalculated v2 - v1 for side checking. 221 fixed_t dx; 222 fixed_t dy; 223 224 // Animation related. 225 unsigned short flags; // [crispy] extended nodes 226 short special; 227 short tag; 228 229 // Visual appearance: SideDefs. 230 // sidenum[1] will be -1 (NO_INDEX) if one sided 231 unsigned short sidenum[2]; // [crispy] extended nodes 232 233 // Neat. Another bounding box, for the extent 234 // of the LineDef. 235 fixed_t bbox[4]; 236 237 // To aid move clipping. 238 slopetype_t slopetype; 239 240 // Front and back sector. 241 // Note: redundant? Can be retrieved from SideDefs. 242 sector_t* frontsector; 243 sector_t* backsector; 244 245 // if == validcount, already checked 246 int validcount; 247 248 // thinker_t for reversable actions 249 void* specialdata; 250 251 // [crispy] calculate sound origin of line to be its midpoint 252 degenmobj_t soundorg; 253 } line_t; 254 255 256 257 258 // 259 // A SubSector. 260 // References a Sector. 261 // Basically, this is a list of LineSegs, 262 // indicating the visible walls that define 263 // (all or some) sides of a convex BSP leaf. 264 // 265 typedef struct subsector_s 266 { 267 sector_t* sector; 268 int numlines; // [crispy] extended nodes 269 int firstline; // [crispy] extended nodes 270 271 } subsector_t; 272 273 274 275 // 276 // The LineSeg. 277 // 278 typedef struct 279 { 280 vertex_t* v1; 281 vertex_t* v2; 282 283 fixed_t offset; 284 285 angle_t angle; 286 287 side_t* sidedef; 288 line_t* linedef; 289 290 // Sector references. 291 // Could be retrieved from linedef, too. 292 // backsector is NULL for one sided lines 293 sector_t* frontsector; 294 sector_t* backsector; 295 296 uint32_t length; // [crispy] fix long wall wobble 297 angle_t r_angle; // [crispy] re-calculated angle used for rendering 298 int fakecontrast; 299 } seg_t; 300 301 302 303 // 304 // BSP node. 305 // 306 typedef struct 307 { 308 // Partition line. 309 fixed_t x; 310 fixed_t y; 311 fixed_t dx; 312 fixed_t dy; 313 314 // Bounding box for each child. 315 fixed_t bbox[2][4]; 316 317 // If NF_SUBSECTOR its a subsector. 318 int children[2]; // [crispy] extended nodes 319 320 } node_t; 321 322 323 324 325 // PC direct to screen pointers 326 //B UNUSED - keep till detailshift in r_draw.c resolved 327 //extern byte* destview; 328 //extern byte* destscreen; 329 330 331 332 333 334 // 335 // OTHER TYPES 336 // 337 338 // This could be wider for >8 bit display. 339 // Indeed, true color support is posibble 340 // precalculating 24bpp lightmap/colormap LUT. 341 // from darkening PLAYPAL to all black. 342 // Could even us emore than 32 levels. 343 typedef pixel_t lighttable_t; 344 345 346 347 348 // 349 // ? 350 // 351 typedef struct drawseg_s 352 { 353 seg_t* curline; 354 int x1; 355 int x2; 356 357 fixed_t scale1; 358 fixed_t scale2; 359 fixed_t scalestep; 360 361 // 0=none, 1=bottom, 2=top, 3=both 362 int silhouette; 363 364 // do not clip sprites above this 365 fixed_t bsilheight; 366 367 // do not clip sprites below this 368 fixed_t tsilheight; 369 370 // Pointers to lists for sprite clipping, 371 // all three adjusted so [x1] is first value. 372 int* sprtopclip; // [crispy] 32-bit integer math 373 int* sprbottomclip; // [crispy] 32-bit integer math 374 int* maskedtexturecol; // [crispy] 32-bit integer math 375 376 } drawseg_t; 377 378 379 380 // A vissprite_t is a thing 381 // that will be drawn during a refresh. 382 // I.e. a sprite object that is partly visible. 383 typedef struct vissprite_s 384 { 385 // Doubly linked list. 386 struct vissprite_s* prev; 387 struct vissprite_s* next; 388 389 int x1; 390 int x2; 391 392 // for line side calculation 393 fixed_t gx; 394 fixed_t gy; 395 396 // global bottom / top for silhouette clipping 397 fixed_t gz; 398 fixed_t gzt; 399 400 // horizontal position of x1 401 fixed_t startfrac; 402 403 fixed_t scale; 404 405 // negative if flipped 406 fixed_t xiscale; 407 408 fixed_t texturemid; 409 int patch; 410 411 // for color translation and shadow draw, 412 // maxbright frames as well 413 // [crispy] brightmaps for select sprites 414 lighttable_t* colormap[2]; 415 byte *brightmap; 416 417 int mobjflags; 418 // [crispy] color translation table for blood colored by monster class 419 byte* translation; 420 #ifdef CRISPY_TRUECOLOR 421 const pixel_t (*blendfunc)(const pixel_t fg, const pixel_t bg); 422 #endif 423 424 } vissprite_t; 425 426 427 // 428 // Sprites are patches with a special naming convention 429 // so they can be recognized by R_InitSprites. 430 // The base name is NNNNFx or NNNNFxFx, with 431 // x indicating the rotation, x = 0, 1-7. 432 // The sprite and frame specified by a thing_t 433 // is range checked at run time. 434 // A sprite is a patch_t that is assumed to represent 435 // a three dimensional object and may have multiple 436 // rotations pre drawn. 437 // Horizontal flipping is used to save space, 438 // thus NNNNF2F5 defines a mirrored patch. 439 // Some sprites will only have one picture used 440 // for all views: NNNNF0 441 // 442 typedef struct 443 { 444 // If false use 0 for any position. 445 // Note: as eight entries are available, 446 // we might as well insert the same name eight times. 447 int rotate; // [crispy] we use a value of 2 for 16 sprite rotations 448 449 // Lump to use for view angles 0-7. 450 short lump[16]; // [crispy] support 16 sprite rotations 451 452 // Flip bit (1 = flip) to use for view angles 0-7. 453 byte flip[16]; // [crispy] support 16 sprite rotations 454 455 } spriteframe_t; 456 457 458 459 // 460 // A sprite definition: 461 // a number of animation frames. 462 // 463 typedef struct 464 { 465 int numframes; 466 spriteframe_t* spriteframes; 467 468 } spritedef_t; 469 470 471 472 // 473 // Now what is a visplane, anyway? 474 // 475 typedef struct 476 { 477 fixed_t height; 478 int picnum; 479 int lightlevel; 480 int minx; 481 int maxx; 482 483 // leave pads for [minx-1]/[maxx+1] 484 485 unsigned int pad1; // [crispy] hires / 32-bit integer math 486 // Here lies the rub for all 487 // dynamic resize/change of resolution. 488 unsigned int top[MAXWIDTH]; // [crispy] hires / 32-bit integer math 489 unsigned int pad2; // [crispy] hires / 32-bit integer math 490 unsigned int pad3; // [crispy] hires / 32-bit integer math 491 // See above. 492 unsigned int bottom[MAXWIDTH]; // [crispy] hires / 32-bit integer math 493 unsigned int pad4; // [crispy] hires / 32-bit integer math 494 495 } visplane_t; 496 497 typedef struct 498 { 499 char c; 500 char a[9]; 501 int l, w, h; 502 } laserpatch_t; 503 extern laserpatch_t *laserpatch; 504 505 506 507 #endif 508