DOOMDEF.H 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  1. // DoomDef.h
  2. #ifndef __DOOMDEF__
  3. #define __DOOMDEF__
  4. #include <stdio.h>
  5. #include <string.h>
  6. #ifdef __WATCOMC__
  7. #include <malloc.h>
  8. #define strcasecmp strcmpi
  9. #define strncasecmp strnicmp
  10. #endif
  11. #define VERSION 130
  12. #define VERSION_TEXT "v1.3"
  13. // if rangecheck is undefined, most parameter validation debugging code
  14. // will not be compiled
  15. //#define RANGECHECK
  16. // all external data is defined here
  17. #include "DoomData.h"
  18. // all important printed strings
  19. #include "DStrings.h"
  20. // header generated by multigen utility
  21. #include "info.h"
  22. extern byte *destview, *destscreen; // PC direct to screen pointers
  23. //
  24. // most key data are simple ascii (uppercased)
  25. //
  26. #define KEY_RIGHTARROW 0xae
  27. #define KEY_LEFTARROW 0xac
  28. #define KEY_UPARROW 0xad
  29. #define KEY_DOWNARROW 0xaf
  30. #define KEY_ESCAPE 27
  31. #define KEY_ENTER 13
  32. #define KEY_F1 (0x80+0x3b)
  33. #define KEY_F2 (0x80+0x3c)
  34. #define KEY_F3 (0x80+0x3d)
  35. #define KEY_F4 (0x80+0x3e)
  36. #define KEY_F5 (0x80+0x3f)
  37. #define KEY_F6 (0x80+0x40)
  38. #define KEY_F7 (0x80+0x41)
  39. #define KEY_F8 (0x80+0x42)
  40. #define KEY_F9 (0x80+0x43)
  41. #define KEY_F10 (0x80+0x44)
  42. #define KEY_F11 (0x80+0x57)
  43. #define KEY_F12 (0x80+0x58)
  44. #define KEY_BACKSPACE 127
  45. #define KEY_PAUSE 0xff
  46. #define KEY_EQUALS 0x3d
  47. #define KEY_MINUS 0x2d
  48. #define KEY_RSHIFT (0x80+0x36)
  49. #define KEY_RCTRL (0x80+0x1d)
  50. #define KEY_RALT (0x80+0x38)
  51. #define KEY_LALT KEY_RALT
  52. #define MAXCHAR ((char)0x7f)
  53. #define MAXSHORT ((short)0x7fff)
  54. #define MAXINT ((int)0x7fffffff) /* max pos 32-bit int */
  55. #define MAXLONG ((long)0x7fffffff)
  56. #define MINCHAR ((char)0x80)
  57. #define MINSHORT ((short)0x8000)
  58. #define MININT ((int)0x80000000) /* max negative 32-bit integer */
  59. #define MINLONG ((long)0x80000000)
  60. #define FINEANGLES 8192
  61. #define FINEMASK (FINEANGLES-1)
  62. #define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000
  63. #define SAVEGAMENAME "hticsav"
  64. #define SAVEGAMENAMECD "c:\\heretic.cd\\hticsav"
  65. /*
  66. ===============================================================================
  67. GLOBAL TYPES
  68. ===============================================================================
  69. */
  70. #define NUMARTIFCTS 28
  71. #define MAXPLAYERS 4
  72. #define TICRATE 35 // number of tics / second
  73. #define TICSPERSEC 35
  74. #define FRACBITS 16
  75. #define FRACUNIT (1<<FRACBITS)
  76. typedef int fixed_t;
  77. #define ANGLE_1 0x01000000
  78. #define ANGLE_45 0x20000000
  79. #define ANGLE_90 0x40000000
  80. #define ANGLE_180 0x80000000
  81. #define ANGLE_MAX 0xffffffff
  82. #define ANG45 0x20000000
  83. #define ANG90 0x40000000
  84. #define ANG180 0x80000000
  85. #define ANG270 0xc0000000
  86. typedef unsigned angle_t;
  87. typedef enum
  88. {
  89. sk_baby,
  90. sk_easy,
  91. sk_medium,
  92. sk_hard,
  93. sk_nightmare
  94. } skill_t;
  95. typedef enum
  96. {
  97. ev_keydown,
  98. ev_keyup,
  99. ev_mouse,
  100. ev_joystick
  101. } evtype_t;
  102. typedef struct
  103. {
  104. evtype_t type;
  105. int data1; // keys / mouse/joystick buttons
  106. int data2; // mouse/joystick x move
  107. int data3; // mouse/joystick y move
  108. } event_t;
  109. typedef struct
  110. {
  111. char forwardmove; // *2048 for move
  112. char sidemove; // *2048 for move
  113. short angleturn; // <<16 for angle delta
  114. short consistancy; // checks for net game
  115. byte chatchar;
  116. byte buttons;
  117. byte lookfly; // look/fly up/down/centering
  118. byte arti; // artitype_t to use
  119. } ticcmd_t;
  120. #define BT_ATTACK 1
  121. #define BT_USE 2
  122. #define BT_CHANGE 4 // if true, the next 3 bits hold weapon num
  123. #define BT_WEAPONMASK (8+16+32)
  124. #define BT_WEAPONSHIFT 3
  125. #define BT_SPECIAL 128 // game events, not really buttons
  126. #define BTS_SAVEMASK (4+8+16)
  127. #define BTS_SAVESHIFT 2
  128. #define BT_SPECIALMASK 3
  129. #define BTS_PAUSE 1 // pause the game
  130. #define BTS_SAVEGAME 2 // save the game at each console
  131. // savegame slot numbers occupy the second byte of buttons
  132. typedef enum
  133. {
  134. GS_LEVEL,
  135. GS_INTERMISSION,
  136. GS_FINALE,
  137. GS_DEMOSCREEN
  138. } gamestate_t;
  139. typedef enum
  140. {
  141. ga_nothing,
  142. ga_loadlevel,
  143. ga_newgame,
  144. ga_loadgame,
  145. ga_savegame,
  146. ga_playdemo,
  147. ga_completed,
  148. ga_victory,
  149. ga_worlddone,
  150. ga_screenshot
  151. } gameaction_t;
  152. typedef enum
  153. {
  154. wipe_0,
  155. wipe_1,
  156. wipe_2,
  157. wipe_3,
  158. wipe_4,
  159. NUMWIPES,
  160. wipe_random
  161. } wipe_t;
  162. /*
  163. ===============================================================================
  164. MAPOBJ DATA
  165. ===============================================================================
  166. */
  167. // think_t is a function pointer to a routine to handle an actor
  168. typedef void (*think_t) ();
  169. typedef struct thinker_s
  170. {
  171. struct thinker_s *prev, *next;
  172. think_t function;
  173. } thinker_t;
  174. struct player_s;
  175. typedef struct mobj_s
  176. {
  177. thinker_t thinker; // thinker links
  178. // info for drawing
  179. fixed_t x,y,z;
  180. struct mobj_s *snext, *sprev; // links in sector (if needed)
  181. angle_t angle;
  182. spritenum_t sprite; // used to find patch_t and flip value
  183. int frame; // might be ord with FF_FULLBRIGHT
  184. // interaction info
  185. struct mobj_s *bnext, *bprev; // links in blocks (if needed)
  186. struct subsector_s *subsector;
  187. fixed_t floorz, ceilingz; // closest together of contacted secs
  188. fixed_t radius, height; // for movement checking
  189. fixed_t momx, momy, momz; // momentums
  190. int validcount; // if == validcount, already checked
  191. mobjtype_t type;
  192. mobjinfo_t *info; // &mobjinfo[mobj->type]
  193. int tics; // state tic counter
  194. state_t *state;
  195. int damage; // For missiles
  196. int flags;
  197. int flags2; // Heretic flags
  198. int special1; // Special info
  199. int special2; // Special info
  200. int health;
  201. int movedir; // 0-7
  202. int movecount; // when 0, select a new dir
  203. struct mobj_s *target; // thing being chased/attacked (or NULL)
  204. // also the originator for missiles
  205. int reactiontime; // if non 0, don't attack yet
  206. // used by player to freeze a bit after
  207. // teleporting
  208. int threshold; // if >0, the target will be chased
  209. // no matter what (even if shot)
  210. struct player_s *player; // only valid if type == MT_PLAYER
  211. int lastlook; // player number last looked for
  212. mapthing_t spawnpoint; // for nightmare respawn
  213. } mobj_t;
  214. // each sector has a degenmobj_t in it's center for sound origin purposes
  215. typedef struct
  216. {
  217. thinker_t thinker; // not used for anything
  218. fixed_t x,y,z;
  219. } degenmobj_t;
  220. // Most damage defined using HITDICE
  221. #define HITDICE(a) ((1+(P_Random()&7))*a)
  222. //
  223. // frame flags
  224. //
  225. #define FF_FULLBRIGHT 0x8000 // flag in thing->frame
  226. #define FF_FRAMEMASK 0x7fff
  227. // --- mobj.flags ---
  228. #define MF_SPECIAL 1 // call P_SpecialThing when touched
  229. #define MF_SOLID 2
  230. #define MF_SHOOTABLE 4
  231. #define MF_NOSECTOR 8 // don't use the sector links
  232. // (invisible but touchable)
  233. #define MF_NOBLOCKMAP 16 // don't use the blocklinks
  234. // (inert but displayable)
  235. #define MF_AMBUSH 32
  236. #define MF_JUSTHIT 64 // try to attack right back
  237. #define MF_JUSTATTACKED 128 // take at least one step before attacking
  238. #define MF_SPAWNCEILING 256 // hang from ceiling instead of floor
  239. #define MF_NOGRAVITY 512 // don't apply gravity every tic
  240. // movement flags
  241. #define MF_DROPOFF 0x400 // allow jumps from high places
  242. #define MF_PICKUP 0x800 // for players to pick up items
  243. #define MF_NOCLIP 0x1000 // player cheat
  244. #define MF_SLIDE 0x2000 // keep info about sliding along walls
  245. #define MF_FLOAT 0x4000 // allow moves to any height, no gravity
  246. #define MF_TELEPORT 0x8000 // don't cross lines or look at heights
  247. #define MF_MISSILE 0x10000 // don't hit same species, explode on block
  248. #define MF_DROPPED 0x20000 // dropped by a demon, not level spawned
  249. #define MF_SHADOW 0x40000 // use fuzzy draw (shadow demons / invis)
  250. #define MF_NOBLOOD 0x80000 // don't bleed when shot (use puff)
  251. #define MF_CORPSE 0x100000 // don't stop moving halfway off a step
  252. #define MF_INFLOAT 0x200000 // floating to a height for a move, don't
  253. // auto float to target's height
  254. #define MF_COUNTKILL 0x400000 // count towards intermission kill total
  255. #define MF_COUNTITEM 0x800000 // count towards intermission item total
  256. #define MF_SKULLFLY 0x1000000 // skull in flight
  257. #define MF_NOTDMATCH 0x2000000 // don't spawn in death match (key cards)
  258. #define MF_TRANSLATION 0xc000000 // if 0x4 0x8 or 0xc, use a translation
  259. #define MF_TRANSSHIFT 26 // table for player colormaps
  260. // --- mobj.flags2 ---
  261. #define MF2_LOGRAV 0x00000001 // alternate gravity setting
  262. #define MF2_WINDTHRUST 0x00000002 // gets pushed around by the wind
  263. // specials
  264. #define MF2_FLOORBOUNCE 0x00000004 // bounces off the floor
  265. #define MF2_THRUGHOST 0x00000008 // missile will pass through ghosts
  266. #define MF2_FLY 0x00000010 // fly mode is active
  267. #define MF2_FOOTCLIP 0x00000020 // if feet are allowed to be clipped
  268. #define MF2_SPAWNFLOAT 0x00000040 // spawn random float z
  269. #define MF2_NOTELEPORT 0x00000080 // does not teleport
  270. #define MF2_RIP 0x00000100 // missile rips through solid
  271. // targets
  272. #define MF2_PUSHABLE 0x00000200 // can be pushed by other moving
  273. // mobjs
  274. #define MF2_SLIDE 0x00000400 // slides against walls
  275. #define MF2_ONMOBJ 0x00000800 // mobj is resting on top of another
  276. // mobj
  277. #define MF2_PASSMOBJ 0x00001000 // Enable z block checking. If on,
  278. // this flag will allow the mobj to
  279. // pass over/under other mobjs.
  280. #define MF2_CANNOTPUSH 0x00002000 // cannot push other pushable mobjs
  281. #define MF2_FEETARECLIPPED 0x00004000 // a mobj's feet are now being cut
  282. #define MF2_BOSS 0x00008000 // mobj is a major boss
  283. #define MF2_FIREDAMAGE 0x00010000 // does fire damage
  284. #define MF2_NODMGTHRUST 0x00020000 // does not thrust target when
  285. // damaging
  286. #define MF2_TELESTOMP 0x00040000 // mobj can stomp another
  287. #define MF2_FLOATBOB 0x00080000 // use float bobbing z movement
  288. #define MF2_DONTDRAW 0X00100000 // don't generate a vissprite
  289. //=============================================================================
  290. typedef enum
  291. {
  292. PST_LIVE, // playing
  293. PST_DEAD, // dead on the ground
  294. PST_REBORN // ready to restart
  295. } playerstate_t;
  296. // psprites are scaled shapes directly on the view screen
  297. // coordinates are given for a 320*200 view screen
  298. typedef enum
  299. {
  300. ps_weapon,
  301. ps_flash,
  302. NUMPSPRITES
  303. } psprnum_t;
  304. typedef struct
  305. {
  306. state_t *state; // a NULL state means not active
  307. int tics;
  308. fixed_t sx, sy;
  309. } pspdef_t;
  310. typedef enum
  311. {
  312. key_yellow,
  313. key_green,
  314. key_blue,
  315. NUMKEYS
  316. } keytype_t;
  317. typedef enum
  318. {
  319. wp_staff,
  320. wp_goldwand,
  321. wp_crossbow,
  322. wp_blaster,
  323. wp_skullrod,
  324. wp_phoenixrod,
  325. wp_mace,
  326. wp_gauntlets,
  327. wp_beak,
  328. NUMWEAPONS,
  329. wp_nochange
  330. } weapontype_t;
  331. #define AMMO_GWND_WIMPY 10
  332. #define AMMO_GWND_HEFTY 50
  333. #define AMMO_CBOW_WIMPY 5
  334. #define AMMO_CBOW_HEFTY 20
  335. #define AMMO_BLSR_WIMPY 10
  336. #define AMMO_BLSR_HEFTY 25
  337. #define AMMO_SKRD_WIMPY 20
  338. #define AMMO_SKRD_HEFTY 100
  339. #define AMMO_PHRD_WIMPY 1
  340. #define AMMO_PHRD_HEFTY 10
  341. #define AMMO_MACE_WIMPY 20
  342. #define AMMO_MACE_HEFTY 100
  343. typedef enum
  344. {
  345. am_goldwand,
  346. am_crossbow,
  347. am_blaster,
  348. am_skullrod,
  349. am_phoenixrod,
  350. am_mace,
  351. NUMAMMO,
  352. am_noammo // staff, gauntlets
  353. } ammotype_t;
  354. typedef struct
  355. {
  356. ammotype_t ammo;
  357. int upstate;
  358. int downstate;
  359. int readystate;
  360. int atkstate;
  361. int holdatkstate;
  362. int flashstate;
  363. } weaponinfo_t;
  364. extern weaponinfo_t wpnlev1info[NUMWEAPONS];
  365. extern weaponinfo_t wpnlev2info[NUMWEAPONS];
  366. typedef enum
  367. {
  368. arti_none,
  369. arti_invulnerability,
  370. arti_invisibility,
  371. arti_health,
  372. arti_superhealth,
  373. arti_tomeofpower,
  374. arti_torch,
  375. arti_firebomb,
  376. arti_egg,
  377. arti_fly,
  378. arti_teleport,
  379. NUMARTIFACTS
  380. } artitype_t;
  381. typedef enum
  382. {
  383. pw_None,
  384. pw_invulnerability,
  385. pw_invisibility,
  386. pw_allmap,
  387. pw_infrared,
  388. pw_weaponlevel2,
  389. pw_flight,
  390. pw_shield,
  391. pw_health2,
  392. NUMPOWERS
  393. } powertype_t;
  394. #define INVULNTICS (30*35)
  395. #define INVISTICS (60*35)
  396. #define INFRATICS (120*35)
  397. #define IRONTICS (60*35)
  398. #define WPNLEV2TICS (40*35)
  399. #define FLIGHTTICS (60*35)
  400. #define CHICKENTICS (40*35)
  401. #define MESSAGETICS (4*35)
  402. #define BLINKTHRESHOLD (4*32)
  403. #define NUMINVENTORYSLOTS 14
  404. typedef struct
  405. {
  406. int type;
  407. int count;
  408. } inventory_t;
  409. /*
  410. ================
  411. =
  412. = player_t
  413. =
  414. ================
  415. */
  416. typedef struct player_s
  417. {
  418. mobj_t *mo;
  419. playerstate_t playerstate;
  420. ticcmd_t cmd;
  421. fixed_t viewz; // focal origin above r.z
  422. fixed_t viewheight; // base height above floor for viewz
  423. fixed_t deltaviewheight; // squat speed
  424. fixed_t bob; // bounded/scaled total momentum
  425. int flyheight;
  426. int lookdir;
  427. boolean centering;
  428. int health; // only used between levels, mo->health
  429. // is used during levels
  430. int armorpoints, armortype; // armor type is 0-2
  431. inventory_t inventory[NUMINVENTORYSLOTS];
  432. artitype_t readyArtifact;
  433. int artifactCount;
  434. int inventorySlotNum;
  435. int powers[NUMPOWERS];
  436. boolean keys[NUMKEYS];
  437. boolean backpack;
  438. signed int frags[MAXPLAYERS]; // kills of other players
  439. weapontype_t readyweapon;
  440. weapontype_t pendingweapon; // wp_nochange if not changing
  441. boolean weaponowned[NUMWEAPONS];
  442. int ammo[NUMAMMO];
  443. int maxammo[NUMAMMO];
  444. int attackdown, usedown; // true if button down last tic
  445. int cheats; // bit flags
  446. int refire; // refired shots are less accurate
  447. int killcount, itemcount, secretcount; // for intermission
  448. char *message; // hint messages
  449. int messageTics; // counter for showing messages
  450. int damagecount, bonuscount;// for screen flashing
  451. int flamecount; // for flame thrower duration
  452. mobj_t *attacker; // who did damage (NULL for floors)
  453. int extralight; // so gun flashes light up areas
  454. int fixedcolormap; // can be set to REDCOLORMAP, etc
  455. int colormap; // 0-3 for which color to draw player
  456. pspdef_t psprites[NUMPSPRITES]; // view sprites (gun, etc)
  457. boolean didsecret; // true if secret level has been done
  458. int chickenTics; // player is a chicken if > 0
  459. int chickenPeck; // chicken peck countdown
  460. mobj_t *rain1; // active rain maker 1
  461. mobj_t *rain2; // active rain maker 2
  462. } player_t;
  463. #define CF_NOCLIP 1
  464. #define CF_GODMODE 2
  465. #define CF_NOMOMENTUM 4 // not really a cheat, just a debug aid
  466. #define BACKUPTICS 12 // CHANGED FROM 12 !?!?
  467. typedef struct
  468. {
  469. unsigned checksum; // high bit is retransmit request
  470. byte retransmitfrom; // only valid if NCMD_RETRANSMIT
  471. byte starttic;
  472. byte player, numtics;
  473. ticcmd_t cmds[BACKUPTICS];
  474. } doomdata_t;
  475. typedef struct
  476. {
  477. long id;
  478. short intnum; // DOOM executes an int to execute commands
  479. // communication between DOOM and the driver
  480. short command; // CMD_SEND or CMD_GET
  481. short remotenode; // dest for send, set by get (-1 = no packet)
  482. short datalength; // bytes in doomdata to be sent
  483. // info common to all nodes
  484. short numnodes; // console is allways node 0
  485. short ticdup; // 1 = no duplication, 2-5 = dup for slow nets
  486. short extratics; // 1 = send a backup tic in every packet
  487. short deathmatch; // 1 = deathmatch
  488. short savegame; // -1 = new game, 0-5 = load savegame
  489. short episode; // 1-3
  490. short map; // 1-9
  491. short skill; // 1-5
  492. // info specific to this node
  493. short consoleplayer;
  494. short numplayers;
  495. short angleoffset; // 1 = left, 0 = center, -1 = right
  496. short drone; // 1 = drone
  497. // packet data to be sent
  498. doomdata_t data;
  499. } doomcom_t;
  500. #define DOOMCOM_ID 0x12345678l
  501. extern doomcom_t *doomcom;
  502. extern doomdata_t *netbuffer; // points inside doomcom
  503. #define MAXNETNODES 8 // max computers in a game
  504. #define CMD_SEND 1
  505. #define CMD_GET 2
  506. #define SBARHEIGHT 42 // status bar height at bottom of screen
  507. /*
  508. ===============================================================================
  509. GLOBAL VARIABLES
  510. ===============================================================================
  511. */
  512. #define TELEFOGHEIGHT (32*FRACUNIT)
  513. #define MAXEVENTS 64
  514. extern event_t events[MAXEVENTS];
  515. extern int eventhead;
  516. extern int eventtail;
  517. extern fixed_t finesine[5*FINEANGLES/4];
  518. extern fixed_t *finecosine;
  519. extern gameaction_t gameaction;
  520. extern boolean paused;
  521. extern boolean shareware; // true if main WAD is the shareware version
  522. extern boolean ExtendedWAD; // true if main WAD is the extended version
  523. extern boolean nomonsters; // checkparm of -nomonsters
  524. extern boolean respawnparm; // checkparm of -respawn
  525. extern boolean debugmode; // checkparm of -debug
  526. extern boolean usergame; // ok to save / end game
  527. extern boolean ravpic; // checkparm of -ravpic
  528. extern boolean altpal; // checkparm to use an alternate palette routine
  529. extern boolean cdrom; // true if cd-rom mode active ("-cdrom")
  530. extern boolean deathmatch; // only if started as net death
  531. extern boolean netgame; // only true if >1 player
  532. extern boolean playeringame[MAXPLAYERS];
  533. extern int consoleplayer; // player taking events and displaying
  534. extern int displayplayer;
  535. extern int viewangleoffset; // ANG90 = left side, ANG270 = right
  536. extern player_t players[MAXPLAYERS];
  537. extern boolean singletics; // debug flag to cancel adaptiveness
  538. extern boolean DebugSound; // debug flag for displaying sound info
  539. extern int maxammo[NUMAMMO];
  540. extern boolean demoplayback;
  541. extern int skytexture;
  542. extern gamestate_t gamestate;
  543. extern skill_t gameskill;
  544. extern boolean respawnmonsters;
  545. extern int gameepisode;
  546. extern int gamemap;
  547. extern int prevmap;
  548. extern int totalkills, totalitems, totalsecret; // for intermission
  549. extern int levelstarttic; // gametic at level start
  550. extern int leveltime; // tics in game play for par
  551. extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS];
  552. extern int ticdup;
  553. #define MAXNETNODES 8
  554. extern ticcmd_t localcmds[BACKUPTICS];
  555. extern int rndindex;
  556. extern int gametic, maketic;
  557. extern int nettics[MAXNETNODES];
  558. #define SAVEGAMESIZE 0x30000
  559. #define SAVESTRINGSIZE 24
  560. extern byte *savebuffer;
  561. extern byte *save_p;
  562. extern mapthing_t *deathmatch_p;
  563. extern mapthing_t deathmatchstarts[10];
  564. extern mapthing_t playerstarts[MAXPLAYERS];
  565. extern int viewwindowx;
  566. extern int viewwindowy;
  567. extern int viewwidth;
  568. extern int scaledviewwidth;
  569. extern int viewheight;
  570. extern int mouseSensitivity;
  571. extern boolean precache; // if true, load all graphics at level load
  572. extern byte *screen; // off screen work buffer, from V_video.c
  573. extern boolean singledemo; // quit after playing a demo from cmdline
  574. extern FILE *debugfile;
  575. extern int bodyqueslot;
  576. extern skill_t startskill;
  577. extern int startepisode;
  578. extern int startmap;
  579. extern boolean autostart;
  580. /*
  581. ===============================================================================
  582. GLOBAL FUNCTIONS
  583. ===============================================================================
  584. */
  585. fixed_t FixedMul (fixed_t a, fixed_t b);
  586. fixed_t FixedDiv (fixed_t a, fixed_t b);
  587. fixed_t FixedDiv2 (fixed_t a, fixed_t b);
  588. #ifdef __WATCOMC__
  589. #pragma aux FixedMul = \
  590. "imul ebx", \
  591. "shrd eax,edx,16" \
  592. parm [eax] [ebx] \
  593. value [eax] \
  594. modify exact [eax edx]
  595. #pragma aux FixedDiv2 = \
  596. "cdq", \
  597. "shld edx,eax,16", \
  598. "sal eax,16", \
  599. "idiv ebx" \
  600. parm [eax] [ebx] \
  601. value [eax] \
  602. modify exact [eax edx]
  603. #endif
  604. #ifdef __BIG_ENDIAN__
  605. short ShortSwap(short);
  606. long LongSwap(long);
  607. #define SHORT(x) ShortSwap(x)
  608. #define LONG(x) LongSwap(x)
  609. #else
  610. #define SHORT(x) (x)
  611. #define LONG(x) (x)
  612. #endif
  613. //-----------
  614. //MEMORY ZONE
  615. //-----------
  616. // tags < 100 are not overwritten until freed
  617. #define PU_STATIC 1 // static entire execution time
  618. #define PU_SOUND 2 // static while playing
  619. #define PU_MUSIC 3 // static while playing
  620. #define PU_DAVE 4 // anything else Dave wants static
  621. #define PU_LEVEL 50 // static until level exited
  622. #define PU_LEVSPEC 51 // a special thinker in a level
  623. // tags >= 100 are purgable whenever needed
  624. #define PU_PURGELEVEL 100
  625. #define PU_CACHE 101
  626. void Z_Init (void);
  627. void *Z_Malloc (int size, int tag, void *ptr);
  628. void Z_Free (void *ptr);
  629. void Z_FreeTags (int lowtag, int hightag);
  630. void Z_DumpHeap (int lowtag, int hightag);
  631. void Z_FileDumpHeap (FILE *f);
  632. void Z_CheckHeap (void);
  633. void Z_ChangeTag2 (void *ptr, int tag);
  634. int Z_FreeMemory (void);
  635. extern boolean MallocFailureOk;
  636. typedef struct memblock_s
  637. {
  638. int size; // including the header and possibly tiny fragments
  639. void **user; // NULL if a free block
  640. int tag; // purgelevel
  641. int id; // should be ZONEID
  642. struct memblock_s *next, *prev;
  643. } memblock_t;
  644. #define Z_ChangeTag(p,t) \
  645. { \
  646. if (( (memblock_t *)( (byte *)(p) - sizeof(memblock_t)))->id!=0x1d4a11) \
  647. I_Error("Z_CT at "__FILE__":%i",__LINE__); \
  648. Z_ChangeTag2(p,t); \
  649. };
  650. //-------
  651. //WADFILE
  652. //-------
  653. typedef struct
  654. {
  655. char name[8];
  656. int handle,position,size;
  657. } lumpinfo_t;
  658. extern lumpinfo_t *lumpinfo;
  659. extern int numlumps;
  660. void W_InitMultipleFiles (char **filenames);
  661. int W_CheckNumForName (char *name);
  662. int W_GetNumForName (char *name);
  663. int W_LumpLength (int lump);
  664. void W_ReadLump (int lump, void *dest);
  665. void *W_CacheLumpNum (int lump, int tag);
  666. void *W_CacheLumpName (char *name, int tag);
  667. //----------
  668. //BASE LEVEL
  669. //----------
  670. void D_DoomMain (void);
  671. void IncThermo(void);
  672. void InitThermo(int max);
  673. void tprintf(char *string, int initflag);
  674. // not a globally visible function, just included for source reference
  675. // calls all startup code
  676. // parses command line options
  677. // if not overrided, calls N_AdvanceDemo
  678. void D_DoomLoop (void);
  679. // not a globally visible function, just included for source reference
  680. // called by D_DoomMain, never exits
  681. // manages timing and IO
  682. // calls all ?_Responder, ?_Ticker, and ?_Drawer functions
  683. // calls I_GetTime, I_StartFrame, and I_StartTic
  684. void D_PostEvent (event_t *ev);
  685. // called by IO functions when input is detected
  686. void NetUpdate (void);
  687. // create any new ticcmds and broadcast to other players
  688. void D_QuitNetGame (void);
  689. // broadcasts special packets to other players to notify of game exit
  690. void TryRunTics (void);
  691. //---------
  692. //SYSTEM IO
  693. //---------
  694. #if 1
  695. #define SCREENWIDTH 320
  696. #define SCREENHEIGHT 200
  697. #else
  698. #define SCREENWIDTH 560
  699. #define SCREENHEIGHT 375
  700. #endif
  701. byte *I_ZoneBase (int *size);
  702. // called by startup code to get the ammount of memory to malloc
  703. // for the zone management
  704. int I_GetTime (void);
  705. // called by D_DoomLoop
  706. // returns current time in tics
  707. void I_StartFrame (void);
  708. // called by D_DoomLoop
  709. // called before processing any tics in a frame (just after displaying a frame)
  710. // time consuming syncronous operations are performed here (joystick reading)
  711. // can call D_PostEvent
  712. void I_StartTic (void);
  713. // called by D_DoomLoop
  714. // called before processing each tic in a frame
  715. // quick syncronous operations are performed here
  716. // can call D_PostEvent
  717. // asyncronous interrupt functions should maintain private ques that are
  718. // read by the syncronous functions to be converted into events
  719. void I_Init (void);
  720. // called by D_DoomMain
  721. // determines the hardware configuration and sets up the video mode
  722. void I_InitGraphics (void);
  723. void I_InitNetwork (void);
  724. void I_NetCmd (void);
  725. void I_Error (char *error, ...);
  726. // called by anything that can generate a terminal error
  727. // bad exit with diagnostic message
  728. void I_Quit (void);
  729. // called by M_Responder when quit is selected
  730. // clean exit, displays sell blurb
  731. void I_SetPalette (byte *palette);
  732. // takes full 8 bit values
  733. void I_Update(void);
  734. // Copy buffer to video
  735. void I_WipeUpdate(wipe_t wipe);
  736. // Copy buffer to video with wipe effect
  737. void I_WaitVBL(int count);
  738. // wait for vertical retrace or pause a bit
  739. void I_BeginRead (void);
  740. void I_EndRead (void);
  741. byte *I_AllocLow (int length);
  742. // allocates from low memory under dos, just mallocs under unix
  743. void I_Tactile (int on, int off, int total);
  744. #ifdef __WATCOMC__
  745. extern boolean useexterndriver;
  746. #define EBT_FIRE 1
  747. #define EBT_OPENDOOR 2
  748. #define EBT_SPEED 4
  749. #define EBT_STRAFE 8
  750. #define EBT_MAP 0x10
  751. #define EBT_INVENTORYLEFT 0x20
  752. #define EBT_INVENTORYRIGHT 0x40
  753. #define EBT_USEARTIFACT 0x80
  754. #define EBT_FLYDROP 0x100
  755. #define EBT_CENTERVIEW 0x200
  756. #define EBT_PAUSE 0x400
  757. #define EBT_WEAPONCYCLE 0x800
  758. typedef struct
  759. {
  760. short vector; // Interrupt vector
  761. signed char moveForward; // forward/backward (maxes at 50)
  762. signed char moveSideways; // strafe (maxes at 24)
  763. short angleTurn; // turning speed (640 [slow] 1280 [fast])
  764. short angleHead; // head angle (+2080 [left] : 0 [center] : -2048 [right])
  765. signed char pitch; // look up/down (-110 : +90)
  766. signed char flyDirection; // flyheight (+1/-1)
  767. unsigned short buttons; // EBT_* flags
  768. } externdata_t;
  769. #endif
  770. //----
  771. //GAME
  772. //----
  773. void G_DeathMatchSpawnPlayer (int playernum);
  774. void G_InitNew (skill_t skill, int episode, int map);
  775. void G_DeferedInitNew (skill_t skill, int episode, int map);
  776. // can be called by the startup code or M_Responder
  777. // a normal game starts at map 1, but a warp test can start elsewhere
  778. void G_DeferedPlayDemo (char *demo);
  779. void G_LoadGame (char *name);
  780. // can be called by the startup code or M_Responder
  781. // calls P_SetupLevel or W_EnterWorld
  782. void G_DoLoadGame (void);
  783. void G_SaveGame (int slot, char *description);
  784. // called by M_Responder
  785. // Support routines for saving games
  786. void SV_Open(char *fileName);
  787. void SV_Close(char *fileName);
  788. void SV_Write(void *buffer, int size);
  789. void SV_WriteByte(byte val);
  790. void SV_WriteWord(unsigned short val);
  791. void SV_WriteLong(unsigned int val);
  792. void G_RecordDemo (skill_t skill, int numplayers, int episode
  793. , int map, char *name);
  794. // only called by startup code
  795. void G_PlayDemo (char *name);
  796. void G_TimeDemo (char *name);
  797. void G_ExitLevel (void);
  798. void G_SecretExitLevel (void);
  799. void G_WorldDone (void);
  800. void G_Ticker (void);
  801. boolean G_Responder (event_t *ev);
  802. void G_ScreenShot (void);
  803. //-----
  804. //PLAY
  805. //-----
  806. void P_Ticker (void);
  807. // called by C_Ticker
  808. // can call G_PlayerExited
  809. // carries out all thinking of monsters and players
  810. void P_SetupLevel (int episode, int map, int playermask, skill_t skill);
  811. // called by W_Ticker
  812. void P_Init (void);
  813. // called by startup code
  814. void P_ArchivePlayers (void);
  815. void P_UnArchivePlayers (void);
  816. void P_ArchiveWorld (void);
  817. void P_UnArchiveWorld (void);
  818. void P_ArchiveThinkers (void);
  819. void P_UnArchiveThinkers (void);
  820. void P_ArchiveSpecials (void);
  821. void P_UnArchiveSpecials (void);
  822. // load / save game routines
  823. //-------
  824. //REFRESH
  825. //-------
  826. extern boolean setsizeneeded;
  827. extern boolean BorderNeedRefresh;
  828. extern boolean BorderTopRefresh;
  829. extern int UpdateState;
  830. // define the different areas for the dirty map
  831. #define I_NOUPDATE 0
  832. #define I_FULLVIEW 1
  833. #define I_STATBAR 2
  834. #define I_MESSAGES 4
  835. #define I_FULLSCRN 8
  836. void R_RenderPlayerView (player_t *player);
  837. // called by G_Drawer
  838. void R_Init (void);
  839. // called by startup code
  840. void R_DrawViewBorder (void);
  841. void R_DrawTopBorder (void);
  842. // if the view size is not full screen, draws a border around it
  843. void R_SetViewSize (int blocks, int detail);
  844. // called by M_Responder
  845. int R_FlatNumForName (char *name);
  846. int R_TextureNumForName (char *name);
  847. int R_CheckTextureNumForName (char *name);
  848. // called by P_Ticker for switches and animations
  849. // returns the texture number for the texture name
  850. //----
  851. //MISC
  852. //----
  853. extern int myargc;
  854. extern char **myargv;
  855. int M_CheckParm (char *check);
  856. // returns the position of the given parameter in the arg list (0 if not found)
  857. boolean M_ValidEpisodeMap(int episode, int map);
  858. // returns true if the episode/map combo is valid for the current
  859. // game configuration
  860. void M_ForceUppercase(char *text);
  861. // Changes a string to uppercase
  862. int M_Random (void);
  863. // returns a number from 0 to 255
  864. int P_Random (void);
  865. // as M_Random, but used only by the play simulation
  866. void M_ClearRandom (void);
  867. // fix randoms for demos
  868. void M_FindResponseFile(void);
  869. void M_ClearBox (fixed_t *box);
  870. void M_AddToBox (fixed_t *box, fixed_t x, fixed_t y);
  871. // bounding box functions
  872. boolean M_WriteFile (char const *name, void *source, int length);
  873. int M_ReadFile (char const *name, byte **buffer);
  874. void M_ScreenShot (void);
  875. void M_LoadDefaults (void);
  876. void M_SaveDefaults (void);
  877. int M_DrawText (int x, int y, boolean direct, char *string);
  878. //----------------------
  879. // Interlude (IN_lude.c)
  880. //----------------------
  881. extern boolean intermission;
  882. void IN_Start(void);
  883. void IN_Ticker(void);
  884. void IN_Drawer(void);
  885. //----------------------
  886. // Chat mode (CT_chat.c)
  887. //----------------------
  888. void CT_Init(void);
  889. void CT_Drawer(void);
  890. boolean CT_Responder(event_t *ev);
  891. void CT_Ticker(void);
  892. char CT_dequeueChatChar(void);
  893. extern boolean chatmodeon;
  894. extern boolean ultimatemsg;
  895. //--------------------
  896. // Finale (F_finale.c)
  897. //--------------------
  898. void F_Drawer(void);
  899. void F_Ticker(void);
  900. void F_StartFinale(void);
  901. //----------------------
  902. // STATUS BAR (SB_bar.c)
  903. //----------------------
  904. extern int SB_state;
  905. void SB_Init(void);
  906. boolean SB_Responder(event_t *event);
  907. void SB_Ticker(void);
  908. void SB_Drawer(void);
  909. //-----------------
  910. // MENU (MN_menu.c)
  911. //-----------------
  912. void MN_Init(void);
  913. void MN_ActivateMenu(void);
  914. void MN_DeactivateMenu(void);
  915. boolean MN_Responder(event_t *event);
  916. void MN_Ticker(void);
  917. void MN_Drawer(void);
  918. void MN_DrTextA(char *text, int x, int y);
  919. int MN_TextAWidth(char *text);
  920. void MN_DrTextB(char *text, int x, int y);
  921. int MN_TextBWidth(char *text);
  922. //------
  923. // VIDEO
  924. //------
  925. extern int dirtybox[4];
  926. extern byte gammatable[5][256];
  927. extern int usegamma;
  928. void V_Init(void); // Allocates buffer screens, call before R_Init
  929. void V_DrawPatch(int x, int y, patch_t *patch);
  930. void V_DrawFuzzPatch(int x, int y, patch_t *patch);
  931. void V_DrawShadowedPatch(int x, int y, patch_t *patch);
  932. void V_DrawRawScreen(byte *raw);
  933. #include "sounds.h"
  934. #endif // __DOOMDEF__