Doom plugin: In anticipation of moving to the EABI toolchain, because of its assumpti...
[kugel-rb.git] / apps / plugins / doom / r_defs.h
blob251f515a07f9316d0ea24a73514fb84ca8485d85
1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
27 * DESCRIPTION:
28 * Refresh/rendering module, shared data struct definitions.
30 *-----------------------------------------------------------------------------*/
32 #ifndef __R_DEFS__
33 #define __R_DEFS__
35 // Screenwidth.
36 #include "doomdef.h"
38 // Some more or less basic data types
39 // we depend on.
40 #include "m_fixed.h"
42 // We rely on the thinker data struct
43 // to handle sound origins in sectors.
44 #include "d_think.h"
45 // SECTORS do store MObjs anyway.
46 #include "p_mobj.h"
48 #ifdef __GNUG__
49 #pragma interface
50 #endif
52 // Silhouette, needed for clipping Segs (mainly)
53 // and sprites representing things.
54 #define SIL_NONE 0
55 #define SIL_BOTTOM 1
56 #define SIL_TOP 2
57 #define SIL_BOTH 3
59 #define MAXDRAWSEGS 256
62 // INTERNAL MAP TYPES
63 // used by play and refresh
67 // Your plain vanilla vertex.
68 // Note: transformed values not buffered locally,
69 // like some DOOM-alikes ("wt", "WebView") do.
71 typedef struct
73 fixed_t x, y;
75 vertex_t;
77 // Each sector has a degenmobj_t in its center for sound origin purposes.
78 typedef struct
80 thinker_t thinker; // not used for anything
81 fixed_t x, y, z;
83 degenmobj_t;
86 // The SECTORS record, at runtime.
87 // Stores things/mobjs.
90 typedef struct
92 fixed_t floorheight;
93 fixed_t ceilingheight;
94 int nexttag,firsttag; // killough 1/30/98: improves searches for tags.
95 int soundtraversed; // 0 = untraversed, 1,2 = sndlines-1
96 mobj_t *soundtarget; // thing that made a sound (or null)
97 int blockbox[4]; // mapblock bounding box for height changes
98 degenmobj_t soundorg; // origin for any sounds played by the sector
99 int validcount; // if == validcount, already checked
100 mobj_t *thinglist; // list of mobjs in sector
102 /* killough 8/28/98: friction is a sector property, not an mobj property.
103 * these fields used to be in mobj_t, but presented performance problems
104 * when processed as mobj properties. Fix is to make them sector properties.
106 int friction,movefactor;
108 // thinker_t for reversable actions
109 void *floordata; // jff 2/22/98 make thinkers on
110 void *ceilingdata; // floors, ceilings, lighting,
111 void *lightingdata; // independent of one another
113 // jff 2/26/98 lockout machinery for stairbuilding
114 int stairlock; // -2 on first locked -1 after thinker done 0 normally
115 int prevsec; // -1 or number of sector for previous step
116 int nextsec; // -1 or number of next step sector
118 // killough 3/7/98: support flat heights drawn at another sector's heights
119 int heightsec; // other sector, or -1 if no other sector
121 int bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps
123 // list of mobjs that are at least partially in the sector
124 // thinglist is a subset of touching_thinglist
125 struct msecnode_s *touching_thinglist; // phares 3/14/98
127 int linecount;
128 struct line_s **lines;
130 // killough 10/98: support skies coming from sidedefs. Allows scrolling
131 // skies and other effects. No "level info" kind of lump is needed,
132 // because you can use an arbitrary number of skies per level with this
133 // method. This field only applies when skyflatnum is used for floorpic
134 // or ceilingpic, because the rest of Doom needs to know which is sky
135 // and which isn't, etc.
137 int sky;
139 // killough 3/7/98: floor and ceiling texture offsets
140 fixed_t floor_xoffs, floor_yoffs;
141 fixed_t ceiling_xoffs, ceiling_yoffs;
143 // killough 4/11/98: support for lightlevels coming from another sector
144 int floorlightsec, ceilinglightsec;
146 short floorpic;
147 short ceilingpic;
148 short lightlevel;
149 short special;
150 short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap)
151 short tag;
153 sector_t;
156 // The SideDef.
159 typedef struct
161 fixed_t textureoffset; // add this to the calculated texture column
162 fixed_t rowoffset; // add this to the calculated texture top
163 short toptexture; // Texture indices. We do not maintain names here.
164 short bottomtexture;
165 short midtexture;
166 sector_t* sector; // Sector the SideDef is facing.
168 // killough 4/4/98, 4/11/98: highest referencing special linedef's type,
169 // or lump number of special effect. Allows texture names to be overloaded
170 // for other functions.
172 int special;
175 side_t;
178 // Move clipping aid for LineDefs.
180 enum
182 ST_HORIZONTAL,
183 ST_VERTICAL,
184 ST_POSITIVE,
185 ST_NEGATIVE
187 typedef int slopetype_t;
189 enum { // cph:
190 RF_TOP_TILE = 1, // Upper texture needs tiling
191 RF_MID_TILE = 2, // Mid texture needs tiling
192 RF_BOT_TILE = 4, // Lower texture needs tiling
193 RF_IGNORE = 8, // Renderer can skip this line
194 RF_CLOSED =16, // Line blocks view
197 typedef struct line_s
199 vertex_t *v1, *v2; // Vertices, from v1 to v2.
200 fixed_t dx, dy; // Precalculated v2 - v1 for side checking.
201 short flags; // Animation related.
202 short special;
203 short tag;
204 short sidenum[2]; // Visual appearance: SideDefs.
205 fixed_t bbox[4]; // A bounding box, for the linedef's extent
206 slopetype_t slopetype; // To aid move clipping.
207 sector_t *frontsector; // Front and back sector.
208 sector_t *backsector;
209 int validcount; // if == validcount, already checked
210 void *specialdata; // thinker_t for reversable actions
211 int tranlump; // killough 4/11/98: translucency filter, -1 == none
212 int firsttag,nexttag; // killough 4/17/98: improves searches for tags.
213 int r_validcount; // cph: if == gametic, r_flags already done
214 int r_flags;
216 line_t;
218 // phares 3/14/98
220 // Sector list node showing all sectors an object appears in.
222 // There are two threads that flow through these nodes. The first thread
223 // starts at touching_thinglist in a sector_t and flows through the m_snext
224 // links to find all mobjs that are entirely or partially in the sector.
225 // The second thread starts at touching_sectorlist in an mobj_t and flows
226 // through the m_tnext links to find all sectors a thing touches. This is
227 // useful when applying friction or push effects to sectors. These effects
228 // can be done as thinkers that act upon all objects touching their sectors.
229 // As an mobj moves through the world, these nodes are created and
230 // destroyed, with the links changed appropriately.
232 // For the links, NULL means top or end of list.
234 typedef struct msecnode_s
236 sector_t *m_sector; // a sector containing this object
237 struct mobj_s *m_thing; // this object
238 struct msecnode_s *m_tprev; // prev msecnode_t for this thing
239 struct msecnode_s *m_tnext; // next msecnode_t for this thing
240 struct msecnode_s *m_sprev; // prev msecnode_t for this sector
241 struct msecnode_s *m_snext; // next msecnode_t for this sector
242 boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms
244 msecnode_t;
247 // The LineSeg.
249 typedef struct
251 vertex_t *v1, *v2;
252 fixed_t offset;
253 angle_t angle;
254 side_t* sidedef;
255 line_t* linedef;
257 boolean miniseg;
259 // Sector references.
260 // Could be retrieved from linedef, too
261 // (but that would be slower -- killough)
262 // backsector is NULL for one sided lines
264 sector_t *frontsector, *backsector;
266 seg_t;
269 // A SubSector.
270 // References a Sector.
271 // Basically, this is a list of LineSegs,
272 // indicating the visible walls that define
273 // (all or some) sides of a convex BSP leaf.
276 typedef struct subsector_s
278 sector_t *sector;
279 unsigned short numlines, firstline;
281 subsector_t;
284 // BSP node.
286 typedef struct
288 fixed_t x, y, dx, dy; // Partition line.
289 fixed_t bbox[2][4]; // Bounding box for each child.
290 unsigned short children[2]; // If NF_SUBSECTOR its a subsector.
292 node_t;
294 // posts are runs of non masked source pixels
295 typedef struct
297 byte topdelta; // -1 is the last post in a column
298 byte length; // length data bytes follows
300 post_t;
302 // column_t is a list of 0 or more post_t, (byte)-1 terminated
303 typedef post_t column_t;
306 // OTHER TYPES
309 // This could be wider for >8 bit display.
310 // Indeed, true color support is posibble
311 // precalculating 24bpp lightmap/colormap LUT.
312 // from darkening PLAYPAL to all black.
313 // Could use even more than 32 levels.
315 typedef byte lighttable_t;
318 // Masked 2s linedefs
320 typedef struct drawseg_s
322 seg_t *curline;
323 int x1, x2;
324 fixed_t scale1, scale2, scalestep;
325 int silhouette; // 0=none, 1=bottom, 2=top, 3=both
326 fixed_t bsilheight; // do not clip sprites above this
327 fixed_t tsilheight; // do not clip sprites below this
329 // Pointers to lists for sprite clipping,
330 // all three adjusted so [x1] is first value.
331 short *sprtopclip, *sprbottomclip, *maskedtexturecol;
334 drawseg_t;
337 // Patches.
338 // A patch holds one or more columns.
339 // Patches are used for sprites and all masked pictures,
340 // and we compose textures from the TEXTURE1/2 lists
341 // of patches.
344 typedef struct
346 short width, height; // bounding box size
347 short leftoffset; // pixels to the left of origin
348 short topoffset; // pixels below the origin
349 int columnofs[8]; // only [width] used
351 patch_t;
353 // proff: Added for OpenGL
354 typedef struct
356 int width,height;
357 int leftoffset,topoffset;
358 int lumpnum;
360 patchnum_t;
363 // A vissprite_t is a thing that will be drawn during a refresh.
364 // i.e. a sprite object that is partly visible.
367 typedef struct vissprite_s
369 int x1, x2;
370 fixed_t gx, gy; // for line side calculation
371 fixed_t gz, gzt; // global bottom / top for silhouette clipping
372 fixed_t startfrac; // horizontal position of x1
373 fixed_t scale;
374 fixed_t xiscale; // negative if flipped
375 fixed_t texturemid;
376 int patch;
377 uint_64_t mobjflags;
379 // for color translation and shadow draw, maxbright frames as well
380 lighttable_t *colormap;
382 // killough 3/27/98: height sector for underwater/fake ceiling support
383 int heightsec;
385 vissprite_t;
388 // Sprites are patches with a special naming convention
389 // so they can be recognized by R_InitSprites.
390 // The base name is NNNNFx or NNNNFxFx, with
391 // x indicating the rotation, x = 0, 1-7.
392 // The sprite and frame specified by a thing_t
393 // is range checked at run time.
394 // A sprite is a patch_t that is assumed to represent
395 // a three dimensional object and may have multiple
396 // rotations pre drawn.
397 // Horizontal flipping is used to save space,
398 // thus NNNNF2F5 defines a mirrored patch.
399 // Some sprites will only have one picture used
400 // for all views: NNNNF0
402 typedef struct
404 // If false use 0 for any position.
405 // Note: as eight entries are available,
406 // we might as well insert the same name eight times.
407 boolean rotate;
409 // Lump to use for view angles 0-7.
410 short lump[8];
412 // Flip bit (1 = flip) to use for view angles 0-7.
413 byte flip[8];
416 spriteframe_t;
419 // A sprite definition:
420 // a number of animation frames.
423 typedef struct
425 int numframes;
426 spriteframe_t *spriteframes;
428 spritedef_t;
431 // Now what is a visplane, anyway?
433 typedef struct visplane
435 struct visplane *next; // Next visplane in hash chain -- killough
436 int picnum, lightlevel, minx, maxx;
437 fixed_t height;
438 fixed_t xoffs, yoffs; // killough 2/28/98: Support scrolling flats
439 unsigned short pad1; // leave pads for [minx-1]/[maxx+1]
440 unsigned short top[MAX_SCREENWIDTH];
441 unsigned short pad2, pad3; // killough 2/8/98, 4/25/98
442 unsigned short bottom[MAX_SCREENWIDTH];
443 unsigned short pad4;
445 visplane_t;
447 #endif