home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / ramfix.lbr / CRTST.1Z0 / CRTST.180
Encoding:
Text File  |  1993-06-07  |  1.9 KB  |  91 lines

  1. cr    equ    13
  2. lf    equ    10
  3.  
  4. wboot    equ    0
  5. dfcb    equ    5Ch        ; Default File Control block
  6.  
  7.     public    $memry
  8.     extrn    cout,print,pa2hc
  9.     extrn    f$make,f$open,f$write,f$close
  10.     extrn    setdma
  11.  
  12.     ld    a,(dfcb+1)
  13.     cp    a,'/'
  14.     jp    z,help
  15.  
  16.     ld    de,fcb        ; Get file control block
  17.     ld    a,(dfcb)    ; Get disk number
  18.     ld    (de),a        ; And set in FCB
  19.     or    a,a        ; See if we have one
  20.     jp    z,nodisk    ; No, complain
  21.  
  22.     call    f$make        ; And make file
  23.     call    f$open        ; And open
  24.     cp    a,0FFh        ; See if we have file
  25.     jp    z,openerr    ; Show error
  26.  
  27.     ld    b,8        ; Write 8 sectors
  28. file_loop:
  29.     push    bc        ; Save counter
  30.     call    fillbuf
  31.     ld    hl,($memry)    ; Get buffer pointer
  32.     call    setdma        ; And set the DMA
  33.     ld    de,fcb        ; Get file control block
  34.     call    f$write        ; And write the file
  35.     or    a,a        ; Set flags on status
  36.     jp    nz,write_err
  37.     pop    bc        ; Get counter
  38.     djnz    file_loop
  39.  
  40.     ld    de,fcb
  41.     call    f$close
  42.     jp    wboot        ; All done
  43.  
  44. fillbuf:
  45.     ld    b,128        ; Number of bytes to fill
  46.     ld    hl,($memry)    ; Point to buffer
  47.     ld    a,(fill_seed)    ; Get our pattern
  48. fillbuf_loop:
  49.     ld    (hl),a        ; Save away
  50.     inc    hl        ; Bump pointer
  51. $1:
  52.     rlca            ; Move pattern
  53.     cp    a,10000111b    ; See if it is eigth pattern
  54.     jr    z,$1        ; Yes, skip over it
  55.     djnz    fillbuf_loop    ; get next one
  56.     ld    (fill_seed),a    ; Save for next time
  57.     ret
  58.  
  59. help:
  60.     call    print
  61.     db    cr,lf,'USAGE: CRTST <disk>:'
  62.     db    cr,lf,'Will create a file "!!!TESTF.TST" on indicated drive with'
  63.     db    cr,lf,'  unique data pattern.  Can be read by "TSTDSK" to determine validity.',0
  64.     jp    wboot
  65.  
  66. nodisk:
  67.     call    print
  68.     db    cr,lf,'CRTST: Disk must be specified.',0
  69.     jp    wboot
  70.  
  71. write_err:
  72. openerr:
  73.     call    print
  74.     db    cr,lf,'CRTST: Error in opening file on disk ',0
  75.     ld    a,(fcb)        ; Get disk
  76.     add    a,'A'-1        ; Make into disk
  77.     call    cout        ; And print it
  78.     call    print
  79.     db    '.',0
  80.     jp    wboot
  81.  
  82. fill_seed
  83.     db    00001111b    ; First of test pattern
  84. $memry    ds    2        ; Bottom of free memory
  85. fcb:
  86.     db    0
  87.     db    '!!!TESTF'
  88.     db    'TST'
  89.     ds    24
  90.  
  91.     end