home *** CD-ROM | disk | FTP | other *** search
/ The Complete Doom Accessory Pack 2 / TheCompleteDoomAccessoryPackVolumeII.iso / editors / vnb / dmglobal.i < prev    next >
Text File  |  1994-05-24  |  7KB  |  208 lines

  1. /******************************************************************************
  2.     INCLUDE:    DMGLOBAL.I
  3.     WRITTEN BY:    Robert Fenske, Jr. (rfenske@swri.edu)
  4.                 Southwest Research Institute
  5.                 Electromagnetics Division
  6.                 6220 Culebra
  7.                 San Antonio, Texas 78238-5166
  8.     CREATED:    Mar. 1994
  9.     DESCRIPTION:    This include file contains all the necessary constant,
  10.             macro, syntax, and type definitions as well as all
  11.             external and global variables needed for the various
  12.             DOOM-related utility programs.
  13.  
  14.             DOOM is a trademark of id Software, Inc.
  15. ******************************************************************************/
  16. #if !defined(DM_Globals)
  17.  
  18. #if defined(sun) && !defined(BSWAP)        /* Suns need bytes swapped */
  19. #define BSWAP        1
  20. #endif
  21.  
  22. /*===========================================================================*/
  23.  
  24. #undef PI
  25. #define PI        (double)3.14159265358979323846    /* ubiquitous PI */
  26. #define TWOPI        (double)6.28318530717958647693
  27. #define bams_to_deg    (double)0.00549316406250000000    /* angle conv consts */
  28. #define deg_to_bams   (double)182.04444444444444444444
  29. #define bams_to_rad    (double)0.00009587379924285258
  30. #define rad_to_bams (double)10430.37835047045272494957
  31. #define deg_to_rad    (double)0.01745329251994329577
  32. #define rad_to_deg     (double)57.29577951308232087680
  33. #define BAMS180        ((bams)0x8000)        /* BAMS: (-)180 degrees */
  34. #define BAMS090        ((bams)0x4000)        /* BAMS: 90 degrees */
  35.  
  36. #define FALSE        0
  37. #define TRUE        (!FALSE)
  38.  
  39. #define MAINS        0
  40. #define THINGS        1
  41. #define LINES        2
  42. #define SIDES        3
  43. #define VERTS        4
  44. #define SEGS        5
  45. #define SSECTS        6
  46. #define NODES        7
  47. #define SECTS        8
  48. #define REJECTS        9
  49. #define BLKMAPS        10
  50. #define ALL        11
  51.  
  52. /*===========================================================================*/
  53.  
  54. #define abs(a)        ((a) < 0 ? -(a) : (a))
  55. #define min(a,b)    ((a) < (b) ? (a) : (b))
  56. #define max(a,b)    ((a) < (b) ? (b) : (a))
  57. #define numbytes(v)    ((unsigned)sizeof(v))
  58. #define numelm(a)    (sizeof a / sizeof a[0])
  59. #define sgn(a)        ((0<(a))-((a)<0))
  60. #if defined(BSWAP)
  61. #define bswapw(v)    ((unsigned short)((((v)>>8)&0xFF) | ((v)<<8)))
  62. #define bswapl(v)    ((unsigned long)((((v)>>24)&0x000000FFL) | \
  63.                              (((v)>> 8)&0x0000FF00L) | \
  64.                              (((v)<< 8)&0x00FF0000L) | \
  65.                              ( (v)<<24)))
  66. #else
  67. #define bswapw(v)    (v)
  68. #define bswapl(v)    (v)
  69. #endif
  70.  
  71. #if defined(__TURBOC__)
  72. #define blockmem(t,n)    (t huge*)farcalloc((unsigned)(n),sizeof(t))
  73. #define blockfree(b)    ((b)!=NULL?farfree((char huge*)(b)):0)
  74. #else
  75. #define blockmem(t,n)    (t *)calloc((unsigned)(n),sizeof(t))
  76. #define blockfree(b)    ((b)!=NULL?free((char *)(b)):0)
  77. #endif
  78.  
  79. #define Things        ((DOOM_THING *)WInfo.data[WInfo.lvlndx+THINGS])
  80. #define Lines        ((DOOM_LINE *)WInfo.data[WInfo.lvlndx+LINES])
  81. #define Sides        ((DOOM_SIDE *)WInfo.data[WInfo.lvlndx+SIDES])
  82. #define Verts        ((DOOM_VERT *)WInfo.data[WInfo.lvlndx+VERTS])
  83. #define Segs        ((DOOM_SEGS *)WInfo.data[WInfo.lvlndx+SEGS])
  84. #define Ssecs        ((DOOM_SSECTOR *)WInfo.data[WInfo.lvlndx+SSECTS])
  85. #define Nodes        ((DOOM_NODE *)WInfo.data[WInfo.lvlndx+NODES])
  86. #define Sects        ((DOOM_SECTOR *)WInfo.data[WInfo.lvlndx+SECTS])
  87. #define Rejects        ((DOOM_REJECT *)WInfo.data[WInfo.lvlndx+REJECTS])
  88. #define Blockmaps    ((DOOM_BLOCKMAP *)WInfo.data[WInfo.lvlndx+BLKMAPS])
  89.  
  90. #define NThings        WInfo.count[WInfo.lvlndx+THINGS]
  91. #define NLines        WInfo.count[WInfo.lvlndx+LINES]
  92. #define NSides        WInfo.count[WInfo.lvlndx+SIDES]
  93. #define NVerts        WInfo.count[WInfo.lvlndx+VERTS]
  94. #define NSegs        WInfo.count[WInfo.lvlndx+SEGS]
  95. #define NSsecs        WInfo.count[WInfo.lvlndx+SSECTS]
  96. #define NNodes        WInfo.count[WInfo.lvlndx+NODES]
  97. #define NSects        WInfo.count[WInfo.lvlndx+SECTS]
  98. #define NRejects    WInfo.count[WInfo.lvlndx+REJECTS]
  99. #define NBlockmaps    WInfo.count[WInfo.lvlndx+BLKMAPS]
  100.  
  101. /*===========================================================================*/
  102.  
  103. #define bcase        break;case        /* for a more reasonabble */
  104. #define bdefault    break;default        /* switch statement       */
  105. #define global                    /* global declarations */
  106. #define forward        extern            /* forward references */
  107. #define local        static            /* local declarations */
  108. #define otherwise    break;default        /* alternate default case */
  109. #define repeat        do
  110. #define until(expr)    while (!(expr))        /* for do ... until loops */
  111.  
  112. /*===========================================================================*/
  113.  
  114. typedef unsigned short    ushort;
  115. typedef unsigned int    boolean;        /* integer used as boolean */
  116. typedef short        word;            /* 16-bit word */
  117. typedef word        bams;            /* 16-bit bams */
  118.  
  119. /*===========================================================================*/
  120.  
  121. typedef struct DOOM_THING {            /* thing information */
  122.     short x, y;
  123.     short angle;
  124.     short flag;
  125.     short item;
  126. } DOOM_THING;
  127.  
  128. typedef struct DOOM_LINE {            /* line information */
  129.     short fndx, tndx;
  130.     short flag, action_flag;
  131.     short sect_tag;
  132.     short rsidndx, lsidndx;
  133. } DOOM_LINE;
  134.  
  135. typedef struct DOOM_SIDE {            /* side information */
  136.     short image_xoff, image_yoff;
  137.     char lowwall[8], highwall[8], fullwall[8];
  138.     short sectndx;
  139. } DOOM_SIDE;
  140.  
  141. typedef struct DOOM_VERT {            /* vertex information */
  142.     short x, y;
  143. } DOOM_VERT;
  144.  
  145. typedef struct DOOM_SEGS {            /* segment information */
  146.     short fndx, tndx;
  147.     bams angle;
  148.     short lndx;
  149.     short sndx;
  150.     short loffset;
  151. } DOOM_SEGS;
  152.  
  153. typedef struct DOOM_SSECTOR {            /* subsector information */
  154.     short count;
  155.     short sndx;
  156. } DOOM_SSECTOR;
  157.  
  158. typedef struct DOOM_NODE {            /* node information */
  159.     short x, y;
  160.     short xdel, ydel;
  161.     short rymax, rymin, rxmin, rxmax;
  162.     short lymax, lymin, lxmin, lxmax;
  163.     short nndx[2];
  164. } DOOM_NODE;
  165.  
  166. typedef struct DOOM_SECTOR {            /* sector information */
  167.     short floor_ht, ceil_ht;
  168.     char floor_desc[8], ceil_desc[8];
  169.     short light_lvl;
  170.     short property;
  171.     short line_tag;
  172. } DOOM_SECTOR;
  173.  
  174. typedef unsigned char    DOOM_REJECT;        /* reject information */
  175.  
  176. typedef short        DOOM_BLOCKMAP;        /* block map information */
  177.  
  178. typedef struct WAD_HEAD {            /* WAD file header */
  179.     char ident[4];
  180.     long count;
  181.     long offset;
  182. } WAD_HEAD;
  183.  
  184. typedef struct DIR_ENTRY {            /* WAD file directory entry */
  185.     long offset;
  186.     long nbytes;
  187.     char name[8];
  188. } DIR_ENTRY;
  189.  
  190. typedef struct WAD_INFO {            /* WAD file information */
  191.     WAD_HEAD head;                    /* file header */
  192.     DIR_ENTRY *origdir,                /* orig directory */
  193.               *dir;                    /* resources dirctry */
  194.     char **data;                    /* resources data */
  195.     boolean *changed;                /* rsrce changed flg */
  196.     int *count;                    /* resources size */
  197.     int lvlndx;                    /* where a level is */
  198.     int ep, mp;                    /* cur episode/map */
  199.     double ver;                    /* patch version */
  200. } WAD_INFO;
  201.  
  202. /*===========================================================================*/
  203.  
  204. extern WAD_INFO WInfo;                /* WAD file information */
  205.  
  206. #define DM_Globals    1            /* now have defined these */
  207. #endif
  208.