diff options
Diffstat (limited to 'src/r_defs.h')
-rw-r--r-- | src/r_defs.h | 428 |
1 files changed, 428 insertions, 0 deletions
diff --git a/src/r_defs.h b/src/r_defs.h new file mode 100644 index 0000000..07057bb --- /dev/null +++ b/src/r_defs.h | |||
@@ -0,0 +1,428 @@ | |||
1 | /* Emacs style mode select -*- C++ -*- | ||
2 | *----------------------------------------------------------------------------- | ||
3 | * | ||
4 | * | ||
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 | ||
11 | * Copyright 2005, 2006 by | ||
12 | * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, write to the Free Software | ||
26 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
27 | * 02111-1307, USA. | ||
28 | * | ||
29 | * DESCRIPTION: | ||
30 | * Refresh/rendering module, shared data struct definitions. | ||
31 | * | ||
32 | *-----------------------------------------------------------------------------*/ | ||
33 | |||
34 | #ifndef __R_DEFS__ | ||
35 | #define __R_DEFS__ | ||
36 | |||
37 | // Screenwidth. | ||
38 | #include "doomdef.h" | ||
39 | |||
40 | // Some more or less basic data types | ||
41 | // we depend on. | ||
42 | #include "m_fixed.h" | ||
43 | |||
44 | // We rely on the thinker data struct | ||
45 | // to handle sound origins in sectors. | ||
46 | #include "d_think.h" | ||
47 | |||
48 | // SECTORS do store MObjs anyway. | ||
49 | #include "p_mobj.h" | ||
50 | |||
51 | #ifdef __GNUG__ | ||
52 | #pragma interface | ||
53 | #endif | ||
54 | |||
55 | // Silhouette, needed for clipping Segs (mainly) | ||
56 | // and sprites representing things. | ||
57 | #define SIL_NONE 0 | ||
58 | #define SIL_BOTTOM 1 | ||
59 | #define SIL_TOP 2 | ||
60 | #define SIL_BOTH 3 | ||
61 | |||
62 | #define MAXDRAWSEGS 256 | ||
63 | |||
64 | // | ||
65 | // INTERNAL MAP TYPES | ||
66 | // used by play and refresh | ||
67 | // | ||
68 | |||
69 | // | ||
70 | // Your plain vanilla vertex. | ||
71 | // Note: transformed values not buffered locally, | ||
72 | // like some DOOM-alikes ("wt", "WebView") do. | ||
73 | // | ||
74 | typedef struct | ||
75 | { | ||
76 | fixed_t x, y; | ||
77 | } vertex_t; | ||
78 | |||
79 | // Each sector has a degenmobj_t in its center for sound origin purposes. | ||
80 | typedef struct | ||
81 | { | ||
82 | thinker_t thinker; // not used for anything | ||
83 | fixed_t x, y, z; | ||
84 | } degenmobj_t; | ||
85 | |||
86 | // | ||
87 | // The SECTORS record, at runtime. | ||
88 | // Stores things/mobjs. | ||
89 | // | ||
90 | |||
91 | typedef struct | ||
92 | { | ||
93 | int iSectorID; // proff 04/05/2000: needed for OpenGL and used in debugmode by the HUD to draw sectornum | ||
94 | boolean no_toptextures; | ||
95 | boolean no_bottomtextures; | ||
96 | fixed_t floorheight; | ||
97 | fixed_t ceilingheight; | ||
98 | int nexttag,firsttag; // killough 1/30/98: improves searches for tags. | ||
99 | int soundtraversed; // 0 = untraversed, 1,2 = sndlines-1 | ||
100 | mobj_t *soundtarget; // thing that made a sound (or null) | ||
101 | int blockbox[4]; // mapblock bounding box for height changes | ||
102 | degenmobj_t soundorg; // origin for any sounds played by the sector | ||
103 | int validcount; // if == validcount, already checked | ||
104 | mobj_t *thinglist; // list of mobjs in sector | ||
105 | |||
106 | /* killough 8/28/98: friction is a sector property, not an mobj property. | ||
107 | * these fields used to be in mobj_t, but presented performance problems | ||
108 | * when processed as mobj properties. Fix is to make them sector properties. | ||
109 | */ | ||
110 | int friction,movefactor; | ||
111 | |||
112 | // thinker_t for reversable actions | ||
113 | void *floordata; // jff 2/22/98 make thinkers on | ||
114 | void *ceilingdata; // floors, ceilings, lighting, | ||
115 | void *lightingdata; // independent of one another | ||
116 | |||
117 | // jff 2/26/98 lockout machinery for stairbuilding | ||
118 | int stairlock; // -2 on first locked -1 after thinker done 0 normally | ||
119 | int prevsec; // -1 or number of sector for previous step | ||
120 | int nextsec; // -1 or number of next step sector | ||
121 | |||
122 | // killough 3/7/98: support flat heights drawn at another sector's heights | ||
123 | int heightsec; // other sector, or -1 if no other sector | ||
124 | |||
125 | int bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps | ||
126 | |||
127 | // list of mobjs that are at least partially in the sector | ||
128 | // thinglist is a subset of touching_thinglist | ||
129 | struct msecnode_s *touching_thinglist; // phares 3/14/98 | ||
130 | |||
131 | int linecount; | ||
132 | struct line_s **lines; | ||
133 | |||
134 | // killough 10/98: support skies coming from sidedefs. Allows scrolling | ||
135 | // skies and other effects. No "level info" kind of lump is needed, | ||
136 | // because you can use an arbitrary number of skies per level with this | ||
137 | // method. This field only applies when skyflatnum is used for floorpic | ||
138 | // or ceilingpic, because the rest of Doom needs to know which is sky | ||
139 | // and which isn't, etc. | ||
140 | |||
141 | int sky; | ||
142 | |||
143 | // killough 3/7/98: floor and ceiling texture offsets | ||
144 | fixed_t floor_xoffs, floor_yoffs; | ||
145 | fixed_t ceiling_xoffs, ceiling_yoffs; | ||
146 | |||
147 | // killough 4/11/98: support for lightlevels coming from another sector | ||
148 | int floorlightsec, ceilinglightsec; | ||
149 | |||
150 | short floorpic; | ||
151 | short ceilingpic; | ||
152 | short lightlevel; | ||
153 | short special; | ||
154 | short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap) | ||
155 | short tag; | ||
156 | } sector_t; | ||
157 | |||
158 | // | ||
159 | // The SideDef. | ||
160 | // | ||
161 | |||
162 | typedef struct | ||
163 | { | ||
164 | fixed_t textureoffset; // add this to the calculated texture column | ||
165 | fixed_t rowoffset; // add this to the calculated texture top | ||
166 | short toptexture; // Texture indices. We do not maintain names here. | ||
167 | short bottomtexture; | ||
168 | short midtexture; | ||
169 | sector_t* sector; // Sector the SideDef is facing. | ||
170 | |||
171 | // killough 4/4/98, 4/11/98: highest referencing special linedef's type, | ||
172 | // or lump number of special effect. Allows texture names to be overloaded | ||
173 | // for other functions. | ||
174 | |||
175 | int special; | ||
176 | |||
177 | } side_t; | ||
178 | |||
179 | // | ||
180 | // Move clipping aid for LineDefs. | ||
181 | // | ||
182 | typedef enum | ||
183 | { | ||
184 | ST_HORIZONTAL, | ||
185 | ST_VERTICAL, | ||
186 | ST_POSITIVE, | ||
187 | ST_NEGATIVE | ||
188 | } slopetype_t; | ||
189 | |||
190 | typedef struct line_s | ||
191 | { | ||
192 | int iLineID; // proff 04/05/2000: needed for OpenGL | ||
193 | vertex_t *v1, *v2; // Vertices, from v1 to v2. | ||
194 | fixed_t dx, dy; // Precalculated v2 - v1 for side checking. | ||
195 | unsigned short flags; // Animation related. | ||
196 | short special; | ||
197 | short tag; | ||
198 | unsigned short sidenum[2]; // Visual appearance: SideDefs. | ||
199 | fixed_t bbox[4]; // A bounding box, for the linedef's extent | ||
200 | slopetype_t slopetype; // To aid move clipping. | ||
201 | sector_t *frontsector; // Front and back sector. | ||
202 | sector_t *backsector; | ||
203 | int validcount; // if == validcount, already checked | ||
204 | void *specialdata; // thinker_t for reversable actions | ||
205 | int tranlump; // killough 4/11/98: translucency filter, -1 == none | ||
206 | int firsttag,nexttag; // killough 4/17/98: improves searches for tags. | ||
207 | int r_validcount; // cph: if == gametic, r_flags already done | ||
208 | enum { // cph: | ||
209 | RF_TOP_TILE = 1, // Upper texture needs tiling | ||
210 | RF_MID_TILE = 2, // Mid texture needs tiling | ||
211 | RF_BOT_TILE = 4, // Lower texture needs tiling | ||
212 | RF_IGNORE = 8, // Renderer can skip this line | ||
213 | RF_CLOSED =16, // Line blocks view | ||
214 | } r_flags; | ||
215 | degenmobj_t soundorg; // sound origin for switches/buttons | ||
216 | } line_t; | ||
217 | |||
218 | |||
219 | // phares 3/14/98 | ||
220 | // | ||
221 | // Sector list node showing all sectors an object appears in. | ||
222 | // | ||
223 | // There are two threads that flow through these nodes. The first thread | ||
224 | // starts at touching_thinglist in a sector_t and flows through the m_snext | ||
225 | // links to find all mobjs that are entirely or partially in the sector. | ||
226 | // The second thread starts at touching_sectorlist in an mobj_t and flows | ||
227 | // through the m_tnext links to find all sectors a thing touches. This is | ||
228 | // useful when applying friction or push effects to sectors. These effects | ||
229 | // can be done as thinkers that act upon all objects touching their sectors. | ||
230 | // As an mobj moves through the world, these nodes are created and | ||
231 | // destroyed, with the links changed appropriately. | ||
232 | // | ||
233 | // For the links, NULL means top or end of list. | ||
234 | |||
235 | typedef struct msecnode_s | ||
236 | { | ||
237 | sector_t *m_sector; // a sector containing this object | ||
238 | struct mobj_s *m_thing; // this object | ||
239 | struct msecnode_s *m_tprev; // prev msecnode_t for this thing | ||
240 | struct msecnode_s *m_tnext; // next msecnode_t for this thing | ||
241 | struct msecnode_s *m_sprev; // prev msecnode_t for this sector | ||
242 | struct msecnode_s *m_snext; // next msecnode_t for this sector | ||
243 | boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms | ||
244 | } msecnode_t; | ||
245 | |||
246 | // | ||
247 | // The LineSeg. | ||
248 | // | ||
249 | typedef struct | ||
250 | { | ||
251 | vertex_t *v1, *v2; | ||
252 | fixed_t offset; | ||
253 | angle_t angle; | ||
254 | side_t* sidedef; | ||
255 | line_t* linedef; | ||
256 | |||
257 | int iSegID; // proff 11/05/2000: needed for OpenGL | ||
258 | // figgi -- needed for glnodes | ||
259 | float length; | ||
260 | boolean miniseg; | ||
261 | |||
262 | |||
263 | // Sector references. | ||
264 | // Could be retrieved from linedef, too | ||
265 | // (but that would be slower -- killough) | ||
266 | // backsector is NULL for one sided lines | ||
267 | |||
268 | sector_t *frontsector, *backsector; | ||
269 | } seg_t; | ||
270 | |||
271 | |||
272 | // | ||
273 | // A SubSector. | ||
274 | // References a Sector. | ||
275 | // Basically, this is a list of LineSegs, | ||
276 | // indicating the visible walls that define | ||
277 | // (all or some) sides of a convex BSP leaf. | ||
278 | // | ||
279 | |||
280 | typedef struct subsector_s | ||
281 | { | ||
282 | sector_t *sector; | ||
283 | unsigned short numlines, firstline; | ||
284 | } subsector_t; | ||
285 | |||
286 | |||
287 | // | ||
288 | // BSP node. | ||
289 | // | ||
290 | typedef struct | ||
291 | { | ||
292 | fixed_t x, y, dx, dy; // Partition line. | ||
293 | fixed_t bbox[2][4]; // Bounding box for each child. | ||
294 | unsigned short children[2]; // If NF_SUBSECTOR its a subsector. | ||
295 | } node_t; | ||
296 | |||
297 | // | ||
298 | // OTHER TYPES | ||
299 | // | ||
300 | |||
301 | // This could be wider for >8 bit display. | ||
302 | // Indeed, true color support is posibble | ||
303 | // precalculating 24bpp lightmap/colormap LUT. | ||
304 | // from darkening PLAYPAL to all black. | ||
305 | // Could use even more than 32 levels. | ||
306 | |||
307 | typedef byte lighttable_t; | ||
308 | |||
309 | // | ||
310 | // Masked 2s linedefs | ||
311 | // | ||
312 | |||
313 | typedef struct drawseg_s | ||
314 | { | ||
315 | seg_t *curline; | ||
316 | int x1, x2; | ||
317 | fixed_t scale1, scale2, scalestep; | ||
318 | int silhouette; // 0=none, 1=bottom, 2=top, 3=both | ||
319 | fixed_t bsilheight; // do not clip sprites above this | ||
320 | fixed_t tsilheight; // do not clip sprites below this | ||
321 | |||
322 | // Added for filtering (fractional texture u coord) support - POPE | ||
323 | fixed_t rw_offset, rw_distance, rw_centerangle; | ||
324 | |||
325 | // Pointers to lists for sprite clipping, | ||
326 | // all three adjusted so [x1] is first value. | ||
327 | |||
328 | int *sprtopclip, *sprbottomclip, *maskedtexturecol; // dropoff overflow | ||
329 | } drawseg_t; | ||
330 | |||
331 | // proff: Added for OpenGL | ||
332 | typedef struct | ||
333 | { | ||
334 | int width,height; | ||
335 | int leftoffset,topoffset; | ||
336 | int lumpnum; | ||
337 | } patchnum_t; | ||
338 | |||
339 | // | ||
340 | // A vissprite_t is a thing that will be drawn during a refresh. | ||
341 | // i.e. a sprite object that is partly visible. | ||
342 | // | ||
343 | |||
344 | typedef struct vissprite_s | ||
345 | { | ||
346 | mobj_t *thing; | ||
347 | boolean flip; | ||
348 | int x1, x2; | ||
349 | fixed_t gx, gy; // for line side calculation | ||
350 | fixed_t gz, gzt; // global bottom / top for silhouette clipping | ||
351 | fixed_t startfrac; // horizontal position of x1 | ||
352 | fixed_t scale; | ||
353 | fixed_t xiscale; // negative if flipped | ||
354 | fixed_t texturemid; | ||
355 | int patch; | ||
356 | uint_64_t mobjflags; | ||
357 | |||
358 | // for color translation and shadow draw, maxbright frames as well | ||
359 | const lighttable_t *colormap; | ||
360 | |||
361 | // killough 3/27/98: height sector for underwater/fake ceiling support | ||
362 | int heightsec; | ||
363 | |||
364 | boolean isplayersprite; | ||
365 | } vissprite_t; | ||
366 | |||
367 | // | ||
368 | // Sprites are patches with a special naming convention | ||
369 | // so they can be recognized by R_InitSprites. | ||
370 | // The base name is NNNNFx or NNNNFxFx, with | ||
371 | // x indicating the rotation, x = 0, 1-7. | ||
372 | // The sprite and frame specified by a thing_t | ||
373 | // is range checked at run time. | ||
374 | // A sprite is a patch_t that is assumed to represent | ||
375 | // a three dimensional object and may have multiple | ||
376 | // rotations pre drawn. | ||
377 | // Horizontal flipping is used to save space, | ||
378 | // thus NNNNF2F5 defines a mirrored patch. | ||
379 | // Some sprites will only have one picture used | ||
380 | // for all views: NNNNF0 | ||
381 | // | ||
382 | |||
383 | typedef struct | ||
384 | { | ||
385 | // If false use 0 for any position. | ||
386 | // Note: as eight entries are available, | ||
387 | // we might as well insert the same name eight times. | ||
388 | boolean rotate; | ||
389 | |||
390 | // Lump to use for view angles 0-7. | ||
391 | short lump[8]; | ||
392 | |||
393 | // Flip bit (1 = flip) to use for view angles 0-7. | ||
394 | byte flip[8]; | ||
395 | |||
396 | } spriteframe_t; | ||
397 | |||
398 | // | ||
399 | // A sprite definition: | ||
400 | // a number of animation frames. | ||
401 | // | ||
402 | |||
403 | typedef struct | ||
404 | { | ||
405 | int numframes; | ||
406 | spriteframe_t *spriteframes; | ||
407 | } spritedef_t; | ||
408 | |||
409 | // | ||
410 | // Now what is a visplane, anyway? | ||
411 | // | ||
412 | // Go to http://classicgaming.com/doom/editing/ to find out -- killough | ||
413 | // | ||
414 | |||
415 | typedef struct visplane | ||
416 | { | ||
417 | struct visplane *next; // Next visplane in hash chain -- killough | ||
418 | int picnum, lightlevel, minx, maxx; | ||
419 | fixed_t height; | ||
420 | fixed_t xoffs, yoffs; // killough 2/28/98: Support scrolling flats | ||
421 | unsigned int pad1; // leave pads for [minx-1]/[maxx+1] | ||
422 | unsigned int top[MAX_SCREENWIDTH]; | ||
423 | unsigned int pad2, pad3; // killough 2/8/98, 4/25/98 | ||
424 | unsigned int bottom[MAX_SCREENWIDTH]; | ||
425 | unsigned int pad4; // dropoff overflow | ||
426 | } visplane_t; | ||
427 | |||
428 | #endif | ||