1 /* R_local.h */ 2 3 #ifndef __R_LOCAL__ 4 #define __R_LOCAL__ 5 6 #include "doomdef.h" 7 8 #define ANGLETOSKYSHIFT 22 /* sky map is 256*128*4 maps */ 9 10 /* #define BASEYCENTER 100 */ 11 #define BASEYCENTER (100-((screenheight-200)/12)) 12 /* #define BASEYCENTER (60+(8000/screenheight)) */ 13 14 #define MAXWIDTH 1120 15 #define MAXHEIGHT 832 16 17 #ifdef HAVE_MATH_H 18 #include <math.h> 19 #else 20 #define PI 3.141592657 21 #endif 22 23 #define CENTERY (screenheight/2) 24 25 #define MINZ (FRACUNIT*4) 26 27 #define FIELDOFVIEW 2048 /* fineangles in the SCREENWIDTH wide window */ 28 29 /* 30 * lighting constants 31 */ 32 #define LIGHTLEVELS 16 33 #define LIGHTSEGSHIFT 4 34 #define MAXLIGHTSCALE 48 35 #define LIGHTSCALESHIFT 12 36 #define MAXLIGHTZ 128 37 #define LIGHTZSHIFT 20 38 #define NUMCOLORMAPS 32 /* number of diminishing */ 39 #define INVERSECOLORMAP 32 40 41 #define WALL_ARRAY /* For GLHeretic (don't use CallLists for walls, if enable) */ 42 43 /* 44 ============================================================================== 45 46 INTERNAL MAP TYPES 47 48 ============================================================================== 49 */ 50 51 /* ================ used by play and refresh */ 52 53 typedef struct 54 { 55 fixed_t x,y; 56 } vertex_t; 57 58 struct line_s; 59 60 typedef struct 61 { 62 #ifdef GL_HERETIC 63 int iSectorID; 64 #endif 65 fixed_t floorheight, ceilingheight; 66 #ifdef WALL_ARRAY 67 fixed_t Prevfloorheight, Prevceilingheight; 68 #endif 69 short floorpic, ceilingpic; 70 short lightlevel; 71 short special, tag; 72 73 int soundtraversed; /* 0 = untraversed, 1,2 = sndlines -1 */ 74 mobj_t *soundtarget; /* thing that made a sound (or null) */ 75 76 int blockbox[4]; /* mapblock bounding box for height changes */ 77 degenmobj_t soundorg; /* for any sounds played by the sector */ 78 79 int validcount; /* if == validcount, already checked */ 80 mobj_t *thinglist; /* list of mobjs in sector */ 81 void *specialdata; /* thinker_t for reversable actions */ 82 int linecount; 83 struct line_s **lines; /* [linecount] size */ 84 } sector_t; 85 86 typedef struct 87 { 88 fixed_t textureoffset; /* add this to the calculated texture col */ 89 fixed_t rowoffset; /* add this to the calculated texture top */ 90 short toptexture, bottomtexture, midtexture; 91 sector_t *sector; 92 } side_t; 93 94 typedef enum 95 { 96 ST_HORIZONTAL, 97 ST_VERTICAL, 98 ST_POSITIVE, 99 ST_NEGATIVE 100 } slopetype_t; 101 102 typedef struct line_s 103 { 104 #ifdef GL_HERETIC 105 int iLineID; 106 #endif 107 vertex_t *v1, *v2; 108 fixed_t dx,dy; /* v2 - v1 for side checking */ 109 short flags; 110 short special, tag; 111 short sidenum[2]; /* sidenum[1] will be -1 if one sided */ 112 fixed_t bbox[4]; 113 slopetype_t slopetype; /* to aid move clipping */ 114 sector_t *frontsector, *backsector; 115 int validcount; /* if == validcount, already checked */ 116 void *specialdata; /* thinker_t for reversable actions */ 117 } line_t; 118 119 120 typedef struct subsector_s 121 { 122 sector_t *sector; 123 short numlines; 124 short firstline; 125 } subsector_t; 126 127 typedef struct 128 { 129 vertex_t *v1, *v2; 130 fixed_t offset; 131 angle_t angle; 132 side_t *sidedef; 133 line_t *linedef; 134 sector_t *frontsector; 135 sector_t *backsector; /* NULL for one sided lines */ 136 } seg_t; 137 138 typedef struct 139 { 140 fixed_t x,y,dx,dy; /* partition line */ 141 fixed_t bbox[2][4]; /* bounding box for each child */ 142 unsigned short children[2]; /* if NF_SUBSECTOR its a subsector */ 143 } node_t; 144 145 146 /* 147 ============================================================================== 148 149 OTHER TYPES 150 151 ============================================================================== 152 */ 153 154 typedef byte lighttable_t; /* this could be wider for >8 bit display */ 155 156 #define MAXVISPLANES 256 157 #define MAXOPENINGS screenwidth*64 158 159 /* 160 typedef struct 161 { 162 fixed_t height; 163 int picnum; 164 int lightlevel; 165 int special; 166 int minx, maxx; 167 unsigned short pad1; 168 unsigned short *top; 169 unsigned short pad2; 170 unsigned short pad3; 171 unsigned short *bottom; 172 unsigned short pad4; 173 } visplane_t; 174 */ 175 176 typedef struct 177 { 178 fixed_t height; 179 int picnum; 180 int lightlevel; 181 int special; 182 int minx, maxx; 183 byte pad1; 184 unsigned short *top; 185 byte pad2; 186 byte pad3; 187 unsigned short *bottom; 188 byte pad4; 189 } visplane_t; 190 191 typedef struct drawseg_s 192 { 193 seg_t *curline; 194 int x1, x2; 195 fixed_t scale1, scale2, scalestep; 196 int silhouette; /* 0=none, 1=bottom, 2=top, 3=both */ 197 fixed_t bsilheight; /* don't clip sprites above this */ 198 fixed_t tsilheight; /* don't clip sprites below this */ 199 /* pointers to lists for sprite clipping */ 200 short *sprtopclip; /* adjusted so [x1] is first value */ 201 short *sprbottomclip; /* adjusted so [x1] is first value */ 202 short *maskedtexturecol; /* adjusted so [x1] is first value */ 203 } drawseg_t; 204 205 #define SIL_NONE 0 206 #define SIL_BOTTOM 1 207 #define SIL_TOP 2 208 #define SIL_BOTH 3 209 210 #define MAXDRAWSEGS 1024 211 212 /* A vissprite_t is a thing that will be drawn during a refresh */ 213 typedef struct vissprite_s 214 { 215 struct vissprite_s *prev, *next; 216 int x1, x2; 217 fixed_t gx, gy; /* for line side calculation */ 218 fixed_t gz, gzt; /* global bottom / top for silhouette clipping */ 219 fixed_t startfrac; /* horizontal position of x1 */ 220 fixed_t scale; 221 fixed_t xiscale; /* negative if flipped */ 222 fixed_t texturemid; 223 int patch; 224 lighttable_t *colormap; 225 int mobjflags; /* for color translation and shadow draw */ 226 boolean psprite; /* true if psprite */ 227 fixed_t footclip; /* foot clipping */ 228 } vissprite_t; 229 230 231 extern visplane_t *floorplane, *ceilingplane; 232 233 /* 234 * Sprites are patches with a special naming convention so they can be 235 * recognized by R_InitSprites. The sprite and frame specified by a 236 * thing_t is range checked at run time. 237 * a sprite is a patch_t that is assumed to represent a three dimensional 238 * object and may have multiple rotations pre drawn. Horizontal flipping 239 * is used to save space. Some sprites will only have one picture used 240 * for all views. 241 */ 242 243 typedef struct 244 { 245 boolean rotate; /* if false use 0 for any position */ 246 short lump[8]; /* lump to use for view angles 0-7 */ 247 byte flip[8]; /* flip (1 = flip) to use for view angles 0-7 */ 248 } spriteframe_t; 249 250 typedef struct 251 { 252 int numframes; 253 spriteframe_t *spriteframes; 254 } spritedef_t; 255 256 extern spritedef_t *sprites; 257 extern int numsprites; 258 259 /* ============================================================================= */ 260 261 extern int numvertexes; 262 extern vertex_t *vertexes; 263 264 extern int numsegs; 265 extern seg_t *segs; 266 267 extern int numsectors; 268 extern sector_t *sectors; 269 270 extern int numsubsectors; 271 extern subsector_t *subsectors; 272 273 extern int numnodes; 274 extern node_t *nodes; 275 276 extern int numlines; 277 extern line_t *lines; 278 279 extern int numsides; 280 extern side_t *sides; 281 282 283 284 extern fixed_t viewx, viewy, viewz; 285 extern angle_t viewangle; 286 extern player_t *viewplayer; 287 288 289 extern angle_t clipangle; 290 291 extern int viewangletox[FINEANGLES/2]; 292 extern angle_t *xtoviewangle; 293 extern fixed_t finetangent[FINEANGLES/2]; 294 295 extern fixed_t rw_distance; 296 extern angle_t rw_normalangle; 297 298 /* 299 * R_main.c 300 */ 301 extern int viewwidth, viewheight, viewwindowx, viewwindowy; 302 extern int centerx, centery; 303 extern int flyheight; 304 extern fixed_t centerxfrac; 305 extern fixed_t centeryfrac; 306 extern fixed_t projection; 307 308 extern int validcount; 309 310 extern int sscount, linecount, loopcount; 311 extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; 312 extern lighttable_t *scalelightfixed[MAXLIGHTSCALE]; 313 extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; 314 315 extern int extralight; 316 extern lighttable_t *fixedcolormap; 317 318 extern fixed_t viewcos, viewsin; 319 320 extern int detailshift; /* 0 = high, 1 = low */ 321 322 extern fixed_t skyiscale; 323 324 extern void (*colfunc) (void); 325 extern void (*basecolfunc) (void); 326 extern void (*fuzzcolfunc) (void); 327 extern void (*spanfunc) (void); 328 329 int R_PointOnSide (fixed_t x, fixed_t y, node_t *node); 330 int R_PointOnSegSide (fixed_t x, fixed_t y, seg_t *line); 331 angle_t R_PointToAngle (fixed_t x, fixed_t y); 332 angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); 333 fixed_t R_PointToDist (fixed_t x, fixed_t y); 334 fixed_t R_ScaleFromGlobalAngle (angle_t visangle); 335 subsector_t *R_PointInSubsector (fixed_t x, fixed_t y); 336 void R_AddPointToBox (int x, int y, fixed_t *box); 337 338 339 /* 340 * R_bsp.c 341 */ 342 extern seg_t *curline; 343 extern side_t *sidedef; 344 extern line_t *linedef; 345 extern sector_t *frontsector, *backsector; 346 347 extern int rw_x; 348 extern int rw_stopx; 349 350 extern boolean segtextured; 351 extern boolean markfloor; /* false if the back side is the same plane */ 352 extern boolean markceiling; 353 extern boolean skymap; 354 355 extern drawseg_t drawsegs[MAXDRAWSEGS], *ds_p; 356 357 extern lighttable_t **hscalelight, **vscalelight, **dscalelight; 358 359 typedef void (*drawfunc_t) (int start, int stop); 360 void R_ClearClipSegs (void); 361 362 void R_ClearDrawSegs (void); 363 void R_InitSkyMap (void); 364 void R_RenderBSPNode (int bspnum); 365 366 /* 367 * R_segs.c 368 */ 369 extern int rw_angle1; /* angle to line origin */ 370 371 void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2); 372 373 374 /* 375 * R_plane.c 376 */ 377 typedef void (*planefunction_t) (int top, int bottom); 378 extern planefunction_t floorfunc, ceilingfunc; 379 380 extern int skyflatnum; 381 382 extern short *openings, *lastopening; 383 384 extern short *floorclip; 385 extern short *ceilingclip; 386 387 extern fixed_t *yslope; 388 extern fixed_t *distscale; 389 390 void R_InitPlanes (void); 391 void R_ClearPlanes (void); 392 void R_MapPlane (int y, int x1, int x2); 393 void R_MakeSpans (int x, int t1, int b1, int t2, int b2); 394 void R_DrawPlanes (void); 395 396 visplane_t *R_FindPlane (fixed_t height, int picnum, int lightlevel, 397 int special); 398 visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop); 399 400 401 /* 402 * R_debug.m 403 */ 404 extern int drawbsp; 405 406 void RD_OpenMapWindow (void); 407 void RD_ClearMapWindow (void); 408 void RD_DisplayLine (int x1, int y1, int x2, int y2, float gray); 409 void RD_DrawNodeLine (node_t *node); 410 void RD_DrawLineCheck (seg_t *line); 411 void RD_DrawLine (seg_t *line); 412 void RD_DrawBBox (fixed_t *bbox); 413 414 415 /* 416 * R_data.c 417 */ 418 extern fixed_t *textureheight; /* needed for texture pegging */ 419 extern fixed_t *spritewidth; /* needed for pre rendering (fracs) */ 420 extern fixed_t *spriteoffset; 421 extern fixed_t *spritetopoffset; 422 extern lighttable_t *colormaps; 423 extern int viewwidth, scaledviewwidth, viewheight; 424 extern int firstflat; 425 extern int numflats; 426 427 extern int *flattranslation; /* for global animation */ 428 extern int *texturetranslation; /* for global animation */ 429 430 extern int firstspritelump, lastspritelump, numspritelumps; 431 432 byte *R_GetColumn (int tex, int col); 433 void R_InitData (void); 434 void R_PrecacheLevel (void); 435 436 437 /* 438 * R_things.c 439 */ 440 #define MAXVISSPRITES 256 441 442 extern vissprite_t vissprites[MAXVISSPRITES], *vissprite_p; 443 extern vissprite_t vsprsortedhead; 444 445 /* constant arrays used for psprite clipping and initializing clipping */ 446 extern short *negonearray; 447 extern short *screenheightarray; 448 449 /* vars for R_DrawMaskedColumn */ 450 extern short *mfloorclip; 451 extern short *mceilingclip; 452 extern fixed_t spryscale; 453 extern fixed_t sprtopscreen; 454 extern fixed_t sprbotscreen; 455 456 extern fixed_t pspritescale, pspriteiscale, pspriteyscale; 457 458 459 void R_DrawMaskedColumn (column_t *column, signed int baseclip); 460 461 462 void R_SortVisSprites (void); 463 464 void R_AddSprites (sector_t *sec); 465 void R_AddPSprites (void); 466 void R_DrawSprites (void); 467 void R_InitSprites (char **namelist); 468 void R_ClearSprites (void); 469 void R_DrawMasked (void); 470 void R_ClipVisSprite (vissprite_t *vis, int xl, int xh); 471 472 /* 473 * ============================================================================= 474 * 475 * R_draw.c 476 * 477 * ============================================================================= 478 */ 479 480 extern lighttable_t *dc_colormap; 481 extern int dc_x; 482 extern int dc_yl; 483 extern int dc_yh; 484 extern fixed_t dc_iscale; 485 extern fixed_t dc_texturemid; 486 extern byte *dc_source; /* first pixel in a column */ 487 488 void R_DrawColumn (void); 489 void R_DrawColumnLow (void); 490 void R_DrawFuzzColumn (void); 491 void R_DrawFuzzColumnLow (void); 492 void R_DrawTranslatedColumn (void); 493 void R_DrawTranslatedFuzzColumn (void); 494 void R_DrawTranslatedColumnLow (void); 495 496 extern int ds_y; 497 extern int ds_x1; 498 extern int ds_x2; 499 extern lighttable_t *ds_colormap; 500 extern fixed_t ds_xfrac; 501 extern fixed_t ds_yfrac; 502 extern fixed_t ds_xstep; 503 extern fixed_t ds_ystep; 504 extern byte *ds_source; /* start of a 64*64 tile image */ 505 506 extern byte *translationtables; 507 extern byte *dc_translation; 508 509 void R_DrawSpan (void); 510 void R_DrawSpanLow (void); 511 512 void R_InitBuffer (int width, int height); 513 void R_InitTranslationTables (void); 514 515 #endif /* __R_LOCAL__ */ 516 517 518