home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
dskstruc
/
parkim10.arj
/
PARKIM.BAS
next >
Wrap
BASIC Source File
|
1991-09-20
|
7KB
|
214 lines
'----------------------------------------------------------------------------|
' ---- ScanSoft(tm) PARKIM (C)1991 Cornel Huth -- All Rights Reserved ---- |
'----------------------------------------------------------------------------|
' program: PARKIM.BAS |
' version: 1.00 |
' by: Cornel Huth |
' date: 20-Sep-1991 |
'function: park either or both hard drives at any cylinder |
' caller: COMMAND |
' use: |
' |
'PARKIM 0:cyl,1:cyl (colon required after drive, comma between drives) |
'No parms - move drive(s) head-assembly to landing zone (LZ) |
' ? - help on usage |
' 0:[cyl] - move drive 0 to cylinder (or LZ if no cyl) |
' 1:[cyl] - move drive 1 to cylinder (or LZ if no cyl) |
' |
'For example: |
' C>parkim 1:821 - attempt to park second drive at cylinder 821 |
' C>parkim 0: - park first drive at landing zone |
' C>parkim 1:,0: - park drive 1 then 0 at landing zone |
' C>parkim - park drive 0 then 1 at landing zone |
' |
'NOTE: If [cyl] parameter > LZ then LZ is used instead of [cyl]. |
'----------------------------------------------------------------------------|
DEFINT A-Z
CONST STDOUT = 1 'DOS console
CONST ONEMORE = 1 'Landing zone 1 more than last cylinder (usually)
'This value is passed after LZ validation check
'so don't make it anything greater than 1 (0 or 1)
TYPE RegTypeX
ax AS INTEGER
bx AS INTEGER
cx AS INTEGER
dx AS INTEGER
bp AS INTEGER
si AS INTEGER
di AS INTEGER
flags AS INTEGER
ds AS INTEGER
es AS INTEGER
END TYPE
DECLARE SUB INTERRUPTX (intnum%, ireg AS RegTypeX, oreg AS RegTypeX)
DIM ireg AS RegTypeX, oreg AS RegTypeX
DIM outm AS STRING * 80
DIM CRLF AS STRING * 2
DIM MaxCyl(&H80 TO &H81) AS INTEGER
DIM HighCyl(&H80 TO &H81) AS INTEGER
DIM HighSec(&H80 TO &H81) AS INTEGER
DIM HighHead(&H80 TO &H81) AS INTEGER
DIM useMsg$(0 TO 9)
CRLF = CHR$(13) + CHR$(10)
MaxCyl(&H80) = 1023 'avoid math screwup on BIOS form conversion
MaxCyl(&H81) = 1023
id$ = "PARKIM 1.00 (C)1991 Cornel Huth - All Rights Reserved" + CRLF
useMsg$(0) = "PARKIM 0:cyl,1:cyl (colon required after drive, comma between drives)" + CRLF
useMsg$(1) = "No parms - move drive(s) head-assembly to landing zone (LZ)"
useMsg$(2) = " ? - help on usage"
useMsg$(3) = " 0:[cyl] - move drive 0 to cylinder (or LZ if no cyl)"
useMsg$(4) = " 1:[cyl] - move drive 1 to cylinder (or LZ if no cyl)" + CRLF
useMsg$(5) = "C>parkim 1:821 - attempt to park second drive at cylinder 821"
useMsg$(6) = "C>parkim 0: - park first drive at landing zone"
useMsg$(7) = "C>parkim 1:,0: - park drive 1 then 0 at landing zone"
useMsg$(8) = "C>parkim - park drive 0 then 1 at landing zone" + CRLF
useMsg$(9) = "NOTE: If [cyl] parameter > LZ then LZ is used instead of [cyl]."
outm = id$
outl = LEN(id$)
GOSUB OutMsg
cl$ = COMMAND$
ShowHelp = INSTR(cl$, "?")
DoDrive0 = INSTR(cl$, "0:")
IF DoDrive0 THEN D0cyl = VAL(MID$(cl$, DoDrive0 + 2)) ELSE D0cyl = 0
DoDrive1 = INSTR(cl$, "1:")
IF DoDrive1 THEN D1cyl = VAL(MID$(cl$, DoDrive1 + 2)) ELSE D1cyl = 0
'get info on drive0
drive = &H80
ireg.ax = &H800
ireg.dx = drive
INTERRUPTX &H13, ireg, oreg
IF (oreg.flags AND 1) = 0 AND (ShowHelp = 0) THEN
locyl = oreg.cx \ 256
hicyl = (oreg.cx AND 255) \ 64
HighCyl(drive) = 256 * hicyl + locyl
HighSec(drive) = oreg.cx AND 63
HighHead(drive) = oreg.dx \ 256
NumDrives = oreg.dx AND 255
'if drive1 get its info
IF NumDrives THEN
drive = drive + 1
ireg.ax = &H800
ireg.dx = drive
INTERRUPTX &H13, ireg, oreg
IF (oreg.flags AND 1) = 0 THEN
locyl = oreg.cx \ 256
hicyl = (oreg.cx AND 255) \ 64
HighCyl(drive) = 256 * hicyl + locyl
HighSec(drive) = oreg.cx AND 63
HighHead(drive) = oreg.dx \ 256
ELSE
NumDrives = 0
END IF
END IF
'do it to it
IF (DoDrive0 <> 0 AND DoDrive1 <> 0) OR (DoDrive0 + DoDrive1 = 0) THEN
IF DoDrive0 <= DoDrive1 THEN 'both/neither on CL, which is first?
GOSUB ParkDrive0
GOSUB ParkDrive1
ELSE
GOSUB ParkDrive1
GOSUB ParkDrive0
END IF
ELSEIF DoDrive0 THEN
GOSUB ParkDrive0 'first drive only
ELSEIF DoDrive1 THEN
GOSUB ParkDrive1 'second drive only
END IF
ELSE
FOR i = LBOUND(useMsg$) TO UBOUND(useMsg$)
outm = useMsg$(i)
outl = LEN(useMsg$(i))
GOSUB OutMsg
NEXT
END IF
SYSTEM
OutMsg:
MID$(outm, outl + 1, 2) = CRLF
vseg = VARSEG(outm)
voff = VARPTR(outm)
ireg.ax = &H4000
ireg.bx = STDOUT
ireg.cx = outl + 2
ireg.dx = voff
ireg.ds = vseg
INTERRUPTX &H21, ireg, oreg
RETURN
ParkDrive0:
tcyl = HighCyl(&H80) + ONEMORE 'go to landing zone--could read LZ from AT
tsec = HighSec(&H80) 'HD parm table but XTs don't have LZ described
thead = HighHead(&H80) 'max it out so 26HDCOM1 reports max cap
IF (D0cyl <> 0) AND D0cyl < tcyl THEN
tcyl = D0cyl
tsec = HighSec(&H80)
thead = HighHead(&H80)
END IF
drive = &H80
IF tcyl > MaxCyl(&H80) THEN GOTO Abend
ireg.ax = &HC00
locyl = (tcyl AND 255) * 256 'CH
hicyl = (tcyl \ 256) * 64 + tsec'CL
ireg.cx = locyl + hicyl
ireg.dx = thead * 256 + &H80
INTERRUPTX &H13, ireg, oreg
tcyl$ = STR$(tcyl)
IF (oreg.flags AND 1) THEN tcyl$ = " ???"
t$ = "Drive0 at cylinder:" + tcyl$ + " Status:" + STR$(oreg.ax \ 256)
IF D0cyl > tcyl THEN t$ = t$ + " * Fail on" + STR$(D0cyl)
outm = t$
outl = LEN(t$)
GOSUB OutMsg
RETURN
ParkDrive1:
IF NumDrives > 0 THEN
tcyl = HighCyl(&H81) + ONEMORE
tsec = HighSec(&H81)
thead = HighHead(&H81)
IF (D1cyl <> 0) AND D1cyl < tcyl THEN
tcyl = D1cyl
tsec = HighSec(&H81)
thead = HighHead(&H81)
END IF
drive = &H81
IF tcyl > MaxCyl(&H81) THEN GOTO Abend
ireg.ax = &HC00
locyl = (tcyl AND 255) * 256 'CH
hicyl = (tcyl \ 256) * 64 + tsec'CL
ireg.cx = locyl + hicyl
ireg.dx = thead * 256 + &H81
INTERRUPTX &H13, ireg, oreg
tcyl$ = STR$(tcyl)
IF (oreg.flags AND 1) THEN tcyl$ = " ???"
t$ = "Drive1 at cylinder:" + tcyl$ + " Status:" + STR$(oreg.ax \ 256)
IF D1cyl > tcyl THEN t$ = t$ + " * Fail on" + STR$(D1cyl)
outm = t$
outl = LEN(t$)
GOSUB OutMsg
END IF
RETURN
Abend:
t$ = "* Drive" + LTRIM$(STR$(drive - &H80)) + ": cylinder" + STR$(tcyl) + " exceeds PARKIM program MaxCyl =" + STR$(MaxCyl(drive))
outm = t$
outl = LEN(t$)
GOSUB OutMsg
SYSTEM