home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / tbmsbios.lbr / RDF.ZZ0 / RDF.Z80
Encoding:
Text File  |  1993-06-07  |  3.0 KB  |  183 lines

  1.  
  2. ; FORMATS ONLY - NO SYSGEN
  3.  
  4.  
  5.  
  6. firstrack    equ    0    ; First track to format
  7. firsect        equ    0    ; First sector to format
  8. ntrks        equ    2    ; Number of tracks to format
  9.  
  10. ddata        equ    2ah    ;    
  11. dcntl        equ    2bh    ;    
  12.  
  13.         ld    bc,51
  14.         ld    hl,(01)
  15.         ld    de,jmptable
  16.         ldir
  17.         ld    c,19h
  18.         call    5    ; Get currently logged in disk
  19.         ld    (curdsk),a
  20.  
  21.  
  22. ; Check to see if Ram disk has been initiated.
  23.  
  24. checki:        
  25.         ld    a,(setram)
  26.         cp    0c3h    ; Do we have a jump command?
  27.         jr    z,chek0
  28.         call    say
  29.         defz    ' BIOS does not support RAM disk'
  30.         ret
  31.         
  32. chek0:
  33.         ld    c,2
  34.         call    setram
  35.         inc    a
  36.         jr    nz,iok
  37.         call    say
  38.         defz    ' RAM disk not initialized'
  39.         ret
  40.  
  41.         
  42.  
  43. ; Set ramdisk to input (just for safety's sake)
  44.  
  45. iok:        dec    a
  46.         ld    (rdnum),a    ; Save away current logical ramdisk
  47.         ld    a,0cfh
  48.         out    (dcntl),a
  49.         ld    a,0ffh
  50.         out    (dcntl),a
  51.  
  52. ; Test high off track for format pattern.  Format if not already done
  53. ;
  54. test:        ld    bc,80h
  55.         call    setdma
  56.         ld    a,(rdnum)
  57.         ld    c,a
  58.         call    seldsk
  59.         ld    c,186
  60.         call    settrk
  61.         ld    c,39
  62.         call    setsec
  63.         call    read
  64.         ld    a,(80h)
  65.         ld    b,a
  66.         ld    a,(dfim)
  67.         cp    b
  68.         jr    nz,set_trks
  69.         call    say
  70.         defz    ' Ram disk already formatted'
  71.         ld    a,(curdsk)
  72.         ld    c,a        ; Return BIOS to current disk
  73.         call    seldsk
  74.         ret
  75.  
  76. set_trks:
  77.         call    say
  78.         defz    ' Formatting RAM disk'
  79.         ld    a,firstrack
  80.         ld    (trck),a
  81. set_secs:
  82.         ld    a,firsect
  83.         ld    (sector),a
  84. do_1_trk:
  85.         ld    bc,dfim
  86.         call    setdma
  87.         ld    a,(rdnum)
  88.         ld    c,a
  89.         call    seldsk
  90.         ld    a,(trck)
  91.         ld    c,a
  92.         call    settrk
  93.         ld    a,(sector)
  94.         ld    c,a
  95.         call    setsec
  96.         call    write
  97.         ld    a,(sector)
  98.         inc    a
  99.         ld    (sector),a
  100.         cp    40        ;40 sectors to a track
  101.         jr    nz,do_1_trk
  102.         ld    c,'.'
  103.         call    conout
  104.         ld    a,(trck)
  105.         inc    a
  106.         ld    (trck),a
  107.         cp    ntrks        ;ntrks tracks to a ramdisk
  108.         jp    nz,set_secs    ;all done w/this track - do next
  109.  
  110. ; Format an off track at end of disk for check for format already done
  111.  
  112.         ld    bc,dfim
  113.         call    setdma
  114.         ld    a,(rdnum)
  115.         ld    c,a
  116.         call    seldsk
  117.         ld    c,186
  118.         call    settrk
  119.         ld    c,39
  120.         call    setsec
  121.         call    write
  122.         ld    a,(curdsk)
  123.         ld    c,a        ; Return BIOS to a disk
  124.         call    seldsk
  125.         ret    
  126.  
  127. print:        ld    a,(hl)
  128.         or    a
  129.         ret    z
  130.         ld    e,a
  131.         ld    c,06h
  132.         push    hl
  133.         call    05
  134.         pop    hl
  135. ck1:        inc    hl
  136.         jp    print
  137.  
  138. say:        pop    hl
  139.         call    print
  140.         push    hl
  141.         ret
  142.  
  143. curdsk:        defb    0    ; Currently logged disk
  144. rdnum        defb    0    ; Ramdisk number
  145. trck:        defb    0    ; Current track
  146. sector:        defb    0    ; Current sector
  147.  
  148. jmptable:
  149. wboot:        db    0,0,0
  150. const:        db    0,0,0
  151. conin:        db    0,0,0
  152. conout:        db    0,0,0
  153. list:        db    0,0,0
  154. punch:        db    0,0,0
  155. reader:        db    0,0,0
  156. home:        db    0,0,0
  157. seldsk:        db    0,0,0
  158. settrk:        db    0,0,0
  159. setsec:        db    0,0,0
  160. setdma:        db    0,0,0
  161. read:        db    0,0,0
  162. write:        db    0,0,0
  163. listst:        db    0,0,0
  164. sectran:    db    0,0,0
  165. setram:        db    0,0,0
  166.  
  167.         
  168.  
  169. fw        equ    0e5e5h        
  170. dfim:
  171.         defw    fw,fw,fw,fw,fw,fw,fw,fw
  172.         defw    fw,fw,fw,fw,fw,fw,fw,fw
  173.         defw    fw,fw,fw,fw,fw,fw,fw,fw
  174.         defw    fw,fw,fw,fw,fw,fw,fw,fw
  175.         defw    fw,fw,fw,fw,fw,fw,fw,fw
  176.         defw    fw,fw,fw,fw,fw,fw,fw,fw
  177.         defw    fw,fw,fw,fw,fw,fw,fw,fw
  178.         defw    fw,fw,fw,fw,fw,fw,fw,fw    
  179.  
  180.         nop
  181.  
  182.         end
  183.