Category : HD Utilities
Archive   : UPS11.ZIP
Filename : UPS.PAS

 
Output of file : UPS.PAS contained in archive : UPS11.ZIP
PROGRAM ups(INPUT, OUTPUT);

{ Universial Parking System (UPS)
Released to Public Domain.

(c) Copyright 1989 - Derek Giedd & Bill Elliott

Any modification to this program must include the original copyright
notice. Portions of this code may be used in other programs with the
proper credit to the author. The author assumes no liability for
improper use of this program or variations.

This program will park the heads on up to two hard disk drives. This
program will only function on an IBM AT, PS/2 or compatible system.

Most head parking programs place the heads over the last cylinder.
This is the correct location for most drives. However, it is not always
correct. The correct method for determing this location is to read
the shipping zone from the disk parameter table. This is the method
used by UPS. }

USES DOS,CRT, params;

VAR
regs : REGISTERS;
i : INTEGER;
parkz : INTEGER;
numdrives : INTEGER;
cha : CHAR;
model : BYTE;
quiet : Boolean;
clear : Boolean;
p1 : String;
rkey : Integer;
resetkey : String[3];
error : Integer;
pcnt : Integer;
pvalue : paramtype;
help : Boolean;
delim : Char;

PROCEDURE move_heads(drive_number : INTEGER; regs : REGISTERS;
disk_vector : INTEGER);

BEGIN
WITH regs DO
BEGIN

{ Get the interrupt vector for the ROM BIOS drive 0 fixed disk parameters }

AH := $35;
AL := disk_vector;
MSDOS(regs);

{ Bytes $0C and $0D of the drive parameter table contain the shipping zone. }

parkz := MEM[ES:BX+$D]* 256 + mem[ES:BX+$C];

{ Move the heads to the shipping zone. }

AH := $0C;
CH := MEM[ES:BX+$C];
CL := MEM[ES:BX+$D] * 64;
DH := 0;
DL := $80 + drive_number;
INTR($13,regs);

{ Check for an error. }

IF (flags AND 1) = 1 THEN
BEGIN
TEXTCOLOR(yellow+blink);
WRITE('** ERROR ** ');
TEXTCOLOR(yellow);
WRITELN('Parking Drive ',drive_number:1);
TEXTCOLOR(lightgray);
END
ELSE
Begin
If Not quiet Then
WRITELN('Parking Drive ',drive_number:1,' to Cylinder ',parkz);
End;
END;
END;

BEGIN
quiet := False;
resetkey := 'Esc';
rkey := 27;
delim := '/';
pcnt := getparams(pvalue, delim, help);
If help Then
Begin
TEXTCOLOR(cyan);
WRITELN(' AT Universal Parking System (UPS) - Version 1.1');
WRITELN(' (c) Copyright 1989 - Derek Giedd & Bill Elliott ');
TEXTCOLOR(lightgray);
WRITELN;
Writeln(' UPS is used to park the hard drive heads on an AT or PS/2 System.');
Writeln;
Writeln(' Syntax:');
Writeln(' UPS [/Q][/C][/Knnn] [?]');
Writeln;
Writeln(' Options:');
Writeln(' ? - Display this screen.');
Writeln(' /Q - Quiet mode. Only error messages are displayed.');
Writeln(' /C - Clear screen before executing.');
Writeln(' /Knnn - Key nnn is used to re-enable system.');
Writeln(' where nnn is the decimal ASCII code for the key.');
Writeln;
Writeln('Most head parking programs place the heads over the last cylinder.');
Writeln('This is the correct location for most drives. However, it is not always');
Writeln('correct. The correct method for determing this location is to read');
Writeln('the shipping zone from the disk parameter table. This is the method');
Writeln('used by UPS. The shipping zone is not stored in the PC or XT disk');
Writeln('parameter table.');
Exit;
End;
For i := 1 To pcnt Do
Begin
If Copy(pvalue[i],1,2) = '/Q' Then
quiet := True
Else If Copy(pvalue[i],1,2) = '/C' Then
clrscr
Else If Copy(pvalue[i],1,2) = '/K' Then
Begin
resetkey := Copy(pvalue[i],3,Length(pvalue[i])-2);
Val(resetkey, rkey, error);
If error <> 0 Then
Begin
TEXTCOLOR(yellow+blink);
WRITE('** ERROR ** ');
TEXTCOLOR(yellow);
WRITELN('Invalid key sequence entered. Esc key used.');
writeln(pvalue[i]);
TEXTCOLOR(lightgray);
resetkey := 'Esc';
rkey := 27;
End;
End;
End;

{ Display the header message }

If Not quiet Then
Begin
TEXTCOLOR(cyan);
WRITELN(' AT Universal Parking System (UPS) - Version 1.1');
WRITELN(' (c) Copyright 1989 - Derek Giedd & Bill Elliott ');
TEXTCOLOR(lightgray);
WRITELN;
End;
WITH regs DO
BEGIN

{ Determine the type of system. UPS will not function correctly when used
on a PC/XT system. The disk parameter table for the XT does not contain
a value for the shipping zone. }

model := MEM[$FFFF:$000E];
CASE model of
$FF, $FE, $FD : { PC, XT or jr }
BEGIN
TEXTCOLOR(yellow+blink);
WRITE('** ERROR ** ');
TEXTCOLOR(yellow);
WRITELN('UPS will not function on this system.');
WRITELN(' An IBM AT or PS/2 is required.');
TEXTCOLOR(lightgray);
END
ELSE { AT or PS/2 }
BEGIN

{ Determine the number of physical drives on the system }

AH := $08;
DL := $80;
INTR($13,regs);
numdrives := DL;

{ If there are no drives then stop }

IF numdrives = 0 THEN
BEGIN
TEXTCOLOR(yellow+blink);
WRITE('** ERROR ** ');
TEXTCOLOR(yellow);
WRITELN('UPS is only for systems with a hard disk');
TEXTCOLOR(lightgray);
END;

{ Park drive 0 and drive 1 if they exist. }

IF numdrives > 0 THEN
move_heads(0,regs,$41);
IF numdrives > 1 THEN
move_heads(1,regs,$46);
IF numdrives > 2 THEN
BEGIN
TEXTCOLOR(yellow+blink);
WRITE('** WARNING ** ');
TEXTCOLOR(yellow);
WRITELN('UPS was unable to park the last ',numdrives-2:1,' drive(s)');
TEXTCOLOR(lightgray);
END;
END;

{ Do not exit the program until the escape key has been pressed three times.
This is to prevent the heads from accidently moving to another cylinder. }

If Not quiet Then
Begin
WRITELN;
WRITE('Press the ',resetkey,' key 3 times to re-enable disk system');
End;

FOR i := 1 TO 3 DO
BEGIN
cha := CHR(0);
while cha <> CHR(rkey) DO
cha := readkey;
END;

TEXTCOLOR(yellow);
WRITELN;
WRITELN('Disk system re-enabled');
END;
END;
TEXTCOLOR(lightgray);
WRITELN;
END.



  3 Responses to “Category : HD Utilities
Archive   : UPS11.ZIP
Filename : UPS.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/