home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB139 / wut312sc.lzh / WUTIL.PAS < prev    next >
Pascal/Delphi Source File  |  1989-04-12  |  10KB  |  295 lines

  1. {$C-}
  2. program Wutil; {Rainbow 100 Winchester Disk Utility}
  3.  
  4. {
  5.  
  6.                                    ********
  7.                                     NOTICE
  8.                                    ********
  9.  
  10.      THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT PAYMENT OF CONSIDERATION.
  11.             IT MAY BE USED ONLY WITH THE UNDERSTANDING THAT THERE
  12.            ARE NO WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, BUT
  13.          NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
  14.                       FITNESS FOR A PARTICULAR PURPOSE.
  15.  
  16.  ***************************************************************************
  17.                        ⌐ COPYRIGHT 1986 Anthony G. Camas
  18.                        ⌐ COPYRIGHT 1988 Vinzenz Esser
  19.                               All rights reserved
  20.  
  21.   A limited license to hold and copy this source code is hereby granted,
  22.   provided the following conditions are met:
  23.   * THIS CODE MAY BE DISTRIBUTED ONLY IF UNMODIFIED IN ANY WAY.  ALL
  24.     CODE (AND THIS COPYRIGHT NOTICE) MUST REMAIN EXACTLY AS YOU RECEIVED
  25.     IT IF YOU GIVE IT TO ANYONE ELSE.  Permission to distribute modified
  26.     versions of this software must be obtained in writing from the author.
  27.   * UNDER NO CIRCUMSTANCES SHALL AN INDIVIDUAL DISTRIBUTING THIS SOFTWARE
  28.     EXPECT, DEMAND, OR ACCEPT PAYMENT OF ANY KIND FOR THE SOFTWARE OR A
  29.     "LICENSE" TO USE IT.  However, recovery of expenses for media and postage
  30.     in connection with this software's distribution is permitted.
  31.  ***************************************************************************
  32.  
  33.   This source code is being published because it may be of some value to
  34.   others attempting similar projects.  The restriction regarding distributing
  35.   versions of this software is being imposed because of the potential peril
  36.   which could be created if bugs are introduced into the software.
  37.  
  38.  
  39.   The author of WUTIL V3 can be reached at this address:
  40.  
  41.                                 Vinzenz Esser
  42.                                 Waldstrasse 2E
  43.                                 D-8052 Moosburg 2
  44.                                 West-Germany
  45.  
  46.   This program performs various functions with winchester hard disks installed
  47.   on DEC Rainbow 100, 100B, and 100+ computers.  It can:
  48.     - Format and initialize a disk according to your parameters
  49.     - Partition and repartition your disk in increments of 1 track (8K bytes)
  50.     - Set up, delete, or change the auto boot partition
  51.     - Print information about how your disk is set up and partitioned
  52.     - Dump arbitrary sectors from the disk
  53.     - Park the disk heads for safe shipping/transportation
  54.     - Do all of the above to a second hard disk connected to the Rainbow via
  55.       the Micro CHS dual winchester controller
  56. }
  57.  
  58. {$IWUREVS.PAS}
  59.  
  60. {$IWUDATA.PAS}
  61.  
  62. {$IWUSUBL.PAS}
  63.  
  64. {$IWUSUBH.PAS}
  65.  
  66. { **************************************************************************
  67.                                 MAJOR SECTIONS
  68.   ************************************************************************** }
  69.  
  70. { Initialize - Startup steps }
  71. procedure Initialize;
  72. begin
  73.   EXITAllowed  := TRUE;
  74.   SetUpExit    := False;
  75.   OutlineDrawn := False;
  76.  
  77.   { Make sure this is a rainbow with the winchester controller installed }
  78.   if (Port[Status2Port] AND $E0) <> $A0 then
  79.   begin
  80.     WriteLn (^G'Winchester controller not installed');
  81.     Halt (1);
  82.   end;
  83.  
  84.   { Initialize PRINT SCREEN stuff }
  85.   FFAfterPrint := False;
  86.   PrintFileName := '';
  87.   if not SetPrintFile (FileSpecForPrinter) then
  88.   begin
  89.     WriteLn (^G'Unable to open printer (PRN) as print device!');
  90.     Halt (1);
  91.   end;
  92.  
  93.   { Find out what (major) version of MS-DOS we are running }
  94.   Registers.AH := $30;
  95.   MsDos (Registers);
  96.   MSDOSVersion := Registers.AL;
  97.  
  98.   { Look through the device driver list to locate the standard hard disk
  99.     driver and the additional CHS driver. }
  100.   if not (FindHDDriver) then
  101.   begin
  102.     WriteLn (^G'CAN''T FIND WINCHESTER SERVICE ROUTINES IN MS-DOS!');
  103.     WriteLn ('Your version of MS-DOS is incompatible with this program');
  104.     Halt (1);
  105.   end;
  106.  
  107.   { Look through interrupt service routine code to set up our pointer to
  108.     the flag set when the Hard Disk interrupts.  Try both the new-style
  109.     vector and the old-style vector.  If both fail, this is a fatal error. }
  110.   if not (FindISRFlag (HDVector2)) then
  111.     if not (FindISRFlag (HDVector1)) then
  112.     begin
  113.       WriteLn (^G'CAN''T FIND WINCHESTER INTERRUPT SERVICE IN MS-DOS!');
  114.       Write ('You either have a TSR program installed, ');
  115.       Writeln ('which uses the winchester interrupt');
  116.       Writeln ('or your version of MS-DOS is incompatible with this program.');
  117.       Halt (1);
  118.     end;
  119.  
  120.   { Now find other data we need for processing based on value we just
  121.     determined.  Again, if this fails, we cannot proceed.  First we'll do it
  122.     for the standard drive. }
  123.   CurrentDrive := 1;
  124.   if not FindHDData THEN
  125.   begin
  126.     WriteLn (^G'CAN''T FIND WINCHESTER SERVICE DATA AREAS IN MS-DOS!');
  127.     WriteLn ('Your version of MS-DOS is incompatible with this program');
  128.     Halt (1);
  129.   end;
  130.  
  131.   { Now let's do the same thing for the second drive, if one is present. }
  132.   if TwoDrives then
  133.   begin
  134.     CurrentDrive := 2;
  135.     if not FindHDData THEN
  136.     begin
  137.       WriteLn (^G'CAN''T FIND WINCHESTER SERVICE DATA AREAS IN THE CHS DRIVER!');
  138.       WriteLn ('Your version of the CHS driver is incompatible with this program');
  139.       Halt (1);
  140.     end;
  141.   end;
  142.  
  143.   CurrentDrive := 1;
  144.   HDStrat      := HDStrategy[CurrentDrive];
  145.   HDInter      := HDInterrupt[CurrentDrive];
  146.  
  147.   { Get the PATH string we will use to find our overlay.  Then try to find it. }
  148.   GetPATHString;
  149.   FindOverlay;
  150.  
  151.   ClrScr;
  152.  
  153. end {Initialize};
  154.  
  155. { DoPrinterMenu - Display and process printer menu }
  156. procedure DoPrinterMenu;
  157. var
  158.   I, J :Integer;
  159.   SecondLine :Str80;
  160.   FileName :Str80;
  161. begin
  162.   While True do { repeat forever until we exit for MainScreen key }
  163.   begin
  164.     If FFAfterPrint then
  165.       SecondLine := 'Formfeed will be printed after PRINT SCREEN output'
  166.     else
  167.       SecondLine := 'Formfeed will NOT be printed after PRINT SCREEN output';
  168.     { Display printer menu and get selection from it.  Then dispatch according
  169.       to the selection. }
  170.     Selection := GetMenuSelection 
  171.                   (PrinterMenu,
  172.                    [MainScreenKeyVal],
  173.                    Concat ('PRINT SCREEN output is being sent to ',
  174.                            PrintFileName),
  175.                    SecondLine, '', I);
  176.     If I = MainScreenKeyCode then Exit;
  177.     Case Selection of
  178.       PMOutToPrinter:
  179.         begin
  180.           If not SetPrintFile (FileSpecForPrinter) then
  181.           begin
  182.             FVRow := 16;  Write (^G);
  183.             Center
  184.              ('UNABLE TO OPEN PRINTER FOR OUTPUT -- Press any key to continue');
  185.             J := RawChar;
  186.           end;
  187.         end;
  188.       PMOutToFile:
  189.         begin
  190.           DrawBox (8, 15, 73, 17, AtNormal);
  191.           FVRow := 16; FVColumn := 10;
  192.           WriteFast ('Enter file name to print on: ');
  193.           ReadScreen (FVColumn, FVRow, (72-FVColumn),
  194.                       ['A'..'Z', '0'..'9', ':', '\', '.', '_', '$'],
  195.                       [MainScreenKeyVal],
  196.                       FileName, I);
  197.           If I = MainScreenKeyCode then Exit;
  198.           If not SetPrintFile (FileName) then
  199.           begin
  200.             FVRow := 18;  FVColumn := 10;  Write (^G);
  201.             WriteFast
  202.              ('UNABLE TO OPEN THIS FILE FOR OUTPUT -- Press any key to continue');
  203.             J := RawChar;
  204.           end;
  205.         end;
  206.       PMToggleFF:
  207.         FFAfterPrint := not FFAfterPrint;
  208.       PMMainMenu:
  209.         Exit;
  210.     end;
  211.   end;
  212. end {DoPrinterMenu};
  213.  
  214. { MenuExit - Processes "exit" request from main menu }
  215. procedure MenuExit;
  216. var
  217.   I :Integer;
  218. begin
  219.   If EXITAllowed then NormalExit;
  220.  
  221.   { If exit not allowed, say so }
  222.  
  223.   Write (^G);
  224.   DrawOutline;
  225.   FVRow := 10; FVAttribute := AtBold;
  226.   Center ('EXIT IS NOT ALLOWED NOW');
  227.   WriteLn;
  228.   if TwoDrives and (CurrentDrive = 2) then
  229.   begin
  230.     CurrentDrive := 1;
  231.     if ReadMajorBlocks then
  232.     begin
  233.       With HOMBlock.HOM do ManualSeek(0,StepRate);
  234.       CurrentDrive :=2;
  235.     end;
  236.   end;
  237.   FVAttribute := AtDefault;
  238.   Center ('Because you have modified your disk''s partitions, you cannot exit');
  239.   Center ('this program now.  You must reboot your system to use the new');
  240.   Center ('partitions.');
  241.   WriteLn;
  242.   FVAttribute := AtBold;
  243.   Center ('To reboot and use the new partitions, press SET-UP and then CTRL/SET-UP');
  244.   Center ('or press any other key to return to the WUTIL main menu');
  245.   SetUpExit := True;
  246.   I := RawChar;
  247. end {MenuExit};
  248.  
  249. { ** NOTE ** WUOVR.PAS included here must contain only OVERLAY procedures }
  250. {$IWUOVR.PAS}
  251.  
  252. { ** NOTE ** WUPART.PAS included here must contain only OVERLAY procedures }
  253. {$IWUPART.PAS}
  254.  
  255. { **************************************************************************
  256.                            M A I N   P R O G R A M
  257.   ************************************************************************** }
  258.  
  259. begin
  260.  
  261.   { Perform initializations as required. }
  262.   Initialize;
  263.  
  264.   { Start by introducing and disclaiming (?) ourselves }
  265.   Intro;
  266.  
  267.   while TRUE do                         { loop forever }
  268.   begin
  269.     { Display main menu and get selection from it.  Then dispatch according to
  270.       the selection. }
  271.     Selection := GetMenuSelection(MainMenu, [], '', 'MX', '', Temp);
  272.     Case Selection of
  273.       MMExit:
  274.         MenuExit;
  275.       MMPrintPart:
  276.         PrPart;
  277.       MMDump:
  278.         DumpSector;
  279.       MMPartition:
  280.         RepartitionDisk;
  281.       MMInitialize:
  282.         FormatAndInitialize (MMInitialize);
  283.       MMCopyBoot:
  284.         FormatAndInitialize (MMCopyBoot);
  285.       MMAutoBoot:
  286.         SetAutoBoot;
  287.       MMParkHeads:
  288.         ParkHeadsForShipping;
  289.       MMPrinterMenu:
  290.         DoPrinterMenu;
  291.     end;
  292.   end;
  293.  
  294. end.
  295.