home *** CD-ROM | disk | FTP | other *** search
/ Home Edutainment Collection 4: Games & Extensions / Aztech-HomeEdutainmentCollection-Vol4-3DGamesExtensions.iso / dhacked / dehack0.txt next >
Text File  |  1994-06-14  |  16KB  |  403 lines

  1.                 "Hacking the DOOM.EXE file"
  2.  
  3.             by Matt Fell (matt.burnett@acebbs.com)
  4.                        June 13, 1994
  5. ===========================================================================
  6.  
  7.   Many of the characteristics of the DOOM environment are determined by the
  8. data in the DOOM.WAD file: the maps data, the picture data, the sounds, etc.
  9. Almost all of this has been explained in the Unofficial DOOM Specs. But 
  10. there is also a host of variables and possibilities in the DOOM.EXE file, 
  11. and in this article I will explain all I know about it. I'll probably 
  12. include a new chapter in the 1.4 specs, to contain this info. This is kind 
  13. of a trial run...
  14.   Many simple variables can be changed in the manner that the classic
  15. "HOCKEY" wad does it - by using the HACK.EXE program to patch doom.exe
  16. in the specified places. I once thought I would write a program that would
  17. enable easy editing of the "thing table" described below, for such cool
  18. effects as invisble Barons and floating imps. But I never did finish it.
  19. I get distracted easily :-), also I just love letting others do all the
  20. real work :-).
  21.   I freely mix hex and decimal numbers below. Hopefully you can tell from
  22. the context :-). All of this refers to the registered version 1.2 DOOM.EXE 
  23. file. When 1.4 comes out, I'll need to change the numbers, obviously. Some 
  24. of the data could be located by using search patterns, since much of it 
  25. doesn't change from version to version. But using the actual numbers is 
  26. probably better, although less flexible.
  27.   By far, the most possibilities are in the thing table, but I included
  28. just about the entireity of my notes, for completeness' sake. I'm compiling
  29. a list of ideas of what can be done by patching the exe, please contribute
  30. your thoughts! Example: reduce the damage done by the missles, for longer
  31. deathmatch battles. Another example: the entries in the thing table for 
  32. demons and spectres are IDENTICAL except for the bit that makes spectres 
  33. "inviso". Suppose one replaces the numbers for the "grey tree" with the 
  34. numbers from the "Baron"'s entry, and change the invisible bit. Then one 
  35. would have ADDED another monster, an invisible Baron, without having "taken 
  36. away" the original non-inviso Baron. Of course, one would no longer have 
  37. grey trees :-). I would really like to be able to expand the size of the 
  38. thing table, the frame table, and the sprite name list, but I have looked 
  39. for the appropriate pointers in vain. If someone could figure this out...
  40.   Also, please report any interesting results gained by experimenting,
  41. any errors, etc. Thanks.
  42.  
  43.   The data begins at $6f414 (455700) and continues to the end of the file,
  44. $8db27 (580391). Here's an overview of the sections:
  45.  
  46. start length what
  47.  
  48. 6f414  3d30  TEXT STRINGS
  49. 73412  1a34  various unknowns, probably to do with I/O, sound, mouse, etc.
  50. 74bf8 10000  looks like hard-coded math tables, for speed?
  51. 84bf8   148  misc.
  52. 84d40    82  gamma correction messages
  53. 84dc2   280  "are you sure you want to quit" messages
  54. 85042   3a2  MENUS (new game, load game, etc.)
  55. 853e4   140  ?
  56. 85524   36c  configuration options and defaults, like in DEFAULT.CFG
  57. 85890   174  ?
  58. 85a04    60  ?
  59. 85a64    54  ?
  60. 85ab8    c4  ?
  61. 85b7c    20  max ammo at start, and ammo per thing
  62. 85b9c    c0  ammo type and frame #s for the weapons
  63. 85c5c   188  ANIMATED WALLS and FLOORS
  64. 85de4   258  SWITCH-WALLS
  65. 8603c    c0  ?
  66. 860fc    d4  ?
  67. 861d0   500  5 colormaps for use with the gamma correction setting 0-4
  68. 866e4    fc  ?
  69. 867e0    40  pointers to chatmacros, "Green:", etc.
  70. 86820    88  pointers to level names, used on Automap
  71. 868a8    d8  splat mark coordinates for end-level screen
  72. 86980   5a8  wimap patch animations for end-level screen
  73. 86f28   224  SONG NAMES list of pointers
  74. 8714c   8b8  SOUND TABLE
  75. 87a04   1a4  SPRITE NAMES list of pointers
  76. 87ba8  3800  FRAME TABLE
  77. 8b3a8    20  ?
  78. 8b3c8  2368  THING TABLE
  79. 8d730   3fd  ?
  80.  
  81.   For readable lists of the TEXT STRINGS, THING TABLE, FRAME TABLE,
  82. SPRITE NAMES, and SOUND TABLE, see the accompanying (or appended below)
  83. Qbasic programs DEHACK. Instead of distributing a few hundred k of text
  84. files, I decided to use simple programs that you can run to get the same
  85. lists and tables that I use. Why Qbasic? Because everyone who has dos has
  86. it, and if you don't, you're smart enough to write little programs yourself.
  87.   This is one of the things I need feedback on - should I include these
  88. mini-programs in the chapter in the 1.4 specs? Or should I just have the
  89. descriptions and offset numbers, as below?
  90.   Unless noted differently, "integer" means a 4-byte integer.
  91.  
  92. 6f414   
  93.   START OF DATA. Several times I'll refer to pointers. All these pointers
  94. are integers. Add the values of these pointers to $6f414 and you'll get the 
  95. location of what's being pointed to.
  96.   Note: there's also at least one other kind of pointer in here, with larger
  97. values, that seem to point to a location in the code, NOT the data. I call
  98. these "code-pointers" for now. I know it's a lame term.
  99.  
  100. 6f414   
  101.   TEXT STRINGS. They all start on 4-byte boundaries, i.e. at xxxx0/4/8/c. 
  102. $00 ends the string. Then the next one starts at the next boundary, so a 4 
  103. byte string is followed by $00, then 3 bytes of random junk, then the next 
  104. string. The first string is 01 01 01, then "ULTRADIR", and so on. See 
  105. DEHACK1.BAS for a program to extract a list of all the text strings, 
  106. DEHACK1.TXT will be about 72k.
  107.  
  108. 73140   
  109.   I think this is the last string, "TZ"
  110.  
  111. 73144   
  112.   Misc. stuff I haven't investigated. Some of it has to do with sound card 
  113. stuff and mice and joysticks, because at 7384c is "DMXGUS.INI" and at 74ba8 
  114. are pointers which point to the strings "None", "PC_Speaker", "Adlib", etc.
  115.  
  116. 74bf8
  117.   64k of precisely ordered numbers, which leads me to believe they are
  118. pre-calculated math tables, to speed up some floating point operations
  119. used in the screen draw routine. Any other guesses?
  120.  
  121. 84bfc
  122.   3 pointers to the episode 1/2/3 end texts, "Once you beat...", "You've
  123. done it...", and "The loathsome Spiderdemon is dead..."
  124.  
  125. 84c24
  126.   pointer to the string "doom.wad"
  127.  
  128. 84c74
  129.   pointer to the string "default.cfg"
  130.  
  131. 84c78
  132.   8 integers: 1, 25, 50, 24, 40, 640, 1280, 320
  133.  
  134. 84c98
  135.   2 code-pointers
  136.  
  137. 84ccc
  138.   29 integers, with values like 90 and 135 and 180. Angles?
  139.  
  140. 84d40
  141.   "Gamma correction OFF", 00s, "Gamma correction level 1", ... 4. Each
  142. occupies $1a bytes.
  143.  
  144. 84dc2
  145.   8 text messages used to confirm quitting, each uses $50 bytes
  146.  
  147. 85042
  148.   MENUS. I know this controls to some extent which menu pictures are used
  149. for which menu, but I haven't figured it all out yet.
  150.  
  151. 853e4
  152.   14 ints: 42, 22, 23, 24, 28, 29, 31, 40, zeros
  153.  
  154. 8541c
  155.   256 bytes, values from 00-ff, no two the same, "random" order.
  156.  
  157. 85524
  158.   The configuration options. Each is 5 integers: a pointer to a string,
  159. like "mouse_sensitivity", a code-pointer, the default value for that
  160. option, a 0 or 1 (1 for all the "key_" options), and a 0. It would be
  161. pretty dense to do anything with this, I think.
  162.  
  163. 85890
  164.   About 117 integers, with a definite structure, but I can't figure it
  165. out, and changing/experimenting seems to do nothing.
  166.  
  167. 85a64
  168.   21 sets of 4 bytes: 0, 0, 1, 0, 320, 168, "33", 0, 1, $(b2 26 26 2e),
  169. $(ff 63 fd ff), a pointer that points to the $(b2...), 0, 1, "ema", 0, 0,
  170. 1, 0, 1, "xma". All these are unchanged from version 0.99 through 1.2,
  171. except the pointer obviously.
  172.  
  173. 85ab8
  174.   Ints: 0, -1, -1, 0, 0, 0, 0, 4, 7, 10, 12, 14, 15, 15, 0, 0, 112, 96, 64,
  175. 176, then 16 that are members of this set {-65536, -47000, 0, 47000, 65536},
  176. then 4, 5, 6, 7, 0, 1, 2, 3, 8, 3, 1, 5, 7
  177.  
  178. 85b7c
  179.   AMMO AMOUNTS. 8 integers: 200, 50, 300, 50, 10, 4, 20, 1. The first four
  180. are the maximum initial capacity for ammo, shells, cells, and rockets. The
  181. backpack doubles these amounts. The second four are how many ammo in a
  182. clip, shells, rockets/rocket, and cells/cell item. Boxes have 5x as much.
  183.  
  184. 859bc
  185.   AMMO TABLE. 8 sets of 6 integers:
  186.  
  187. Punch     5  4  3  2  5  0      
  188. Pistol    0 12 11 10 13 17
  189. Shotgun   1 20 19 18 21 30
  190. Chaingun  0 34 33 32 35 38
  191. Laucher   3 42 41 40 43 46
  192. Plasma    2 59 58 57 60 62
  193. BFG       2 66 65 64 67 71
  194. Chainsaw  5 53 52 50 54  0
  195.  
  196.   The first number of each set is the ammo type. Type 5 never runs out. The
  197. next three numbers are 3 frame #s (see the FRAME TABLE below) for the pics
  198. displayed when moving while holding that weapon. You know, the "bobbing
  199. weapon" effect? Fifth is the first frame of the "shoot" sequence for that
  200. weapon, and last is the first frame of the "firing" sequence. The "firing"
  201. pics are the ones that are lit up, fire coming out, etc.
  202.  
  203. 85c5c
  204.   ANIMATED WALLS and FLOORS. Each is 26 bytes: an integer, a 8-byte string,
  205. $00, a 8-byte string, $00, and a final int.
  206.  
  207. 0 NUKAGE3  NUKAGE1  8
  208. 0 FWATER4  FWATER1  8
  209. 0 SWATER4  SWATER1  8
  210. 0 LAVA4    LAVA1    8
  211. 0 BLOOD4   BLOOD1   8
  212. 1 BLODGR4  BLODGR1  8
  213. 1 SLADRIP4 SLADRIP1 8
  214. 1 BLODRIP4 BLODRIP1 8
  215. 1 FIREWALL FIREWALA 8
  216. 1 GSTFONT3 GSTFONT1 8
  217. 1 FIRELAVA FIRELAV3 8
  218. 1 FIREBLU2 FIREBLU1 8
  219. 1 ROCKRED3 ROCKRED1 8
  220.  
  221.   Obviously the 0/1 means floor or wall. The first string is the name of
  222. the animation cycle's LAST listed texture, the second string is the FIRST
  223. listed texture. The cycle includes them and all entries between them in
  224. whichever wad file is in effect (It doesn't have to be DOOM.WAD, a pwad
  225. with new TEXTURE1 and 2 resources works quite nicely. I'm doing it myself,
  226. for my levels). The final 08 doesn't seem to mean much.
  227.  
  228. 85dc8
  229.   A -1 then a bunch of zeros, maybe space for another animation cycle?
  230.  
  231. 85de4
  232.   SWITCH WALL NAMES. Each is 20 bytes: an 8-byte string, 00, another string,
  233. 00, and a 2-byte integer. There are 28 switches here, from (SW1BRCOM 
  234. SW2BRCOM 1) to (SW1WOOD SW2WOOD 2). When a switch is pulled, the game
  235. checks to see if the wall texture is on this list. If it is, it changes
  236. the wall texture to the corresponding alternate texture. The 2-byte integer
  237. 1 or 2 tells it to look in either TEXTURE1 or TEXTURE2.
  238.  
  239. 86028
  240.   20 zeros, again, room for one more?
  241.  
  242. 8603c
  243.   48 integers: 3 0 2 1 3 0 2 0 3 1 2 0 0 0 0 0
  244.                2 0 2 1 0 0 0 0 3 1 3 0 0 0 0 0
  245.                2 0 3 1 2 1 3 1 2 1 3 0 0 0 0 0
  246.  
  247. 860fc
  248.   50 integers, all are either 50 or -50.
  249.  
  250. 861d0
  251.   5 sets of 256 bytes, each is a COLORMAP, for the gamma correction
  252. settings OFF, 1, 2, 3, 4.
  253.  
  254. 866d0
  255.   5 integers: 1, 0, -1, 0, 0
  256.  
  257. 866e4
  258.   13 sets of 5 - 10 bytes, each set terminated by a $FF
  259.  
  260. 8675e
  261.   $74 $20
  262.  
  263. 86760
  264.   13 pointers to the stuff at 866e4. An integer '0' between each pointer.
  265.  
  266. 867c8
  267.   6 integers: -1, -1, 0, -1, 0, 1
  268.  
  269. 867e0
  270.   10 pointers to the 10 default chatmacros, then 4 pointers, to "Green:",
  271. "Indigo:", "Brown:", "Red:"
  272.  
  273. 86820
  274.   AUTOMAP LEVEL NAMES. 27 pointers to the level names used on the automap.
  275.  
  276. 8689c
  277.   The ascii letters "gibr" - the keys for sending messages in multiplayer.
  278.  
  279. 868a8
  280.   SPLAT MARK COORDINATES. At what screen coordinates to place the WISPLAT
  281. picture on the end-level screen, for th 27 levels. 54 integers, 27 pairs.
  282. e1m1 x, e1m1 y, ..., e3m9 y.
  283.  
  284. 86980, 86bb0, 86da8
  285.   END-LEVEL MAP ANIMATIONS. Each is 14 integers. The first one is (0, 11,  
  286. 3, 224, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0). The first number is 0 for all the
  287. ones on maps 0 and 2 (episodes 1 and 3), and it's 2 for map 1. The 11 is
  288. always 11 except the last one of map 2 is 8. The 3 means 3 pictures are
  289. involved in the animation, e.g WIA00100, WIA00101, and WIA00102. 224 and 104
  290. are the x and y coordinates. The sixth number is not 0 for map 1 - it's
  291. from 1 to 8. This controls the way the Tower of Mystery "appears". All the
  292. other numbers are always 0.
  293.  
  294. 86ef8
  295.   Three integers, how many animations for WIMAP0, 1, 2 respectively.
  296.  
  297. 86f04 
  298.   Three pointers, to the starts of the animations for WIMAP0, 1, 2
  299. respectively.
  300.  
  301. 8714c
  302.   SOUND TABLE. 61 and 1/2 sounds are listed here. Each is 9 integers: a
  303. pointer to the string which is the sound's "name", then a 0 or 1, then
  304. a value ranging from 32 to 128, then 0, -1, -1, 0, 0, 0. The names are
  305. "pistol", "shotgn", ... "hoof", "metal", "chgun". Prefix DS or DP and you
  306. get the entries in DOOM.WAD for the sound data. The "chgun" is the 1/2 -
  307. there's no "DSCHGUN" in doom.wad, and the entry in this table is incomplete
  308. anyway, lacking the all-important 0, -1, -1, 0, 0, 0 ending :-). There seem
  309. to be a few glitches in the way the sounds were fit into the whole scheme,
  310. this is just one of them. See DEHACK5.BAS for how to extract the whole
  311. table and list of sound names
  312.  
  313. 879ec
  314.   pointer to start of SOUND TABLE.
  315.  
  316. 879f0
  317.   Integer = 150. 150 whats?
  318.  
  319. 87a04
  320.   SPRITE NAME LIST. 105 pointers to the strings "TROO", "SHTG", ...,
  321. "SMRT". See DEHACK4.BAS to extract the whole list.
  322.  
  323. 87ba8
  324.   FRAME TABLE. 512 entries, each is 28 bytes:
  325.  
  326. longint     sprite number 0-104, lookup in sprite name list pointers
  327. longint     sprite subnumber, 0 = "A", 1 = "B", in for example, SMRTA0.
  328. longint     duration, how many timeslices until it looks for the next
  329.             frame in the sequence. -1 means forever.
  330. 2-byte int  ?
  331. 2-byte int  ?
  332. longint     next frame in sequence. 0 means no next frame, sequence done.
  333. longint     always 0, has no effect
  334. longint     always 0
  335.  
  336.   See DEHACK3.BAS to extract the whole table
  337.  
  338. 8b3a8
  339.   Two integers: 1, 0, then 6 code-pointers.
  340.  
  341. 8b3c8
  342.   THING TABLE. 103 entries, each is 88 bytes, or 21 integers. See
  343. DEHACK2.BAS to extract the table. Here's a list of what the 21 ints do:
  344.   
  345.   1. Thing number. 3001 is an imp, 5 is a blue key, etc. Some of them are
  346.      -1, e.g. the very first entry (players), the fireballs, ... 
  347.   2. First frame number of the thing's frame sequence, for 'regular' items.
  348.      For monsters, it's the first frame of the standing-in-place sequence.
  349.   3. Toughness/hit points.
  350.   4. 'moving' first frame #, monsters/player only
  351.   5. 'see player' sound # for monsters, or 'first' sound for projectiles.
  352.      Note the sounds are 1-61, not 0-60. 0 indicates no sound.
  353.   6. Always 8, except for player. What does it do?
  354.   7. 'attack' sound #, monsters only.
  355.   8. 'injury' first frame #, monsters/player only.
  356.   9. ???. monsters/player only.
  357.   10. 'pain' sound #, monsters/player only.
  358.   11. 'close attack' frame #, monsters/player.
  359.   12. 'distance attack' frame #, monsters/player.
  360.   13. 'death' frame # for monsters, 'explode' frame # for projectiles.
  361.   14. 'explosive death' frame #, only PLAY, POSS, SPOS, TROO are this weak.
  362.   15. 'death' sound # for monsters, 'explode' sound # for projectiles. 
  363.   16. Speed of movement. Projectiles' speeds are * 65536 (or split this
  364.       into two 2-byte integers.
  365.   17. Horizontal size * 65536
  366.   18. Height * 65536
  367.   19. Point value? Not implemented.
  368.   20. Missle damage. Also, SKUL has a 3 here, I presume it turns into a
  369.       projectile when attacking.
  370.   21. 'act' sound #, monsters.
  371.   22. Attributes, controlled by bits. Bit set = condition true. bit0 =
  372.       1/0, bit8 = 256/0, bit16 = 65536/0, ...
  373.  
  374.    bit0     a gettable thing
  375.    bit1     an obstacle to players and monsters (but not projectiles)
  376.    bit2     can be hurt (note barrels have this set)
  377.    bit3     ? teleport destination is only one with it set
  378.    bit4     'automatics' like PUFF, TFOG, BLUD, projectiles
  379.    bit5-7   unused?
  380.    bit8     hung from ceiling
  381.    bit9     floating monsters and not-on-ground things
  382.    bit10    projectiles and player
  383.    bit11    ? player only
  384.    bit12-13 unused?
  385.    bit14    floating monsters
  386.    bit15    unused?
  387.    bit16    projectiles
  388.    bit17    unused?
  389.    bit18    'Inviso' like Spectres!
  390.    bit19    ? barrel only
  391.    bit20-21 unused?
  392.    bit22    Monster: counts towards KILL % at end-of-level screen
  393.    bit23    Artifact: counts towards ITEM %
  394.    bit24    unused?
  395.    bit25    the 6 keys and the player
  396.    bit26-31 unused?
  397.  
  398. 8d730
  399.   Misc junk I can't figure out.
  400.  
  401. 8db27
  402.   End of doom.exe
  403.