home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / cpm / utils / a / bios-5.arc / FORMAT81.MAC < prev    next >
Encoding:
Text File  |  1989-05-08  |  6.0 KB  |  241 lines

  1. ;
  2.  
  3. ; FORMAT81.MAC  --  Version 1.1
  4.  
  5. ;
  6.  
  7. ; This is an interim program to format a disk in the Commodore 1581
  8.  
  9. ; disk drive for use under CP/M 3.0 on the C-128.  Disks formatted
  10.  
  11. ; with this program are NOT likely to be compatible with the
  12.  
  13. ; official BIOS upgrade, when it is finally delivered by Commodore
  14.  
  15. ; Business Machines.
  16.  
  17. ;
  18.  
  19. ; USAGE:
  20.  
  21. ;
  22.  
  23. ;    FORMAT81 {d:}
  24.  
  25. ;
  26.  
  27. ; Formats the disk in the given drive.  If a drive specification is
  28.  
  29. ; not supplied in the command tail, then the currently logged disk
  30.  
  31. ; is assumed.  Only drives A, B, C, and D will be accepted; all
  32.  
  33. ; others result in an 'invalid drive' message.  Permissible drives
  34.  
  35. ; may be further restricted in the drive list (DrvLst:) below.
  36.  
  37. ;
  38.  
  39. ; Version 1.0 (9/10/87) -- successfully formatted disks in 1581 drive
  40.  
  41. ;    using Epson QX-10 format options.
  42.  
  43. ;
  44.  
  45. ; Version 1.1 (9/12/87) -- added command line drive selection, drive
  46.  
  47. ;    list, error checking, and drive reset.
  48.  
  49. ;
  50.  
  51. ;        Gene Pizzetta
  52.  
  53. ;        481 Revere Street
  54.  
  55. ;        Revere, MA  02151
  56.  
  57. ;        Voice (617) 284-0891
  58.  
  59. ;        CompuServe 72060,505
  60.  
  61. ;        Quantum-Link GeneP
  62.  
  63. ;
  64.  
  65. ; This utility was developed with SLRMAC, but should be fully compatible
  66.  
  67. ; with MAC.  Z80.LIB is required for assembly.
  68.  
  69. ;
  70.  
  71. WBoot        equ    0000h
  72.  
  73. Bdos        equ    0005h
  74.  
  75. FcbDrv        equ    005ch    ; drive number in default FCB
  76.  
  77. lf        equ    0ah
  78.  
  79. cr        equ    0dh
  80.  
  81. esc        equ    1bh
  82.  
  83. ;
  84.  
  85. ; BDOS functions
  86.  
  87. ;
  88.  
  89. ConIn        equ    1    ; console input
  90.  
  91. PrtStr        equ    9    ; print string
  92.  
  93. CurDsk        equ    25    ; get current (default) drive
  94.  
  95. ResetDr        equ    37    ; reset drive
  96.  
  97. ConMode        equ    109    ; set console mode
  98.  
  99. SetDlmt        equ    110    ; set string delimiter
  100.  
  101. ;
  102.  
  103. ; BIOS user vectors
  104.  
  105. ;
  106.  
  107. DrvStr        equ    0fe00h    ; string to send drive
  108.  
  109. VicDrv        equ    0fd02h    ; drive number vector
  110.  
  111. VicData        equ    0fd06h    ; drive error flags
  112.  
  113. Fast        equ    0fd08h    ; fast drive flag
  114.  
  115. BiosUser    equ    30    ; BIOS user function
  116.  
  117. DiskFunc    equ    4    ; reg A for user disk function
  118.  
  119. FormatFunc    equ    8    ; reg L for user format disk subfunction
  120.  
  121. QueryFunc    equ    5    ; reg L for user inquire disk subfunction
  122.  
  123. ;
  124.  
  125.     MACLIB    Z80
  126.  
  127. ;
  128.  
  129.     org    100h
  130.  
  131. ;
  132.  
  133.     jmp    Main
  134.  
  135. ;
  136.  
  137. ; valid drives in system (A: through D:), where
  138.  
  139. DrvLst:    db    0,0,0,0        ; 00h = valid drive, 0ffh = not valid
  140.  
  141. ;
  142.  
  143. ; string to send drive:
  144.  
  145. ;    byte 1 = number of characters in string
  146.  
  147. ;    byte 2 = format flag
  148.  
  149. ;    byte 3 = sector size (512K)
  150.  
  151. ;    byte 4 = last track (79)
  152.  
  153. ;    byte 5 = sectors per track (10)
  154.  
  155. ;    byte 6 = starting track (0)
  156.  
  157. ;    byte 7 = fill byte (0E5h)
  158.  
  159. ;    byte 8 = starting sector (1)
  160.  
  161. FmtStr:    db    07h,86h,02h,4fh,0ah,00h,0e5h,01h
  162.  
  163. VicByt:    db    0        ; VicDrv byte storage
  164.  
  165. SignOn:    db    1ah,lf,esc,'G4 C-128  1581 CP/M FORMAT PROGRAM  v1.1 '
  166.  
  167.     db    esc,'G0',cr,lf,0
  168.  
  169. AskMsg:    db    lf,lf,lf,'Press ''$'' to format disk in drive '
  170.  
  171. Drive:    db    0,': ',0
  172.  
  173. InvMsg:    db    cr,lf,lf,'          ',07h,'Invalid drive',cr,lf,0
  174.  
  175. WrkMsg:    db    cr,lf,lf,'          Formatting ...',cr,lf,lf,0
  176.  
  177. ErrMsg:    db    '          ',07h,'Formatting error',cr,lf,0
  178.  
  179. FinMsg:    db    cr,lf,lf,lf,lf,'  Format another disk? ',0
  180.  
  181. ExMsg:    db    cr,lf,lf,'       < Returning to CP/M >',lf,0
  182.  
  183. ;
  184.  
  185. Main:    mvi    c,SetDlmt    ; set string delimiter to nul
  186.  
  187.     lxi    d,0
  188.  
  189.     call    Bdos
  190.  
  191.     mvi    c,ConMode    ; don't allow ^C to abort
  192.  
  193.     lxi    d,08h
  194.  
  195.     call    Bdos
  196.  
  197.     lda    FcbDrv        ; was a drive given?
  198.  
  199.     cpi    0
  200.  
  201.     jrnz    SaveDr        ; (yes)
  202.  
  203.     mvi    c,CurDsk    ; no, find out what the default is
  204.  
  205.     call    Bdos
  206.  
  207.     inr    a        ; increment to match FCB (A=1, ...)
  208.  
  209. SaveDr:    push    psw        ; save it on the stack
  210.  
  211.     adi    40h        ; make it ASCII
  212.  
  213.     sta    Drive        ; ..and store it in drive message
  214.  
  215.     pop    psw        ; get back the original
  216.  
  217.     push    psw        ; ..and save it again
  218.  
  219. ;
  220.  
  221. ; check drive list for invalid drive
  222.  
  223. ;
  224.  
  225.     lxi    h,DrvLst-1    ; point HL to drive list - 1
  226.  
  227.     mvi    b,00h        ; zero b
  228.  
  229.     mov    c,a        ; move drive number (1-4) to c
  230.  
  231.     dad    b        ; add drive number to HL pointer
  232.  
  233.     mvi    a,00h        ; ..and check it
  234.  
  235.     cmp    m        ; valid drive?
  236.  
  237.     jnz    Invalid        ; (no, abort)
  238.  
  239. ;
  240.  
  241. ; now set up VicByt to be sent to VicDrv vector
  242.  
  243. ;
  244.  
  245.     pop    psw        ; recover drive number
  246.  
  247.     cpi    1        ; drive A?
  248.  
  249.     jrz    DrvA
  250.  
  251.     cpi    2        ; drive B?
  252.  
  253.     jrz    DrvB
  254.  
  255.     cpi    3        ; drive C?
  256.  
  257.     jrz    DrvC
  258.  
  259.     cpi    4        ; drive D?
  260.  
  261.     jrz    drvD
  262.  
  263.     jmp    Invalid
  264.  
  265. ;
  266.  
  267. ; set vicbyt byte for selected drive
  268.  
  269. ;
  270.  
  271. DrvA:    mvi    a,1
  272.  
  273.     sta    VicByt
  274.  
  275.     jr    Hello
  276.  
  277. ;
  278.  
  279. DrvB:    mvi    a,2
  280.  
  281.     sta    VicByt
  282.  
  283.     jr    Hello
  284.  
  285. ;
  286.  
  287. DrvC:    mvi    a,4
  288.  
  289.     sta    VicByt
  290.  
  291.     jr    Hello
  292.  
  293. ;
  294.  
  295. DrvD:    mvi    a,8
  296.  
  297.     sta    VicByt
  298.  
  299.     jr    Hello
  300.  
  301. ;
  302.  
  303. Hello:    mvi    c,PrtStr    ; print sign on
  304.  
  305.     lxi    d,SignOn
  306.  
  307.     call    Bdos
  308.  
  309.     mvi    c,PrtStr    ; now ask user
  310.  
  311.     lxi    d,AskMsg
  312.  
  313.     call    Bdos
  314.  
  315.     mvi    c,ConIn        ; ..and get a response
  316.  
  317.     call    Bdos
  318.  
  319.     cpi    '$'        ; was it yes?
  320.  
  321.     jrz    Cont        ; (yes, continue)
  322.  
  323.     cpi    '4'
  324.  
  325.     jnz    Fini        ; (no, abort)
  326.  
  327. Cont:    mvi    c,PrtStr    ; tell 'em we're working
  328.  
  329.     lxi    d,WrkMsg
  330.  
  331.     call    Bdos
  332.  
  333. ;
  334.  
  335. ;    
  336.  
  337. Format:    lxi    h,FmtStr    ; move format string to
  338.  
  339.     lxi    d,DrvStr    ; ..drive string buffer
  340.  
  341.     lxi    b,08h
  342.  
  343.     ldir
  344.  
  345. ;
  346.  
  347.     lda    VicByt        ; get stored drive byte
  348.  
  349.     sta    VicDrv        ; ..put it in drive vector
  350.  
  351.     sta    Fast        ; ..and in fast flag
  352.  
  353. ;
  354.  
  355. ; call user function to format disk
  356.  
  357. ;
  358.  
  359.     mvi    a,DiskFunc
  360.  
  361.     mvi    l,FormatFunc
  362.  
  363.     call    UserFunc
  364.  
  365. ;
  366.  
  367. ; check for error (we don't care what the error is)
  368.  
  369. ;
  370.  
  371.     lda    VicData
  372.  
  373.     ani    11110001b    ; mask unimportant bits
  374.  
  375.     cpi    0
  376.  
  377.     jrz    DrvLog        ; (no error)
  378.  
  379.     mvi    c,PrtStr    ; report error
  380.  
  381.     lxi    d,ErrMsg
  382.  
  383.     call    Bdos
  384.  
  385.     jr    Fini
  386.  
  387. ;
  388.  
  389. ; call user function to log in disk
  390.  
  391. ;
  392.  
  393. DrvLog:    mvi    a,DiskFunc
  394.  
  395.     mvi    l,QueryFunc
  396.  
  397.     call    UserFunc
  398.  
  399.     jr    Fini
  400.  
  401. ;
  402.  
  403. Invalid:
  404.  
  405.     mvi    c,PrtStr    ; report invalid drive
  406.  
  407.     lxi    d,InvMsg
  408.  
  409.     call    Bdos
  410.  
  411.     jr    Exit
  412.  
  413. ;
  414.  
  415. Fini:    mvi    c,PrtStr    ; we're done ... do it again?
  416.  
  417.     lxi    d,FinMsg
  418.  
  419.     call    Bdos
  420.  
  421.     mvi    c,ConIn
  422.  
  423.     call    Bdos
  424.  
  425.     cpi    'y'
  426.  
  427.     jz    Hello        ; (yes, start over)
  428.  
  429.     cpi    'Y'
  430.  
  431.     jz    hello
  432.  
  433. ;
  434.  
  435. ; call Bdos to reset drive
  436.  
  437. ;
  438.  
  439.     lda    VicByt
  440.  
  441.     mvi    c,ResetDr
  442.  
  443.     mvi    d,00h
  444.  
  445.     mov    e,a
  446.  
  447.     call    Bdos
  448.  
  449. ;
  450.  
  451. Exit    mvi    c,PrtStr    ; sign off
  452.  
  453.     lxi    d,ExMsg
  454.  
  455.     call    Bdos
  456.  
  457.     jmp    WBoot
  458.  
  459. ;
  460.  
  461. ; subroutine UserFunc  --  calculates address and calls user function
  462.  
  463. ;
  464.  
  465. UserFunc:
  466.  
  467.     push    h        ; save HL
  468.  
  469.     lhld    WBoot+1        ; address vector for warm boot
  470.  
  471.     mvi    l,BiosUser*3    ; get offset
  472.  
  473.     xthl            ; exchange HL with stack
  474.  
  475.     ret
  476.  
  477. ;
  478.  
  479.     end
  480.  
  481. c╡ÿ┌ª╦╪╖╒Kñ)J'╓