home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / dskstruc / parkim10.arj / PARKIM.BAS next >
BASIC Source File  |  1991-09-20  |  7KB  |  214 lines

  1. '----------------------------------------------------------------------------|
  2. ' ---- ScanSoft(tm) PARKIM (C)1991 Cornel Huth -- All Rights Reserved ----   |
  3. '----------------------------------------------------------------------------|
  4. ' program:     PARKIM.BAS                                                    |
  5. ' version:     1.00                                                          |
  6. '      by:     Cornel Huth                                                   |
  7. '    date:     20-Sep-1991                                                   |
  8. 'function:     park either or both hard drives at any cylinder               |
  9. '  caller:     COMMAND                                                       |
  10. '     use:                                                                   |
  11. '                                                                            |
  12. 'PARKIM 0:cyl,1:cyl (colon required after drive, comma between drives)       |
  13. 'No parms - move drive(s) head-assembly to landing zone (LZ)                 |
  14. '       ? - help on usage                                                    |
  15. ' 0:[cyl] - move drive 0 to cylinder (or LZ if no cyl)                       |
  16. ' 1:[cyl] - move drive 1 to cylinder (or LZ if no cyl)                       |
  17. '                                                                            |
  18. 'For example:                                                                |
  19. '  C>parkim 1:821 - attempt to park second drive at cylinder 821             |
  20. '  C>parkim 0:    - park first drive at landing zone                         |
  21. '  C>parkim 1:,0: - park drive 1 then 0 at landing zone                      |
  22. '  C>parkim       - park drive 0 then 1 at landing zone                      |
  23. '                                                                            |
  24. 'NOTE: If [cyl] parameter > LZ then LZ is used instead of [cyl].             |
  25. '----------------------------------------------------------------------------|
  26. DEFINT A-Z
  27.  
  28. CONST STDOUT = 1        'DOS console
  29. CONST ONEMORE = 1       'Landing zone 1 more than last cylinder (usually)
  30.                         'This value is passed after LZ validation check
  31.                         'so don't make it anything greater than 1 (0 or 1)
  32. TYPE RegTypeX
  33. ax AS INTEGER
  34. bx AS INTEGER
  35. cx AS INTEGER
  36. dx AS INTEGER
  37. bp AS INTEGER
  38. si AS INTEGER
  39. di AS INTEGER
  40. flags AS INTEGER
  41. ds AS INTEGER
  42. es AS INTEGER
  43. END TYPE
  44.  
  45. DECLARE SUB INTERRUPTX (intnum%, ireg AS RegTypeX, oreg AS RegTypeX)
  46. DIM ireg AS RegTypeX, oreg AS RegTypeX
  47.  
  48. DIM outm AS STRING * 80
  49. DIM CRLF AS STRING * 2
  50. DIM MaxCyl(&H80 TO &H81) AS INTEGER
  51. DIM HighCyl(&H80 TO &H81) AS INTEGER
  52. DIM HighSec(&H80 TO &H81) AS INTEGER
  53. DIM HighHead(&H80 TO &H81) AS INTEGER
  54. DIM useMsg$(0 TO 9)
  55.  
  56. CRLF = CHR$(13) + CHR$(10)
  57. MaxCyl(&H80) = 1023     'avoid math screwup on BIOS form conversion
  58. MaxCyl(&H81) = 1023
  59.  
  60. id$ = "PARKIM 1.00 (C)1991 Cornel Huth - All Rights Reserved" + CRLF
  61. useMsg$(0) = "PARKIM 0:cyl,1:cyl (colon required after drive, comma between drives)" + CRLF
  62. useMsg$(1) = "No parms - move drive(s) head-assembly to landing zone (LZ)"
  63. useMsg$(2) = "       ? - help on usage"
  64. useMsg$(3) = " 0:[cyl] - move drive 0 to cylinder (or LZ if no cyl)"
  65. useMsg$(4) = " 1:[cyl] - move drive 1 to cylinder (or LZ if no cyl)" + CRLF
  66. useMsg$(5) = "C>parkim 1:821 - attempt to park second drive at cylinder 821"
  67. useMsg$(6) = "C>parkim 0:    - park first drive at landing zone"
  68. useMsg$(7) = "C>parkim 1:,0: - park drive 1 then 0 at landing zone"
  69. useMsg$(8) = "C>parkim       - park drive 0 then 1 at landing zone" + CRLF
  70. useMsg$(9) = "NOTE: If [cyl] parameter > LZ then LZ is used instead of [cyl]."
  71.  
  72. outm = id$
  73. outl = LEN(id$)
  74. GOSUB OutMsg
  75.  
  76. cl$ = COMMAND$
  77. ShowHelp = INSTR(cl$, "?")
  78. DoDrive0 = INSTR(cl$, "0:")
  79. IF DoDrive0 THEN D0cyl = VAL(MID$(cl$, DoDrive0 + 2)) ELSE D0cyl = 0
  80. DoDrive1 = INSTR(cl$, "1:")
  81. IF DoDrive1 THEN D1cyl = VAL(MID$(cl$, DoDrive1 + 2)) ELSE D1cyl = 0
  82.  
  83. 'get info on drive0
  84.  
  85. drive = &H80
  86. ireg.ax = &H800
  87. ireg.dx = drive
  88. INTERRUPTX &H13, ireg, oreg
  89. IF (oreg.flags AND 1) = 0 AND (ShowHelp = 0) THEN
  90.    locyl = oreg.cx \ 256
  91.    hicyl = (oreg.cx AND 255) \ 64
  92.    HighCyl(drive) = 256 * hicyl + locyl
  93.    HighSec(drive) = oreg.cx AND 63
  94.    HighHead(drive) = oreg.dx \ 256
  95.    NumDrives = oreg.dx AND 255
  96.  
  97.    'if drive1 get its info
  98.  
  99.    IF NumDrives THEN
  100.       drive = drive + 1
  101.       ireg.ax = &H800
  102.       ireg.dx = drive
  103.       INTERRUPTX &H13, ireg, oreg
  104.       IF (oreg.flags AND 1) = 0 THEN
  105.          locyl = oreg.cx \ 256
  106.          hicyl = (oreg.cx AND 255) \ 64
  107.          HighCyl(drive) = 256 * hicyl + locyl
  108.          HighSec(drive) = oreg.cx AND 63
  109.          HighHead(drive) = oreg.dx \ 256
  110.       ELSE
  111.          NumDrives = 0
  112.       END IF
  113.    END IF
  114.  
  115.    'do it to it
  116.  
  117.    IF (DoDrive0 <> 0 AND DoDrive1 <> 0) OR (DoDrive0 + DoDrive1 = 0) THEN
  118.       IF DoDrive0 <= DoDrive1 THEN  'both/neither on CL, which is first?
  119.          GOSUB ParkDrive0
  120.          GOSUB ParkDrive1
  121.       ELSE
  122.          GOSUB ParkDrive1
  123.          GOSUB ParkDrive0
  124.       END IF
  125.    ELSEIF DoDrive0 THEN
  126.       GOSUB ParkDrive0  'first drive only
  127.    ELSEIF DoDrive1 THEN
  128.       GOSUB ParkDrive1  'second drive only
  129.    END IF
  130. ELSE
  131.    FOR i = LBOUND(useMsg$) TO UBOUND(useMsg$)
  132.       outm = useMsg$(i)
  133.       outl = LEN(useMsg$(i))
  134.       GOSUB OutMsg
  135.    NEXT
  136. END IF
  137. SYSTEM
  138.  
  139. OutMsg:
  140. MID$(outm, outl + 1, 2) = CRLF
  141. vseg = VARSEG(outm)
  142. voff = VARPTR(outm)
  143. ireg.ax = &H4000
  144. ireg.bx = STDOUT
  145. ireg.cx = outl + 2
  146. ireg.dx = voff
  147. ireg.ds = vseg
  148. INTERRUPTX &H21, ireg, oreg
  149. RETURN
  150.  
  151. ParkDrive0:
  152. tcyl = HighCyl(&H80) + ONEMORE  'go to landing zone--could read LZ from AT
  153. tsec = HighSec(&H80)         'HD parm table but XTs don't have LZ described
  154. thead = HighHead(&H80)       'max it out so 26HDCOM1 reports max cap
  155. IF (D0cyl <> 0) AND D0cyl < tcyl THEN
  156.    tcyl = D0cyl
  157.    tsec = HighSec(&H80)
  158.    thead = HighHead(&H80)
  159. END IF
  160. drive = &H80
  161. IF tcyl > MaxCyl(&H80) THEN GOTO Abend
  162.  
  163. ireg.ax = &HC00
  164. locyl = (tcyl AND 255) * 256    'CH
  165. hicyl = (tcyl \ 256) * 64 + tsec'CL
  166. ireg.cx = locyl + hicyl
  167. ireg.dx = thead * 256 + &H80
  168. INTERRUPTX &H13, ireg, oreg
  169. tcyl$ = STR$(tcyl)
  170. IF (oreg.flags AND 1) THEN tcyl$ = " ???"
  171. t$ = "Drive0 at cylinder:" + tcyl$ + "  Status:" + STR$(oreg.ax \ 256)
  172. IF D0cyl > tcyl THEN t$ = t$ + " * Fail on" + STR$(D0cyl)
  173. outm = t$
  174. outl = LEN(t$)
  175. GOSUB OutMsg
  176. RETURN
  177.  
  178. ParkDrive1:
  179. IF NumDrives > 0 THEN
  180.    tcyl = HighCyl(&H81) + ONEMORE
  181.    tsec = HighSec(&H81)
  182.    thead = HighHead(&H81)
  183.    IF (D1cyl <> 0) AND D1cyl < tcyl THEN
  184.       tcyl = D1cyl
  185.       tsec = HighSec(&H81)
  186.       thead = HighHead(&H81)
  187.    END IF
  188.    drive = &H81
  189.    IF tcyl > MaxCyl(&H81) THEN GOTO Abend
  190.  
  191.    ireg.ax = &HC00
  192.    locyl = (tcyl AND 255) * 256    'CH
  193.    hicyl = (tcyl \ 256) * 64 + tsec'CL
  194.    ireg.cx = locyl + hicyl
  195.    ireg.dx = thead * 256 + &H81
  196.    INTERRUPTX &H13, ireg, oreg
  197.    tcyl$ = STR$(tcyl)
  198.    IF (oreg.flags AND 1) THEN tcyl$ = " ???"
  199.    t$ = "Drive1 at cylinder:" + tcyl$ + "  Status:" + STR$(oreg.ax \ 256)
  200.    IF D1cyl > tcyl THEN t$ = t$ + " * Fail on" + STR$(D1cyl)
  201.    outm = t$
  202.    outl = LEN(t$)
  203.    GOSUB OutMsg
  204. END IF
  205. RETURN
  206.  
  207. Abend:
  208. t$ = "* Drive" + LTRIM$(STR$(drive - &H80)) + ": cylinder" + STR$(tcyl) + " exceeds PARKIM program MaxCyl =" + STR$(MaxCyl(drive))
  209. outm = t$
  210. outl = LEN(t$)
  211. GOSUB OutMsg
  212. SYSTEM
  213.  
  214.