home *** CD-ROM | disk | FTP | other *** search
/ Supergames 2 / SupergamesVolume2.bin / faqs / dspec1.2 < prev    next >
Text File  |  1994-03-07  |  60KB  |  1,368 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.2 - March 6, 1994 EST
  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.
  47.         I do not understand much of what is contained in this file, so if
  48. you have any questions about the information, write to Matt Fell at
  49. "matt.burnett@acebbs.com" on the Internet.  If you would like to request a
  50. copy of this file, or have any questions about its distribution, write to me,
  51. Hank Leukart, at "ap641@cleveland.freenet.edu" on the Internet.
  52.  
  53. --------
  54. CONTENTS
  55. --------
  56.  
  57. [1] Author's Notes
  58.         [1-1] Acknowledgements
  59. [2] Basics
  60. [3] Directory Overview
  61. [4] The Maps, The Levels
  62.         [4-1] ExMy
  63.         [4-2] THINGS
  64.                 [4-2-1] Thing Types
  65.         [4-3] LINEDEFS
  66.                 [4-3-1] Linedef Attributes
  67.                 [4-3-2] Linedef Types
  68.         [4-4] SIDEDEFS
  69.         [4-5] VERTEXES
  70.         [4-6] SEGS
  71.         [4-7] SSECTORS
  72.         [4-8] NODES
  73.         [4-9] SECTORS
  74.         [4-10] REJECT
  75.         [4-11] BLOCKMAP
  76. [5] Pictures' Format
  77.         [5-1] Headers
  78.         [5-2] Pointers
  79.         [5-3] Pixel Data
  80. [6] Floor and Ceiling Textures
  81.         [6-1] Animated floors
  82. [7] Songs and Sounds
  83.         [7-1] Songs
  84.         [7-2] Sounds
  85. [8] Miscellaneous Non-Picture Resources
  86.         [8-1] PLAYPAL
  87.         [8-2] COLORMAP
  88.         [8-3] DEMOs
  89.         [8-4] TEXTURE1 and TEXTURE2
  90.                 [8-4-1] Animated walls
  91.         [8-5] PNAMES
  92.  
  93. ---------------------------
  94. CHAPTER [1]: Author's Notes
  95. ---------------------------
  96.  
  97. I didn't want to release another incomplete version of the specs, but
  98. the NODES structure is so much more difficult than all of the other stuff,
  99. I'm not sure how much longer it will be until either I or someone
  100. helping me can figure it out. Since I have almost complete information
  101. on everything else, I felt I should go ahead and release this now.
  102.  
  103. Without knowing how to do the NODES, we still can't create levels from
  104. scratch. So these specs will have to undergo another revision. I've heard
  105. rumors of the hint book, with the official specs, being released "soon";
  106. if anyone knows more about this, or if they get the book, please contact me.
  107.  
  108. I haven't kept track of all the minor revisions that have been made since
  109. 1.1, sorry. You can get rid of the 1.1 specs, as this has everything it
  110. had except the errors :-)
  111.  
  112. id SOFTWARE'S COPYRIGHT AND THE SHAREWARE VERSION:
  113.  
  114. I'm moving the location of the soapbox I had in the 1.1 Specs to here. I'm
  115. certainly not an official spokesman for id. I have made some inquiries to
  116. them regarding specific questions on third-party additions. Until they
  117. respond, though, I'll just make a couple excerpts from the official
  118. documents we have at this time:
  119.  
  120.  
  121. The LICENSE.DOC says
  122.  
  123.        "You may not:  rent, lease, modify, translate, disassemble,
  124.         decompile, reverse engineer, or create derivative works based
  125.         upon the Software. Notwithstanding the foregoing, you may create
  126.         a map editor, modify maps and make your own maps (collectively
  127.         referenced as the "Permitted Derivative Works") for the Software.
  128.         You may not sell or distribute any Permitted Derivative Works but
  129.         you may exchange the Permitted Derivative Works at no charge
  130.         amongst other end-users."
  131.  
  132. It also says
  133.  
  134.         (except for backup purposes) "You may not otherwise reproduce,
  135.         copy or disclose to others, in whole or in any part, the Software."
  136.  
  137. I think this is clear. You may not distribute a WAD file that contains
  138. any of the original entries from DOOM.WAD.
  139.  
  140. Then how can you just make a new set of THINGS for a level? Simple. Have
  141. a pwad file that has only two entries - E3M1 for example, and THINGS.
  142.  
  143. The README.EXE says
  144.  
  145.        "id Software respectfully requests that you do not modify the
  146.         levels for the shareware version of DOOM.  We feel that the
  147.         distribution of new levels that work with the shareware version
  148.         of DOOM will lessen a potential user's incentive to purchase the
  149.         registered version.
  150.  
  151.        "If you would like to work with modified levels of DOOM, we
  152.         encourage you to purchase the registered version of the game."
  153.  
  154. I feel that this is also pretty clear: if you distribute levels, they should
  155. not work with the shareware version. This is easily accomplished: do
  156. not distribute ANY episode one maps! The shareware version cannot work
  157. with episode 2 or 3 pwads, but it can work with episode 1 pwads (they
  158. should have disabled the -file feature in the shareware).
  159.  
  160. If you are writing a utility that will operate on DOOM, have it first check
  161. the WAD file for the existence of an "E3M1" entry in the directory (explained
  162. below), or some other entry that will only be in the registered version.
  163. If it's not there, the program should quit. You should not be making
  164. programs that will work on the shareware version.
  165.  
  166. The point is that the regular shareware players shouldn't be able to exceed
  167. their rights. They are getting a complete game as it is!
  168.  
  169. [1-1]: Acknowledgements
  170. =======================
  171.  
  172. I have received much assistance lately from the following people. They
  173. either brought mistakes to my attention, or provided additional information
  174. that I've incorporated into these specs:
  175.  
  176. Ted (tedv@geom.umn.ed) - I had the THING angles wrong. Unforgivable.
  177. Matt Tagliaferri (matt.tagliaferri@pcohio.com) - I forgot to describe the
  178.         TEXTURE1/2 pointer table. Also, gave lots of help with linedef types.
  179. Raphael Quinet (quinet@montefiore.ulg.ac.be) - The author of the NEWDEU
  180.         editor; new info on linedef types and attributes, special sectors.
  181. Robert Fenske (fenske@swri.edu) - part of the VERDA team, gave lots of help
  182.         on linedef attributes and types, blockmap list, special sectors,
  183.         and other stuff
  184. John A. Matzen (jamatzen@cs.twsu.edu) - instrument names in GENMIDI.
  185. Jeff Bird (jeff@wench.ece.jcu.edu.au) - good ideas and suggestions about
  186.         the nodes.
  187.  
  188. Sorry if I left anyone out. Thanks for all the help!
  189.  
  190. If you have any comments, have spotted any errors, or have any possible
  191. additions, please send me e-mail. Questions will be gladly answered also,
  192. no matter how trivial, unless I get too many, which I doubt. Please note,
  193. however, that if it's not in here, I'm either working on it or I just don't
  194. know it. If YOU know "it", tell me!
  195.  
  196. -------------------
  197. CHAPTER [2]: Basics
  198. -------------------
  199.  
  200. Don't make episode 1 maps! Don't make utilities that work on the shareware
  201. version!  For more information on this, see Chapter [1].
  202.  
  203. There are two types of WAD files. The original DOOM.WAD file is an "IWAD",
  204. meaning it contains all of the data necessary to play. The other type is the
  205. "PWAD" file, an external file which has the same structure, but with far
  206. fewer entries in the directory (explained below). The data in a PWAD is
  207. substituted for the original data in the DOOM.WAD, thus allowing for much
  208. easier distribution of new levels. Only what the PWAD wants to change is
  209. changed, everything else stays the same. Most PWADs will contain the 11
  210. entries necessary to define a single level. For example, if Bill Clinton
  211. were to create a new level 7 for episode 3, he might call it BILLC-37.WAD
  212.  
  213. To use this level instead of the original E3M7 level, a player would type
  214.  
  215. DOOM -FILE BILLC-37.WAD
  216.  
  217. at the command line, along with any other parameters. More than one can be
  218. done at the same time, thus in general
  219.  
  220. DOOM -FILE [pwad_filename] [pwad_filename] [pwad_filename] ...
  221.  
  222. When the game loads, a "modified game" message will appear if there are any
  223. PWADs involved, reminding the player that id Software will not give technical
  224. support or answer questions regarding modified levels.
  225.  
  226. Note that PWAD files must have the .WAD extension to work - I've tried
  227. extensions like .PWD and .37 and they don't work.
  228.  
  229. The original doom levels are pretty complicated, and they are from 50-200
  230. kilobytes in size, uncompressed. My simple prototype levels are just a
  231. few kbytes. I'm estimating that my first epsiode 2 with 9 complete levels
  232. plus a few other things, will be about 1 megabyte uncompressed, about 300k
  233. in a ZIP file.
  234.  
  235. The first twelve bytes of a WAD file are as follows:
  236.  
  237. Bytes 0 to 3 - must contain the ASCII letters "IWAD" or "PWAD"
  238.  
  239. Bytes 4 to 7 - contain a long integer which is the number of entries in the
  240.                "directory"
  241.  
  242. Bytes 8 to 11 - contain a pointer to the first byte of the "directory"
  243.  
  244. (Bytes 12 to the start of the directory contain resource data)
  245.  
  246. The directory referred to is a list, located at the end of the WAD file,
  247. which contains the pointers, lengths, and names of all the resources in the
  248. WAD file. The resources in the wad include item pictures, monster's pictures
  249. for animation, wall patches, floor and ceiling textures, songs, sound
  250. effects, map data, and many others.
  251.  
  252. Specifically, the first 12 bytes of the DOOM.WAD file in version 1.2, which
  253. I am working with, are (in hexadecimal):
  254.  
  255. 49 57 41 44 fd 07 00 00 84 2e 9e 00
  256.  
  257. This is "IWAD", then 7fd hex (=2045 decimal) for the number of directory
  258. entries, then 9e2e84 (=10366596 decimal) for the first byte of the directory.
  259.  
  260. Each directory entry is 16 bytes long, arranged this way:
  261.  
  262. First four bytes:       pointer to start of resource (a long integer)
  263. Next four bytes:        length of resource (another long integer)
  264. Last eight bytes:       name of resource, in ASCII letters, ending with
  265.                         00s if less than eight bytes.
  266.  
  267. -------------------------------
  268. CHAPTER [3]: Directory Overview
  269. -------------------------------
  270.  
  271. This is a list of most of the directory entries.
  272.  
  273. PLAYPAL   contains fourteen 256 color palettes, used while playing Doom.
  274. COLORMAP  maps colors in the palette down to darker ones, for areas of less
  275.           than maximum brightness (quite a few of these places, huh?).
  276. ENDOOM    is the text message displayed when you exit to DOS.
  277. DEMOx     x=1-3, are the demos which will play if you just sit and watch.
  278.  
  279. E1M1      etc, to E3M9, along with its 10 subsequent entries, defines the
  280.           map data for a single level or mission.
  281.  
  282. TEXTURE1  is a list of wall type names used in the SIDEDEF portion of each
  283.           level's data, and their composition data, i.e. what wall patches
  284.           make up each "meta-wall".
  285. TEXTURE2  contains the walls that are only in the registered version.
  286. PNAMES    is the list of wall patches, which are referenced by number in
  287.           the TEXTURE1/2 resources.
  288.  
  289. GENMIDI   has the names of every General Midi standard instrument in order
  290.           from 0-127. Anyone know more...?
  291. DMXGUS    obviously has to do with Gravis Ultra Sound...
  292.  
  293. D_ExMy    is the music for episode x level y.
  294. D_INTER   is the music played on the summary screen between levels.
  295. D_INTRO   is the the 4 second music played when the game starts.
  296. D_INTROA  is also intoductory music.
  297. D_VICTOR  is the music played on the victory text-screen after an episode.
  298. D_BUNNY   is music for while a certain rabbit has his story told...
  299.  
  300. DP_xxxxx  DP and DS come in pairs and are the sound effects.
  301. DS_xxxxx     DP_ are the PC speaker sounds, DS_ are the sound card sounds.
  302.  
  303. all the remaining entries in the directory, except the floor textures at the
  304. end, and the "separators" like S_START, refer to resources which are pictures
  305. in the doom/wad picture format described in chapter [4].
  306.  
  307. The next seven are full screen (320 by 200 pixel) pictures:
  308.  
  309. HELP1     The ad-screen that says Register!, with some screen shots
  310. HELP2     The actual help, all the controls explained
  311. TITLEPIC  Maybe this is the title screen? Gee, I dunno...
  312. CREDIT    The credits, the people at id Software who created this great game
  313. VICTORY2  The screen shown after a victorious end to episode 2
  314. PFUB1     A nice little rabbit minding his own peas and queues...
  315. PFUB2     ...maybe a hint of what's waiting in Doom Commercial version.
  316.  
  317. ENDx      x=0-6, "THE END" text, with (x) bullet holes.
  318.  
  319. AMMNUMx   x=0-9, are the grey digits used in the status bar for ammo count.
  320. STxxxxxx  are small pictures and text used on the status bar.
  321. M_xxxxxx  are text messages (yes, in picture format) used in the menus.
  322. BRDR_xxx  are tiny two pixel wide pictures use to frame the viewing window
  323.           when it is not full screen.
  324. WIxxxxxx  are pictures and messages used on the summary screen after
  325.           the completion of a level.
  326. WIMAPx    x=0-2, are the summary-screen maps used by each episode.
  327.  
  328. S_START   has 0 length and is right before the item/enemy section
  329. S_END     is immediately after the last "sprite"
  330. P_START   marks the beginning of the wall patches
  331. P1_START      before the first of the shareware wall patches
  332. P1_END        after the last of the shareware wall patches
  333. P2_START      before the first of the registered wall patches
  334. P2_END        before the first of the registered wall patches
  335. P_END     marks the end of the wall patches
  336. F_START   marks the beginnning of the floors
  337. F1_START      before the first shareware floor texture
  338. F1_END        after the last shareware floor texture
  339. F2_START      before the first registered floor texture
  340. F2_END        after the last registered floor texture
  341. F_END     marks the end of the floors
  342.  
  343. And that's the end of the directory. Detailed info on specific resources
  344. follows...
  345.  
  346. ---------------------------------
  347. CHAPTER [4]: The Maps, The Levels
  348. ---------------------------------
  349.  
  350. Each level needs eleven resources/directory entries: E[x]M[y] (where x is a
  351. single digit 1-3 for the episode number and y is 1-9 for the mission/level
  352. #), THINGS, LINEDEFS, SIDEDEFS, VERTEXES, SEGS, SSECTORS, NODES, SECTORS,
  353. REJECT, BLOCKMAP.
  354.  
  355. [4-1]: ExMy
  356. ===========
  357.  
  358. This is just the name resource for a (single) level, and has zero length.
  359. In the DOOM.WAD file, each is followed by all ten of the component resources
  360. for that level. In a pwad external file, they don't all need to be present.
  361. Whichever entries are in a pwad will be substituted for the originals.
  362. For example, a pwad with just two entries, E3M1 and THINGS, would use all
  363. the walls and such from the original E3M1, but could have a completely
  364. different set of THINGS on it.
  365.  
  366. [4-2]: THINGS
  367. =============
  368.  
  369. Each thing is ten bytes, consisting of five (integer) fields:
  370.  
  371. (1) X coordinate of thing
  372. (2) Y coordinate of thing
  373.  
  374. Each level has a different "range" to its coordinates. On E1M1, X ranges
  375. from (c.) -288 to +3440, and Y ranges from (c.) -4832 to -2144.
  376. On the automap within the game, with the grid on (press 'G'), the lines are
  377. hex 80 (decimal 128) apart, two lines = hex 100, dec 256.
  378.  
  379. (3) Angle the thing faces. On the automap, 0 is east, 90 is north, 180 is
  380.     west, 270 is south.
  381.  
  382. This value is only used for enemies, player starts, deathmatch random starts,
  383. and teleporter incoming spots. Other things look the same from all
  384. directions. Values are rounded to the nearest 45 degree angle, so if the
  385. value is 80, it will actually face 90 - north.
  386.  
  387. (4) Type of thing, see next subsection
  388. (5) Attributes of thing, which are set by bits:
  389.  
  390. bit 0   is set if the THING is present at skill 1 and 2
  391. bit 1   is set if the THING is on skill 3 (hurt me plenty)
  392. bit 2   is set if the THING is on skill 4 and 5 (ultra-violence, nightmare)
  393.  
  394.         The skill settings are most used with the ENEMIES, of course...the
  395.         most common skill level settings are hex 07/0f (on all skills),
  396.         06/0e (on skill 3-4-5), and 04/0c (only on skill 4-5).
  397.  
  398. bit 3   is set to indicate a deaf guard. This only has meaning for enemies,
  399.  
  400.         who will not attack until they see a player if they are "deaf".
  401.         Otherwise, they will activate when they hear gunshots, etc. Sound
  402.         does not travel through solid walls (walls that are solid at the
  403.         time of the noise). Also, lines can be set so that sound does not
  404.         pass through them (see [3-3-1] bit 6). This attribute is also
  405.         known as the "ambush" attribute.
  406.  
  407. bit 4   makes the THING only appear in multiplayer mode.
  408.  
  409. bits 5-15 have no effect.
  410.  
  411. [4-2-1]: Thing Types
  412. --------------------
  413.  
  414. Bytes 6-7 of each thing are an integer which specifies what kind it is.
  415.  
  416. Symbol  means
  417.  
  418. CAPITAL It's a monster; counts towards KILL ratio at end of level.
  419. $       A regular item that you can get.
  420.  
  421. !       An artifact item whose acquisition counts towards the ITEM ratio
  422.         at the end of a level
  423. *       An obstacle, something that players and monsters can't move through.
  424. 2,3,4   Indicates number of different frames for animated things, except
  425.         monsters
  426.  
  427. Decimal Hex     Thing is:
  428.  
  429. 0       0000    (nothing?)
  430. 1       0001    Player 1 start
  431. 2       0002    Player 2 start for cooperative mode multiplayer games.
  432. 3       0003    Player 3 start          "                "
  433. 4       0004    Player 4 start          "                "
  434. 5       0005 2$ Blue keycard
  435. 6       0006 2$ Yellow keycard
  436. 7       0007  * SPIDER DEMON: giant walking brain boss (SPID)
  437. 8       0008 2$ Backpack
  438. 9       0009  * FORMER HUMAN SERGEANT: black armor shotgunners (SPOS)
  439. 10      000a    Bloody mess (an exploded player)
  440. 11      000b    Deathmatch start positions. Must be at least 4 per level.
  441. 12      000c    Bloody mess, exactly the same as 10
  442. 13      000d 2$ Red Keycard
  443. 14      000e    Marks the spot where a player (or enemy) lands when
  444.                 they teleport to the SECTOR that contains this thing.
  445. 15      000f    Dead player
  446. 16      0010  * CYBER-DEMON: robo-boss, rocket launcher (CYBR)
  447. 17      0011  $ Cell charge pack
  448. 18      0012    Dead former human
  449. 19      0013    Dead former sargeant
  450. 20      0014    Dead imp
  451. 21      0015    Dead demon
  452. 22      0016    Dead cacodemon
  453. 23      0017    Dead lost soul, invisible since they blow up when killed
  454. 24      0018    Pool of blood
  455. 25      0019  * Impaled human
  456. 26      001a 2* Twitching impaled human
  457. 27      001b  * Skull on a pole
  458. 28      001c  * 5 skulls shishkebob
  459. 29      001d 2* Pile of skulls and candles
  460. 30      001e  * Tall green pillar
  461. 31      001f  * Short green pillar
  462. 32      0020  * Tall red pillar
  463. 33      0021  * Short red pillar
  464. 34      0022    Candle
  465. 35      0023  * Candelabra
  466. 36      0024 2* Short green pillar with beating heart
  467. 37      0025  * Short red pillar with skull
  468. 38      0026 2$ Red skullkey
  469. 39      0027 2$ Yellow skullkey
  470. 40      0028 2$ Blue skullkey
  471. 41      0029 3* Eye in symbol
  472. 42      002a 3* Flaming skull-rock
  473. 43      002b  * Grey tree
  474. 44      002c 4* Tall blue firestick
  475. 45      002d 4* Tall green firestick
  476. 46      002e 4* Tall red firestick
  477. 47      002f  * Small brown scrub
  478. 48      0030  * Tall, techno column
  479. 49      0031 3* Hanging victim, swaying, legs gone
  480. 50      0032  * Hanging victim, arms out
  481. 51      0033  * Hanging victim, 1-legged
  482. 52      0034  * Hanging victim, upside-down, upper body gone
  483. 53      0035  * Hanging severed leg
  484. 54      0036  * Large brown tree
  485. 55      0037 4* Short blue firestick
  486. 56      0038 4* Short green firestick
  487. 57      0039 4* Short red firestick
  488. 58      003a  * SPECTRE: invisible version of the DEMON (SARG)
  489. 59      003b    Hanging victim, arms out
  490. 60      003c    Hanging victim, upside-down, upper body gone
  491. 61      003d    Hanging victim, 1-legged
  492. 62      003e    Hanging severed leg
  493. 63      003f 3  Hanging victim, swaying, legs gone
  494.  
  495. 2001    07d1  $ Shotgun
  496. 2002    07d2  $ Chaingun, gatling gun, mini-gun, whatever
  497. 2003    07d3  $ Rocket launcher
  498. 2004    07d4  $ Plasma gun
  499. 2005    07d5  $ Chainsaw
  500.  
  501. 2006    07d6  $ BFG9000
  502. 2007    07d7  $ Ammo clip
  503. 2008    07d8  $ 4 shotgun shells
  504. 2010    07da  $ 1 rocket
  505. 2011    07db  $ Stimpak
  506. 2012    07dc  $ Medikit
  507. 2013    07dd 4! Soulsphere, Supercharge, +100% health
  508. 2014    07de 4! Health bonus
  509. 2015    07df 4! Armor bonus
  510. 2018    07e2 2$ Green armor 100%
  511. 2019    07e3 2$ Blue armor 200%
  512. 2022    07e6 4! Invulnerability
  513. 2023    07e7  ! Berserk Strength
  514. 2024    07e8 4! Invisibility
  515. 2025    07e9  ! Radiation suit
  516. 2026    07ea 4! Computer map
  517. 2028    07ec  * Floor lamp
  518. 2035    07f3 2* Barrel - if blown up, doesn't block way anymore.
  519. 2045    07fd 2! Lite goggles
  520. 2046    07fe  $ Box of Rockets
  521. 2047    07ff  $ Cell charge
  522. 2048    0800  $ Box of Ammo
  523. 2049    0801  $ Box of Shells
  524.  
  525. 3001    0bb9  * IMP: brown fireball hurlers (TROO)
  526. 3002    0bba  * DEMON: pink bull-like chewers (SARG)
  527. 3003    0bbb  * BARON OF HELL: cloven hooved boss (BOSS)
  528. 3004    0bbc  * FORMER HUMAN: regular pistol shooting slimy human (POSS)
  529. 3005    0bbd  * CACODEMON: red one-eyed floating heads. Behold... (HEAD)
  530. 3006    0bbe  * LOST SOUL: flying flaming skulls, like to bite (SKUL)
  531.  
  532. [4-3]: LINEDEFS
  533. ===============
  534.  
  535. Each linedef represents a line from one of the VERTEXES to another, and each
  536. is 14 bytes, containing 7 (integer) fields:
  537.  
  538. (1) from the VERTEX with this number (the first vertex is 0).
  539. (2) to the VERTEX with this number (31 is the 32nd vertex).
  540. (3) attributes, see [3-3-1] below.
  541. (4) types, see [3-3-2] below.
  542. (5) is a "trigger" or "tag" number which ties this line's "effect" type to
  543.     all SECTORS that have the same "trigger" number in their last field.
  544. (6) "right" SIDEDEF, indexed number.
  545. (7) "left" SIDEDEF, if this line adjoins 2 SECTORS. Otherwise, it is equal
  546.     to -1 (FFFF hex).
  547.  
  548. "right" and "left" are based on the direction of the linedef as indicated
  549. by the "from" and "to" VERTEXES. This attempt at a sketch should make it
  550. clear what I mean:
  551.  
  552.         "left" side            "right" side
  553.  FROM -----------------> TO <----------------- FROM
  554.         "right" side           "left" side
  555.  
  556. In the original episodes, a line with a single side ALWAYS has that side
  557. as the "right" side. So it would probably be best to follow the convention.
  558.  
  559. [4-3-1]: Linedef Attributes
  560. ---------------------------
  561.  
  562. The third field of each linedef is an integer which controls that line's
  563. attributes with bits, as follows:
  564.  
  565. bit #   condition if it is set (=1)
  566.  
  567. bit 0   Impassibile. Players and monsters cannot cross this line, and
  568.         projectiles explode or "end" if they hit this line. Note, however,
  569.         that if there is no sector on the other side, beings can't go through
  570.         this line anyway. Important: if bit 2 is also set, projectiles CAN go
  571.         through the line, and if there is no sector on the other side, they
  572.         can go "forever", usually causing a CRASH.
  573.  
  574. bit 1   Monster-blocker. Monsters cannot cross this line.
  575.  
  576. bit 2   Two-sided. If this bit is set, then the linedef's two sidedefs can
  577.         have "-" as a texture, which means "transparent". If this bit is not
  578.         set, the sidedefs can't be transparent: if "-" is viewed, it will
  579.         result in the same hyper-junk that you see when you use the walk-
  580.         thru-walls cheat to go outside into nowhere. However, the linedef CAN
  581.         have two non-transparent sidedefs, even if this bit is not set, if it
  582.         is between two sectors.
  583.  
  584.         Another side effect of this bit is that if it is set, then
  585.         projectiles can go through it no matter what, and gunfire (pistol,
  586.         etc.) can go through it if there is a sector on the other side.
  587.  
  588. bit 3   Upper texture is "unpegged". This is usually done at windows.
  589.         "Pegged" textures move up and down when the neighbor sector moves up
  590.         or down. For example, if a ceiling comes down, then a pegged texture
  591.         on its side will move down with it so that it looks right. If the
  592.         side isn't pegged, it just sits there, the new material is
  593.         spontaneously created. The best way to get an idea of this is to
  594.         change a linedef on an elevator or door, which are always pegged,
  595.         and observe the result.
  596.  
  597. bit 4   Lower texture is unpegged.
  598.  
  599. bit 5   Secret. The automap will draw this line like a normal solid line that
  600.         doesn't have anything on the other side, thus protecting the secret
  601.         until it is opened. This bit is NOT what determines the SECRET ratio
  602.         at the end of a level, that is done by special sectors (#9).
  603.  
  604. bit 6   Blocks sound. Sound cannot cross a line that has this bit set.
  605.  
  606.         Sound normally travels from sector to sector, so long as the floor
  607.         and ceiling heights allow it (e.g. sound wouldn't go from a sector
  608.         with 0/64 floor/ceiling height to one with 72/128, but sound WOULD
  609.         go from a sector with 0/64 to one with 56/128).
  610.  
  611. bit 7   Not on map. The line is not shown on the regular automap, not even if
  612.         the computer all-map power up is gained. All lines show up on the
  613.         cheater's map, however (Booooo! I wish there were no cheat codes!)
  614.  
  615. bit 8   Already on map. When the level is begun, this line is already on the
  616.         automap, even if it hasn't been "seen" yet.
  617.  
  618. bits 9-15 are unused, EXCEPT for a large section of e2m7, where every wall
  619.         on the border of the section has bits 9-15 set, so they have values
  620.         like 1111111000000000 (-511) and 1111111000010000 (-495). This area
  621.         of e2m7 is also the only place in all 27 levels where there is a
  622.         linedef 4 value of -1. But the linedef isn't a switch. These unique
  623.         values either do nothing, or something that is as yet unknown. The
  624.         currently prevailing opinion is that they do nothing.
  625.  
  626. [4-3-2]: Linedef Types
  627. ----------------------
  628.  
  629. The integers in field 4 of a linedef control various special characteristics,
  630. mostly to do with what happens to a "triggered" SECTOR when the line is
  631. crossed or activated by a player.
  632.  
  633. Except for "Doors", the end-level switches, and the special type 48 (hex 30),
  634. all these effects need "trigger" or "tag" numbers. Then any and all sectors
  635. whose last field contains the same trigger number are affected when the
  636. linedef's function is activated.
  637.  
  638. What the letters in the ACT column mean:
  639.  
  640. W means the function happens when a player WALKS across the linedef. S means
  641. a player must push SPACEBAR near the linedef to activate it (doors and
  642. switches). G means a player must shoot the linedef (GUN).
  643.  
  644. 1 means it works once only. R means it is a repeatable function. This is
  645. tentative, because some functions that appear to work only once might
  646. actually work again if the conditions were reset. E.g. a sector ceiling
  647. rises, opening a little room with baddies in it. Usually, that's it. But
  648. perhaps if some other linedef triggered that sector ceiling to come down
  649. again, then the original trigger could make it go up, etc...
  650.  
  651. Dec/Hex   ACT   EFFECT
  652.  
  653. -1 ffff   ? ?   None? Only once in whole game, on e2m7, (960,768)-(928,768)
  654. 0    00   - -   nothing
  655. 1    01   S R   Door. Sector on the other "side" of this line has its
  656.                 ceiling rise c. 96 in altitude, then comes back down
  657.                 after c. 5 seconds.
  658. 2    02   W 1   ceiling rises like door
  659. 3    03   W 1   ceiling lowers
  660. 5    05   W 1   floor rises to match neighbor sector floor height.
  661. 7    07   S 1   staircase rises up from floor in appropriate sectors.
  662. 8    08   W 1   stairs
  663.  
  664. Note: The stairs function requires special handling. In the original
  665. episodes,
  666. an even number of steps get raised up; the first step and every other one
  667. thereafter are sectors which have the "trigger" number that the control
  668. linedef has, OR they (the sectors/steps) will have 999 or 99 as their
  669. trigger number. I can't figure out why the game uses the 999 thing, since
  670. just using the original trigger number works fine. Also, I don't know yet
  671. if all the steps must be the same size/shape, as they always are in real-map
  672. examples.
  673.  
  674. 9    09   S 1   floor lowers; neighbor sector's floor rises and changes
  675.                 TEXTURE to match yet another neighbor, and sector special
  676.                 type changes to 0.
  677. 10   0a   W 1   floor lowers, wait 3 seconds, rises
  678. 11   0b   S -   End level. Go to next level.
  679. 13   0d   W 1   brightness goes to 255
  680. 14   0e   S 1   floor rises to c. 64 above neighbor sector's floor
  681. 16   10   W 1   ceiling closes, opens after c. 30 seconds.
  682. 18   12   S 1   floor rises to equal first neighbor "on the way up"
  683. 19   13   W 1   floor lowers to equal the highest of the neighboring
  684.                 sector's floors
  685. 20   14   S 1   floor rises, TEXTURE change also.
  686. 21   15   S 1   floor lowers to equal, for c. 3 seconds, then rises back
  687.                 up to stop 8 below neighbor's ceiling height
  688. 22   16   W 1   floor rises, TEXTURE change also
  689. 23   17   S 1   floor lowers to match LOWEST neighbor sector?
  690. 26   1a   S R   Door. Need blue key to open. Closes after 5 seconds.
  691. 27   1b   S R   Door. Yellow key.
  692. 28   1c   S R   Door. Red key.
  693. 29   1d   S 1   ceiling rises, closes after c. 6 seconds?
  694. 30   1e   W 1   floor rises to c. 100-128 above neighbor's floor?
  695. 31   1f   S 1   Door. Stays open.
  696. 32   20   S 1   Door. Blue key. Stays open.
  697. 33   21   S 1   Door. Yellow key. Stays open.
  698. 34   22   S 1   Door. Red key. Stays open.
  699. 35   23   W ?   brightness goes to 0.
  700. 36   24   W ?   lower floor to 8 above neighbor.
  701.  
  702. 37   25   W 1   floor lowers, change floor to acid (special sector 7).
  703. 38   26   W 1   floor lowers
  704. 39   27   W 1   teleport to sector. make sure only one sector has the same
  705.                 trigger number as a line with this effect!
  706. 40   28   W 1   ceiling raises, like 2?
  707. 41   29   S 1   ceiling lowers to floor
  708. 42   2a   S R   ceiling closes like door
  709. 44   2c   W 1?  ceiling lowers to 8 above floor
  710. 46   2e   G 1   Shoot this line, then sector ceiling rises like a door
  711. 48   30   - -   Animated, horizontally scrolling wall.
  712. 51   33   S -   End level. Go to secret level 9.
  713. 52   34   W -   End level. Go to next level
  714. 56   38   W ?   crushing floor rises to 8 below ceiling
  715. 58   3a   W 1   floor rises c. 24-48
  716. 59   3b   W 1   floor rises 8, TEXTURE change to neighbor also
  717. 61   3d   S R   ceiling rises like door
  718. 62   3e   S R   floor lowers, rises after c. 3 seconds
  719. 63   3f   S R?  ceiling rises, lowers after c. 3 seconds
  720. 70   46   S R   sector floor drops quickly to 8 above neighbor
  721. 73   49   W R   start crushing ceiling, slow crush but fast damage
  722. 74   4a   W R   stops crushing ceiling
  723. 75   4b   W R   ceiling closes, and ?
  724. 76   4c   W ?   ceiling closes like door, opens after c. 10 seconds
  725. 77   4d   W R   start crushing ceiling, fast crush but slow damage
  726. 80   50   W 1?  brightness to 255
  727. 82   52   W R   floor lowers to equal neighbor
  728. 86   56   W R   ceiling rises, closes after c. 5 seconds
  729. 87   57   W R?  floor rises and lowers every 5 seconds
  730. 88   58   W R   floor lowers quickly, rises back up after c. 3 seconds
  731. 89   59   W R?  stops the up/down syndrome started by #87
  732. 90   5a   W R   ceiling rises, wait 5 seconds, comes down
  733. 91   5b   W R   floor rises to (neighbor ceiling - 8)
  734. 97   61   W R   teleport to sector. make sure only one sector has the same
  735.                 trigger number as a line with this effect!
  736. 98   62   W R   floor lowers to 8 above neighbor
  737. 102  66   S ?   floor lowers to equal neighbor
  738. 103  67   S 1?  ceiling rises like door, stays open
  739. 104  68   S 1   light drops to lowest light level amongst neighbor sectors
  740.  
  741. [4-4]: SIDEDEFS
  742. ===============
  743.  
  744. A sidedef is a definition of what wall meta-textures to draw along a LINEDEF,
  745. and a group of sidedefs define a SECTOR.
  746.  
  747. There will be one sidedef for a line that borders only one sector, since it
  748. is not necessary to define what the doom player would see from the "other"
  749. side of that line because the doom player can't go there. The doom player
  750. can only "go" where there is a sector (unless you use the no clipping cheat,
  751. which will cause the screen to freak out if you go "outside" to a non-sector
  752. area).
  753.  
  754. Each SIDEDEF is 30 bytes, comprising 2 (integer) fields, then 3 (8-byte
  755. string) fields, then a final (integer) field:
  756.  
  757. (1) X offset for pasting the appropriate wall texture onto the wall's
  758.     "space": positive offset moves "into" the texture, so the left portion
  759.     gets cut off (# of columns off left side = offset). Negative offset moves
  760. texture
  761.     farther right, in the wall's "space"
  762. (2) Y offset: analogous to the X, for vertical.
  763.  
  764. (3) "upper" texture name: the part "above" the juncture with a lower ceiling
  765.     of an adjacent SECTOR.
  766. (4) "lower" texture name: the part "below" a juncture with a higher floored
  767.     adjacent SECTOR.
  768. (5) "full" texture name: the regular part of the wall
  769.  
  770.     The texture names are from the TEXTURE1/2 resources. The names of wall
  771.     patches in the DIRECTORY are not directly used, they are referenced
  772.     through PNAMES.
  773.  
  774.     Simple sidedefs have no upper or lower texture, and so they will have
  775.     "-" instead of a texture name. Also, two-sided lines can be transparent,
  776.     in which case "-" means transparent (no texture)
  777.  
  778.     00s fill the space after a wall name that is less than 8 characters.
  779.  
  780. (6) SECTOR that this sidedef "helps to surround" or "faces"
  781.  
  782. [4-5]: VERTEXES
  783. ===============
  784.  
  785. These are the beginnings and ends for LINEDEFS and SEGS, each is 4 bytes,
  786. 2 (integer) fields:
  787.  
  788. (1) X coordinate
  789. (2) Y coordinate
  790.  
  791. [4-6]: SEGS
  792. ===========
  793.  
  794. The SEGS are in a sequential order determined by the SSECTORS, which are
  795. part of the NODES recursive tree.
  796.  
  797. Each SEG is 12 bytes, having 6 (integer) fields:
  798.  
  799. (1) from VERTEX with this number
  800. (2) to VERTEX
  801.  
  802. (3) angle: 0= east, 16384=north, -16384=south, -32768=west.
  803.     In hex, it's 0000=east, 4000=north, 8000=west, c000=south.
  804.  
  805. (4) LINEDEF that this seg goes along
  806. (5) 0 = this seg is on the front "side" of the linedef.
  807.     1 = this seg is on the back "side" of the linedef.
  808.  
  809.     This could also be thought of as direction: 0 if the seg goes the same
  810.     direction as the linedef it's on, 1 if it goes the opposite direction.
  811.  
  812. (6) Is the distance along the linedef that the seg begins. If the seg begins
  813.     at one of the two endpoints of the linedef, this will be 0. If the seg
  814.     and linedef are a "diagonal" line, the length will be according to the
  815.     distance in the coordinate plane of the vertexes, i.e.
  816.  
  817.     SQR((X2 - X1)^2 + (Y2 - Y1)^2).
  818.  
  819.     Actually, it seems to be off by 1 or 2 from what it should be, like they
  820.     are using ABS(X2 - X1) values that are 1 less than the "real" value
  821.     should be.
  822.  
  823. [4-7]: SSECTORS
  824. ===============
  825.  
  826. Each SSECTOR is 4 bytes, having 2 (integer) fields
  827.  
  828. (1) This many SEGS are in this SSECTOR...
  829. (2) ...starting with this SEG number
  830.  
  831. Ssector stands for sub-sector. These divide up all the SECTORS into
  832. non-convex polygons. They are then referenced through the NODES resources.
  833.  
  834. [4-8]: NODES
  835. ============
  836.  
  837. This is what we need to figure out!
  838.  
  839. The nodes are branches in a binary space partition that divides up the level
  840. and is used to determine which walls and floors are in front of others, thus
  841. "clipping" the walls behind from the virtual view. The nodes/ssectors/segs
  842. resources are used exclusively for these display purposes, and seem to be
  843. precalculated to ease the burden on the game engine.
  844.  
  845. There are ((number of SSECTORS) - 1) NODES. Each NODE has 14 (integer)
  846. fields:
  847.  
  848. (1)  X coordinate of partition line's start
  849. (2)  Y coordinate of partition line's start
  850. (3)  DX, change in X to end of partion line
  851. (4)  DY, change in Y to end of partion line
  852.  
  853.      thus 64, 128, -64, -64 would be a partition line from (64,128) to (0,64)
  854.  
  855. (5)  Y upper bound for the first bounding-box
  856. (6)  Y lower bound
  857. (7)  X upper bound
  858. (8)  X lower bound
  859.  
  860. (9)  Y upper bound for the second bounding box
  861. (10) Y lower bound
  862. (11) X upper bound
  863. (12) X lower bound
  864.  
  865.      Each node has two "children", each of which is either a node or a
  866.      ssector. The bounding box is just big enough to contain whatever is
  867.      in the "child", e.g. if the child is a ssector with 1 seg, then the
  868.      bounding box will be just big enough to contain the extents of the
  869.      seg (and thus a bounding "box" can have zero width, for a horizontal
  870.      or verical seg)
  871.  
  872.      If the child is a node, the bounding box will be just big enough to
  873.      hold both of its children.
  874.  
  875. (13) a NODE or SSECTOR number for the first bounding box. If bit 15 is set,
  876.      then the rest of the number represents the child SSECTOR. If not, the
  877.      child is a recursed node.
  878. (14) a NODE or SSECTOR number for the second bounding box.
  879.  
  880. So there is a heavy iterative aspect to this structure. The final NODE is
  881. always the size of the entire level.
  882.  
  883. I am optimistic that a valid set of nodes/ssectors/segs can be generated
  884. from a set of vertices and lines by some automatic algorithm, but so far it
  885. isn't happening. Once this problem is solved, we will be able to create
  886. levels from scratch!
  887.  
  888. [4-9]: SECTORS
  889. ==============
  890.  
  891. A SECTOR is a horiontal (east-west and north-south) area of the map where a
  892. floor height and ceiling height is defined, so a doom player may go there.
  893. Any change in floor or ceiling "altitude" or texture requires a new SECTOR
  894. (and therefore separating LINEDEF(s) and SIDEDEF(s)).
  895.  
  896. Each is 26 bytes, comprising 2 (integer) fields, then 2 (8-byte string)
  897. fields, then 3 (integer) fields:
  898.  
  899. (1) Floor is at this "altitude" for this sector
  900. (2) Ceiling altitude
  901.  
  902.     The altitudes can probably range from about -500 to 500. A difference
  903.     of 30 between the floor heights of two adjacent sectors is passable
  904.     (upwards), but a difference of 32 is "too high". The player may fall
  905.     any amount.
  906.  
  907. (3) name of floor texture, from the DIRECTORY
  908. (4) name of ceiling texture, from DIRECTORY
  909.  
  910.     All the "floor" pictures in the DIRECTORY work as either floors or
  911.     ceilings. F_SKY1 is used as a ceiling to indicate that it is transparent
  912.     to the sky above/behind.
  913.  
  914. (5) brightness of this sector: 0 = total dark, 255 (ff) = maximum light
  915.  
  916. (6) special sector:
  917.  
  918. 0   00  is normal, no special characteristic.
  919. 1   01  light level goes to 0 for a fraction of a second, at random times.
  920. 2   02  light pulsates abruptly for 0.5 second
  921. 3   03  light pulsates abruptly for 1.0 second
  922. 4   04  -10/20% health AND lights on/off every 0.5 seconds
  923. 5   05  -5/10% health (-5% at skill 1, -10% at higher skills)
  924. 7   07  -2/5% health, this is the usual NUKAGE acid-floor.
  925. 8   08  light oscillates from 255 (this sector's brightness) to whatever
  926.         light level is lowest amongst all the adjacent sectors.
  927. 9   09  SECRET (a player must walk into this sector to get credit for
  928.         discovering this "secret")
  929. 10  0a  Still undetermined: This is a strange one. 30 seconds after a level
  930.         is begun, the ceiling of any sector with this number will come down
  931.         to the floor. If it hits a player's head, it stops (without crushing).
  932.         Also the ceiling seems to be blocked by a barrel, but is not blocked
  933.         by many other objects. And sometimes the ceiling will take off UP,
  934.         never stopping. Definately a mystery, this one.
  935. 11  0b  -10/20% health; when player's HEALTH <= 10%, then the level ends.
  936.         If it is a level 8, then the episode ends.
  937. 12  0c  light smoothly oscillates between value in (5) and 0.
  938. 13  0d  light on/off every 0.25 seconds
  939. 14  0e  ?
  940. 16  10  -10/20% health
  941.  
  942. All other values cause an "UNKOWN SPECIAL SECTOR" error - exit to DOS.
  943.  
  944. (7) is a "trigger" number corresponding to a certain LINEDEF with the same
  945.     "trigger" number. When that LINEDEF is crossed, something happens to this
  946.     SECTOR - it goes up or down, etc...
  947.  
  948.     There are a few unusual trigger numbers. 99 and 999 can be used in
  949.     staircases, see [3-3-2] under linedef types 7 and 8. 666 is used on e1m8,
  950.     any sector with that trigger number has it's floor go all the way down
  951.     to equal the height of the lowest neighbor floor. This happens when
  952.     the last Baron of Hell on the level is killed. The function does not
  953.     work on any other level, including e2m8 and e3m8, and it only applies
  954.     to the Barons, not the other bosses. Are there any other special
  955.     trigger events?
  956.  
  957. [4-10]: REJECT
  958. ==============
  959.  
  960. Reject is an array of bits. It's size in bytes is
  961.  
  962. (number of SECTORS ^ 2) / 8, rounded up.
  963.  
  964. "It is used for optimization and all the bits may be set to 0" -
  965. this is a quote from John Carmack at id software.
  966.  
  967. In fact, the length of the object may be made 0 (same as making it all 0s),
  968. and I can't detect any difference.
  969.  
  970. [4-11]: BLOCKMAP
  971. ================
  972.  
  973. The BLOCKMAP is a pre-calculated structure that the game engine uses to
  974. simplify collision-detection between moving things and walls. It is possible
  975. to make an algorithm that generates the BLOCKMAP, given the locations of all
  976. the LINEDEFS. For reasons of space, and the fact that I haven't made one,
  977. the algorithm is not included here.
  978.  
  979. If you don't have a BLOCKMAP, the level displays fine, but everybody walks
  980. through walls, and no one can hurt anyone else with their gunfire.
  981.  
  982. All of BLOCKMAP's fields are integers.
  983.  
  984. The whole level is cut into "blocks", each is a 128 (hex 80) wide square (the
  985. grid lines in the automap correspond to these blocks).
  986.  
  987. The first two integers are XORIGIN and YORIGIN, which specify the coordinates
  988. of the bottom-left corner of the bottom-left (southwest) block.
  989.  
  990. Then come XBLOCKS and YBLOCKS, which specify how many "blocks" there are in
  991. the X and Y directions. XBLOCKS is the number of COLUMNS, YBLOCKS is the
  992. number of ROWS.
  993.  
  994. Then come (ROWS * COLUMNS) integers which are pointers to the offset within
  995. the BLOCKMAP resource for that "block". These "offsets" refer to the INTEGER
  996. number, NOT the byte number, where to find the block's list. The blocks go
  997. right (east) and up (north). The first block is at row 0, column 0; the next
  998. at row 0, column 1; if there are 34 columns like on e1m1, the 35th block is
  999. row 1, column 0, etc.
  1000.  
  1001. After all the pointers, come the block lists. Each blocklist describes the
  1002. numbers of all the LINEDEFS which are partially or wholly "in" that block.
  1003.  
  1004. An "empty" block is two integers: 0 and then -1.
  1005.  
  1006. A non-empty block will go something like: 0 330 331 333 -1. This means that
  1007. LINEDEFS 330, 331, and 333 are "in" that block. Part of each of those line
  1008. segments lies within the (hex 80 by 80) boundaries of that block.
  1009.  
  1010. What about the block that has LINEDEF 0? It goes: 0 0 ... etc ... -1.
  1011.  
  1012. Here's another way of describing BLOCKMAP as a list of the integers, in
  1013. order:
  1014.  
  1015.         Coordinate of block-grid X origin
  1016.         Coordinate of block-grid Y origin
  1017.         # of columns (blocks in X direction)
  1018.         # of rows (blocks in Y direction)
  1019.         Block 0 offset from start of BLOCKMAP, in integers
  1020.           .
  1021.           .
  1022.         Block N-1 offset (N = number of columns * number of rows)
  1023.         Block 0 list: 0, numbers of every LINEDEF in block 0, -1 (ffff)
  1024.           .
  1025.           .
  1026.         Block N-1 list: 0, numbers of every LINEDEF in block N-1, -1 (ffff)
  1027.  
  1028. -----------------------------
  1029. CHAPTER [5]: Pictures' Format
  1030. -----------------------------
  1031.  
  1032. The great majority of the entries if the directory reference resources that
  1033. are in a special "picture" format. The same format is used for the pictures
  1034. of items (like medikits), the sprites for the enemies (like imps), the
  1035. wall patches, and various miscellaneous pictures for the status bar, menu
  1036. text, inter-level map, and etc. The floor and ceiling textures are NOT in
  1037. this format, they are raw data; see chapter 5.
  1038.  
  1039. Each picture has three sections, basically. First, a four-integer header.
  1040. Then a number of long-integer pointers. Then the picture pixel color data.
  1041.  
  1042. [5-1]: Header
  1043. =============
  1044.  
  1045. The header has four fields:
  1046.  
  1047. (1) Width. The number of columns of picture data.
  1048. (2) Height. The number of rows.
  1049.  
  1050.     This defines a rectangular space or limits for drawing a picture within.
  1051.  
  1052. (3) Left offset. The number of pixels to the left of the center; where the
  1053.     first column gets drawn.
  1054. (4) Top offset. The number of pixels above the origin; where the top row is.
  1055.  
  1056.     To be "centered", (3) is usually about half of the total width. If the
  1057.     picture had 30 columns, and (3) was 10, then it would be off-center to
  1058.     the right, especially when the player is standing right in front of it,
  1059.     looking at it. If a picture has 30 rows, and (4) is 60, it will appear
  1060.     to "float" like a blue soul-sphere. If (4) equals the number of rows,
  1061.     it will appear to rest on the ground. If (4) is less than that for an
  1062.     object, the bottom part of the picture looks awkward.
  1063.  
  1064.     With walls patches, (3) is always (columns/2)-1, and (4) is always
  1065.     (rows)-5. This is because the walls are drawn consistently within their
  1066.     own space (There are two integers in each SIDEDEF which can offset the
  1067.     beginning of a wall's texture).
  1068.  
  1069.     Finally, if (3) and (4) are NEGATIVE integers, then they are the absolute
  1070.     coordinates from the top-left corner of the screen, to begin drawing the
  1071.     picture, assuming the VIEW is FULL-SCREEN (the full 320x200). This is
  1072.     only done with the picture of the doom player's current weapon - fist,
  1073.     chainsaw, bfg9000, etc. The game engine scales the picture down
  1074.     appropriately if the view is less than full-screen.
  1075.  
  1076. [5-2]: Pointers
  1077. ===============
  1078.  
  1079. After the header, there are N = (# of columns) long integers (4 bytes each).
  1080. These are pointers to the data for each COLUMN. The value of the pointer
  1081. represents the offset in bytes from the first byte of the picture resource.
  1082.  
  1083. [5-3]: Pixel Data
  1084. =================
  1085.  
  1086. Each column is composed of some number of BYTES (NOT integers), arranged in
  1087. "posts":
  1088.  
  1089. The first byte is the row to begin drawing this post at. 0 means whatever
  1090. height the header (4) upwards-offset describes, larger numbers move
  1091. correspondingly down.
  1092.  
  1093. The second byte is how many colored pixels (non-transparent) to draw, going
  1094. downwards.
  1095.  
  1096. Then follow (# of pixels) + 2 bytes, which define what color each pixel is,
  1097. using the game palette. The first and last bytes AREN'T drawn, and I don't
  1098. know why they are there. Probably just leftovers from the creation process on
  1099. the NExT machines. Only the middle (# of pixels in this post) are drawn,
  1100. starting at the row specified in byte 1 of the post.
  1101.  
  1102. After the last byte of a post, either the column ends, or there is another
  1103. post, which will start as stated above.
  1104.  
  1105. 255 (hex FF) ends the column, so a column that starts this way is a null
  1106. column, all "transparent". Goes to the next column.
  1107.  
  1108. Thus, transparent areas can be defined for either items or walls.
  1109.  
  1110. Note that all the item and enemy sprites' names are in the DIRECTORY between
  1111. the S_START and S_END entries, and all the wall patches are between the
  1112. P_START and P_END entries.
  1113.  
  1114. ---------------------------------------
  1115. CHAPTER [6]: Floor and Ceiling Textures
  1116. ---------------------------------------
  1117.  
  1118. All the names for these textures are in the DIRECTORY between the F_START and
  1119. F_END entries. There is no look-up or meta-structure as with the walls.
  1120.  
  1121. Each texture is 4096 raw bytes, making a square 64 by 64 pixels, which is
  1122. pasted onto a BLOCK's floor or ceiling, with the same orientation as the
  1123. automap would imply, i.e. the first byte is the color at the NW corner, the
  1124. 64th is the color at the NE, etc.
  1125.  
  1126. The data in F_SKY1 isn't even used since the game engine interprets that
  1127. "special" ceiling as see-thru to the SKY texture beyond. So the F_SKY1 entry
  1128. can have zero length.
  1129.  
  1130. [6-1]: Animated floors
  1131. ----------------------
  1132.  
  1133. See Chapter [8-4-1] for a discussion of how the animated floors and walls
  1134. work.
  1135.  
  1136. -----------------------------
  1137. CHAPTER [7]: Sounds and Songs
  1138. -----------------------------
  1139.  
  1140. Not much detail here, and I'm just guessing at the song format anyway.
  1141.  
  1142. [7-1]: D_[xxxxxx]
  1143. =================
  1144.  
  1145. Songs.  What format are they? Somewhere I read that they are in the MUS
  1146. format, which I have absolutely no knowledge of. But it's obvious what each
  1147. song is for, from their names.
  1148.  
  1149. [7-2]: DP[xxxxxx] and DS[xxxxxx]
  1150. ================================
  1151.  
  1152. These are the sound effects. They come in pairs - DP for pc speaker sounds,
  1153. DS for sound cards.
  1154.  
  1155.  
  1156. The DS sounds are in RAW format: they have a four integer header, then the
  1157. sound samples (each is 1 byte since they are 8-bit samples).
  1158.  
  1159. The headers' four integers are: 3, then 11025 (the sample rate), then the
  1160. # of samples, then 0.
  1161.  
  1162. ------------------------------------------------
  1163. CHAPTER [8]: Miscellaneous Non-picture Resources
  1164. ------------------------------------------------
  1165.  
  1166. [8-1]: PLAYPAL
  1167. ==============
  1168.  
  1169. There are 14 palettes here, each is 768 bytes = 256 rgb triples. That is, the
  1170. first three bytes of a palette are the red, green, and blue portions of
  1171. color 0. And so on.
  1172.  
  1173. Palette 0 is the one that is used for almost everything.
  1174.  
  1175. Palettes 10-12 are used (briefly) when an item is picked up, the more items
  1176. that are picked up in quick succession, the brighter it gets, palette 12
  1177. being the brightest.
  1178.  
  1179. Palette 13 is used while wearing a radiation suit.
  1180.  
  1181. Palettes 3, then 2, then 1 again are used after getting beserk strength.
  1182.  
  1183. If the player is hurt, then the palette shifts up to X, then comes "down" one
  1184. every half second or so, to palette 2, then palette 0 (normal) again. What X
  1185. is depends on how badly the player got hurt: Over 100% damage (add health
  1186. loss and armor loss), X=8. 93%, X=7. 81%, X=6. 55%, X=5. 35%, X=4. 16%, X=2.
  1187.  
  1188. Palettes 1 and 9 contain the secret codes which allow you to play
  1189. Commercial Doom eight months before it gets released. Just kidding!
  1190. Maybe F_SKY1 has that data in it. Let's get outta here!
  1191.  
  1192. [8-2]: COLORMAP
  1193. ===============
  1194.  
  1195. This resource contains 34 sets of 256 bytes, which "map" the colors "down" in
  1196. brightness. (Brightness is controlled by the 5th field in the SECTORS, see
  1197. Chapter 4-9 above). E.g. at very low brightness, almost all the colors are
  1198. "mapped" to black, the darkest grey, green, blue, etc. In each set of 256
  1199. bytes, byte 0 will have the number of the palette color to which original
  1200. color 0 gets mapped. Etc. Which set of 34 corresponds to which exact
  1201. brightness level is something I haven't bothered to figure out. Better things
  1202. to do...like the maps.
  1203.  
  1204. [8-3]: DEMOs
  1205. ==============
  1206.  
  1207. These are the demos that will be shown if you start doom, but don't play an
  1208. episode. Each has a record of the keystrokes. Didn't bother to figure the
  1209. formats out, since demos can be created using the devparm parameter:
  1210.  
  1211. DOOM -devparm -record DEMONAME
  1212.  
  1213. The extension .LMP is automatically added to the DEMONAME. Other parameters
  1214. may be used simultaneously, such as -skill [1-5], -warp [1-3] [1-9]. The
  1215. demos in the WAD are in exactly the same format as these LMP files, so a LMP
  1216. file may be simply pasted or assembled into a WAD, and if its length and
  1217. pointer directory entries are correct, it will work.
  1218.  
  1219. I've read that someone is collecting LMP files which show truly heroic feats,
  1220. like slaughtering boss guys with just a pistol, killing a whole level of bad
  1221. guys with just beserk punch, while at 1% health, etc. By the time you read
  1222. this, it's probably too late to join in the fun (i.e. submit a good one), but
  1223. who knows. At this moment, I don't know who to contact, please send me any
  1224. information you have.
  1225.  
  1226. I've also read that some are worried that if the .LMP formats are cracked,
  1227. cheaters will make bogus demos and destroy the whole point of distributing
  1228. .LMPs to prove how great a player one is. I think it would be a ridiculously
  1229. difficult feat to make a fake demo, but out of deference to paranoia, I'll
  1230. never even attempt to crack the structure, nor distribute info on it.
  1231.  
  1232. [8-4]: TEXTURE1 and TEXTURE2
  1233. ============================
  1234.  
  1235. These resources contains a list of the wall names used in the various
  1236. SIDEDEFS sections of the level data. Each wall name actually references a
  1237. meta-structure, defined in this list. TEXTURE2 has all the walls that are
  1238. only in the registered version.
  1239.  
  1240. First is a table of pointers to the start of the entries. There is a long
  1241. integer (say, N) which is the number of entries in the TEXTURE resource.
  1242.  
  1243. Then follow N long integers which are the offsets in bytes from the beginning
  1244. of the TEXTURE resource to the start of that texture's definition entry.
  1245.  
  1246. Then follow N texture entries, which each consist of a 8-byte name field and
  1247. then a variable number of 2-byte integer fields:
  1248.  
  1249. (1) The name of the texture, like STARTAN3, is the name that is used in a
  1250.     SIDEDEFS resource.
  1251. (2) always 0. Purpose unkown.
  1252. (3) always 0. Purpose unkown.
  1253.  
  1254. (4) total width of texture
  1255. (5) total height of texture
  1256.  
  1257. The fourth and fifth fields define a "space" (usually 32 by 128 or 64 by 72
  1258. or etc...) in which individual wall patches are "placed" to form the overall
  1259. picture. This is done because there are some wall patches that are used in
  1260. several different walls, like computer screens, etc.
  1261.  
  1262. (6) always 0. Purpose unkown.
  1263. (7) always 0. Purpose unkown.
  1264.  
  1265. (8) Number of 5-field patches that follow. This is why each texture entry
  1266.     has variable length. Many entries have just 1 patch, one has 64 patches!
  1267.  
  1268.         1. x offset from top-left corner of texture space defined in field
  1269.            4/5 to start placement of this patch
  1270.         2. y offset
  1271.         3. number, from 0 to whatever, of the entry in the PNAMES resource,
  1272.            which contains the name from the DIRECTORY, of the wall patch to
  1273.            use...
  1274.         4. always 1, is for something called "stepdir"...
  1275.         5. always 0, is for "colormap"...
  1276.  
  1277. Note that patches can have transparent parts, since they are in the same
  1278. picture format as everything else. Thus there can be (and are) transparent
  1279. wall textures. These should only be used on a border between two sectors, to
  1280. avoid the "displaying nothing" problems discussed earlier.
  1281.  
  1282. Here is how one can "add" walls, while still retaining all the original ones
  1283. it came with: in a pwad, have replacement entries for PNAMES and TEXTURE2.
  1284. These will be the same as the originals, but with more entries, for the wall
  1285. patches and assembled textures that you're adding. Then have P_START,
  1286. P2_START, ...,  P2_END, and P_END entries, with the ... representing however
  1287. many entries are needed for the number of new wall patches you have.
  1288.  
  1289. Note you must be careful with naming the entries. If the name duplicates an
  1290. entry in the main DOOM.WAD, the one in the pwad will replace the original,
  1291. and if they aren't the same size in pixel dimensions, problems could occur
  1292. in the display (no crashes, probably, just ugly walls to look at because
  1293. of the random junk).
  1294.  
  1295. So names like "WALL66_6" or "W119_24" whatever are probably not a good idea,
  1296. unless you are using some great program that indexes and keeps track of all
  1297. the wall names in the universe (If you have such a program, please send it
  1298. to me!). Names like "JS_W12_3" and "JOEWALL2" are better.
  1299.  
  1300. [8-4-1]: Animated walls
  1301. -----------------------
  1302.  
  1303. It is possible to change the walls and floors that are animated, like the
  1304. green blocks with a sewer-like grate that's spewing green slime (SLADRIPx).
  1305. The game engine sets up as many as 8 animation cycles for walls and 5
  1306. for floors based on the entries in the TEXTURE resources. The entries in
  1307. "First" and "Last", and all the entries between them (in the order that they
  1308. occur in a TEXTURE list), are linked. If one of them is called by a SIDEDEF,
  1309. that SIDEDEF will change texture to the next in the cycle about 5 times a
  1310. second (?), going back to "First" after "Last". Note that the entries between
  1311. First and Last need not be the same in number as in the original, nor do they
  1312. have to follow the same naming pattern, though that would probaly be wise.
  1313. E.g. one could set up ROCKRED1, ROCKREDA, ROCKREDB, ROCKREDC, ROCKREDD,
  1314. ROCKREDE, ROCKRED3 for a 7-frame animated wall!
  1315.  
  1316. If "First" and "Last" aren't in either TEXTURE, no problem. Then that cycle
  1317. isn't used. But if "First" is, and "Last" either isn't or is listed BEFORE
  1318. "First", then an error occurs.
  1319.  
  1320. First           Last            Normal # of frames
  1321.  
  1322. BLODGR1         BLODGR4         4
  1323. BLODRIP1        BLODRIP4        4
  1324. FIREBLU1        FIREBLU2        2
  1325. FIRELAV3        FIRELAVA        2
  1326. FIREMAG1        FIREMAG3        3
  1327. FIREWALA        FIREWALL        3
  1328. GSTFONT1        GSTFONT3        3
  1329. ROCKRED1        ROCKRED3        3
  1330. SLADRIP1        SLADRIP3        3
  1331.  
  1332. (floor/ceiling animations) -
  1333.  
  1334. NUKAGE1         NUKAGE3         3
  1335. FWATER1         FWATER3         3
  1336. SWATER1         SWATER4         4?
  1337. LAVA1           LAVA4           4
  1338. BLOOD1          BLOOD3          3
  1339.  
  1340. Note that the SWATER entries aren't in the regular DOOM.WAD, so there's your
  1341. easy opportunity to put in a custom floor animation without taking away any
  1342. originals...
  1343.  
  1344. [8-5]: PNAMES
  1345. =============
  1346.  
  1347. This is a lookup table for the numbers in TEXTURE[1 or 2] to reference to an
  1348. actual entry in the DIRECTORY which is a wall patch (in the picture format
  1349. described in chapter 4).
  1350.  
  1351. The first two bytes of the PNAMES resource is an integer P which is how
  1352. many entries there are in the list.
  1353.  
  1354. Then come P 8-byte names, each of which duplicates an entry in the DIRECTORY.
  1355. If a patch name can't be found in the directory (including the external
  1356. pwad's directories), an error will occur. This naming of resources is
  1357. apparently not case-sensitive, lowercase letters will match uppercase.
  1358.  
  1359. The middle integer of each 5-integer "set" of a TEXTURE1 entry is something
  1360.  
  1361. from 0 to whatever. Number 0 means the first entry in this PNAMES list, 1 is
  1362. the second, etc...
  1363. -- 
  1364. ****  **  ***  ***  **  **** : CALL OF THE  |         Hank Leukart
  1365. *  * *  * *  *  *  *  * *  * :   SHADOWS    |  (ap641@cleveland.freenet.edu)
  1366. **** **** ***   *  *  * **** :Apogee//Cygnus|   "Official" DOOM FAQ Writer  
  1367. * *  *  * *     *   **  * *  :    March     |  FAQ via E-mail or ftp.uwp.edu
  1368.