home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / A / BIOS-R62.LZH / FORMAT81.MAC < prev    next >
Text File  |  2000-06-30  |  6KB  |  241 lines

  1. ;
  2. ; FORMAT81.MAC  --  Version 1.1
  3. ;
  4. ; This is an interim program to format a disk in the Commodore 1581
  5. ; disk drive for use under CP/M 3.0 on the C-128.  Disks formatted
  6. ; with this program are NOT likely to be compatible with the
  7. ; official BIOS upgrade, when it is finally delivered by Commodore
  8. ; Business Machines.
  9. ;
  10. ; USAGE:
  11. ;
  12. ;    FORMAT81 {d:}
  13. ;
  14. ; Formats the disk in the given drive.  If a drive specification is
  15. ; not supplied in the command tail, then the currently logged disk
  16. ; is assumed.  Only drives A, B, C, and D will be accepted; all
  17. ; others result in an 'invalid drive' message.  Permissible drives
  18. ; may be further restricted in the drive list (DrvLst:) below.
  19. ;
  20. ; Version 1.0 (9/10/87) -- successfully formatted disks in 1581 drive
  21. ;    using Epson QX-10 format options.
  22. ;
  23. ; Version 1.1 (9/12/87) -- added command line drive selection, drive
  24. ;    list, error checking, and drive reset.
  25. ;
  26. ;        Gene Pizzetta
  27. ;        481 Revere Street
  28. ;        Revere, MA  02151
  29. ;        Voice (617) 284-0891
  30. ;        CompuServe 72060,505
  31. ;        Quantum-Link GeneP
  32. ;
  33. ; This utility was developed with SLRMAC, but should be fully compatible
  34. ; with MAC.  Z80.LIB is required for assembly.
  35. ;
  36. WBoot        equ    0000h
  37. Bdos        equ    0005h
  38. FcbDrv        equ    005ch    ; drive number in default FCB
  39. lf        equ    0ah
  40. cr        equ    0dh
  41. esc        equ    1bh
  42. ;
  43. ; BDOS functions
  44. ;
  45. ConIn        equ    1    ; console input
  46. PrtStr        equ    9    ; print string
  47. CurDsk        equ    25    ; get current (default) drive
  48. ResetDr        equ    37    ; reset drive
  49. ConMode        equ    109    ; set console mode
  50. SetDlmt        equ    110    ; set string delimiter
  51. ;
  52. ; BIOS user vectors
  53. ;
  54. DrvStr        equ    0fe00h    ; string to send drive
  55. VicDrv        equ    0fd02h    ; drive number vector
  56. VicData        equ    0fd06h    ; drive error flags
  57. Fast        equ    0fd08h    ; fast drive flag
  58. BiosUser    equ    30    ; BIOS user function
  59. DiskFunc    equ    4    ; reg A for user disk function
  60. FormatFunc    equ    8    ; reg L for user format disk subfunction
  61. QueryFunc    equ    5    ; reg L for user inquire disk subfunction
  62. ;
  63.     MACLIB    Z80
  64. ;
  65.     org    100h
  66. ;
  67.     jmp    Main
  68. ;
  69. ; valid drives in system (A: through D:), where
  70. DrvLst:    db    0,0,0,0        ; 00h = valid drive, 0ffh = not valid
  71. ;
  72. ; string to send drive:
  73. ;    byte 1 = number of characters in string
  74. ;    byte 2 = format flag
  75. ;    byte 3 = sector size (512K)
  76. ;    byte 4 = last track (79)
  77. ;    byte 5 = sectors per track (10)
  78. ;    byte 6 = starting track (0)
  79. ;    byte 7 = fill byte (0E5h)
  80. ;    byte 8 = starting sector (1)
  81. FmtStr:    db    07h,86h,02h,4fh,0ah,00h,0e5h,01h
  82. VicByt:    db    0        ; VicDrv byte storage
  83. SignOn:    db    1ah,lf,esc,'G4 C-128  1581 CP/M FORMAT PROGRAM  v1.1 '
  84.     db    esc,'G0',cr,lf,0
  85. AskMsg:    db    lf,lf,lf,'Press ''$'' to format disk in drive '
  86. Drive:    db    0,': ',0
  87. InvMsg:    db    cr,lf,lf,'          ',07h,'Invalid drive',cr,lf,0
  88. WrkMsg:    db    cr,lf,lf,'          Formatting ...',cr,lf,lf,0
  89. ErrMsg:    db    '          ',07h,'Formatting error',cr,lf,0
  90. FinMsg:    db    cr,lf,lf,lf,lf,'  Format another disk? ',0
  91. ExMsg:    db    cr,lf,lf,'       < Returning to CP/M >',lf,0
  92. ;
  93. Main:    mvi    c,SetDlmt    ; set string delimiter to nul
  94.     lxi    d,0
  95.     call    Bdos
  96.     mvi    c,ConMode    ; don't allow ^C to abort
  97.     lxi    d,08h
  98.     call    Bdos
  99.     lda    FcbDrv        ; was a drive given?
  100.     cpi    0
  101.     jrnz    SaveDr        ; (yes)
  102.     mvi    c,CurDsk    ; no, find out what the default is
  103.     call    Bdos
  104.     inr    a        ; increment to match FCB (A=1, ...)
  105. SaveDr:    push    psw        ; save it on the stack
  106.     adi    40h        ; make it ASCII
  107.     sta    Drive        ; ..and store it in drive message
  108.     pop    psw        ; get back the original
  109.     push    psw        ; ..and save it again
  110. ;
  111. ; check drive list for invalid drive
  112. ;
  113.     lxi    h,DrvLst-1    ; point HL to drive list - 1
  114.     mvi    b,00h        ; zero b
  115.     mov    c,a        ; move drive number (1-4) to c
  116.     dad    b        ; add drive number to HL pointer
  117.     mvi    a,00h        ; ..and check it
  118.     cmp    m        ; valid drive?
  119.     jnz    Invalid        ; (no, abort)
  120. ;
  121. ; now set up VicByt to be sent to VicDrv vector
  122. ;
  123.     pop    psw        ; recover drive number
  124.     cpi    1        ; drive A?
  125.     jrz    DrvA
  126.     cpi    2        ; drive B?
  127.     jrz    DrvB
  128.     cpi    3        ; drive C?
  129.     jrz    DrvC
  130.     cpi    4        ; drive D?
  131.     jrz    drvD
  132.     jmp    Invalid
  133. ;
  134. ; set vicbyt byte for selected drive
  135. ;
  136. DrvA:    mvi    a,1
  137.     sta    VicByt
  138.     jr    Hello
  139. ;
  140. DrvB:    mvi    a,2
  141.     sta    VicByt
  142.     jr    Hello
  143. ;
  144. DrvC:    mvi    a,4
  145.     sta    VicByt
  146.     jr    Hello
  147. ;
  148. DrvD:    mvi    a,8
  149.     sta    VicByt
  150.     jr    Hello
  151. ;
  152. Hello:    mvi    c,PrtStr    ; print sign on
  153.     lxi    d,SignOn
  154.     call    Bdos
  155.     mvi    c,PrtStr    ; now ask user
  156.     lxi    d,AskMsg
  157.     call    Bdos
  158.     mvi    c,ConIn        ; ..and get a response
  159.     call    Bdos
  160.     cpi    '$'        ; was it yes?
  161.     jrz    Cont        ; (yes, continue)
  162.     cpi    '4'
  163.     jnz    Fini        ; (no, abort)
  164. Cont:    mvi    c,PrtStr    ; tell 'em we're working
  165.     lxi    d,WrkMsg
  166.     call    Bdos
  167. ;
  168. ;    
  169. Format:    lxi    h,FmtStr    ; move format string to
  170.     lxi    d,DrvStr    ; ..drive string buffer
  171.     lxi    b,08h
  172.     ldir
  173. ;
  174.     lda    VicByt        ; get stored drive byte
  175.     sta    VicDrv        ; ..put it in drive vector
  176.     sta    Fast        ; ..and in fast flag
  177. ;
  178. ; call user function to format disk
  179. ;
  180.     mvi    a,DiskFunc
  181.     mvi    l,FormatFunc
  182.     call    UserFunc
  183. ;
  184. ; check for error (we don't care what the error is)
  185. ;
  186.     lda    VicData
  187.     ani    11110001b    ; mask unimportant bits
  188.     cpi    0
  189.     jrz    DrvLog        ; (no error)
  190.     mvi    c,PrtStr    ; report error
  191.     lxi    d,ErrMsg
  192.     call    Bdos
  193.     jr    Fini
  194. ;
  195. ; call user function to log in disk
  196. ;
  197. DrvLog:    mvi    a,DiskFunc
  198.     mvi    l,QueryFunc
  199.     call    UserFunc
  200.     jr    Fini
  201. ;
  202. Invalid:
  203.     mvi    c,PrtStr    ; report invalid drive
  204.     lxi    d,InvMsg
  205.     call    Bdos
  206.     jr    Exit
  207. ;
  208. Fini:    mvi    c,PrtStr    ; we're done ... do it again?
  209.     lxi    d,FinMsg
  210.     call    Bdos
  211.     mvi    c,ConIn
  212.     call    Bdos
  213.     cpi    'y'
  214.     jz    Hello        ; (yes, start over)
  215.     cpi    'Y'
  216.     jz    hello
  217. ;
  218. ; call Bdos to reset drive
  219. ;
  220.     lda    VicByt
  221.     mvi    c,ResetDr
  222.     mvi    d,00h
  223.     mov    e,a
  224.     call    Bdos
  225. ;
  226. Exit    mvi    c,PrtStr    ; sign off
  227.     lxi    d,ExMsg
  228.     call    Bdos
  229.     jmp    WBoot
  230. ;
  231. ; subroutine UserFunc  --  calculates address and calls user function
  232. ;
  233. UserFunc:
  234.     push    h        ; save HL
  235.     lhld    WBoot+1        ; address vector for warm boot
  236.     mvi    l,BiosUser*3    ; get offset
  237.     xthl            ; exchange HL with stack
  238.     ret
  239. ;
  240.     end
  241. c╡ÿ┌ª╦╪╖╒Kñ)J'╓