6 #define ANGLETOSKYSHIFT 22 // sky map is 256*128*4 maps
8 #define BASEYCENTER 100
13 #define PI 3.141592657
15 #define CENTERY (SCREENHEIGHT/2)
17 #define MINZ (FRACUNIT*4)
19 #define FIELDOFVIEW 2048 // fineangles in the SCREENWIDTH wide window
24 #define LIGHTLEVELS 16
25 #define LIGHTSEGSHIFT 4
26 #define MAXLIGHTSCALE 48
27 #define LIGHTSCALESHIFT 12
29 #define LIGHTZSHIFT 20
30 #define NUMCOLORMAPS 32 // number of diminishing
31 #define INVERSECOLORMAP 32
34 ==============================================================================
38 ==============================================================================
41 //================ used by play and refresh
52 fixed_t floorheight, ceilingheight;
53 short floorpic, ceilingpic;
57 int soundtraversed; // 0 = untraversed, 1,2 = sndlines -1
58 mobj_t *soundtarget; // thing that made a sound (or null)
60 int blockbox[4]; // mapblock bounding box for height changes
61 degenmobj_t soundorg; // for any sounds played by the sector
63 int validcount; // if == validcount, already checked
64 mobj_t *thinglist; // list of mobjs in sector
65 void *specialdata; // thinker_t for reversable actions
67 struct line_s **lines; // [linecount] size
69 int flatoffx, flatoffy; // Scrolling flats.
70 int skyfix; // Offset to ceiling height rendering w/sky.
76 fixed_t textureoffset; // add this to the calculated texture col
77 fixed_t rowoffset; // add this to the calculated texture top
78 short toptexture, bottomtexture, midtexture;
82 typedef enum {ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE} slopetype_t;
87 fixed_t dx,dy; // v2 - v1 for side checking
90 short sidenum[2]; // sidenum[1] will be -1 if one sided
92 slopetype_t slopetype; // to aid move clipping
93 sector_t *frontsector, *backsector;
94 int validcount; // if == validcount, already checked
95 void *specialdata; // thinker_t for reversable actions
105 typedef struct subsector_s
111 // Sorted edge vertices for rendering floors and ceilings.
113 fvertex_t* edgeverts; // A list of edge vertices.
114 fvertex_t* origedgeverts; // Unmodified, accurate edge vertices.
115 fvertex_t bbox[2]; // Min and max points.
116 fvertex_t midpoint; // Center of bounding box.
128 sector_t *frontsector;
129 sector_t *backsector; // NULL for one sided lines
131 float len; // Length of the segment (v1 -> v2) for texture mapping.
138 fixed_t x,y,dx,dy; // partition line
139 fixed_t bbox[2][4]; // bounding box for each child
140 unsigned short children[2]; // if NF_SUBSECTOR its a subsector
145 int originx; // block origin (allways UL), which has allready
146 int originy; // accounted for the patch's internal origin
150 // a maptexturedef_t describes a rectangular texture, which is composed of one
151 // or more mappatch_t structures that arrange graphic patches
154 char name[8]; // for switch changing, etc
158 texpatch_t patches[1]; // [patchcount] drawn back to front
159 // into the cached texture
161 boolean masked; // from maptexture_t
166 ==============================================================================
170 ==============================================================================
173 typedef byte lighttable_t; // this could be wider for >8 bit display
175 #define MAXVISPLANES 128
176 #define MAXOPENINGS SCREENWIDTH*64
185 byte pad1; // leave pads for [minx-1]/[maxx+1]
186 byte top[SCREENWIDTH];
189 byte bottom[SCREENWIDTH];
193 typedef struct drawseg_s
197 fixed_t scale1, scale2, scalestep;
198 int silhouette; // 0=none, 1=bottom, 2=top, 3=both
199 fixed_t bsilheight; // don't clip sprites above this
200 fixed_t tsilheight; // don't clip sprites below this
201 // pointers to lists for sprite clipping
202 short *sprtopclip; // adjusted so [x1] is first value
203 short *sprbottomclip; // adjusted so [x1] is first value
204 short *maskedtexturecol; // adjusted so [x1] is first value
212 #define MAXDRAWSEGS 256
214 // A vissprite_t is a thing that will be drawn during a refresh
215 typedef struct vissprite_s
217 struct vissprite_s *prev, *next;
219 fixed_t gx, gy; // for line side calculation
220 fixed_t gz, gzt; // global bottom / top for silhouette clipping
221 fixed_t startfrac; // horizontal position of x1
223 fixed_t xiscale; // negative if flipped
228 float v1[2], v2[2]; // The vertices (v1 is the left one).
229 float secfloor, secceil;
231 lighttable_t *colormap;
233 int mobjflags; // for color translation and shadow draw
234 boolean psprite; // true if psprite
235 fixed_t footclip; // foot clipping
239 extern visplane_t *floorplane, *ceilingplane;
241 // Sprites are patches with a special naming convention so they can be
242 // recognized by R_InitSprites. The sprite and frame specified by a
243 // thing_t is range checked at run time.
244 // a sprite is a patch_t that is assumed to represent a three dimensional
245 // object and may have multiple rotations pre drawn. Horizontal flipping
246 // is used to save space. Some sprites will only have one picture used
251 boolean rotate; // if false use 0 for any position
252 short lump[8]; // lump to use for view angles 0-7
253 byte flip[8]; // flip (1 = flip) to use for view angles 0-7
259 spriteframe_t *spriteframes;
262 extern spritedef_t *sprites;
263 extern int numsprites;
265 //=============================================================================
267 extern int numvertexes;
268 extern vertex_t *vertexes;
273 extern int numsectors;
274 extern sector_t *sectors;
276 extern int numsubsectors;
277 extern subsector_t *subsectors;
280 extern node_t *nodes;
283 extern line_t *lines;
286 extern side_t *sides;
290 extern fixed_t viewx, viewy, viewz;
291 extern angle_t viewangle;
292 extern player_t *viewplayer;
295 extern float viewpitch;
296 extern int sbarscale;
299 extern angle_t clipangle;
301 extern int viewangletox[FINEANGLES/2];
302 extern angle_t xtoviewangle[SCREENWIDTH+1];
303 extern fixed_t finetangent[FINEANGLES/2];
305 extern fixed_t rw_distance;
306 extern angle_t rw_normalangle;
311 extern int viewwidth, viewheight, viewwindowx, viewwindowy;
312 extern int centerx, centery;
313 extern int flyheight;
314 extern fixed_t centerxfrac;
315 extern fixed_t centeryfrac;
316 extern fixed_t projection;
318 extern int validcount;
320 extern int sscount, linecount, loopcount;
321 extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
322 extern lighttable_t *scalelightfixed[MAXLIGHTSCALE];
323 extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
325 extern int extralight;
326 extern lighttable_t *fixedcolormap;
328 extern fixed_t viewcos, viewsin;
330 extern int detailshift; // 0 = high, 1 = low
332 extern void (*colfunc) (void);
333 extern void (*basecolfunc) (void);
334 extern void (*fuzzcolfunc) (void);
335 extern void (*spanfunc) (void);
337 int R_PointOnSide (fixed_t x, fixed_t y, node_t *node);
338 int R_PointOnSegSide (fixed_t x, fixed_t y, seg_t *line);
339 angle_t R_PointToAngle (fixed_t x, fixed_t y);
340 angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2);
341 fixed_t R_PointToDist (fixed_t x, fixed_t y);
342 fixed_t R_ScaleFromGlobalAngle (angle_t visangle);
343 subsector_t *R_PointInSubsector (fixed_t x, fixed_t y);
344 void R_AddPointToBox (int x, int y, fixed_t *box);
350 extern seg_t *curline;
351 extern side_t *sidedef;
352 extern line_t *linedef;
353 extern sector_t *frontsector, *backsector;
358 extern boolean segtextured;
359 extern boolean markfloor; // false if the back side is the same plane
360 extern boolean markceiling;
361 extern boolean skymap;
363 extern drawseg_t drawsegs[MAXDRAWSEGS], *ds_p;
365 extern lighttable_t **hscalelight, **vscalelight, **dscalelight;
367 typedef void (*drawfunc_t) (int start, int stop);
368 void R_ClearClipSegs (void);
370 void R_ClearDrawSegs (void);
371 void R_InitSkyMap (void);
372 void R_RenderBSPNode (int bspnum);
377 extern int rw_angle1; // angle to line origin
379 void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2);
385 typedef void (*planefunction_t) (int top, int bottom);
386 extern planefunction_t floorfunc, ceilingfunc;
388 extern int skyflatnum;
390 extern short openings[MAXOPENINGS], *lastopening;
392 extern short floorclip[SCREENWIDTH];
393 extern short ceilingclip[SCREENWIDTH];
395 extern fixed_t yslope[SCREENHEIGHT];
396 extern fixed_t distscale[SCREENWIDTH];
398 void R_InitPlanes (void);
399 void R_ClearPlanes (void);
400 void R_MapPlane (int y, int x1, int x2);
401 void R_MakeSpans (int x, int t1, int b1, int t2, int b2);
402 void R_DrawPlanes (void);
404 visplane_t *R_FindPlane (fixed_t height, int picnum, int lightlevel,
406 visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop);
414 void RD_OpenMapWindow (void);
415 void RD_ClearMapWindow (void);
416 void RD_DisplayLine (int x1, int y1, int x2, int y2, float gray);
417 void RD_DrawNodeLine (node_t *node);
418 void RD_DrawLineCheck (seg_t *line);
419 void RD_DrawLine (seg_t *line);
420 void RD_DrawBBox (fixed_t *bbox);
426 extern fixed_t *textureheight; // needed for texture pegging
427 extern fixed_t *spritewidth; // needed for pre rendering (fracs)
428 extern fixed_t *spriteoffset;
429 extern fixed_t *spritetopoffset;
430 extern lighttable_t *colormaps;
431 extern int viewwidth, scaledviewwidth, viewheight;
432 extern int firstflat;
435 extern int *flattranslation; // for global animation
436 extern int *texturetranslation; // for global animation
438 extern int firstspritelump, lastspritelump, numspritelumps;
440 byte *R_GetColumn (int tex, int col);
441 void R_InitData (void);
442 void R_PrecacheLevel (void);
448 #define MAXVISSPRITES 128
450 extern vissprite_t vissprites[MAXVISSPRITES], *vissprite_p;
451 extern vissprite_t vsprsortedhead;
453 // constant arrays used for psprite clipping and initializing clipping
454 extern short negonearray[SCREENWIDTH];
455 extern short screenheightarray[SCREENWIDTH];
457 // vars for R_DrawMaskedColumn
458 extern short *mfloorclip;
459 extern short *mceilingclip;
460 extern fixed_t spryscale;
461 extern fixed_t sprtopscreen;
462 extern fixed_t sprbotscreen;
464 extern fixed_t pspritescale, pspriteiscale;
467 void R_DrawMaskedColumn (column_t *column, signed int baseclip);
470 void R_SortVisSprites (void);
472 void R_AddSprites (sector_t *sec);
473 void R_AddPSprites (void);
474 void R_DrawSprites (void);
475 void R_InitSprites (char **namelist);
476 void R_ClearSprites (void);
477 void R_DrawMasked (void);
478 void R_ClipVisSprite (vissprite_t *vis, int xl, int xh);
480 //=============================================================================
484 //=============================================================================
486 extern lighttable_t *dc_colormap;
490 extern fixed_t dc_iscale;
491 extern fixed_t dc_texturemid;
492 extern byte *dc_source; // first pixel in a column
494 void R_DrawColumn (void);
495 void R_DrawColumnLow (void);
496 void R_DrawFuzzColumn (void);
497 void R_DrawFuzzColumnLow (void);
498 void R_DrawTranslatedColumn (void);
499 void R_DrawTranslatedFuzzColumn (void);
500 void R_DrawTranslatedColumnLow (void);
505 extern lighttable_t *ds_colormap;
506 extern fixed_t ds_xfrac;
507 extern fixed_t ds_yfrac;
508 extern fixed_t ds_xstep;
509 extern fixed_t ds_ystep;
510 extern byte *ds_source; // start of a 64*64 tile image
512 extern byte *translationtables;
513 extern byte *dc_translation;
515 void R_DrawSpan (void);
516 void R_DrawSpanLow (void);
518 void R_InitBuffer (int width, int height);
519 void R_InitTranslationTables (void);
521 #endif // __R_LOCAL__