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