home *** CD-ROM | disk | FTP | other *** search
/ D!Zone (Collector's Edition) / D_ZONE_CD.ISO / programs / editors / dhtk100 / dfe.pas < prev    next >
Pascal/Delphi Source File  |  1994-12-06  |  30KB  |  1,026 lines

  1. {****************************************************************************
  2. *                      The DOOM Hacker's Tool Kit                           *
  3. *****************************************************************************
  4. * Program: DFE v1.31                                                        *
  5. * Purpose: DOOM 1.2  Front End                                              *
  6. * Date:    4/28/94                                                          *
  7. * Author:  Joshua Jackson        Internet: joshjackson@delphi.com           *
  8. ****************************************************************************}
  9.  
  10. {As of this point in time, I have not found a way to allow execution of
  11.  the Watcom DOS extender while running under DPMI... however I am looking
  12.  into a way to switch the system back to real mode before launching DOOM}
  13.  
  14. {$IFNDEF DPMI}
  15. uses     app,objects,menus,drivers,views,memory,dialogs,strings,windos,Dos,crt,
  16.         WadDecl,Wad,mapread,StdDlg,Swap,MsgBox;
  17. {$ELSE} {You CAN NOT use the SWAP unit under DPMI!!!}
  18. uses     app,objects,menus,drivers,views,memory,dialogs,strings,windos,Dos,crt,
  19.         WadDecl,Wad,mapread,StdDlg,MsgBox;
  20. {$ENDIF}
  21.  
  22. const    cmOnePlayerMenu    = 100;
  23.         cmSerialMenu        = 101;
  24.         cmIPXMenu            = 102;
  25.         cmModemMenu            = 103;
  26.         cmViewMaps            = 105;
  27.         cmNull                = 255;
  28.  
  29.         gtNormal                = 00;
  30.         gtIPXNet                = 01;
  31.         gtModem                = 02;
  32.         gtDirLinkModem        = 03;
  33.         gtSerial                = 04;
  34.         gtSetMode            = 05;
  35.         gtViewSprites        = 06;
  36.         gtViewMaps            = 07;
  37.  
  38. type    PMyApp=^TMyApp;
  39.         TMyApp=Object(Tapplication)
  40.             Constructor Init;
  41.             Procedure InitMenuBar; virtual;
  42.             Procedure Idle; virtual;
  43.             Procedure HandleEvent(Var Event:TEvent); virtual;
  44.             Function GetPalette:PPalette; virtual;
  45.             Procedure RunDoom(GameType:integer;Params:string);
  46.             Procedure OnePlayerMenu;
  47.             Procedure SerialMenu;
  48.             Procedure IPXMenu;
  49.             Procedure ModemMenu;
  50.             Procedure ViewMaps;
  51.         end;
  52.         SelLevelArray=array[1..4] of PCluster;
  53.         LevelNameArray=array[1..9] of String;
  54.  
  55. var    MyApp:TMyApp;
  56.         Debug:boolean;
  57.  
  58. Procedure SetLevelData(R:TRect;var SelLevel:PRadioButtons;Level:word);
  59.  
  60.     begin
  61.         case Level of
  62.             1:SelLevel:=New(PRadioButtons, Init(R,
  63.               NewSItem('~1~ Hanger',
  64.               NewSItem('~2~ Nuclear Plant',
  65.               NewSItem('~3~ Toxin Refinery',
  66.               NewSItem('~4~ Command Control',
  67.               NewSItem('~5~ Phobos Lab',
  68.               NewSItem('~6~ Central Processing',
  69.               NewSItem('~7~ Computer Station',
  70.               NewSItem('~8~ Phobos Anomaly',
  71.               NewSItem('~9~ Military Base',
  72.               nil)))))))))));
  73.             2:SelLevel:=New(PRadioButtons, Init(R,
  74.               NewSItem('~1~ Deimos Anomaly',
  75.               NewSItem('~2~ Containment Area',
  76.               NewSItem('~3~ Refinery',
  77.               NewSItem('~4~ Deimos Lab',
  78.               NewSItem('~5~ Command Center',
  79.               NewSItem('~6~ Halls of the Damned',
  80.               NewSItem('~7~ Spawning Vats',
  81.               NewSItem('~8~ Towel of Babel',
  82.               NewSItem('~9~ Fortress of Mystery',
  83.               nil)))))))))));
  84.             3:SelLevel:=New(PRadioButtons, Init(R,
  85.               NewSItem('~1~ Hell Keep',
  86.               NewSItem('~2~ Slough of Despair',
  87.               NewSItem('~3~ Pandemonium',
  88.               NewSItem('~4~ House of Pain',
  89.               NewSItem('~5~ Unholy Cathedrial',
  90.               NewSItem('~6~ Mount Erebus',
  91.               NewSItem('~7~ Limbo',
  92.               NewSItem('~8~ DIS',
  93.               NewSItem('~9~ Warrens',
  94.               nil)))))))))));
  95.         end;
  96.     end;
  97.  
  98. Procedure FindLevelNames(FileSpec:PathStr;var Levels:LevelNameArray;R:TRect; var SelLevel:PRadioButtons);
  99.  
  100.     var   PDir:PWadDirectory;
  101.             t,i1,i2,CurLevel:integer;
  102.             tmpstr:string;
  103.             Code:integer;
  104.             TmpArray:PSItem;
  105.             CurItem,ItemList:PSitem;
  106.  
  107.     begin
  108.         TmpStr:=FileSpec;
  109.         PDir:=new(PWadDirectory, Init(FileSpec));
  110.         if WadResult<>wrOk then begin
  111.             MessageBox(WadResultMsg(WadResult),Nil,mfError+ mfOkButton);
  112.             exit;
  113.         end;
  114.         CurLevel:=1;
  115.         CurItem:=Nil;
  116.         ItemList:=Nil;
  117.         Levels[1]:='';
  118.         for t:=1 to PDir^.DirEntries do begin
  119.             if (PDir^.DirEntry^[t].ObjName[1]='E') and (PDir^.DirEntry^[t].ObjName[3]='M') then begin
  120.                 tmpstr:=PDir^.DirEntry^[t].ObjName[2];
  121.                 val(TmpStr,i1,Code);
  122.                 if Code<>0 then
  123.                     continue;
  124.                 tmpstr:=PDir^.DirEntry^[t].ObjName[4];
  125.                 val(TmpStr,i2,Code);
  126.                 if Code<>0 then
  127.                     continue;
  128.                 Levels[CurLevel]:=PDir^.DirEntry^[t].ObjName;
  129.                 if ItemList=Nil then begin
  130.                     ItemList:=New(PSItem);
  131.                     ItemList^.Value:=NewStr(Levels[CurLevel]);
  132.                     ItemList^.Next:=Nil;
  133.                     CurItem:=ItemList;
  134.                  end
  135.                 else begin
  136.                     CurItem^.Next:=New(PSItem);
  137.                     CurItem:=CurItem^.Next;
  138.                     CurItem^.Value:=NewStr(Levels[CurLevel]);
  139.                     CurItem^.Next:=Nil;
  140.                 end;
  141.                 inc(CurLevel);
  142.                 if CurLevel=10 then begin
  143.                     PDir^.Done;
  144.                     Dispose(PDir);
  145.                     SelLevel:=New(PRadioButtons, Init(R,ItemList));
  146.                     exit;
  147.                 end;
  148.             end;
  149.         end;
  150.         PDir^.Done;
  151.         Dispose(PDir);
  152.         SelLevel:=New(PRadioButtons, Init(R,ItemList));
  153.     end;
  154.  
  155. Procedure SetMenuData(MenuNum:byte;var Param1,Param2:string);
  156.  
  157.     var    R:Trect;
  158.             SelModem,SelGame,Monsters,SelSkill,Players:PCluster;
  159.             DialNum:PInputLine;
  160.             SelLevel:PRadioButtons;
  161.             Dialog1,Dialog2:PDialog;
  162.             Dialog3:PFileDialog;
  163.             ComPort:PCluster;
  164.             Control,Episode:word;
  165.             TmpStr,DmParam,ModeParam:string;
  166.             ExtFile:PathStr;
  167.             ExtLevelPos:byte;
  168.             jb:byte;
  169.             FileName: FNameStr;
  170.             LevelNames:LevelNameArray;
  171.  
  172.     begin
  173.         Case MenuNum of
  174.             1:begin
  175.                 R.Assign(2,1,30,5);
  176.                 SelGame:=New(PRadioButtons, Init(R,
  177.                   NewSItem('~K~nee-Deep In The Dead',
  178.                   NewSItem('~S~hores Of Hell',
  179.                   NewSItem('~I~nferno!',
  180.                   NewSItem('~L~oad External Wad File',
  181.                   nil))))));
  182.                 R.Assign(20,6,60,15);
  183.                 Dialog1:=New(PDialog,Init(r,'Episodes'));
  184.                 with Dialog1^ do begin
  185.                     R.Assign(5,6,15,8);
  186.                     Insert(New(PButton,Init(R,'~O~k',cmOk,bfDefault)));
  187.                     R.Assign(25,6,35,8);
  188.                     Insert(New(PButton,Init(R,'~C~ancel',cmCancel,bfNormal)));
  189.                     Insert(SelGame);
  190.                 end;
  191.                 Control:=Desktop^.ExecView(Dialog1);
  192.                 Episode:=SelGame^.Value + 1;
  193.                 Param1:='';
  194.                 DmParam:='';
  195.                 if Episode=4 then begin
  196.                     FileName := '*.WAD';
  197.                     Dialog3:=New(PFileDialog, Init('*.WAD', 'Select Wad File','~N~ame',fdOkButton,100));
  198.                     Dialog3^.SetData(FileName);
  199.                     Control:=Desktop^.ExecView(Dialog3);
  200.                     if Control=cmFileOpen then
  201.                         Control:=cmOk;
  202.                     if Control=cmOK then begin
  203.                         ExtFile:=Dialog3^.Directory^+(Dialog3^.FileName^.Data^);
  204.                         R.Assign(2, 1, 28, 10);
  205.                         FindLevelNames(ExtFile,LevelNames,R,SelLevel);
  206.                         if WadResult<>wrOk then
  207.                             exit;
  208.                         if LevelNames[1]='' then begin
  209.                             Param1:='';
  210.                             MessageBox('No valid level entries found.',Nil,mfError+mfOkButton);
  211.                             control:=cmCancel;
  212.                          end
  213.                         else begin
  214.                             Episode:=4;
  215.                             Param1:='-file '+ExtFile+' ';
  216.                         end;
  217.                     end;
  218.                     Dialog3^.Done;
  219.                     Dispose(Dialog3);
  220.                 end;
  221.                 if Control=cmOK then begin
  222.                     R.Assign(30, 3, 55, 8);
  223.                     SelSkill:=New(PRadioButtons, Init(R,
  224.                       NewSItem('~I~''m too young to die',
  225.                       NewSItem('~H~ey Not too Rough',
  226.                       NewSItem('H~u~rt Me Plenty',
  227.                       NewSItem('U~l~tra Violence',
  228.                       NewSItem('~N~ightmare!',
  229.                       nil)))))));
  230.                     R.Assign(30, 1, 50, 2);
  231.                     Monsters:=New(PCheckBoxes, Init(R,
  232.                       NewSItem('No ~M~onsters',
  233.                       nil)));
  234.                     R.Assign(2, 1, 28, 10);
  235.                     if Episode < 4 then
  236.                         SetLevelData(R,SelLevel,1);
  237.                     R.Assign(11,4,69,18);
  238.                     Dialog2:=New(PDialog,Init(r,'Game Options'));
  239.                     with Dialog2^ do begin
  240.                         Insert(Monsters);
  241.                         Insert(SelSkill);
  242.                         R.Assign(15,11,25,13);
  243.                         Insert(New(PButton,Init(R,'~C~ancel',cmCancel,bfNormal)));
  244.                         R.Assign(2,11,12,13);
  245.                         Insert(New(PButton,Init(R,'~O~k',cmOk,bfDefault)));
  246.                         Insert(SelLevel);
  247.                     end;
  248.                     Control:=Desktop^.ExecView(Dialog2);
  249.                     if Control=cmOk then begin
  250.                         if Episode < 4 then begin
  251.                             Str(Episode,TmpStr);
  252.                             DmParam:='-devparm -warp '+TmpStr+' ';
  253.                             Str(SelLevel^.Value + 1,TmpStr);
  254.                             DmParam:=DmParam+TmpStr
  255.                          end
  256.                         else begin
  257.                             DmParam:='-devparm -warp ';
  258.                             DmParam:=DmParam+LevelNames[SelLevel^.Value+1][2]+' ';
  259.                             DmParam:=DmParam+LevelNames[SelLevel^.Value+1][4];
  260.                         end;
  261.