home *** CD-ROM | disk | FTP | other *** search
/ Deathday Collection / dday.bin / edit / dfe / dfe.txt < prev    next >
Text File  |  1994-05-26  |  28KB  |  783 lines

  1. *****************************************************************************
  2. *                       The DOOM Hacker's Tool Kit v1.00                    *
  3. *****************************************************************************
  4. * Author:  Joshua Jackson          internet: joshjackson@delphi.com         *
  5. * Release Date: 5/25/94                                                     *
  6. * Language: Borland Pascal 7.0   (Mostly Object Oriented)                   *
  7. *    Destination Platform:  DOS real mode  -OR-  DPMI DOS protected mode    *
  8. *                                                                           *
  9. * The DOOM Hacker's Tool Kit is a product of Jackson Software               *
  10. *****************************************************************************
  11.  
  12. Welcome fellow DOOM hacker!
  13.  
  14.     I have released this source code in hopes that someone out there with a
  15.     bit more brains than I have can put it to good use.  I am also making
  16.     a request that anyone willing to trade source code and ideas, please
  17.     email me at the above address.  I am mostly interested in 3D rendering
  18.     code, but am looking for anything that is not contained in this tool kit,
  19.     or improves upon it.
  20.  
  21.     I am also considering setting up a DOOM Hacker's BBS.  If you are
  22.     interested in such a BBS, please let me know so.  It will be setup on
  23.     a File Point system with no ratio required for Long Distance callers.
  24.     I would also accept UUENCODED source over the internet, which would
  25.     then be placed onto the BBS.
  26.  
  27.     NOTE: This BBS would be for programs that include the SOURCE CODE only!
  28.             I will also have a section for technical FAQs and the like...
  29.             similiar to DMSPEC13.TXT
  30.             All Languages would be accepted.
  31.  
  32.     This is a rather extensive set of utilities that I hacked up to access
  33.     just about everything in the WAD file.  Resource utilities include:
  34.  
  35.         Sprite Viewer
  36.         Map Viewer (With object recognition/sprite viewing)
  37.         Floor/Ceiling Texture Viewer
  38.         Wall Texture Viewier
  39.         Sound Player
  40.         Resource Extractor
  41.         Object Caching
  42.  
  43. In addition, I have also included the source code for the DOOM Front End
  44. v1.31.  The majority of the code here is written in Borland Pascal 7.0 and
  45. is mostly geared toward OOP (Object Oriented Programming).  There is also some
  46. assembly language thrown into it here and there.
  47.  
  48. Comments, Suggestions, Bashing, and Questions are more than welcome!
  49.  
  50. (Please, don't write just to tell me that the code is not fully cleaned up!
  51.  I do realize that there are declared variables that aren't used and things
  52.  of that nature.  This is because I wanted to get this program into your
  53.  hands as soon as possible, and that this code, even though its version 1.0,
  54.  has done some massive evolving since I first began construction of it.  It
  55.  was originally written in staight pascal, no objects that is, and was VERY
  56.  pathetic!  This tool kit has probably under gone several dozen revisions
  57.  since I begin the project about a month ago.)
  58.  
  59. Contacting me:
  60.  
  61. Internet:       joshjackson@delphi.com
  62.  
  63. Snail Mail: Joshua Jackson
  64.                 10506 Bayard Rd.
  65.                 Minerva, OH  44657
  66.  
  67. Phone:      (216) 868-1169
  68.  
  69. !*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*
  70. DISCLAIMER:
  71.  
  72. The author will not accept any resposibility for damage resulting from the
  73. use of these programs, whether it be hardware, software, or mental.
  74.  
  75. COPYING/USE of this code:
  76.  
  77. All of the code in the DOOM Hacker's tool kit is placed in the public domain
  78. with the exception of DFE.  The DFE source has been released simply for
  79. educational purposes only, I would appriciate if you would not modify and
  80. release and versions of this program.
  81. !*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*
  82.  
  83. NOTE: If you plan to compile this tool kit under DPMI, you should use the
  84.         BGI256.BGI or BGI256.OBJ (for linking in the graphics driver).  I
  85.         obtained these drivers off of the official Borland BBS.  Most public
  86.         domain BGI drivers will cause a general protection fault under DPMI,
  87.         BGI256 is designed to be compatible.
  88.  
  89. Well, enough of that, lets get onto the part you probably are interested in
  90. reading.
  91.  
  92. The following are descriptions of all of the Objects/Routines that are
  93. contained in the WAD Hacker's Toolkit.
  94.  
  95. ------------------------------------------------------------------------------
  96. Unit:   WADDECL.PAS
  97. Purpose:        Declarations Unit
  98.  
  99.     There is not much to this unit,  it is simply the type declarations for
  100. many of the different structured variables in the tool kit...  If you can't
  101. understand this unit, you may want to stop here! :)
  102. ------------------------------------------------------------------------------
  103.  
  104. ------------------------------------------------------------------------------
  105. Unit:   WAD.PAS
  106. Purpose:        Accessing a WAD file's directory
  107.  
  108.     This unit is the center of the tool kit.  It contains an object that
  109. loads a given WAD file's directory into memory.  Almost all of the other units
  110. rely on this unit for their access into the WAD files.
  111.  
  112. The object contained in this unit (TWadDirectory) MUST be initialized before
  113. any other units can be  initialized.
  114.  
  115. The following is a listing of the TWadDirectory object declaration:
  116.  
  117. type    PWadDirectory=^TWadDirectory;
  118.         TWadDirectory=object
  119.             WadName         :array[1..9] of char;
  120.             WadFile         :file;
  121.             WadID                   :array[1..4] of char;
  122.             DirEntries      :longint;
  123.             DirStart                :longint;
  124.             DirEntry        :PWADDirList;
  125.             Constructor Init(WadFileName:String);
  126.             Procedure DisplayWadDir;
  127.             Function FindObject(ObjName:ObjNameStr):word;
  128.             Procedure SetWadPalette(PlayPalNum:integer);
  129.             Procedure RestorePalette;
  130.             Destructor Done;
  131.         end;
  132.  
  133. When calling the init constructor, the only needed parameter is the path and
  134. name of the WAD file that you wish to load. The following is an example
  135. program that will load a WAD file directory:
  136.  
  137.     uses Wad;
  138.  
  139.     var     WDir:PWadDirectory;
  140.  
  141.     begin
  142.  
  143.         {Initialize WAD file directory for DOOM.WAD}
  144.         WDir:=New(PWadDirectory, Init('C:\DOOM\DOOM.WAD'));
  145.  
  146.         {Your code goes here}
  147.  
  148.         {Dispose of the WAD file directory}
  149.         Dispose(WDir, Done);
  150.  
  151.     end.
  152.  
  153. You will also notice that I included the call to the object's done destructor
  154. when disposing of the object.  This is mandatory unless you want a ton of
  155. garbage left on the heap.
  156.  
  157. The other methods besides init and done are use mainly by the other units in
  158. the tool kit.  However, if you would like you implement them in your own
  159. programs here is the syntax for them:
  160.  
  161.  
  162. Function FindObject(ObjName:ObjNameStr):word
  163.     Returns the position in the directory array of the given object's name.
  164.     NOTE: you may use use the WildCard value of '?' for any or all letters in
  165.     the name if you want to do a "find first that matches" type search.
  166.  
  167. Procedure DisplayWadDir
  168.     displays the given WAD file's directory to the screen
  169.  
  170. Procedure SetWadPalette(PlayPalNum:integer);
  171.     Sets the current graphics palette to one of the 17 palettes available in
  172.     the WAD file.  The main play palette is 0.
  173.  
  174. Procedure RestorePalette
  175.     Restores the current graphics palette to the original palette before the
  176.     first call to SetWadPalette
  177.  
  178. Finally, the variable fields in this object are defined as follows:
  179.  
  180. WadName         :array[1..9] of char;
  181.     The ASCIIZ name of the WAD file that this object contains the directory to.
  182.     (NOTE: the .WAD extension is not included)
  183.  
  184. WadFile         :file;
  185.     This file identifier used when accessing the WAD file.  This field should
  186.     NEVER be altered.
  187.  
  188. WadID                   :array[1..4] of char;
  189.     Indicated if the loaded file is a 'PWAD' or an 'IWAD'
  190.  
  191. DirEntries      :longint;
  192.     The number of directory entires contained in the WAD file.
  193.  
  194. DirStart                :longint;
  195.     The file offset of the begining of the directory structure.
  196.  
  197. DirEntry        :PWADDirList;
  198.     The directory entries themselves.  The number of entries will vary
  199.     depending on the size of the WAD file.
  200.     NOTE: The number of entries in this array is always equal to DirEntries.
  201.  
  202.     The structure for PWADDirList is contained in the WADDECL unit and has the
  203.     following structure:
  204.  
  205.         PWADDirList=^TWADDirList;
  206.         TWADDirList=array[1..MaxEntries] of TWADDirEntry;
  207.  
  208.         PWADDirEntry=^TWADDirEntry;
  209.         TWADDirEntry=record
  210.             ObjStart        :longint;
  211.             ObjLength:longint;
  212.             ObjName :array[1..8] of char;
  213.         end;
  214.  
  215.         Another NOTE:  I used a little trickery to make the size of the directory
  216.         array variable.  Therefor, it is possible to address entries outside of
  217.         the directory array itself.  Be careful not to do this, especially when
  218.         in DPMI (You will more than likely cause a segment overrun error)
  219. ------------------------------------------------------------------------------
  220. ------------------------------------------------------------------------------
  221. Unit:   OBJCACHE.PAS
  222. Purpose:        WAD Object Cache
  223.  
  224.     This unit is use to optimize the speed at which object are loaded from the
  225. WAD file.  I had originally written routines for loading sprites and the like
  226. based on the code contained in DEU.  Their code works good, but is slow as
  227. a dog!  When using the code based on DEU, I was able to load around one sprite
  228. per second of so.  When using the Object Cache, the speed of loading sprites
  229. increased to around 10-15 sprites/sec!
  230.  
  231. The following is a listing of the TObjectCache declaration:
  232.  
  233. type    PObjectCache=^TObjectCache;
  234.         TObjectCache=Object
  235.             Constructor Init(WDir:PWadDirectory;ObjNum:word);
  236.             Procedure SetPos(NewPos:longint);
  237.             Function CurPos:Longint;
  238.             Procedure IncPos(IncVal:longint);
  239.             Procedure CacheRead(var Dest;Count:word);
  240.             Function Size:Longint;
  241.             Destructor Done;
  242.          private
  243.             NumLumps:byte;
  244.             Lump:array[1..MaxLumps] of PCacheLump;
  245.             CachePos:longint;
  246.             LumpPos:word;
  247.             CurLump:byte;
  248.         end;
  249.  
  250. Basically, the object cache is simply a way to allocate more that 64k for
  251. loading an object into memory.
  252.  
  253. When initializing the TObjectCache object, a WAD file directory (see WAD.PAS)
  254. and an object number are needed.  The object number is obtained through a call
  255. to TWadDirectory.FindObject.
  256.  
  257. Once you have initialized the object cache, you may read blocks from it using
  258. calls to CacheRead.  CacheRead requires a viariable destination and the number
  259. of bytes that you wish to transfer.  After the read, the cache pointer will
  260. move to the end of the transfered area (kind of like a file pointer).
  261.  
  262. You may move the cache pointer around in the cache by making calls to IncPos
  263. and SetPos.  IncPos moves the pointer IncVal bytes from the current pointer,
  264. where SetPos moves the pointer relative to the beginning of the cache.
  265.  
  266. CurPos returns the current value of the cache pointer.
  267. Size returns the number of bytes allocated for the cache.
  268.  
  269. Sample Code:
  270.  
  271.     uses Wad,ObjCache;
  272.  
  273.     var     WDir:PWadDirectory;
  274.             OC:PObjectCache;
  275.  
  276.     begin
  277.         {Initialize WAD file directory}
  278.         WDir:=New(PWadDirectory, Init('C:\DOOM\DOOM.WAD'));
  279.         {Initialize Object Cache for Object TROOA1  (an imp)}
  280.         OC:=New(PObjectCache, Init(WDir, WDir^.FindObject('TROOA1  ')));
  281.  
  282.         {Your Code Goes Here}
  283.  
  284.         {Clean Up the Heap}
  285.         Dispose(OC, Done);
  286.         Dispose(WDir, Done);
  287.     end.
  288.  
  289. ------------------------------------------------------------------------------
  290. ------------------------------------------------------------------------------
  291. Unit:   FLOORS.PAS
  292. Purpose:        Loading and Displaying Floor Texures
  293. Cached: no
  294.  
  295. This unit will load and display a floor texture out of the wad file.
  296.  
  297. The following is a listing of the TFloorTexture object declaration:
  298.  
  299. type    PFloorTexture=^TFloorTexture;
  300.         TFloorTexture=object
  301.             Constructor Init(WDir:PWadDirectory;FloorName:ObjNameStr);
  302.             Procedure Draw(Scale,XOffset,YOffset:word);
  303.             Destructor Done;
  304.          private
  305.             FBuff:PFloorBuff;
  306.         end;
  307.  
  308. You may notice that this is one of the least complex objects in the tool kit.
  309. To Initialize the object, you will need an initialized WAD file directory
  310. and the texture name for the floor.
  311.  
  312. Once initialized, you may call Draw to display the texture on any part of the
  313. screen at any scale.  The scale factor used is percentage based (100 = 1:1).
  314.  
  315. NOTE: this unit requires you to initialize the GRAPH unit in Borland or Turbo
  316. Pascal.  I had orginally written the screen output routines to directly write
  317. to screen memory, however, I switched over to the graph unit's PutPixel, that
  318. way I could maintain compatability with SVGA screen modes.  If you would like
  319. to use this routine in a High Speed application, feel free to remove the
  320. graph unit oriented code.
  321.  
  322. Sample Code:
  323.  
  324.     uses    Graph,Wad,Floors;
  325.  
  326.     var     WDir:PWadDirectory;
  327.             FT:PFloorTexture;
  328.             gd,gm:integer;
  329.  
  330.     begin
  331.         {Initalize WAD directory}
  332.         WDir:=New(PWadDirectory, Init('C:\DOOM\DOOM.WAD'));
  333.         {Initalize Floor Texture}
  334.         FT:=New(PFloorTexture, Init(WDir, 'NUKAGE1 '));
  335.  
  336.         gd:=InstallUserDriver('BGI256',Nil);
  337.         {640x480x256}
  338.         gm:=2;
  339.         {Initialize Graphics}
  340.         InitGraph(gd,gm,'');
  341.  
  342.         {Set the Play Palette}
  343.         WDir^.SetWadPalette(0);
  344.  
  345.         {Draw the texture 2:1 scale at coords 5,5}
  346.         FT^.Draw(200,5,5);
  347.  
  348.         {Wait for the ENTER key}
  349.         readln;
  350.  
  351.         {Restore the palette}
  352.         WDir^.RestorePalette;
  353.  
  354.         {Shut down graphics}
  355.         CloseGraph;
  356.  
  357.         {Clean up the heap}
  358.         Dispose(FT, Done);
  359.         Dispose(WDir, Done);
  360.     end.
  361.  
  362. --------------------------------------------------------------------------------
  363. ------------------------------------------------------------------------------
  364. Unit:   THINGS.PAS
  365. Purpose:        Loading and Displaying Sprites
  366. Cached: Yes
  367.  
  368. This unit will load and display a sprite out of the wad file.  You can also
  369. use this routine to load and display the title pictures and fonts.
  370.  
  371. The following is a listing of the TWadThing declaration:
  372.  
  373. Type  PWadThing=^TWadThing;
  374.         TWadThing=object
  375.             SBuff:PPictureBuff;
  376.             Constructor Init(WDir:PWadDirectory;ThingName:ObjNameStr);
  377.             Procedure Draw(Scale,XOffset,YOffset:word);
  378.             Function Height:word;
  379.             Function Width:word;
  380.             Destructor Done;
  381.         end;
  382.  
  383. To Initialize the object, you will need an initialized WAD file directory
  384. and the thing name for the sprite/picture.
  385.  
  386. Once initialized, you may call Draw to display the thing on any part of the
  387. screen at any scale.  The scale factor used is percentage based (100 = 1:1).
  388.  
  389. NOTE: this unit requires you to initialize the GRAPH unit in Borland or Turbo
  390. Pascal.  I had orginally written the screen output routines to directly write
  391. to screen memory, however, I switched over to the graph unit's PutPixel, that
  392. way I could maintain compatability with SVGA screen modes.  If you would like
  393. to use this routine in a High Speed application, feel free to remove the
  394. graph unit oriented code.
  395.  
  396. Sample Code:
  397.  
  398.     uses    Graph,Wad,Things;
  399.  
  400.     var     WDir:PWadDirectory;
  401.             T:PWadThing;
  402.             gd,gm:integer;
  403.  
  404.     begin
  405.         {Initalize WAD directory}
  406.         WDir:=New(PWadDirectory, Init('C:\DOOM\DOOM.WAD'));
  407.         {Initalize WadThing (an imp)}
  408.         T:=New(PWadThing, Init(WDir, 'TROOA1  '));
  409.  
  410.         gd:=InstallUserDriver('BGI256',Nil);
  411.         {640x480x256}
  412.         gm:=2;
  413.         {Initialize Graphics}
  414.         InitGraph(gd,gm,'');
  415.  
  416.         {Set the Play Palette}
  417.         WDir^.SetWadPalette(0);
  418.  
  419.         {Draw the thing 2:1 scale at coords 5,5}
  420.         T^.Draw(200,5,5);
  421.  
  422.         {Wait for the ENTER key}
  423.         readln;
  424.  
  425.         {Restore the palette}
  426.         WDir^.RestorePalette;
  427.  
  428.         {Shut down graphics}
  429.         CloseGraph;
  430.  
  431.         {Clean up the heap}
  432.         Dispose(T, Done);
  433.         Dispose(WDir, Done);
  434.     end.
  435.  
  436. I think the the Height and Width functions should be pretty much self
  437. explanatory!
  438. ------------------------------------------------------------------------------
  439. ------------------------------------------------------------------------------
  440. Unit:   WALLS.PAS
  441. Purpose:        loading and displaying Wall Textures
  442. Cached: Yes
  443.  
  444. This unit will load and display a Wall texture out of the wad file.  This is
  445. the only unit in this tool kit that I am still not real happy with.  It still
  446. requires anywhere from 2-4 seconds to load complex textures.  The code that
  447. I have written has the living daylights cached out of it, but I still can't
  448. get it to fly.  If you have any ideas, let me know.
  449.  
  450. NOTE: It may look as though I am going through a lot of unecessary crap in
  451.         this routine, but it's not.  The reason that I dispose of the texture
  452.         cache and reload it is to avoid a "gap" in the heap.  The routine
  453.         might be a touch faster if I didn't do this, but the memory managment
  454.         would REALLY hoot!
  455.  
  456. The following is a listing of the TWallPatch object declaration:
  457.  
  458. type  PWallTexture=^TWallTexture;
  459.         TWallTexture=object
  460.     Name            :objnamestr;
  461.      Patches  :word;
  462.      Image          :^BA;
  463.      Width          :word;
  464.      Height :word;
  465.             Constructor Init(WDir:PWadDirectory;TextName:ObjNameStr);
  466.             Procedure Draw(Scale,XOfs,YOfs:integer);
  467.             Destructor Done;
  468.         end;
  469.  
  470. To Initialize the object, you will need an initialized WAD file directory
  471. and the texture name for the Wall.
  472.  
  473. Once initialized, you may call Draw to display the texture on any part of the
  474. screen at any scale.  The scale factor used is percentage based (100 = 1:1).
  475.  
  476. NOTE: this unit requires you to initialize the GRAPH unit in Borland or Turbo
  477. Pascal.  I had orginally written the screen output routines to directly write
  478. to screen memory, however, I switched over to the graph unit's PutPixel, that
  479. way I could maintain compatability with SVGA screen modes.  If you would like
  480. to use this routine in a High Speed application, feel free to remove the
  481. graph unit oriented code.
  482.  
  483. Sample Code:
  484.  
  485.     uses    Graph,Wad,Walls;
  486.  
  487.     var     WDir:PWadDirectory;
  488.             WT:PWallTexture;
  489.             gd,gm:integer;
  490.  
  491.     begin
  492.         {Initalize WAD directory}
  493.         WDir:=New(PWadDirectory, Init('C:\DOOM\DOOM.WAD'));
  494.         {Initalize Floor Texture}
  495.         WT:=New(PWallTexture, Init(WDir, 'AASTINKY'));
  496.  
  497.         gd:=InstallUserDriver('BGI256',Nil);
  498.         {640x480x256}
  499.         gm:=2;
  500.         {Initialize Graphics}
  501.         InitGraph(gd,gm,'');
  502.  
  503.         {Set the Play Palette}
  504.         WDir^.SetWadPalette(0);
  505.  
  506.         {Draw the texture 2:1 scale at coords 5,5}
  507.         WT^.Draw(200,5,5);
  508.  
  509.         {Wait for the ENTER key}
  510.         readln;
  511.  
  512.         {Restore the palette}
  513.         WDir^.RestorePalette;
  514.  
  515.         {Shut down graphics}
  516.         CloseGraph;
  517.  
  518.         {Clean up the heap}
  519.         Dispose(WT, Done);
  520.         Dispose(WDir, Done);
  521.     end.
  522.  
  523. ------------------------------------------------------------------------------
  524. ------------------------------------------------------------------------------
  525. Unit:   SOUNDS.PAS
  526. Purpose:        Declarations Unit
  527. Cached: Yes
  528.  
  529. Type    PSoundDef=^TSoundDef;
  530.         TSoundDef=object
  531.             Constructor Init(WDir:PWadDirectory;SndName:ObjNameStr);
  532.             Procedure PlaySound;
  533.             Funciton IsComplete:boolean;
  534.             Procedure EndSound;
  535.             Destructor Done;
  536.          Private
  537.             SoundBuff:PSoundBuff;
  538.             IsPlaying:Boolean;
  539.             sbBuff:word;
  540.         end;
  541.  
  542. This units will play any sound (NOT SONG) from the WAD file.  The sounds
  543. unit will work under protected mode!!  This may not sound all that impressive
  544. to those of you who have never tried to access the DMA whe in protected mode,
  545. but its a little bit tricky!
  546.  
  547. When the conditional symbol DPMI in Borland Pascal is defined (automatic when
  548. you compile for a Protected Mode Destination Platform) the unit automatically
  549. includes the unit DPMI.  DPMI has routines for allocating memory in low, DOS
  550. memory.  This makes DMA transfer a whole lot simpler.
  551.  
  552. To intialize a sound, you will need an open Wad File Directory and the Sound
  553. name.  Next, a call to PlaySound will play the sound and a call to EndSound
  554. terminates it.  The Boolean function IsComplete will indicate true when the
  555. sound blaster card signals that it has completed the DMA transfer.
  556.  
  557. Sample Code:
  558.  
  559.     uses    Wad,Sounds;
  560.  
  561.     var     WDir:PWadDirectory;
  562.             S:PSoundDef;
  563.  
  564.     begin
  565.         {Initialize the WAD directory}
  566.         WDir:=New(PWadDirectory, Init('C:\DOOM\DOOM.WAD'));
  567.         {Intialize the Sound Player}
  568.         S:=New(PSoundDef, Init(WDir, 'DSSLOP  '));
  569.  
  570.         {Play the sound}
  571.         S^.PlaySound;
  572.  
  573.         {Wait for completion}
  574.         while not S^.IsComplete do;
  575.  
  576.         {Terminate Sound}
  577.         S^.EndSound;
  578.  
  579.         {Clean Up Heap}
  580.         Dispose(S, Done);
  581.         Dispose(WDir, Done);
  582.     end.
  583.  
  584. ------------------------------------------------------------------------------
  585. ------------------------------------------------------------------------------
  586. Unit:   DOOMGUI.PAS, DOOMGUI.PAS, DOOMOBJ.PAS
  587. Purpose:        Map Viewer Graphical User Interface Units
  588.  
  589. This unit is used by MAPREAD  (the map viewing unit for DFE)
  590.  
  591. Since this unit is so far from complete and optimized, I will not go into
  592. a detailed description of it.
  593.  
  594. At this point, the only relevant Object in the DOOMGUI unit is the
  595. TGraphGroup object (a descendant of the TGraphView object).  The acutal
  596. map viewing object TMapViewer is of type TGraphGroup and the Map routines
  597. are of type TGraphView.
  598. ------------------------------------------------------------------------------
  599. ------------------------------------------------------------------------------
  600. Unit:   MAPS.PAS
  601. Purpose:        Map Loading/drawing routines
  602.  
  603. This object is by far the most complex of all the objects.  It loads and
  604. displays a map and any offset and scale.  It also places selected objects
  605. at their locations. The map viewer is currently designed to display the
  606. map to a 640x480 screen.  Even though you can display it in any screen mode,
  607. the scaling parameters will be off.
  608.  
  609. type  PWadMap=^TWadMap;
  610.         TWadMap=Object(TGraphView)
  611.             LevelEntries:PLevelEntries;
  612.             ThingList       :PThingList;
  613.             VertexList      :PVertexList;
  614.             LineDefList     :PLineDefList;
  615.             ViewerMask      :word;
  616.             ThingMask       :word;
  617.             ScaleInc,XOffset,YOffset:word;
  618.             Constructor Init(WDir:PWadDirectory;LevelName:ObjNameStr);
  619.             Procedure Draw; virtual;
  620.             Procedure SetScale(NewScaleInc,NewXOffset,NewYOffset:word);
  621.             Function GetThingInArea(x1,y1,x2,y2:word):word;
  622.             Destructor Done; virtual;
  623.         end;
  624.  
  625. To initialize this object you will need an initialized WAD directory and the
  626. level name (eg E1M1).
  627.  
  628. Once the Map is initialized, you should set the ViewerMask and ThingMask
  629. variables to indicate which objects you want the map viewer to diaplay.  The
  630. format for these masks are as follows:
  631.  
  632.  Viewer Mask Bits:
  633.  
  634. 15-8  7 6 5 4 3 2 1 0
  635.  |    | | | | | | | |
  636.  |    | | | | | | | `--> Display Monsters
  637.  |    | | | | | | `----> Display Goodies (Bonuses & collectables)
  638.  |    | | | | | `------> Display Weapons
  639.  |    | | | | `--------> Display Objects on Skills 1&2 \
  640.  |    | | | `----------> Display Objects on Skill  3    > Can be set together
  641.  |    | | `------------> Display Objects on Skills 4&5 /
  642.  |    | `--------------> Display Objects Only Avail in Multi Player Games
  643.  |    `----------------> Display Secret Linedefs as White
  644.  `---------------------> Unused at this time
  645.  
  646.  Thing Mask Word:
  647.  
  648.  This word contains a thing ID number to display on map.  The thing ID #'s
  649.  are defined by DOOM.  See the file DMSPEC13.TXT for a listing of these
  650.  numbers.  When the Thing Mask is set, it will only display Objects that
  651.  have the same thing ID # as the thing mask.
  652.  
  653. The next step is to set the scale and offset factors with a call to SetScale.
  654. the ScaleInc value is ratio based (1 = 1:1, 2= 2:2, etc).  The scale factor
  655. is actually based on a full screen view, scale factor 1 is a full screen map.
  656. The offset factors are only useful when you have "ZOOMED IN" on the map, they
  657. allow you to move the map around on the screen.
  658. NOTE: See MAPREAD.PAS for a full example of creating a MapViewer.
  659.  
  660. Now we are ready to draw the map. Simply call draw.
  661.  
  662. NOTE: this unit requires you to initialize the GRAPH unit in Borland or Turbo
  663. Pascal.  I had orginally written the screen output routines to directly write
  664. to screen memory, however, I switched over to the graph unit's PutPixel, that
  665. way I could maintain compatability with SVGA screen modes.  If you would like
  666. to use this routine in a High Speed application, feel free to remove the
  667. graph unit oriented code.
  668.  
  669. Sample Code:
  670.  
  671.     uses    Graph,Wad,Maps;
  672.  
  673.     var     WDir:PWadDirectory;
  674.             WMap:PWadMap;
  675.             gd,gm:integer;
  676.  
  677.     begin
  678.         {Initalize WAD directory}
  679.         WDir:=New(PWadDirectory, Init('C:\DOOM\DOOM.WAD'));
  680.         {Initalize the map}
  681.         WMap:=New(PWadMap, Init(WDir, 'E2M7'));
  682.  
  683.         gd:=InstallUserDriver('BGI256',Nil);
  684.         {640x480x256}
  685.         gm:=2;
  686.         {Initialize Graphics}
  687.         InitGraph(gd,gm,'');
  688.  
  689.         {Set the Play Palette}
  690.         WDir^.SetWadPalette(0);
  691.  
  692.         {Viewer Mask = Monsters + Skill Level 3}
  693.         WMap^.ViewerMask:=9;
  694.         {Thing Mask = 0  (Display all)}
  695.         WMap^.ThingMask:=0;
  696.         {Set Scale factor 1 (Full Screen) and 0 the offsets}
  697.         WMap^.SetScale(1,0,0);
  698.         {Draw the Map);
  699.         WMap^.Draw(200,5,5);
  700.  
  701.         {Wait for the ENTER key}
  702.         readln;
  703.  
  704.         {Restore the palette}
  705.         WDir^.RestorePalette;
  706.  
  707.         {Shut down graphics}
  708.         CloseGraph;
  709.  
  710.         {Clean up the heap}
  711.         Dispose(WMap, Done);
  712.         Dispose(WDir, Done);
  713.     end.
  714.  
  715. The Method GetThingInArea can be used to determine if a given area of a 640x
  716. 480 screen contains an object.  If the given are does contian an object, it
  717. will return the Sprite ID number.
  718. ------------------------------------------------------------------------------
  719. ------------------------------------------------------------------------------
  720. Unit:   MAPREAD.PAS
  721. Purpose:        Map Viewer unit for DFE
  722.  
  723. This unit is part of DFE, therefor it is not documented.
  724. ------------------------------------------------------------------------------
  725. ------------------------------------------------------------------------------
  726. Unit:   SPRITEVI.PAS
  727. Purpose:        Sprite Viewer unit for DFE
  728.  
  729. This unit is part of DFE, therefor it is not documented.
  730. ------------------------------------------------------------------------------
  731. ------------------------------------------------------------------------------
  732. Unit:   SWAP.PAS
  733. Purpose:        Memory Swapping Routines
  734.  
  735. This unit is part of DFE, therefor it is not documented.
  736.  
  737. Note: This is a hacked routine from a source listing found in Turbo Pascal
  738.         Internals  by Michael Tischer
  739. ------------------------------------------------------------------------------
  740. ------------------------------------------------------------------------------
  741. Unit:   SWAPA.ASM
  742. Purpose:        Assembly part of Swapping Routines
  743.  
  744. This unit is part of DFE, therefor it is not documented.
  745.  
  746. Note: This is a hacked routine from a source listing found in Turbo Pascal
  747.         Internals  by Michael Tischer
  748. ------------------------------------------------------------------------------
  749. ------------------------------------------------------------------------------
  750. Unit:   EMS.PAS
  751. Purpose:        EMS Accessing Part of SWAP
  752.  
  753. This unit is part of DFE, therefor it is not documented.
  754.  
  755. Note: This is a hacked routine from a source listing found in Turbo Pascal
  756.         Internals  by Michael Tischer
  757. ------------------------------------------------------------------------------
  758. ------------------------------------------------------------------------------
  759. Unit:   SWAPA.ASM
  760. Purpose:        Assembly part of Swapping Routines
  761.  
  762. This unit is part of DFE, therefor it is not documented.
  763.  
  764. Note: This is a hacked routine from a source listing found in Turbo Pascal
  765.         Internals  by Michael Tischer
  766. ------------------------------------------------------------------------------
  767. ------------------------------------------------------------------------------
  768. Program:        DFE.PAS
  769. Purpose:        DOOM Front End Main Program
  770.  
  771. This is the Pascal Source Code for the DOOM Front End (written in mostly
  772. Turbo Vision).
  773.  
  774. If you compile DFE, please follow the following steps:
  775.  
  776.   1. Select the Options Menu from Borland/Turbo Pascal
  777.   2. Select the Compiler Option
  778.   3. Enter the letters DFE  in the Conditional Defines area
  779.   4. Select the Compile Menu
  780.   5. Select Build
  781.   6. It should now be ready to go!
  782. ------------------------------------------------------------------------------
  783.