home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / z33rcp02.lbr / RCPDIR.LZB / RCPDIR.LIB
Encoding:
Text File  |  1993-10-25  |  2.9 KB  |  110 lines

  1.     page
  2.  
  3. ; RCP-DIR.Z80    'DIR' Command
  4.  
  5. ;=============================================================================
  6. ;
  7. ;    D I R E C T O R Y    D I S P L A Y    C O M M A N D
  8. ;
  9. ;=============================================================================
  10.  
  11. ; Command:    DIR
  12. ; Function:    Display a directory of the files on disk
  13. ; Syntax:    DIR <afn>    Displays the DIR files
  14. ;        DIR <afn> S    Displays the SYS files
  15. ;        DIR <afn> A    Display both DIR and SYS files
  16. ;        DIR /S        Equivalent to DIR *.* S
  17. ;        DIR /A        Equivalent to DIR *.* A
  18.  
  19. dir:
  20.     call    retsave        ; Save return address and set stack
  21.  
  22. ; See if FCB should be made wild (all '?')
  23.  
  24.     ld    hl,fcb1+1    ; Point to file name in FCP
  25.     ld    a,(hl)        ; Get first character of filename
  26.  
  27.      if    slashchk    ; Allow "DIR /S" and "DIR /A" formats
  28.     cp    '/'        ; If name does not start with '/'
  29.     jr    nz,dir01    ; ..branch and process normally
  30.     inc    hl        ; Point to second character
  31.     ld    a,(hl)        ; Get option character after slash
  32.     ld    (fcb2+1),a    ; ..and put it into second FCB
  33.     dec    hl        ; Back to first character
  34.     ld    a,' '        ; Simulate empty FCB
  35.      endif    ;slashchk
  36.  
  37. dir01:
  38.     ld    b,11        ; Prepare to fill FCB name and type with '?'
  39.     cp    ' '        ; See if no file spec given
  40.     ld    a,'?'        ; Get ready to fill with '?'
  41.     call    z,fillp        ; ..carry out fill
  42.  
  43.      if    nosys        ; Suppress-SYS-file-if-no-wheel option
  44.     ld    a,(z3whl)    ; Get wheel byte
  45.     or    a
  46.     jr    z,dirnly    ; If wheel off, ignore options
  47.      endif
  48.  
  49.     ld    a,(fcb2+1)    ; Get first char of 2nd file name
  50.     ld    b,1        ; Set for both dir and sys files
  51.     cp    allflag        ; SYS and DIR flag specifier?
  52.     jr    z,dirpr        ; Got system specifier
  53.     dec    b        ; B=0 for sys files only
  54.     cp    sysflag        ; SYS only?
  55.     jr    z,dirpr
  56.  
  57. dirnly:    ld    b,80h        ; Must be dir-only selection
  58.  
  59. ; DIRECTORY PRINT ROUTINE; ON ENTRY, B REG IS SET AS FOLLOWS:
  60. ;    0 FOR ONLY SYSTEM FILES, 80H FOR ONLY DIR FILES, 1 FOR BOTH
  61. ;
  62. dirpr:
  63.     ld    a,b        ; Get systst flag
  64.     call    getdir        ; Load and sort directory
  65.     jp    z,prfnf        ; Print no file message
  66.     ld    e,4        ; Count down to 0
  67. ;
  68. ; ENTRY PRINT LOOP; ON ENTRY, HL PTS TO FILES SELECTED (TERMINATED BY 0)
  69. ;    AND E IS ENTRY COUNTER
  70. ;
  71. dir3:
  72.     ld    a,(hl)        ; Check for done
  73.     or    a
  74.      if    dirsp and spaceon
  75.     jp    z,spaexit    ; Show space when done
  76.      else
  77.     jp    z,exit        ; Exit if done
  78.      endif            ; Dirsp and spaceon
  79.     ld    a,e        ; Get entry counter
  80.     or    a        ; Output <crlf> if 4 entries printed in line
  81.     jr    nz,dir3a    ; Continue
  82.     call    crlf        ; New line
  83.     ld    e,4        ; Reset entry count
  84.     ld    a,e        ; Get entry count
  85. dir3a    cp    4        ; First entry?
  86.     jr    z,dir4
  87.     call    print
  88. ;
  89.      if    wide
  90. ;
  91.     db    '  '        ; 2 spaces
  92.     db    fence        ; Then fence char
  93.     db    ' '+80h        ; Then 1 more space
  94. ;
  95.      else
  96. ;
  97.     db    ' '        ; Space
  98.     db    fence+80h    ; Then fence char
  99. ;
  100.      endif            ; Wide
  101. ;
  102. dir4:
  103.     call    prfn        ; Print file name
  104.     call    break        ; Check for abort
  105.     dec    e        ; Decrement entry counter
  106.     jr    dir3
  107.  
  108. ; End RCP-DIR.Z80
  109.  
  110.