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 } vertex_t; 73 74 75 // Forward of LineDefs, for Sectors. 76 struct line_s; 77 78 // Each sector has a degenmobj_t in its center 79 // for sound origin purposes. 80 // I suppose this does not handle sound from 81 // moving objects (doppler), because 82 // position is prolly just buffered, not 83 // updated. 84 typedef struct 85 { 86 thinker_t thinker; // not used for anything 87 fixed_t x; 88 fixed_t y; 89 fixed_t z; 90 91 } degenmobj_t; 92 93 // 94 // The SECTORS record, at runtime. 95 // Stores things/mobjs. 96 // 97 typedef struct 98 { 99 fixed_t floorheight; 100 fixed_t ceilingheight; 101 short floorpic; 102 short ceilingpic; 103 short lightlevel; 104 short special; 105 short tag; 106 107 // 0 = untraversed, 1,2 = sndlines -1 108 int soundtraversed; 109 110 // thing that made a sound (or null) 111 mobj_t* soundtarget; 112 113 // mapblock bounding box for height changes 114 int blockbox[4]; 115 116 // origin for any sounds played by the sector 117 degenmobj_t soundorg; 118 119 // if == validcount, already checked 120 int validcount; 121 122 // list of mobjs in sector 123 mobj_t* thinglist; 124 125 // thinker_t for reversable actions 126 void* specialdata; 127 128 int linecount; 129 struct line_s** lines; // [linecount] size 130 131 } sector_t; 132 133 134 135 136 // 137 // The SideDef. 138 // 139 140 typedef struct 141 { 142 // add this to the calculated texture column 143 fixed_t textureoffset; 144 145 // add this to the calculated texture top 146 fixed_t rowoffset; 147 148 // Texture indices. 149 // We do not maintain names here. 150 short toptexture; 151 short bottomtexture; 152 short midtexture; 153 154 // Sector the SideDef is facing. 155 sector_t* sector; 156 157 } side_t; 158 159 160 161 // 162 // Move clipping aid for LineDefs. 163 // 164 typedef enum 165 { 166 ST_HORIZONTAL, 167 ST_VERTICAL, 168 ST_POSITIVE, 169 ST_NEGATIVE 170 171 } slopetype_t; 172 173 174 175 typedef struct line_s 176 { 177 // Vertices, from v1 to v2. 178 vertex_t* v1; 179 vertex_t* v2; 180 181 // Precalculated v2 - v1 for side checking. 182 fixed_t dx; 183 fixed_t dy; 184 185 // Animation related. 186 short flags; 187 short special; 188 short tag; 189 190 // Visual appearance: SideDefs. 191 // sidenum[1] will be -1 if one sided 192 short sidenum[2]; 193 194 // Neat. Another bounding box, for the extent 195 // of the LineDef. 196 fixed_t bbox[4]; 197 198 // To aid move clipping. 199 slopetype_t slopetype; 200 201 // Front and back sector. 202 // Note: redundant? Can be retrieved from SideDefs. 203 sector_t* frontsector; 204 sector_t* backsector; 205 206 // if == validcount, already checked 207 int validcount; 208 209 // thinker_t for reversable actions 210 void* specialdata; 211 } line_t; 212 213 214 215 216 // 217 // A SubSector. 218 // References a Sector. 219 // Basically, this is a list of LineSegs, 220 // indicating the visible walls that define 221 // (all or some) sides of a convex BSP leaf. 222 // 223 typedef struct subsector_s 224 { 225 sector_t* sector; 226 short numlines; 227 short firstline; 228 229 } subsector_t; 230 231 232 233 // 234 // The LineSeg. 235 // 236 typedef struct 237 { 238 vertex_t* v1; 239 vertex_t* v2; 240 241 fixed_t offset; 242 243 angle_t angle; 244 245 side_t* sidedef; 246 line_t* linedef; 247 248 // Sector references. 249 // Could be retrieved from linedef, too. 250 // backsector is NULL for one sided lines 251 sector_t* frontsector; 252 sector_t* backsector; 253 254 } seg_t; 255 256 257 258 // 259 // BSP node. 260 // 261 typedef struct 262 { 263 // Partition line. 264 fixed_t x; 265 fixed_t y; 266 fixed_t dx; 267 fixed_t dy; 268 269 // Bounding box for each child. 270 fixed_t bbox[2][4]; 271 272 // If NF_SUBSECTOR its a subsector. 273 unsigned short children[2]; 274 275 } node_t; 276 277 278 279 280 // PC direct to screen pointers 281 //B UNUSED - keep till detailshift in r_draw.c resolved 282 //extern byte* destview; 283 //extern byte* destscreen; 284 285 286 287 288 289 // 290 // OTHER TYPES 291 // 292 293 // This could be wider for >8 bit display. 294 // Indeed, true color support is posibble 295 // precalculating 24bpp lightmap/colormap LUT. 296 // from darkening PLAYPAL to all black. 297 // Could even us emore than 32 levels. 298 typedef byte lighttable_t; 299 300 301 302 303 // 304 // ? 305 // 306 typedef struct drawseg_s 307 { 308 seg_t* curline; 309 int x1; 310 int x2; 311 312 fixed_t scale1; 313 fixed_t scale2; 314 fixed_t scalestep; 315 316 // 0=none, 1=bottom, 2=top, 3=both 317 int silhouette; 318 319 // do not clip sprites above this 320 fixed_t bsilheight; 321 322 // do not clip sprites below this 323 fixed_t tsilheight; 324 325 // Pointers to lists for sprite clipping, 326 // all three adjusted so [x1] is first value. 327 short* sprtopclip; 328 short* sprbottomclip; 329 short* maskedtexturecol; 330 331 } drawseg_t; 332 333 334 335 // A vissprite_t is a thing 336 // that will be drawn during a refresh. 337 // I.e. a sprite object that is partly visible. 338 typedef struct vissprite_s 339 { 340 // Doubly linked list. 341 struct vissprite_s* prev; 342 struct vissprite_s* next; 343 344 int x1; 345 int x2; 346 347 // for line side calculation 348 fixed_t gx; 349 fixed_t gy; 350 351 // global bottom / top for silhouette clipping 352 fixed_t gz; 353 fixed_t gzt; 354 355 // horizontal position of x1 356 fixed_t startfrac; 357 358 fixed_t scale; 359 360 // negative if flipped 361 fixed_t xiscale; 362 363 fixed_t texturemid; 364 int patch; 365 366 // for color translation and shadow draw, 367 // maxbright frames as well 368 lighttable_t* colormap; 369 370 int mobjflags; 371 372 } vissprite_t; 373 374 375 // 376 // Sprites are patches with a special naming convention 377 // so they can be recognized by R_InitSprites. 378 // The base name is NNNNFx or NNNNFxFx, with 379 // x indicating the rotation, x = 0, 1-7. 380 // The sprite and frame specified by a thing_t 381 // is range checked at run time. 382 // A sprite is a patch_t that is assumed to represent 383 // a three dimensional object and may have multiple 384 // rotations pre drawn. 385 // Horizontal flipping is used to save space, 386 // thus NNNNF2F5 defines a mirrored patch. 387 // Some sprites will only have one picture used 388 // for all views: NNNNF0 389 // 390 typedef struct 391 { 392 // If false use 0 for any position. 393 // Note: as eight entries are available, 394 // we might as well insert the same name eight times. 395 boolean rotate; 396 397 // Lump to use for view angles 0-7. 398 short lump[8]; 399 400 // Flip bit (1 = flip) to use for view angles 0-7. 401 byte flip[8]; 402 403 } spriteframe_t; 404 405 406 407 // 408 // A sprite definition: 409 // a number of animation frames. 410 // 411 typedef struct 412 { 413 int numframes; 414 spriteframe_t* spriteframes; 415 416 } spritedef_t; 417 418 419 420 // 421 // Now what is a visplane, anyway? 422 // 423 typedef struct 424 { 425 fixed_t height; 426 int picnum; 427 int lightlevel; 428 int minx; 429 int maxx; 430 431 // leave pads for [minx-1]/[maxx+1] 432 433 byte pad1; 434 // Here lies the rub for all 435 // dynamic resize/change of resolution. 436 byte top[SCREENWIDTH]; 437 byte pad2; 438 byte pad3; 439 // See above. 440 byte bottom[SCREENWIDTH]; 441 byte pad4; 442 443 } visplane_t; 444 445 446 447 448 #endif 449