Subversion Repositories Kolibri OS

Rev

Rev 325 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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