home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / include / r_defs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-17  |  10.1 KB  |  495 lines

  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.  
  26.  
  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    floorpic;
  106.     short    ceilingpic;
  107.     short    lightlevel;
  108.     short    special;
  109.     short    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.  
  315. /*   4 * 8 */
  316. /*   2 * (15,16) */
  317. /*   1 * (24,32) */
  318. typedef long    lighttable_t;    
  319.  
  320.  
  321.  
  322.  
  323. /*  */
  324. /*  ? */
  325. /*  */
  326. typedef struct drawseg_s
  327. {
  328.     seg_t*        curline;
  329.     int            x1;
  330.     int            x2;
  331.  
  332.     fixed_t        scale1;
  333.     fixed_t        scale2;
  334.     fixed_t        scalestep;
  335.  
  336.     /*  0=none, 1=bottom, 2=top, 3=both */
  337.     int            silhouette;
  338.  
  339.     /*  do not clip sprites above this */
  340.     fixed_t        bsilheight;
  341.  
  342.     /*  do not clip sprites below this */
  343.     fixed_t        tsilheight;
  344.     
  345.     /*  Pointers to lists for sprite clipping, */
  346.     /*   all three adjusted so [x1] is first value. */
  347.     short*        sprtopclip;        
  348.     short*        sprbottomclip;    
  349.     short*        maskedtexturecol;
  350.     
  351. } drawseg_t;
  352.  
  353.  
  354.  
  355. /*  Patches. */
  356. /*  A patch holds one or more columns. */
  357. /*  Patches are used for sprites and all masked pictures, */
  358. /*  and we compose textures from the TEXTURE1/2 lists */
  359. /*  of patches. */
  360. typedef struct 
  361.     short        width;        /*  bounding box size  */
  362.     short        height; 
  363.     short        leftoffset;    /*  pixels to the left of origin  */
  364.     short        topoffset;    /*  pixels below the origin  */
  365.     int            columnofs[8];    /*  only [width] used */
  366.     /*  the [0] is &columnofs[width]  */
  367. } patch_t;
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375. /*  A vissprite_t is a thing */
  376. /*   that will be drawn during a refresh. */
  377. /*  I.e. a sprite object that is partly visible. */
  378. typedef struct vissprite_s
  379. {
  380.     /*  Doubly linked list. */
  381.     struct vissprite_s*    prev;
  382.     struct vissprite_s*    next;
  383.     
  384.     int            x1;
  385.     int            x2;
  386.  
  387.     /*  for line side calculation */
  388.     fixed_t        gx;
  389.     fixed_t        gy;        
  390.  
  391.     /*  global bottom / top for silhouette clipping */
  392.     fixed_t        gz;
  393.     fixed_t        gzt;
  394.  
  395.     /*  horizontal position of x1 */
  396.     fixed_t        startfrac;
  397.     
  398.     fixed_t        scale;
  399.     
  400.     /*  negative if flipped */
  401.     fixed_t        xiscale;    
  402.  
  403.     fixed_t        texturemid;
  404.     int            patch;
  405.  
  406.     /*  for color translation and shadow draw, */
  407.     /*   maxbright frames as well */
  408.     lighttable_t*    colormap;
  409.    
  410.     int            mobjflags;
  411.     
  412. } vissprite_t;
  413.  
  414.  
  415. /*      */
  416. /*  Sprites are patches with a special naming convention */
  417. /*   so they can be recognized by R_InitSprites. */
  418. /*  The base name is NNNNFx or NNNNFxFx, with */
  419. /*   x indicating the rotation, x = 0, 1-7. */
  420. /*  The sprite and frame specified by a thing_t */
  421. /*   is range checked at run time. */
  422. /*  A sprite is a patch_t that is assumed to represent */
  423. /*   a three dimensional object and may have multiple */
  424. /*   rotations pre drawn. */
  425. /*  Horizontal flipping is used to save space, */
  426. /*   thus NNNNF2F5 defines a mirrored patch. */
  427. /*  Some sprites will only have one picture used */
  428. /*  for all views: NNNNF0 */
  429. /*  */
  430. typedef struct
  431. {
  432.     /*  If false use 0 for any position. */
  433.     /*  Note: as eight entries are available, */
  434.     /*   we might as well insert the same name eight times. */
  435.     boolean    rotate;
  436.  
  437.     /*  Lump to use for view angles 0-7. */
  438.     short    lump[8];
  439.  
  440.     /*  Flip bit (1 = flip) to use for view angles 0-7. */
  441.     byte    flip[8];
  442.     
  443. } spriteframe_t;
  444.  
  445.  
  446.  
  447. /*  */
  448. /*  A sprite definition: */
  449. /*   a number of animation frames. */
  450. /*  */
  451. typedef struct
  452. {
  453.     int            numframes;
  454.     spriteframe_t*    spriteframes;
  455.  
  456. } spritedef_t;
  457.  
  458.  
  459.  
  460. /*  */
  461. /*  Now what is a visplane, anyway? */
  462. /*   */
  463. typedef struct
  464. {
  465.   fixed_t        height;
  466.   int            picnum;
  467.   int            lightlevel;
  468.   int            minx;
  469.   int            maxx;
  470.   
  471.   /*  leave pads for [minx-1]/[maxx+1] */
  472.   
  473.   byte        pad1;
  474.   /*  Here lies the rub for all */
  475.   /*   dynamic resize/change of resolution. */
  476.   byte        top[SCREENWIDTH];
  477.   byte        pad2;
  478.   byte        pad3;
  479.   /*  See above. */
  480.   byte        bottom[SCREENWIDTH];
  481.   byte        pad4;
  482.  
  483. } visplane_t;
  484.  
  485.  
  486.  
  487.  
  488. #endif
  489. /* ----------------------------------------------------------------------------- */
  490. /*  */
  491. /*  $Log:$ */
  492. /*  */
  493. /* ----------------------------------------------------------------------------- */
  494.