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 / ZSYS / SIMTEL20 / ZCPR3 / VFILR4-2.LBR / VFCMDS2.ZZ0 / VFCMDS2.Z80
Text File  |  2000-06-30  |  5KB  |  221 lines

  1. ;===========================================================================
  2. ;
  3. ; VFCMDS2.Z80 - Tagging, Untagging, Retagging Commands (T, U, W, Y)
  4. ;
  5. ;===========================================================================
  6.  
  7.  
  8. ; * * *COMMAND: T
  9.  
  10. tag:
  11.     ld    b,tagch        ; Tag char
  12.     jr    ut        ; Do tag
  13.  
  14.  
  15. ; * *  COMMAND: U
  16.  
  17. untag:
  18.     ld    b,' '        ; Reset tag byte to space
  19.  
  20.  
  21. ;  Common Entry Point for Untag/Tag:  Reg B = Untag/Tag Char
  22.  
  23. ut:
  24.     ld    hl,(ringpos)    ; Move back one..
  25.     ld    a,' '
  26.     cp    b
  27.     jr    nz,ut0        ; Tagging, carry on..
  28.     push    hl        ; Save ringpos
  29.     ld    de,9
  30.     add    hl,de        ; Point to R/O attribute
  31.     ld    a,128
  32.     cp    (hl)
  33.     pop    hl        ; Restore ringpos
  34.     jr    nc,ut0        ; File is R/W
  35.     ld    b,'r'        ; Flag as R/O
  36. ut0:
  37.     push    hl
  38.     ld    de,eltsiz-1    ; Character position..
  39.     add    hl,de        ; And check tagging status.
  40.     ld    (hl),b        ; If file previously tagged, remove.
  41.     pop    hl
  42.     call    reffn        ; Refresh file name
  43.     jp    forward
  44.  
  45. ; SOFTAG - Untag but remember it was tagged
  46.  
  47. stag:
  48.     ld    hl,(ringpos)    ; Current file
  49.     ld    de,eltsiz-1
  50.     add    hl,de        ; Point to tag
  51.     ld    a,tagch
  52.     cp    (hl)
  53.     ret    nz        ; Not tagged, forget it
  54.     ld    (hl),stagch    ; Soft tag it
  55.  
  56. ; REFFN - Refresh file name with new tag
  57.  
  58. reffn:
  59.      if    bihelp
  60.     ld    a,(helpdisp)    ; Currently displaying help?
  61.     or    a        ; Nop if so.
  62.     ret    nz
  63.      endif
  64.     call    clrcur        ; Clear cursor
  65.     ld    hl,(ringpos)    ; Reprint file name
  66.  
  67. ; Enter with HL pointing to file in ring
  68.  
  69. reffnt:
  70.     push    hl
  71.     ld    de,eltsiz-1    ; Character position..
  72.     add    hl,de        ; Point to tag
  73.     ld    a,(hl)        ; Get tag character
  74.     cp    tagch        ; Hard tag?
  75.  
  76.      if    revvideo
  77.     call    z,stndout    ; Reverse if tagged
  78.      else
  79.     call    nz,stndout    ; Dim if not tagged
  80.      endif
  81.  
  82.     pop    hl        ; Restore ringpos
  83.     inc    hl        ; Point to name
  84.     call    prfn
  85.     ld    a,(hl)
  86.     call    cout        ; Print tag
  87.     jp    stndend        ; Bright
  88.  
  89.  
  90. ; ; * COMMAND: W
  91.  
  92. wtag:
  93.     call    cprmpt
  94.     db    'Tag/Untag (T/U)? ',0
  95.     call    keyin        ; Get response.
  96.     cp    'T'        ; Wild tag?
  97.     ld    b,tagch        ; Get tag character
  98.     jr    z,wtag1        ; Br if wild tag.
  99.     cp    'U'        ; Wild untag?
  100.     jp    nz,loop        ; Return to position if not.
  101.     ld    b,' '        ; Get untag byte
  102. wtag1:
  103.     push    bc        ; Save tag.
  104.     call    cprmpt
  105.     db    'Match (filename.ext)? ',0
  106.     ld    de,d$fcb    ; -> match pattern.
  107.     call    filename    ; Get match file id.
  108.  
  109. wtagen:
  110.     ld    hl,(ringpos)    ; Save current ring position.
  111.     ld    (sringpos),hl
  112.  
  113.     ld    hl,(ring)    ; -> start of ring.
  114.     ld    (ringpos),hl
  115.     pop    bc        ; Restore tag
  116.  
  117. wtag2:
  118.     ld    hl,(ringend)    ; At end of ring?
  119.     ex    de,hl
  120.     ld    hl,(ringpos)
  121.     call    cmpdehl        ; Same if so
  122.     jr    z,wtag3        ; Exit if done.
  123.  
  124.     ex    de,hl        ; De-> current file id.
  125.     ld    hl,eltsiz    ; -> next file in ring.
  126.     add    hl,de
  127.     ld    (ringpos),hl    ; Save pointer to next file.
  128.  
  129.     ld    hl,d$fcb    ; -> match pattern.
  130.     call    fmatch        ; Check for file match.
  131.     jr    nz,wtag2    ; Br if not a match.
  132.  
  133.     ld    hl,(ringpos)    ; -> current tag char
  134.     dec    hl
  135.     ld    (hl),b        ; Set tag/untag
  136.     jr    wtag2        ; Next file.
  137.  
  138. ; Redisplay files with updated tag indicators
  139.  
  140. wtag3:
  141.     ld    hl,(sringpos)    ; Restore current ring position.
  142.     ld    (ringpos),hl
  143.     jp    runsh4        ; Redisplay files, return for next command.
  144.  
  145.  
  146. ; FMATCH - Check two file ID's for a match
  147. ;
  148. ;    Input:    HL    -> Match File ID (possibly ambiguous); ;    DE    -> Current File ID
  149. ;    Output: Z    Match
  150. ;        NZ    Not a match
  151.  
  152. fmatch:
  153.     push    bc        ; Save regs.
  154.     push    de
  155.     push    hl
  156.  
  157.     inc    de        ; Bypass drive
  158.     inc    hl
  159.  
  160.     ld    b,11        ; Length of file name and file type.
  161. fmat1:
  162.     ld    a,(hl)        ; Get match character.
  163.     cp    '?'        ; Wild char?
  164.     jr    z,fmat2        ; Yes - automatic match.
  165.     ld    a,(de)        ; Get current file id char
  166.     and    7fh        ; Ignore attributes
  167.     cp    (hl)        ; Match?
  168.     jr    nz,fmat3    ; Exit on first difference. (nz)
  169.  
  170. fmat2:
  171.     inc    de        ; Next char
  172.     inc    hl
  173.     djnz    fmat1        ; Loop until all chars checked.
  174.  
  175. fmat3:
  176.     pop    hl        ; Restore regs
  177.     pop    de
  178.     pop    bc
  179.     ret            ; Exit
  180.  
  181.  
  182.  
  183. ;  COMMAND: 'Y' Retag soft tags
  184.  
  185. yank:
  186.     ld    hl,(ringpos)    ; Old ring position
  187.     ld    (sringpos),hl    ; Save ring position
  188.     ld    hl,(curat)
  189.     ld    (scurat),hl    ; Save cursor position
  190.     ld    hl,(ring)    ; Beginning of ring
  191.     ld    de,-eltsiz
  192.     add    hl,de        ; Back up
  193.     ld    (ringpos),hl    ; New ring position (-1)
  194. yank1:
  195.     ld    hl,(ringpos)    ; Last position
  196.     ld    de,eltsiz    ; One element size
  197.     add    hl,de
  198.     ld    (ringpos),hl    ; New position
  199.     ex    de,hl        ; To DE
  200.     ld    hl,(ringend)    ; Check end of ring
  201.     call    cmpdehl
  202.     jr    z,yankex    ; Finished
  203.  
  204. ; Check for soft tag.  Hard tag if found
  205.  
  206.     ld    hl,(ringpos)    ; Current position
  207.     ld    de,eltsiz-1
  208.     add    hl,de        ; Point to tag
  209.     ld    a,(hl)        ; Get it
  210.     cp    stagch        ; Soft?
  211.     jr    nz,yank1    ; Try again..
  212.     ld    (hl),tagch    ; Tag it
  213.     jr    yank1        ; Try again..
  214. yankex:
  215.     ld    hl,(sringpos)
  216.     ld    (ringpos),hl    ; Restore ring location
  217.     ld    hl,(scurat)
  218.     ld    (curat),hl    ; Restore cursor location
  219.     jp    runsh5        ; Continue..
  220.