r_defs.h 8.9 KB

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