|
|
1.1 root 1: // Emacs style mode select -*- C++ -*-
2: //-----------------------------------------------------------------------------
3: //
4: // $Id:$
5: //
6: // Copyright (C) 1993-1996 by id Software, Inc.
7: //
1.1.1.2 ! root 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.
1.1 root 12: //
1.1.1.2 ! root 13: // This program is distributed in the hope that it will be useful,
1.1 root 14: // but WITHOUT ANY WARRANTY; without even the implied warranty of
1.1.1.2 ! root 15: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 16: // GNU General Public License for more details.
1.1 root 17: //
18: // DESCRIPTION:
19: // Refresh/rendering module, shared data struct definitions.
20: //
21: //-----------------------------------------------------------------------------
22:
23:
24: #ifndef __R_DEFS__
25: #define __R_DEFS__
26:
27:
28: // Screenwidth.
29: #include "doomdef.h"
30:
31: // Some more or less basic data types
32: // we depend on.
33: #include "m_fixed.h"
34:
35: // We rely on the thinker data struct
36: // to handle sound origins in sectors.
37: #include "d_think.h"
38: // SECTORS do store MObjs anyway.
39: #include "p_mobj.h"
40:
41:
42:
43: #ifdef __GNUG__
44: #pragma interface
45: #endif
46:
47:
48:
49: // Silhouette, needed for clipping Segs (mainly)
50: // and sprites representing things.
51: #define SIL_NONE 0
52: #define SIL_BOTTOM 1
53: #define SIL_TOP 2
54: #define SIL_BOTH 3
55:
56: #define MAXDRAWSEGS 256
57:
58:
59:
60:
61:
62: //
63: // INTERNAL MAP TYPES
64: // used by play and refresh
65: //
66:
67: //
68: // Your plain vanilla vertex.
69: // Note: transformed values not buffered locally,
70: // like some DOOM-alikes ("wt", "WebView") did.
71: //
72: typedef struct
73: {
74: fixed_t x;
75: fixed_t y;
76:
77: } vertex_t;
78:
79:
80: // Forward of LineDefs, for Sectors.
81: struct line_s;
82:
83: // Each sector has a degenmobj_t in its center
84: // for sound origin purposes.
85: // I suppose this does not handle sound from
86: // moving objects (doppler), because
87: // position is prolly just buffered, not
88: // updated.
89: typedef struct
90: {
91: thinker_t thinker; // not used for anything
92: fixed_t x;
93: fixed_t y;
94: fixed_t z;
95:
96: } degenmobj_t;
97:
98: //
99: // The SECTORS record, at runtime.
100: // Stores things/mobjs.
101: //
102: typedef struct
103: {
104: fixed_t floorheight;
105: fixed_t ceilingheight;
106: short floorpic;
107: short ceilingpic;
108: short lightlevel;
109: short special;
110: short tag;
111:
112: // 0 = untraversed, 1,2 = sndlines -1
113: int soundtraversed;
114:
115: // thing that made a sound (or null)
116: mobj_t* soundtarget;
117:
118: // mapblock bounding box for height changes
119: int blockbox[4];
120:
121: // origin for any sounds played by the sector
122: degenmobj_t soundorg;
123:
124: // if == validcount, already checked
125: int validcount;
126:
127: // list of mobjs in sector
128: mobj_t* thinglist;
129:
130: // thinker_t for reversable actions
131: void* specialdata;
132:
133: int linecount;
134: struct line_s** lines; // [linecount] size
135:
136: } sector_t;
137:
138:
139:
140:
141: //
142: // The SideDef.
143: //
144:
145: typedef struct
146: {
147: // add this to the calculated texture column
148: fixed_t textureoffset;
149:
150: // add this to the calculated texture top
151: fixed_t rowoffset;
152:
153: // Texture indices.
154: // We do not maintain names here.
155: short toptexture;
156: short bottomtexture;
157: short midtexture;
158:
159: // Sector the SideDef is facing.
160: sector_t* sector;
161:
162: } side_t;
163:
164:
165:
166: //
167: // Move clipping aid for LineDefs.
168: //
169: typedef enum
170: {
171: ST_HORIZONTAL,
172: ST_VERTICAL,
173: ST_POSITIVE,
174: ST_NEGATIVE
175:
176: } slopetype_t;
177:
178:
179:
180: typedef struct line_s
181: {
182: // Vertices, from v1 to v2.
183: vertex_t* v1;
184: vertex_t* v2;
185:
186: // Precalculated v2 - v1 for side checking.
187: fixed_t dx;
188: fixed_t dy;
189:
190: // Animation related.
191: short flags;
192: short special;
193: short tag;
194:
195: // Visual appearance: SideDefs.
196: // sidenum[1] will be -1 if one sided
197: short sidenum[2];
198:
199: // Neat. Another bounding box, for the extent
200: // of the LineDef.
201: fixed_t bbox[4];
202:
203: // To aid move clipping.
204: slopetype_t slopetype;
205:
206: // Front and back sector.
207: // Note: redundant? Can be retrieved from SideDefs.
208: sector_t* frontsector;
209: sector_t* backsector;
210:
211: // if == validcount, already checked
212: int validcount;
213:
214: // thinker_t for reversable actions
215: void* specialdata;
216: } line_t;
217:
218:
219:
220:
221: //
222: // A SubSector.
223: // References a Sector.
224: // Basically, this is a list of LineSegs,
225: // indicating the visible walls that define
226: // (all or some) sides of a convex BSP leaf.
227: //
228: typedef struct subsector_s
229: {
230: sector_t* sector;
231: short numlines;
232: short firstline;
233:
234: } subsector_t;
235:
236:
237:
238: //
239: // The LineSeg.
240: //
241: typedef struct
242: {
243: vertex_t* v1;
244: vertex_t* v2;
245:
246: fixed_t offset;
247:
248: angle_t angle;
249:
250: side_t* sidedef;
251: line_t* linedef;
252:
253: // Sector references.
254: // Could be retrieved from linedef, too.
255: // backsector is NULL for one sided lines
256: sector_t* frontsector;
257: sector_t* backsector;
258:
259: } seg_t;
260:
261:
262:
263: //
264: // BSP node.
265: //
266: typedef struct
267: {
268: // Partition line.
269: fixed_t x;
270: fixed_t y;
271: fixed_t dx;
272: fixed_t dy;
273:
274: // Bounding box for each child.
275: fixed_t bbox[2][4];
276:
277: // If NF_SUBSECTOR its a subsector.
278: unsigned short children[2];
279:
280: } node_t;
281:
282:
283:
284:
285: // posts are runs of non masked source pixels
286: typedef struct
287: {
288: byte topdelta; // -1 is the last post in a column
289: byte length; // length data bytes follows
290: } post_t;
291:
292: // column_t is a list of 0 or more post_t, (byte)-1 terminated
293: typedef post_t column_t;
294:
295:
296:
297: // PC direct to screen pointers
298: //B UNUSED - keep till detailshift in r_draw.c resolved
299: //extern byte* destview;
300: //extern byte* destscreen;
301:
302:
303:
304:
305:
306: //
307: // OTHER TYPES
308: //
309:
310: // This could be wider for >8 bit display.
311: // Indeed, true color support is posibble
312: // precalculating 24bpp lightmap/colormap LUT.
313: // from darkening PLAYPAL to all black.
314: // Could even us emore than 32 levels.
315: typedef byte lighttable_t;
316:
317:
318:
319:
320: //
321: // ?
322: //
323: typedef struct drawseg_s
324: {
325: seg_t* curline;
326: int x1;
327: int x2;
328:
329: fixed_t scale1;
330: fixed_t scale2;
331: fixed_t scalestep;
332:
333: // 0=none, 1=bottom, 2=top, 3=both
334: int silhouette;
335:
336: // do not clip sprites above this
337: fixed_t bsilheight;
338:
339: // do not clip sprites below this
340: fixed_t tsilheight;
341:
342: // Pointers to lists for sprite clipping,
343: // all three adjusted so [x1] is first value.
344: short* sprtopclip;
345: short* sprbottomclip;
346: short* maskedtexturecol;
347:
348: } drawseg_t;
349:
350:
351:
352: // Patches.
353: // A patch holds one or more columns.
354: // Patches are used for sprites and all masked pictures,
355: // and we compose textures from the TEXTURE1/2 lists
356: // of patches.
357: typedef struct
358: {
359: short width; // bounding box size
360: short height;
361: short leftoffset; // pixels to the left of origin
362: short topoffset; // pixels below the origin
363: int columnofs[8]; // only [width] used
364: // the [0] is &columnofs[width]
365: } patch_t;
366:
367:
368:
369:
370:
371:
372:
373: // A vissprite_t is a thing
374: // that will be drawn during a refresh.
375: // I.e. a sprite object that is partly visible.
376: typedef struct vissprite_s
377: {
378: // Doubly linked list.
379: struct vissprite_s* prev;
380: struct vissprite_s* next;
381:
382: int x1;
383: int x2;
384:
385: // for line side calculation
386: fixed_t gx;
387: fixed_t gy;
388:
389: // global bottom / top for silhouette clipping
390: fixed_t gz;
391: fixed_t gzt;
392:
393: // horizontal position of x1
394: fixed_t startfrac;
395:
396: fixed_t scale;
397:
398: // negative if flipped
399: fixed_t xiscale;
400:
401: fixed_t texturemid;
402: int patch;
403:
404: // for color translation and shadow draw,
405: // maxbright frames as well
406: lighttable_t* colormap;
407:
408: int mobjflags;
409:
410: } vissprite_t;
411:
412:
413: //
414: // Sprites are patches with a special naming convention
415: // so they can be recognized by R_InitSprites.
416: // The base name is NNNNFx or NNNNFxFx, with
417: // x indicating the rotation, x = 0, 1-7.
418: // The sprite and frame specified by a thing_t
419: // is range checked at run time.
420: // A sprite is a patch_t that is assumed to represent
421: // a three dimensional object and may have multiple
422: // rotations pre drawn.
423: // Horizontal flipping is used to save space,
424: // thus NNNNF2F5 defines a mirrored patch.
425: // Some sprites will only have one picture used
426: // for all views: NNNNF0
427: //
428: typedef struct
429: {
430: // If false use 0 for any position.
431: // Note: as eight entries are available,
432: // we might as well insert the same name eight times.
433: boolean rotate;
434:
435: // Lump to use for view angles 0-7.
436: short lump[8];
437:
438: // Flip bit (1 = flip) to use for view angles 0-7.
439: byte flip[8];
440:
441: } spriteframe_t;
442:
443:
444:
445: //
446: // A sprite definition:
447: // a number of animation frames.
448: //
449: typedef struct
450: {
451: int numframes;
452: spriteframe_t* spriteframes;
453:
454: } spritedef_t;
455:
456:
457:
458: //
459: // Now what is a visplane, anyway?
460: //
461: typedef struct
462: {
463: fixed_t height;
464: int picnum;
465: int lightlevel;
466: int minx;
467: int maxx;
468:
469: // leave pads for [minx-1]/[maxx+1]
470:
471: byte pad1;
472: // Here lies the rub for all
473: // dynamic resize/change of resolution.
474: byte top[SCREENWIDTH];
475: byte pad2;
476: byte pad3;
477: // See above.
478: byte bottom[SCREENWIDTH];
479: byte pad4;
480:
481: } visplane_t;
482:
483:
484:
485:
486: #endif
487: //-----------------------------------------------------------------------------
488: //
489: // $Log:$
490: //
491: //-----------------------------------------------------------------------------
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.