home *** CD-ROM | disk | FTP | other *** search
/ Ultimate DOOM Companion / PowersourceMultimedia-UltimateDOOMCompanion.iso / faq / dmspcs11.zip / DMSPEC11.TXT next >
Text File  |  1994-02-20  |  39KB  |  1,029 lines

  1. -----------------------------------------------------------------------------
  2.        T H E   U N O F F I C I A L   *-D-*-*-O-*-*-O-*-*-M-*   S P E C S
  3.                         Release v1.1 - February 19, 1994
  4.                   Written by: Matt Fell (matt.burnett@acebbs.com)
  5.               Released by: Hank Leukart (ap641@cleveland.freenet.edu)
  6.           "DOOM: Where hackers gnaw the bones left from the banquet
  7.                  of data prepared by the mighty wizards of id."
  8.            "The poets talk about love, but what I talk about is DOOM,
  9.                  because in the end, DOOM is all that counts."
  10.            - Alex Machine/George Stark/Stephen King, _The Dark Half_
  11. -----------------------------------------------------------------------------
  12.  
  13. ----------
  14. DISCLAIMER
  15. ----------
  16.  
  17.         These specs are to aid in informing the public about the game DOOM,
  18. by id Software.  In no way should this promote your killing yourself, killing
  19. others, or killing in any other fashion.  Additionally, neither Hank Leukart
  20. nor Matt Fell claim ANY responsibility regarding ANY illegal activity
  21. concerning this file, or indirectly related to this file.  The information
  22. contained in this file only reflects id Software indirectly, and questioning
  23. id Software regarding any information in this file is not recommended.
  24.  
  25. ---------
  26. COPYRIGHT
  27. ---------
  28.  
  29.         You may NOT distribute this work by any non-electronic media,
  30. including but not limited to books, newsletters, magazines, manuals,
  31. catalogs, and speech.  You may NOT distribute this work in electronic
  32. magazines, or within computer software without prior written explicit
  33. permission.  These rights are temporary and revocable upon written, oral,
  34. or other notice by Hank Leukart.  This copyright notice shall be governed
  35. by the laws of the state of Ohio.
  36.         If you would like additional rights beyond those granted above,
  37. write to the distributor at "ap641@cleveland.freenet.edu" on the Internet.
  38.  
  39. ------------
  40. INTRODUCTION
  41. ------------
  42.  
  43.         Here are the long awaited unofficial specs for DOOM.  These specs
  44. should be used for creating add-on software for the game.  I would like to
  45. request that these specs be used in making utilities that ONLY work on the
  46. registered version of DOOM.  You may not use these for modifing, translating,
  47. disassembling, decompiling, reverse engineering, or creating derivative works
  48. based upon DOOM.  Notwithstanding the foregoing, you may create a map editor,
  49. modify maps and make your own maps (collectively referenced as the "Permitted
  50. Derivative Works") for the Software.  You may not sell or distribute any
  51. Permitted Derivative Works but you may exchange the Permitted Derivative
  52. Works at no charge amongst other end-users.
  53.         I do not understand much of what is contained in this file, so if
  54. you have any questions about the information, write to Matt Fell at
  55. "matt.burnett@acebbs.com" on the Internet.  If you would like to request a
  56. copy of this file, or have any questions about its distribution, write to me,
  57. Hank Leukart, at "ap641@cleveland.freenet.edu" on the Internet.
  58.  
  59. --------------------
  60. (LONG) AUTHOR'S NOTE
  61. --------------------
  62.  
  63. This document is a summary and explanation of almost all the data structures
  64. in the DOOM.WAD file. ALMOST all. The structure of the NODES/SSECTOR/SEGS
  65. objects is apparent, but their exact purpose is proving elusive. Everything
  66. else is fairly easy. Thankfully, there is no compression or encryption used,
  67. that would really complicate things.
  68.  
  69. All of this information is true to the best of my knowledge at this time,
  70. which means that there's certainly a few things in here which are WRONG!
  71. So here's the obligatory reminder to back up your DOOM.WAD file and any other
  72. files you intend to change, unless you enjoy re-installing the whole package
  73. [ Hope you have 11 megs just lying around :-) ]. If you aren't experienced
  74. with programming and/or data structures, you probably shouldn't be fooling
  75. around anyway. And remember, id Software will NOT give technical support for
  76. modifications.
  77.  
  78. Whatever you do, do NOT distribute any data extracted from the original
  79. doom.wad file. It is COPYRIGHTED. This includes pictures, sounds, and the
  80. original maps. I don't know about the technicality of it, but I'm also,
  81. especially, referring to distributing changed versions of the original maps.
  82. E.g. you change one or two of the items on a level, or you move some walls
  83. around. Great! But don't distribute it! It's still THEIR level.
  84.  
  85. As far as I can determine at this point in time, here is the preferred
  86. method of handling third-party additions:
  87.  
  88. If you are writing a utility that will operate on DOOM, have it first check
  89. the WAD file for the existence of an "E3M1" entry in the directory (explained
  90. below), or some other entry that will only be in the registered version.
  91.  
  92. If you are going to be distributing a modified map, plan on using the -file
  93. parameter. At the command line, the user will type
  94.  
  95. DOOM -DEVPARM -FILE yourfile.wad
  96.  
  97. (in addition to any other command line parameters they are using). This
  98. causes doom to use any resources in the "yourfile.wad" instead of the
  99. originals in the "doom.wad" file. Thus, if you only make one level (good
  100. luck on even making one!), you can distribute a wad file which will be very
  101. small compared to the full wad file. Your external wad file for a single
  102. level would have just eleven entries in its directory.
  103.  
  104. When doom loads, the doom OS will say "adding external file (whatever).wad"
  105. Call your file something like JOELEVEL.WAD or XMENRULE.WAD; if you use a name
  106. like E1M1.WAD or E3M6.WAD or probably any real name from the real directory,
  107. it will either not work, or lock-up.
  108.  
  109. By the way, I've known most of this info for weeks now, but have been
  110. "sitting" on it for various reasons....And if you like difficult levels
  111. oriented towards combat and thinking, remember me. When I get good enough
  112. tools, I guarantee I will make some interesting levels. The desire to create
  113. levels is what really got me started on this whole thing; my resume includes
  114. some critically acclaimed levels for wolf and spear.
  115.  
  116. If you have any comments, or even better, possible additions, please send me
  117. e-mail. Questions will be gladly answered also, no matter how trivial, unless
  118. I get too many, which I doubt. Please note, however, that if it's not in
  119. here, I'm either working on it or I just don't know it. If YOU know "it", tell
  120. me!
  121.  
  122. --------
  123. CONTENTS
  124. --------
  125.  
  126. [1] Basics
  127. [2] Directory Overview
  128. [3] The Maps, The Levels
  129.         [3-1] ExMy
  130.         [3-2] THINGS
  131.                 [3-2-1] Thing Types
  132.         [3-3] LINEDEFS
  133.                 [3-3-1] Linedef Attributes
  134.                 [3-3-2] Linedef Types
  135.         [3-4] SIDEDEFS
  136.         [3-5] VERTEXES
  137.         [3-6] SEGS
  138.         [3-7] SSECTORS
  139.         [3-8] NODES
  140.         [3-9] SECTORS
  141.         [3-10] REJECT
  142.         [3-11] BLOCKMAP
  143. [4] Pictures' Format
  144.         [4-1] Headers
  145.         [4-2] Pointers
  146.         [4-3] Pixel Data
  147. [5] Floor and Ceiling Textures
  148. [6] Songs and Sounds
  149.         [6-1] Songs
  150.         [6-2] Sounds
  151. [7] Miscellaneous Non-Picture Resources
  152.         [7-1] PLAYPAL
  153.         [7-2] COLORMAP
  154.         [7-3] DEMOs
  155.         [7-4] TEXTURE1 and TEXTURE2
  156.         [7-5] PNAMES
  157.  
  158. -------------------
  159. CHAPTER [1]: Basics
  160. -------------------
  161.  
  162. The first twelve bytes of a *.WAD file are as follows:
  163.  
  164. Bytes 0 to 3 - contain the ASCII letters "IWAD"
  165.                may also contain "PWAD", which will give the "modified game"
  166.                message during the Doom OS startup. Therefore, I recommend
  167.                that all modified WAD files have PWAD instead of IWAD. I have
  168.                been unable to find out what ID thinks about this, they are so
  169.                busy...
  170. Bytes 4 to 7 - contain a long integer which is the number of entries in the
  171.                "directory"
  172. Bytes 8 to 11 - contain a pointer to the first byte of the "directory"
  173.  
  174. (Bytes 12 to the start of the directory contain resource data)
  175.  
  176. The directory referred to is a list, located at the end of the WAD file,
  177. which contains the pointers, lengths, and names of all the resources in the
  178. WAD file. The resources in the wad: item pictures, enemies' pictures for
  179. animation, wall patches, floor and ceiling textures, songs, sound effects,
  180. map data, and many others.
  181.  
  182. Specifically, the first 12 bytes of the DOOM.WAD file in version 1.1, which
  183. I am working with, are:
  184.  
  185. 49 57 41 44 1a 08 00 00 be 20 9e 00
  186.  
  187. This is "IWAD", then 81a hex (=2074 decimal) for the number of directory
  188. entries, then 9e20be (=10363070 decimal) for the first byte of the directory.
  189.  
  190. Each directory entry is 16 bytes long, arranged this way:
  191.  
  192. First four bytes: pointer to start of resource (a long integer)
  193. Next four bytes: length of resource (another long integer)
  194. Last eight bytes: name of resource, in ASCII capitals, ending with 00s if
  195.         less than eight bytes.
  196.  
  197. -------------------------------
  198. CHAPTER [2]: Directory Overview
  199. -------------------------------
  200.  
  201. PLAYPAL   contains fourteen 256 color palettes, used while playing Doom.
  202. COLORMAP  maps colors in the palette down to darker ones, for areas of less
  203.           than maximum brightness (quite a few of these places, huh?)
  204. ENDOOM    is the text message displayed when you exit to DOS.
  205. DEMO[1-3] are the demos which will play if you just sit and watch.
  206.  
  207. E1M1      etc, to E3M9, along with its 10 subsequent entries, defines the
  208.           map data for a single level or mission. More on this below.
  209.  
  210. TEXTURE1  is a list of wall type names used in the SIDEDEF portion of each
  211.           level's data, and their composition data, i.e. what wall patches
  212.           make up each "meta-wall".
  213. TEXTURE2  contains the walls that are only in the registered version.
  214. PNAMES    is the list of wall patches, which are referenced by number in
  215.           the TEXTURE1/2 objects.
  216.  
  217. GENMIDI   has some instrument names in it, and obviously has to do with the
  218.           MIDI mappings used for the songs...?
  219. DMXGUS    has to do with Gravis Ultra Sound, I suppose.
  220.  
  221. D_xxxxxx  is a song
  222. DP_xxxxx  DP and DS come in pairs and are the sound effects.
  223. DS_xxxxx     DP_ are the PC speaker sounds, DS_ are the sound card sounds.
  224.  
  225. all the remaining entries in the directory, except the floor textures at the
  226. end, and the "separators" like S_START, refer to resources which are pictures
  227.  
  228. in the doom/wad picture format described in chapter 6. I could've listed here
  229.  
  230. what every single one of them is, e.g. WIMSTBP3 is text "FOUR" in grey, but
  231. I figured it to be a waste of time.
  232.  
  233. HELP[1-2] These are full screen (320 by 200 pixel) pictures.
  234. TITLEPIC
  235. CREDIT
  236. VICTORY2
  237. PFUB[1-2]
  238.  
  239. END[0-6]  "THE END" text, with 0 to 6 bullet holes.
  240.  
  241. AMMNUM[0-9] are the grey digits used in the status bar for ammo count.
  242. STxxxxxx  are small pictures and text used on the status bar.
  243. M_xxxxxx  are text messages (yes, in picture format), used in the menus.
  244. BRDR_xxx  are tiny two pixel wide pictures use to frame the viewing window
  245.           when it is not full screen.
  246. WIxxxxxx  are pictures and messages used on the summary screen done after
  247.           the completion of a level.
  248. WIMAP[0-2] are full screen, 320 by 200.
  249.  
  250. S_START   has 0 length and is right before the item/enemy section
  251. S_END     is immediately after the last "frame"
  252. P_START   the beginning of the wall patches
  253. P1_START      before the first of the shareware wall patches
  254. P1_END        after the last of the shareware wall patches
  255. P2_START      before the first of the registered wall patches
  256. P2_END        before the first of the registered wall patches
  257. P_END     the end of the wall patches
  258. F_START   the beginnning of the floors
  259. F1_START      before the first shareware floor texture
  260. F1_END        after the last shareware floor texture
  261. F2_START      before the first registered floor texture
  262. F2_END        after the last registered floor texture
  263. F_END     the end of the floors
  264.  
  265. And that's the end of the directory. Detailed info on specific resources
  266. follows...
  267.  
  268. ---------------------------------
  269. CHAPTER [3]: The Maps, The Levels
  270. ---------------------------------
  271.  
  272. Each level has eleven resources/directory entries: E[x]M[y] (where x is a
  273. single digit 1-3 for the episode number and y is 1-9 for the mission/level
  274. #),
  275. THINGS, LINEDEFS, SIDEDEFS, VERTEXES, SEGS, SSECTORS, NODES, SECTORS, REJECT,
  276.  
  277. BLOCKMAP.
  278.  
  279. [3-1]: ExMy
  280. ===========
  281.  
  282. This is just the name resource for a (single) level, and has zero length. The
  283.  
  284. next 10 entries in the directory after one of these must be
  285. THINGS...BLOCKMAP.
  286.  
  287. [3-2]: THINGS
  288. =============
  289.  
  290. Each thing is ten bytes, consisting of five (integer) fields:
  291.  
  292. 1. X coordinate of thing
  293. 2. Y coordinate of thing
  294.  
  295. Each level has a different "range" to its coordinates. On E1M1, X ranges
  296. from (c.) -288 to +3440, and Y ranges from (c.) -4832 to -2144.
  297. On the automap within the game, with the grid on (press 'G'), the lines are
  298. hex 80 (decimal 128) apart, two lines = hex 100, dec 256.
  299.  
  300. 3. Angle the thing faces, 0 is west (according to automap).
  301.  
  302. May be 0,45,90,135,180,225,270,315. Only important for enemies.
  303.  
  304. 4. Type of thing, see next subsection
  305. 5. Attributes of thing, which are set by bits:
  306.  
  307. bit 0  is set if the THING is present at skill 1 and 2
  308. bit 1  is set if the THING is on skill 3 (hurt me plenty)
  309. bit 2  is set if the THING is on skill 4 (ultra-violence)
  310. bit 3  is set to indicate a deaf guard. This only has meaning for enemies,
  311. who will not attack until they see a player if they are "deaf". Otherwise,
  312. they will activate when they hear gunshots, etc. Sound does not travel
  313. through solid walls (walls that are solid at the time of the noise).
  314. bit 4  makes the THING only appear in multiplayer mode.
  315. bits 5-15 are never set in any THING , and have no effect.
  316.  
  317. The skill settings are most used with the ENEMIES, of course...the most
  318. common skill level settings are hex 07/0f (on all skills), 06/0e (on skill
  319. 3-4), and 04/0c (only on skill 4).
  320.  
  321. [3-2-1]: Thing Types
  322. --------------------
  323.  
  324. Bytes 6-7 of each thing are an integer which means the thing at that x,y
  325. location is one of these:
  326.  
  327. 1       Player 1 start
  328. 2       Player 2 start
  329. 3       Player 3 start
  330. 4       Player 4 start
  331. 5       Blue keycard
  332. 6       Yellow keycard
  333. 7       SPIDER BOSS (SPID)
  334. 8       Backpack
  335. 9       FORMER HUMAN SERGEANT (SPOS)
  336. 10      Bloody mess
  337. 11      The possible start positions for players in deathmatch mode. There
  338.         must be at least FOUR 11s on each level.
  339. 12      Bloody mess 2
  340. 13      Red Keycard
  341. 14      Marks the spot where a player (or enemy) lands when they teleport
  342.         to the SECTOR that contains this thing.
  343. 15      Dead player
  344. 16      CYBER-BOSS (CYBR)
  345. 17      Cell charge pack
  346. 18      Dead former human
  347. 19      Dead former sargeant
  348. 20      Dead imp
  349. 21      Dead demon
  350. 22      Dead cacodemon
  351. 23      ?
  352. 24      Pool of blood
  353. 25      Impaled human
  354. 26      Twitching impaled human
  355. 27      Skulltop pole
  356. 28      Head shishkebob
  357. 29      Pile of skulls with candle
  358. 30      Tall green pillar
  359. 31      Short green pillar
  360. 32      Tall red pillar
  361. 33      Short red pillar
  362. 34      Candle
  363. 35      Candelabra
  364. 36      Pedestal w/heart
  365. 37      Short red pillar with skull
  366. 38      Red skullkey
  367. 39      Yellow skullkey
  368. 40      Blue skullkey
  369. 41      Eye in symbol
  370. 42      Flaming skull-rock
  371. 43      Grey tree
  372. 44      Tall blue firestick
  373. 45      Tall green firestick
  374. 46      Tall red firestick
  375. 47      Small brown scrub
  376. 48      Tall, techno column
  377. 49      Swaying body
  378. 50      Hung by ankle, arms out
  379. 51      Hanging 1-legged human
  380. 52      Hanging torso
  381. 53      Severed Leg
  382. 54      Large brown tree
  383. 55      Short blue firestick
  384. 56      Short green firestick
  385. 57      Short red firestick
  386. 58      SPECTRE (SARG)
  387. 59      Hanging torso
  388. 60      Severed leg
  389. 61      Hanging 1-legged human
  390. 62      Hung by ankle, arms out
  391. 63      Swaying body
  392.  
  393. 2001    Shotgun
  394. 2002    Chaingun
  395. 2003    Rocket launcher
  396. 2004    Plasma gun
  397. 2005    Chainsaw
  398. 2006    BFG9000
  399. 2007    Ammo clip
  400. 2008    4 shotgun shells
  401. 2010    1 rocket
  402. 2011    Stimpak
  403. 2012    Medikit
  404. 2013    Soulsphere = +100% health
  405. 2014    Health bonus
  406. 2015    Armor bonus
  407. 2018    Green armor 100%
  408. 2019    Blue armor 200%
  409. 2022    Invlnerability
  410. 2023    Berserk Strength
  411. 2024    Invisibility
  412. 2025    Radiation suit
  413. 2026    Computer map
  414. 2028    Floor lamp
  415. 2035    Barrel
  416. 2045    Lite goggles
  417. 2046    Box of Rockets
  418. 2047    Cell charge
  419. 2048    Box of Ammo
  420. 2049    Box of Shells
  421.  
  422. 3001    IMP (TROO)
  423. 3002    DEMON (SARG)
  424. 3003    GOAT BOSS (BOSS)
  425. 3004    FORMER HUMAN (POSS)
  426. 3005    CACODEMON (HEAD)
  427. 3006    LOST SOUL (SKUL)
  428.  
  429. [3-3]: LINEDEFS
  430. ===============
  431.  
  432. Each linedef represents a line from one of the VERTEXES to another, and each
  433. has 7 (integer) fields:
  434.  
  435. 1. from the VERTEX with this number (the first vertex is 0)
  436. 2. to the VERTEX with this number (31 is the 32nd vertex)
  437. 3. attributes, see below
  438. 4. types, see below
  439. 5. is a "trigger" number which ties crossing this line to the SECTOR with
  440. this same number as its last field.
  441. 6. SIDEDEF one (always present, since this line adjoins at least 1 SECTOR)
  442. 7. SIDEDEF two, if this line adjoins 2 SECTORS
  443.  
  444. [3-3-1]: Linedef Attributes
  445. ---------------------------
  446.  
  447. The third field of each linedef is an integer which controls that line's
  448. attributes, as follows:
  449.  
  450. bit# = condition if it is set (=1)
  451.  
  452. bit0 =  impassibile (by players). Only really matters for lines between 2
  453.         sectors, lines adjoining just one sector are impassible regardless.
  454. bit1 =  ?, has to do with the above/below.
  455. bit2 =  may shoot through; also, "transparent", meaning the "above" and
  456.         "below" wall textures are displayed as appropriate.
  457. bit3 =  ?, has to do with the above/below.
  458. bit4 =  enemies do not cross this line (I think)
  459. bit5 =  a secret. this is NOT what determines the SECRET ratio at the end of
  460.         a level, that is done by special sectors (#9). So this bit is only
  461.         really useful for mapping.
  462. bit6 =  ?, to do with being high up/overhang.
  463. bit7 =  the "above" part is transparent to the sky behind. this one is
  464. usually
  465.         used in the outside courtyard areas.
  466. bit8-15 unused.
  467.  
  468. [3-3-2]: Linedef Types
  469. ----------------------
  470.  
  471. The integers in field 4 of a linedef control various special characteristics
  472. of that line, mostly to do with what happens to a "triggered" SECTOR when the
  473.  
  474. line is crossed by a player.
  475.  
  476. The * means the linedef needs a trigger # (in field 5) to link it to the
  477. appropriate sector(s). $ and & mean the player activates the function by
  478. pressing spacebar: $ is for switches which operate once only, & is for doors
  479. which can be used over and over. And yes, some of the switches can be used
  480. over and over, which ones are they? @ means I'm not sure yet if it is
  481. one-time
  482. or repeatable.
  483.  
  484. Value = Effect
  485.  
  486. -1
  487. 0       Nothing special.
  488. 1 &     Door. Sector ceiling rises.
  489. 2 *     removes/raises sector permanently
  490. 3
  491. 5 *
  492. 7 *$    staircase rises up from floor in appropriate sectors.
  493. 8 *     stairs
  494. 9 *@
  495. 10
  496. 11 $    End level. Go to next level.
  497. 13
  498. 14
  499. 16 *
  500. 18 *$   floor of sector rises to equal height of neighbor sector. The first
  501.         sector height it finds "on the way up", amongst its neighbors, is
  502.         where it stops.
  503. 19
  504. 20 *$   floor rises to equal neighbor, and the floor's texture changes to
  505.         match that neighbor also.
  506. 21
  507. 22
  508. 23
  509. 24
  510. 26 &    Door. Need blue key to open.
  511. 27 &    Door. Yellow key.
  512. 28 &    Door. Red key.
  513. 29
  514. 30
  515. 31
  516. 32 $    Door. Blue key. Stays open.
  517. 33 $    Door. Yellow key. Stays open.
  518. 34 $    Door. Red key. Stays open.
  519. 35 *    sector's brightness goes to 0.
  520. 36 *    sector's floor drops to 8 above neighbor.
  521. 37
  522. 38
  523. 39 *    teleport to sector
  524. 40
  525. 41
  526. 42
  527. 44
  528. 46 *    Shoot this line, then sector ceiling rises to neighbor
  529. 48      Animated, horizontal scrolling wall.
  530. 51 $    End level. Go to secret level 9.
  531. 52
  532. 56
  533. 58
  534. 59
  535. 61
  536. 62
  537. 63
  538. 70 *@   sector floor drops to just above neighbor
  539. 73
  540. 74
  541. 75
  542. 76
  543. 77 *    Crushing ceiling!
  544. 82
  545. 86
  546. 87
  547. 88 *    sector floor drops to match neighbor
  548. 89
  549. 90
  550. 91
  551. 97 *    Teleport to...
  552. 98
  553. 102
  554. 103
  555. 104
  556.  
  557. Obviously, I'm still working on this list. These are all the values that
  558. occur anywhere in the registered version, but I haven't tested many of them
  559. yet.
  560.  
  561. [3-4]: SIDEDEFS
  562. ===============
  563.  
  564. A sidedef is a definition of what wall meta-textures to draw along the
  565. various LINEDEFS, and a group of sidedefs define a SECTOR.
  566.  
  567. There will be one sidedef for a line that borders only one sector, since it
  568. is not necessary to define what the doom player would see from the "other"
  569. side of that line because the doom player can't go there. The doom player
  570. can only "go" where there is a sector (unless you use the no clipping cheat,
  571. which will cause the screen to freak out if you go "outside" to a non-sector
  572. area).
  573.  
  574. Each SIDEDEF has 2 (integer) fields, then 3 (8-byte string) fields, then a
  575. final (integer) field:
  576.  
  577. 1. X offset for pasting the appropriate wall texture onto the wall's "space":
  578.  
  579.    positive offset moves "into" the texture, so the left portion gets cut off
  580.  
  581.    (# of columns off left side = offset). negative offset moves texture
  582.    farther right, in the wall's "space"
  583. 2. Y offset: analogous to the X, for vertical.
  584. 3. name of wall type 1 = the part "above" the juncture with a lower ceiling
  585.    of an adjacent SECTOR.
  586. 4. name of wall type 2 = the part "below" a juncture with a higher floored
  587.    adjacent SECTOR
  588. 5. name of wall type 3 = the regular part of the wall
  589. 6. SECTOR that this sidedef "helps to surround"
  590.  
  591. The wall type fields will be "-" if nothing, thus the sidedef for looking IN
  592. a "window" is "-" "-" "-". A typical sidedef, with no above or below, is
  593. "-" "-" "WALLNAME".
  594.  
  595. 00s fill the space after a wall name that is less than 8 characters.
  596.  
  597. The wall names are from the TEXTURE1/2 objects. The names in the DIRECTORY
  598. are not directly used, they are referenced through PNAMES.
  599.  
  600. [3-5]: VERTEXES
  601. ===============
  602.  
  603. These are the beginnings and ends for LINEDEFS and SEGS, each has
  604. 2 (integer) fields:
  605.  
  606. 1. X coordinate
  607. 2. Y coordinate
  608.  
  609. [3-6]: SEGS
  610. ===========
  611.  
  612. Each SEG has 6 (integer) fields
  613.  
  614. 1. from vertex #
  615. 2. to vertex #
  616. 3. angle: 0= east, 16384=north, -16384=south, -32768=west.
  617.    In hex, it's 0000=east, 4000=north, 8000=west, c000=south.
  618. 4. linedef that this seg goes along
  619. 5. 0 if it goes in the same direction as the linedef it is on. 1 if it goes
  620.    the opposite direction. "direction" is indicated by which vertex is first.
  621. 6. Is the distance along the linedef that the seg begins. If the seg begins
  622.    at one of the two endpoints of the linedef, this will be 0. If the seg and
  623.  
  624.    linedef are a "diagonal" line, the length will be according to the
  625. distance
  626.    in the coordinate plane of the vertexes, i.e.
  627.  
  628.    SQR((X2 - X1)^2 + (Y2 - Y1)^2).
  629.  
  630.    Actually, it seems to be off by 1 or 2 from what it should be, like they
  631.    are using ABS(X2 - X1) values that are 1 less than the "real" value
  632.    should be.
  633.  
  634. [3-7]: SSECTORS
  635. ===============
  636.  
  637. each SSECTOR has 2 (integer) fields
  638.  
  639. 1. # of SEGS in this SSECTOR
  640. 2. starting with this SEG #
  641.  
  642. The segs that make up a ssector are the sides (or parts of the sides) of a
  643. polygon, SOMETIMES. Many of the ssectors are only 1 SEG.
  644.  
  645. [3-8]: NODES
  646. ============
  647.  
  648. There are ((number of SSECTORS) - 1) NODES. Each NODE has 14 (integer)
  649. fields:
  650.  
  651. 1. X coordinate of nodeline's start
  652. 2. Y coordinate of nodeline's start
  653. 3. X offset to end of nodeline
  654. 4. Y offset to end of nodeline
  655.  
  656. thus 64, 128, -64, -64 would be a nodeline from (64,128) to (0,64)
  657.  
  658. 5/6.    Y coordinates bounding the nodesq1 on the right side of the nodeline.
  659. 7/8.    X coordinates bounding the nodesq1 on the right side of the nodeline.
  660. 9/10.   Y coords bounding the nodesq2 on the left side of the nodeline.
  661. 11/12.  X coords bounding the nodesq2 on the left side of the nodeline.
  662. 13.     Is a NODE or SSECTOR number for nodesq1. If bit15 of this 2-byte
  663.         field is set, it means that the nodesq1 contains the SSECTOR whose
  664.         number is in the remaining bits. If the bit15 is not set, then
  665.         nodesq1 is a previously listed NODE.
  666. 14.     As with field 13, for nodesq2 on the left.
  667.  
  668. Each node is thus a "sum" of two other rectangular horizontal spaces, each
  669. of which contains either a NODE or a SSECTOR. So there is a heavy iterative
  670. aspect to this structure. The final NODE is always the size of the entire
  671. level. When a SSECTOR is being "contained", the X and Y coordinates of the
  672. nodesq are such that every SEG in that SSECTOR is completely within the
  673. nodesq. If a NODE is being "contained", then the coordinates will bound the
  674. furthest extent of that (recursed) NODE.
  675.  
  676. So what are the nodes for? I don't know yet. Stopped working on it a while
  677. back. Will finish sooner or later. Also, need to create an algorithm to
  678. generate the segs, ssectors, and nodes, given the vertexes and linedefs.
  679.  
  680. [3-9]: SECTORS
  681. ==============
  682.  
  683. A SECTOR is a horiontal (east-west and north-south) area of the map where a
  684. floor height and ceiling height is defined, so a doom player may go there.
  685. Any change in floor or ceiling "altitude" or texture requires a new SECTOR
  686. (and therefore separating LINEDEF(s) and SIDEDEF(s)).
  687.  
  688. Each is 2 (integer) fields, 2 (8-byte string) fields, then 3 (integer)
  689. fields:
  690.  
  691. 1. floor is at this "altitude" for this sector
  692. 2. ceiling altitude
  693.  
  694. the altitudes range from -264 to 264. a difference of 28 between the floor
  695. heights of two adjacent sectors is passable (upwards), but a difference of
  696. 32 is "too high". The player may fall any amount.
  697.  
  698. 3. name of floor texture, from the DIRECTORY
  699. 4. name of ceiling texture, from DIRECTORY
  700.  
  701. (note: all the ones listed in the DIRECTORY work as either floors or
  702. ceilings)
  703.  
  704. 5. brightness of this sector: 0=total dark, 255=maximum bright
  705. 6. special sector:
  706.         0 is normal
  707.         1 light level "blinks" randomly
  708.         2 light quickly pulsates
  709.         3 blinks: off for a while, then on quickly
  710.         4 pulsates AND take 10/20% health hit when stand here
  711.         5 -5/10% health (-5% at skill 1, -10% at higher skills)
  712.         6 UNKNOWN SPECIAL SECTOR, causes program to exit to DOS
  713.         7 -2/5%
  714.         8 ?, light pulsates usually, but not always.
  715.         9 SECRET (player must walk into this sector to get credit for
  716.           discovering this "secret")
  717.         10 ?
  718.         11 -10/20% health
  719.         12 blink
  720.         13 quick pulsate
  721.         14 ?
  722.         15 UNKNOWN SPECIAL SECTOR, useless
  723.         16 -10/20%
  724.  
  725.         17 and up are all UNKNOWN
  726.  
  727. 7. is a "trigger" number corresponding to a certain LINEDEF with the same
  728.    "trigger" number. When that LINEDEF is crossed, something happens to this
  729.    SECTOR - it goes up or down, etc...
  730.  
  731. [3-10]: REJECT
  732. ==============
  733.  
  734. Reject is an array of bits. It's size in bytes is
  735.  
  736. (number of SECTORS ^ 2) / 8, rounded up.
  737.  
  738. "It is used for optimization and all the bits may be set to 0" -
  739. this is from John Carmack at id software.
  740.  
  741. In fact, the length of the object may be made 0 (same as making it all 0s),
  742. and the only thing different about the level is that sometimes enemies seem
  743. to "float" when they walk off a step or platform to a lower one.
  744.  
  745. [3-11]: BLOCKMAP
  746. ================
  747.  
  748. All of BLOCKMAP's fields are integers.
  749.  
  750. The whole level is cut into "blocks", each hex 80 wide (the grid lines in the
  751.  
  752. automap correspond to these blocks).
  753.  
  754. The first two integers are XORIGIN and YORIGIN, which specify the coordinates
  755.  
  756. of the bottom-left corner of the bottom-left (southwest) block.
  757.  
  758. Then come XBLOCKS and YBLOCKS, which specify how many "blocks" there are in
  759. the X and Y directions. XBLOCKS is the number of COLUMNS, YBLOCKS is the
  760. number of ROWS.
  761.  
  762. Then come (ROWS * COLUMNS) integers which are pointers to the offset within
  763. the BLOCKMAP resource for that "block". These "offsets" refer to the INTEGER
  764. number, NOT the byte number, where to find the block's list. The blocks go
  765. right (east) and up (north). The first block is at row 0, column 0; the next
  766. at row 0, column 1; if there are 34 columns like on e1m1, the 35th block is
  767. row 1, column 0, etc.
  768.  
  769. After all the pointers, come the block lists. Each blocklist describes the
  770. numbers of all the LINEDEFS which are partially or wholly "in" that block.
  771.  
  772. An "empty" block is two integers: 0 and then -1.
  773.  
  774. A non-empty block will go something like: 0 330 331 333 -1. This means that
  775. LINEDEFS 330, 331, and 333 are "in" that block. Part of each of those line
  776. segments lies within the (hex 80 by 80) boundaries of that block.
  777.  
  778. What about the block that has LINEDEF 0? It goes: 0 0 ... etc ... -1.
  779.  
  780. If you don't have a BLOCKMAP, the level displays fine, but everybody walks
  781. through walls, and no one can hurt anyone else with their gunfire.
  782.  
  783. -----------------------------
  784. CHAPTER [4]: Pictures' Format
  785. -----------------------------
  786.  
  787. The great majority of the entries if the directory reference resources that
  788. are in a special "picture" format. The same format is used for the pictures
  789. of items (like medikits), the frames that make up enemies (like demons), the
  790. wall patches, and various miscellaneous pictures for the status bar, menu
  791. text, inter-level map, and etc. The floor and ceiling textures are NOT in
  792. this format, they are raw data; see chapter 5.
  793.  
  794. Each picture has three sections, basically. First, a four-integer header.
  795. Then a number of long-integer pointers. Then the picture pixel color data.
  796.  
  797. [4-1]: Header
  798. =============
  799.  
  800. The header has four fields:
  801.  
  802. 1. The number of columns of picture data
  803. 2. The number of rows
  804.  
  805. this defines a rectangular "space" or limits for drawing a picture within
  806.  
  807. 3. leftwards x offset from the center to begin the first column. positive
  808.    value moves left.
  809. 4. upwards y offset from the bottom to begin the first row. positive value
  810.    moves up.
  811.  
  812. To be "centered", #3 is usually about half of the total width. If the picture
  813.  
  814. had 30 columns, and #3 was 0, then it would be off-center to the right,
  815. especially when the player is standing right in front of it, looking at it.
  816. If a picture has 30 rows, and #4 is 60, it will appear to "float" like a
  817. blue soul-sphere. If #4 equals the number of rows, it will appear to rest on
  818. the ground. If #4 is more than 5 less than #2, the bottom part of the picture
  819.  
  820. looks akward.
  821.  
  822. With walls patches, #3 is always (columns/2)-1, and #4 is always (rows)-5.
  823. This is because the walls are drawn consistently within their own space.
  824. (There are two integers in each SIDEDEF which can offset the beginning of a
  825. wall)
  826.  
  827. Finally, if #3 and #4 are NEGATIVE integers, then they are the absolute
  828. coordinates from the top-left corner of the screen, to begin drawing the
  829. picture, assuming the VIEW is FULL-SCREEN (the full 320x200). This is only
  830. done with the pictures of the weapons of the doom player - fist, chainsaw,
  831. bfg9000, etc. The game engine scales the picture down appropriately if the
  832. view is less than full-screen.
  833.  
  834. [4-2]: Pointers
  835. ===============
  836.  
  837. After the header, there are N = (# of columns) long integers (4 bytes each).
  838. These are pointers to the data for each COLUMN. The value of the pointer
  839. represents the offset from the first byte of that picture.
  840.  
  841. [4-3]: Pixel Data
  842. =================
  843.  
  844. Each column is composed of some number of BYTES (NOT integers), arranged in
  845. sets:
  846.  
  847. The first byte is the row to begin drawing this set at. 0 means whatever
  848. height the header#4 upwards-offset describes.
  849.  
  850. The second byte is how many colored pixels (non-transparent) to draw, going
  851. downwards.
  852.  
  853. Then follow (# of pixels) + 2 bytes, which define what color each pixel is,
  854. using the game palette. The first and last bytes AREN'T drawn, and I don't
  855. know why they are there. Probably just leftovers from the creation process on
  856. the NeXT machines. Only the middle (# of pixels in this set) are drawn,
  857. starting at the row specified in byte 1 of the set.
  858.  
  859. After the last byte of a set, either the column ends, or there is another
  860. set,
  861. which will start as stated above.
  862.  
  863. 255 (hex FF) ends the column, so a column that starts this way is a null
  864. column, all "transparent". Goes to the next column.
  865.  
  866. Thus, transparent areas can be defined for either items or walls (but you
  867. should only use a wall with transparent parts on a SIDEDEF between two
  868. SECTORS):
  869.  
  870. Note that all the item and enemy pictures names are in the DIRECTORY between
  871. the S_START and S_END entries, and all the wall patches are  between the
  872. P_START and P_END entries.
  873.  
  874. ---------------------------------------
  875. CHAPTER [5]: Floor and Ceiling Textures
  876. ---------------------------------------
  877.  
  878. All the names for these textures are in the DIRECTORY between the F_START and
  879.  
  880. F_END entries. There is no look-up or meta-structure as with the walls.
  881.  
  882. Each texture is 4096 raw bytes, making a square 64 by 64 pixels, which is
  883. pasted onto a BLOCK's floor or ceiling, with the same orientation as the
  884. automap would imply, i.e. the first byte is the color at the NW corner, the
  885. 64th is the color at the NE, etc.
  886.  
  887. The data in F_SKY1 isn't even used since the game engine interprets that
  888. "special" ceiling as see-thru to the SKY texture beyond. So the F_SKY1 entry
  889. can have zero length.
  890.  
  891. -----------------------------
  892. CHAPTER [6]: Sounds and Songs
  893. -----------------------------
  894.  
  895. Not much detail necessary here, since I'm just guessing at the song format
  896. anyway.
  897.  
  898. [6-1]: D_[xxxxxx]
  899. =================
  900.  
  901. Songs, probably in general MIDI format. It's obvious what each song is for,
  902. from their names.
  903.  
  904. [6-2]: DP[xxxxxx] and DS[xxxxxx]
  905. ================================
  906.  
  907. These are the sound effects. They come in pairs - DP for pc speaker sounds,
  908. DS for sound cards.
  909.  
  910. The DS sounds are in RAW format: they have a four integer header, then the
  911. sound samples (each sample is 1 byte).
  912.  
  913. The headers' four integers are: 3, then 11025 (the sample rate), then the
  914. # of samples, then 0.
  915.  
  916. ------------------------------------------------
  917. CHAPTER [7]: Miscellaneous Non-picture Resources
  918. ------------------------------------------------
  919.  
  920. [7-1]: PLAYPAL
  921. ==============
  922.  
  923. There are 14 palettes here, each is 768 bytes = 256 rgb triples. That is, the
  924.  
  925. first three bytes of a palette are the red, green, and blue portions of
  926. color 0. And so on.
  927.  
  928. Palette 0 is the one that is used for almost everything.
  929.  
  930. Palette 10-12 are used (briefly) when an item is picked up, the more items
  931. that are picked up in quick succession, the brighter it gets, palette 12
  932. being the brightest.
  933.  
  934. Palette 13 is used while wearing a rad suit.
  935.  
  936. Palettes 3, then 2, are used after getting beserk strength.
  937.  
  938. If the player is hurt, then the palette shifts up to X, then comes "down" one
  939.  
  940. every half second or so, to palette 2, then palette 0 (normal) again.
  941. What X is depends on how badly the player got hurt: Over 100% damage
  942. (add health loss and armor loss), X=8. 93%, X=7. 81%, X=6. 55%, X=5.
  943. 35%, X=4. 16%, X=2.
  944.  
  945. Palettes 1 and 9 contain the secret codes which allow you to play
  946. Commercial Doom eight months before it gets released. Just kidding!
  947.  
  948. [7-2]: COLORMAP
  949. ===============
  950.  
  951. This resource contains 34 sets of 256 bytes, which "map" the colors "down" in
  952.  
  953. brightness. (Brightness is controlled by the 5th field in the SECTORS, see
  954. chapter 3-9 above). E.g. at very low brightness, almost all the colors are
  955. "mapped" to black, the darkest grey, green, blue, etc. In each set of 256
  956. bytes, byte 0 will have the number of the palette color to which original
  957. color 0 gets mapped. Etc. Which set of 34 corresponds to which exact
  958. brightness level is something I haven't bothered to figure out. Better things
  959.  
  960. to do...like the maps.
  961.  
  962. [7-3]: DEMOs
  963. ==============
  964.  
  965. These are the demos that will be shown if you start doom, but don't play an
  966. episode. Each has a record of the keystrokes. Didn't bother to figure the
  967. formats out, since demos can be created using the devparm parameter:
  968.  
  969. DOOM -devparm -record DEMONAME
  970.  
  971. The extension .LMP is automatically added to the DEMONAME. Other parameters
  972. may be used simultaneously, such as -skill [1-4], -warp [1-3] [1-9]. The
  973. demos in the WAD are in exactly the same format as these LMP files, so a LMP
  974. file may be simply pasted or assembled into a WAD, and if its length and
  975. pointer directory entries are correct, it will work.
  976.  
  977. [7-4]: TEXTURE1 and TEXTURE2
  978. ============================
  979.  
  980. These resources contains a list of the wall names used in the various
  981. SIDEDEFS
  982. sections of the level data. Each wall name actually references a
  983. meta-structure, defined in this list. TEXTURE2 has all the walls that are
  984. only in the registered version.
  985.  
  986. Each entry in this list begins with a 8-byte "name" field, but then each
  987. entry has variable length.
  988.  
  989. All the remaining fields of an entry are integers.
  990.  
  991. The second and third fields are always 0 and 0. Purpose is unknown.
  992.  
  993. The fourth and fifth fields define the width in columns and height in rows,
  994. for this entry, thus defining a "space" (usually 32 by 128 or 64 by 72
  995. or etc...) in which individual wall textures are "placed" to form the overall
  996.  
  997. picture. This is done because there are some wall patches that are used in
  998. several different walls, like computer screens, etc.
  999.  
  1000. The sixth and seventh fields are 0 and 0. Purpose unknown.
  1001.  
  1002. The eigth field is the number of 5-integer "sets" that follow. Each "set"
  1003. defines a wall texture for placement, and the integers within each set mean
  1004. this:
  1005.  
  1006. 1. x offset from top-left corner of "space" (size defined in field 4/5) to
  1007.    start placement of this "patch"
  1008. 2. y offset
  1009. 3. number, from 0 to 349, of the entry in the PNAMES object, which contains
  1010.    the name from the DIRECTORY, of the wall patch to use...
  1011. 4. always 1
  1012. 5. always 0
  1013.  
  1014. Some of the entries have 1 "patch", one has 64 "patches"!
  1015.  
  1016. [7-5]: PNAMES
  1017. =============
  1018.  
  1019. This is a lookup table for the numbers in TEXTURE[1 or 2] to reference to an
  1020. actual entry in the DIRECTORY which is a wall patch (in the picture format
  1021. described in chapter 4).
  1022.  
  1023. The middle integer of each 5-integer "set" of a TEXTURE1 entry is something
  1024. from 0 to 349. Number 0 means the first entry in this PNAMES list, 1 is the
  1025. second, etc...
  1026.  
  1027. Every entry in this list is eight bytes, and exactly duplicates an entry in
  1028. the DIRECTORY.
  1029.