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 / CPM / ZCPR33 / S-Z / VFILER43.LBR / VFCMDS1.LZB / VFCMDS1.LIB
Text File  |  2000-06-30  |  13KB  |  630 lines

  1. ;===========================================================================
  2. ;
  3. ; VFCMDS1.Z80 -- Command Branch Tables, Screen Display Commands, and
  4. ;         File-Pointer Movement Commands
  5. ;
  6. ;===========================================================================
  7.  
  8.  
  9. ; CTABLE - Command Table
  10.  
  11. ; The command branch table entries have the form:
  12. ;    db    character to recognize
  13. ;    db    wheel flag (0ff = any user / 00 = wheel only)
  14. ;    dw    address of code to perform function
  15.  
  16. ctable:
  17.     db    0        ; User cursor positioning
  18.     db    0ffh        ; (safe)
  19.     dw    up
  20.  
  21.     db    0
  22.     db    0ffh        ; (safe)
  23.     dw    down
  24.  
  25.     db    0
  26.     db    0ffh        ; (safe)
  27.     dw    forward
  28.  
  29.     db    0
  30.     db    0ffh        ; (safe)
  31.     dw    reverse
  32.  
  33. ctab1:
  34.         ; Ring top and bottom
  35.  
  36.     db    ctrlb        ; Jump to bottom of ring
  37.     db    0ffh        ; (safe)
  38.     dw    ringbot
  39.  
  40.     db    ctrlt        ; Jump to top of ring
  41.     db    0ffh        ; (safe)
  42.     dw    ringtop
  43.  
  44.         ; Screen top and bottom
  45.  
  46.     db    ctrlc
  47.     db    0ffh        ; (safe)
  48.     dw    locbot        ; Jump to bottom of screen
  49.  
  50.     db    ctrlr
  51.     db    0ffh        ; (safe)
  52.     dw    loctop        ; Jump to top of screen
  53.  
  54.         ; Vertical cursor movement
  55.  
  56.     db    ctrle
  57.     db    0ffh        ; (safe)
  58.     dw    up
  59.  
  60.     db    ctrlx
  61.     db    0ffh        ; (safe)
  62.     dw    down
  63.  
  64.         ; Next file
  65.  
  66.     db    ctrld
  67.     db    0ffh        ; (safe)
  68.     dw    forward
  69.  
  70.     db    cr        ; Nop
  71.     db    0ffh        ; (safe)
  72.     dw    forward
  73.  
  74.     db    ' '        ; Go forward
  75.     db    0ffh        ; (safe)
  76.     dw    forward
  77.  
  78.         ; Previous file
  79.  
  80.     db    ctrls
  81.     db    0ffh        ; (safe)
  82.     dw    reverse
  83.  
  84.     db    bs        ; Back up?
  85.     db    0ffh        ; (safe)
  86.     dw    reverse
  87.  
  88.         ; Next screen
  89.  
  90.     db    '+'        ; Jump forward
  91.     db    0ffh        ; (safe)
  92.     dw    jumpf
  93.  
  94.     db    ctrlf
  95.     db    0ffh
  96.     dw    jumpf
  97.  
  98.     db    '.'
  99.     db    0ffh        ; (safe)
  100.     dw    jumpf
  101.  
  102.     db    '>'
  103.     db    0ffh        ; (safe)
  104.     dw    jumpf
  105.  
  106.         ; Previous screen
  107.  
  108.     db    '-'        ; Jump backward
  109.     db    0ffh        ; (safe)
  110.     dw    jumpb
  111.  
  112.     db    ctrla
  113.     db    0ffh
  114.     dw    jumpb
  115.  
  116.     db    ','
  117.     db    0ffh        ; (safe)
  118.     dw    jumpb
  119.  
  120.     db    '<'
  121.     db    0ffh        ; (safe)
  122.     dw    jumpb
  123.  
  124.         ; Non-cursor commands
  125.  
  126.     db    'A'        ; Alphabetize?
  127.     db    0ffh        ; (safe)
  128.     dw    alphasw
  129.  
  130.     db    'C'        ; Copy a file?
  131.     db    0        ; (wheel)
  132.     dw    fcopy
  133.  
  134.     db    'D'        ; Delete a file?
  135.     db    0        ; (wheel)
  136.     dw    fdel
  137.  
  138.     db    'F'        ; Show file size?
  139.     db    0ffh        ; (safe)
  140.     dw    fsize
  141.  
  142.     db    'G'        ; Group operation?
  143.     db    0ffh        ; (safe)
  144.     dw    group$op
  145.  
  146.     db    'J'        ; Jump to a file?
  147.     db    0ffh        ; (safe)
  148.     dw    goto
  149.  
  150.     db    'M'        ; Group operation?
  151.     db    0        ; (wheel)
  152.     dw    move        ; Move files
  153.  
  154.     db    'P'        ; Output file to 'list' device?
  155.     db    0        ; (wheel)
  156.     dw    flist
  157.  
  158.     db    'Q'        ; Unsqueeze a file?
  159.     db    0        ; (wheel)
  160.     dw    fusq
  161.  
  162.     db    'R'        ; Rename?
  163.     db    0        ; (wheel)
  164.     dw    rename
  165.  
  166.     db    'T'        ; If tag, put tagch in..
  167.     db    0ffh        ; (safe)
  168.     dw    tag        ; Front of cursor.
  169.  
  170.     db    'U'        ; Remove tagch from..
  171.     db    0ffh        ; (safe)
  172.     dw    untag        ; In front of cursor?
  173.  
  174.     db    'V'        ; 'view' file at console?
  175.     db    0ffh        ; (safe)
  176.     dw    fview
  177.  
  178.     db    'W'        ; Wild card tag/untag?
  179.     db    0ffh        ; (safe)
  180.     dw    wtag
  181.  
  182.     db    'Y'        ; Retag
  183.     db    0ffh        ; (safe)
  184.     dw    yank
  185.  
  186. ;---------------------------------------------------------------------------
  187.  
  188. ; Commands available with ring empty
  189.  
  190. ctab2:
  191.     db    'E'        ; Screen refresh?
  192.     db    0ffh        ; (safe)
  193.     dw    runsh4
  194.  
  195.     db    'H'        ; External help?
  196.     db    0ffh        ; (safe)
  197.     dw    exthelp
  198.  
  199.     db    'N'        ; New directory/mask?
  200.     db    0ffh        ; (safe)
  201.     dw    logdir
  202.  
  203.      if    optcmd        ; Optional command for setting options
  204.     db    'O'
  205.     db    0ffh        ; (safe)
  206.     dw    setopt        ; Set options
  207.      endif    ;optcmd
  208.  
  209.     db    'S'        ; Free bytes on..
  210.     db    0ffh        ; (safe)
  211.     dw    dstat        ; Requested drive?
  212.  
  213.     db    'X'        ; If exit, then to opsys
  214.     db    0ffh        ; (safe)
  215.     dw    os$ccp
  216.  
  217.     db    esc        ; Escape also exits
  218.     db    0ffh
  219.     dw    os$ccp
  220.  
  221.     db    'Z'        ; Run zcpr3 command
  222.     db    0ffh        ; (safe)
  223.     dw    runzcpr3
  224.  
  225.     db    dircmd        ; New directory/mask? (alternate)
  226.     db    0ffh        ; (safe)
  227.     dw    logdir
  228.  
  229.      if    bihelp        ; Built-in help?
  230.  
  231.     db    '?'        ; Help
  232.     db    0ffh        ; (safe)
  233.     dw    help
  234.  
  235.     db    '/'        ; Help also
  236.     db    0ffh        ; (safe)
  237.     dw    help
  238.  
  239.      else
  240.  
  241.     db    '?'        ; Help
  242.     db    0ffh        ; (safe)
  243.     dw    exthelp
  244.  
  245.     db    '/'        ; Help also
  246.     db    0ffh        ; (safe)
  247.     dw    exthelp
  248.  
  249.      endif            ; Bihelp
  250.  
  251.     db    0        ; End of table
  252.  
  253. ;---------------------------------------------------------------------------
  254.  
  255. ; Screen Display Commands: previous-screen (-), next-screen (+),
  256. ;               alphabetization (A)
  257.  
  258.  
  259. ; * * *  COMMAND: - (Previous Screen)
  260.  
  261. jumpb:
  262.     ld    hl,(ringcnt)    ; Get # files in ring.
  263.     ld    de,eps        ; And maximum number that can be displayed.
  264.     call    cmpdehl
  265.     jp    nc,loop        ; Done if all files will be displayed.
  266.  
  267.     ld    hl,curhome    ; Set cursor home
  268.     ld    (curat),hl
  269.     ld    hl,(ring)    ; At front?
  270.     ex    de,hl
  271.     ld    hl,(locbeg)
  272.     call    cmpdehl
  273.     jr    z,jumpbw    ; Back up and wrap around
  274.     ld    (locend),hl    ; Old beginning is new end
  275.     ld    de,-eps*eltsiz    ; Back up one full screen
  276.     add    hl,de
  277.     ld    (locbeg),hl    ; New beginning
  278.     ld    (ringpos),hl    ; New position
  279.     jp    runsh4
  280.  
  281. jumpbw:
  282.     ld    hl,(locbeg)    ; At first screen?
  283.     ex    de,hl
  284.     ld    hl,(ring)    ; Pt to first element of ring
  285.     call    cmpdehl
  286.     jr    z,jbw0        ; Advance to end
  287.     ld    hl,-eps*eltsiz    ; Back up
  288.     add    hl,de        ; First element of new local ring
  289.     jr    jfw0
  290.  
  291. jbw0:
  292.     ld    de,eps*eltsiz    ; Pt to next screen
  293.     add    hl,de
  294.     ex    de,hl
  295.     ld    hl,(ringend)
  296.     call    cmpdehl
  297.     ex    de,hl
  298.     jr    z,jbw1
  299.     jr    c,jbw0
  300.  
  301. jbw1:
  302.     ld    de,-eps*eltsiz
  303.     add    hl,de        ; Pt to first element of new local ring
  304.     jr    jfw0
  305.  
  306.  
  307. ; * * *  COMMAND: + (Next Screen)
  308.  
  309. jumpf:
  310.     ld    hl,(ringcnt)    ; Get # files in ring.
  311.     ld    de,eps        ; And maximum number that can be displayed.
  312.     call    cmpdehl
  313.     jp    nc,loop        ; Done if all files will be displayed.
  314.     ld    hl,curhome    ; Set cursor to home
  315.     ld    (curat),hl
  316.     ld    hl,(locend)    ; See if local end <= ring end
  317.     ex    de,hl
  318.     ld    hl,(ringend)
  319.     call    cmpdehl
  320.     jr    z,cmdloop
  321.     ld    hl,(locend)    ; New screen starting at locend
  322.  
  323. ; JFW0 - Reset RING Position to HL
  324.  
  325. jfw0:
  326.     call    setscr1        ; Reset ringpos on ...
  327.     jp    runsh4
  328.  
  329. ; CMDLOOP - Reset to Beginning of RING and Resume Command Looping
  330.  
  331. cmdloop:
  332.     call    setscr        ; Reset all screen pointers
  333.     jp    runsh4
  334.  
  335.  
  336. ;---------------------------------------------------------------------------
  337.  
  338.  
  339. ; File-Pointer Movement Commands: J (jump), ^R, ^C, ^T, ^B, SP, CR, ^D, ^F,
  340. ;                  BS, ^S, ^A, up-arrow, down-arrow
  341.  
  342.  
  343. ; * * * COMMAND: J
  344.  
  345. goto:
  346.     call    cprmpt        ; Entry point for 'J' command
  347.     db    'Jump to Filename: ',0
  348.     ld    de,d$fcb    ; Pt to fcb
  349.     call    filename    ; Get file name & init fcb.
  350.     ld    hl,d$fcb+1    ; Replace blanks in fcb by '?'
  351.     ld    c,'?'
  352.     ld    b,11        ; Scan 11 characters
  353. goto0:
  354.     ld    a,(hl)        ; Get present character
  355.     cp    ' '        ; Is it a space?
  356.     jr    nz,goto0a    ; If not, skip
  357.     ld    (hl),c        ; Otherwise, replace by '?'
  358. goto0a:
  359.     inc    hl        ; Advance to next character
  360.     djnz    goto0
  361.  
  362. goto1:
  363.     ld    hl,(ringpos)    ; Old ring position
  364.     ld    (sringpos),hl    ; Save it in case of error
  365.     ld    hl,(ring)    ; Beginning of ring
  366.     ld    de,-eltsiz
  367.     add    hl,de        ; Back up one
  368.     ld    (ringpos),hl
  369.     call    clrcur        ; Clear the cursor for a start
  370.     ld    hl,(locbeg)    ; Get local beginning
  371.     push    hl        ; Save it on the stack
  372. got0:
  373.     ld    hl,(ringpos)
  374.     ld    de,eltsiz    ; One element
  375.     add    hl,de        ; Next
  376.     ld    (ringpos),hl
  377.     ex    de,hl        ; Ring pointer to DE
  378.     ld    hl,(ringend)
  379.     call    cmpdehl        ; End of ring?
  380.     jr    z,goterr    ; Yes, quit
  381.     ld    hl,d$fcb    ; User's filespec
  382.     call    fmatch        ; Do we have a match?
  383.     jr    nz,got0        ; No, try again
  384.  
  385. ; We found it
  386.  
  387.     call    findscr        ; Set LOCBEG and CURAT according to RINGPOS
  388.     ld    hl,(locbeg)    ; New beginning
  389.     pop    de        ; Old beginning
  390.     call    cmpdehl        ; Same?
  391.     jr    nz,gotex0    ; Rebuild the screen if not
  392.     ld    a,(initflag)    ; See if this is initial setup
  393.     or    a
  394.     jr    z,gotex        ; If not, skip rebuild
  395. gotex0:
  396.     call    rebuild
  397. gotex:
  398.     xor    a        ; Reset initflag
  399.     ld    (initflag),a
  400.     call    setcur        ; Display the cursor
  401.     jp    loopfn        ; Display current file and get next command
  402. goterr:
  403.     pop    hl        ; Adjust stack
  404.     ld    hl,(sringpos)    ; Get saved ring position
  405.     ld    (ringpos),hl    ; Restore old ring position
  406.     ld    a,(initflag)    ; Is this initial pointer setting
  407.     or    a        ; ..a program startup?
  408.     call    z,fnf1        ; If not, say we can't find file
  409.     jr    gotex0        ; Rebuild and quit
  410.  
  411.  
  412. ; * * *  COMMAND: - ^R  Jump to beginning of local screen
  413.  
  414. loctop:
  415.     call    clrcur        ; Clear the cursor
  416.     ld    hl,(locbeg)    ; First entry of this screen
  417.     ld    (ringpos),hl    ; New ring position
  418.     call    cur$first    ; Position the cursor
  419.     call    setcur        ; Print it
  420.     jp    loopfn        ; Print new current file and continue
  421.  
  422.  
  423. ; * * *  COMMAND: - ^C  Jump to end of local screen
  424.  
  425. locbot:
  426.     call    clrcur        ; Clear the cursor
  427.     call    cur$last    ; Position the cursor
  428.     call    setcur        ; Print it
  429.     ld    hl,(locend)    ; End of current screen
  430.     ld    de,-eltsiz    ; Element size
  431.     add    hl,de        ; Back up to last
  432.     ld    (ringpos),hl    ; New ring position
  433.     jp    loopfn        ; Print new current file and continue
  434.  
  435.  
  436. ; * * *  COMMAND: - ^T  Jump to beginning of ring
  437.  
  438. ringtop:
  439.     call    clrcur        ; Clear cursor
  440.     ld    hl,(locbeg)    ; Current beginning
  441.     push    hl        ; Save it
  442.     ld    hl,(ring)    ; Beginning of ring
  443.     ld    (ringpos),hl    ; New ring position
  444.     call    findscr        ; Set LOCBEG
  445.     ld    hl,(locbeg)    ; (New?) beginning
  446.     pop    de        ; Old beginning
  447.     call    cmpdehl        ; Same?
  448.     call    nz,rebuild    ; No
  449. ringtx:
  450.     call    setcur        ; Print it
  451.     jp    loopfn        ; Print new current file and continue
  452.  
  453.  
  454. ; * * *  COMMAND: - ^B  Jump to end of ring
  455.  
  456. ringbot:
  457.     call    clrcur        ; Clear the cursor
  458.     ld    hl,(locend)    ; Current end
  459.     push    hl        ; Save it
  460.     ld    hl,(ringend)    ; End of the ring
  461.     ld    de,-eltsiz    ; One element
  462.     add    hl,de        ; Back up
  463.     ld    (ringpos),hl    ; New ring position
  464.     call    findscr        ; Find new screen
  465.     ld    hl,(locend)    ; New LOCEND
  466.     pop    de        ; Old locend
  467.     call    cmpdehl        ; Same screen?
  468.     call    nz,rebuild    ; No
  469. ringbx:
  470.     call    setcur        ; Print it
  471.     jp    loopfn        ; Print new current file and continue
  472.  
  473.  
  474. ; * * *  COMMAND: SP, CR, ^D, ^F
  475.  
  476. forward:
  477.     call    clrcur        ; Clear cursor
  478.     call    for0        ; Position on screen and in ring
  479.     call    setcur        ; Set cursor
  480.     jp    loopfn
  481.  
  482.  
  483. ; * * *  COMMAND: BS, ^S, ^A
  484.  
  485. reverse:
  486.     call    clrcur        ; Clear cursor
  487.     call    rev0        ; Position on screen and in ring
  488.     call    setcur        ; Set cursor
  489.     jp    loopfn
  490.  
  491.  
  492. ; * * *  COMMAND: Up-Arrow
  493.  
  494. up:
  495.     call    clrcur        ; Clear cursor
  496.     call    toc        ; Top of column?
  497.     jr    c,up2        ; Wrap around
  498.     ld    b,fcols        ; Back up 4 or 5 entries
  499.  
  500. up1:
  501.     push    bc        ; Save count
  502.     call    rev0        ; Back up in ring and on screen (no print)
  503.     pop    bc        ; Get count
  504.     djnz    up1
  505.     jr    down1a        ; Set cursor and quit
  506.  
  507. up2:
  508.     call    boc        ; Bottom of column?
  509.     jr    c,up3        ; Yes
  510.     ld    (ringpos),hl    ; New ring position
  511.     ld    hl,(curat)    ; Advance cursor
  512.     inc    h        ; Next line
  513.     ld    (curat),hl
  514.     jr    up2
  515.  
  516. ; Top of column check (return carry if at top, return new ring position in DE)
  517.  
  518. toc:
  519.     ld    hl,(ringpos)    ; See if wrap around
  520.     ld    de,-eltsiz*fcols ; 4 or 5 entries
  521.     add    hl,de
  522.     ex    de,hl
  523.     ld    hl,(locbeg)    ; Beginning of local screen
  524.     call    cmpdehl
  525.     ret
  526.  
  527. ; Bottom of column check (return carry if at bottom, HL with new ring position)
  528.  
  529. boc:
  530.     ld    hl,(ringpos)    ; Current position
  531.     ld    de,eltsiz*fcols
  532.     add    hl,de        ; Down 1
  533.     ld    de,(locend)
  534.     dec    de        ; Ensure carry if at or past end
  535.     call    cmpdehl
  536.     ret
  537.  
  538. up3:
  539.     call    rev0        ; Move back one column
  540.     call    boc        ; Check if bottom of this column
  541.     jr    c,down1a    ; Yes, quit.  Else fall DOWN
  542.  
  543.  
  544. ; * * *  COMMAND: Down-Arrow
  545.  
  546. down:
  547.     call    clrcur        ; Clear cursor
  548.     call    boc        ; Bottom of column?
  549.     jr    c,down2        ; Wrap around
  550.     ld    b,fcols        ; Forward 4 or 5 entries
  551.  
  552. down1:
  553.     push    bc        ; Save count
  554.     call    for0        ; Advance in ring and on screen (no print)
  555.     pop    bc        ; Get count
  556.     djnz    down1
  557.  
  558. down1a:
  559.     call    setcur        ; Set cursor
  560.     jp    loopfn        ; Display current file and LOOP
  561.  
  562. down1b:
  563.     ld    hl,(curat)    ; Current cursor
  564.     ld    a,l        ; Column to A
  565.     add    a,entsiz    ; One entry
  566.     cp    entsiz*[fcols-1]+2 ; Last column?
  567.     ld    b,1        ; Just in case
  568.     jr    c,down1        ; Move forward one position, else..
  569.     ld    hl,(locbeg)    ; Beginning of local screen..
  570.     ld    (ringpos),hl    ; To ring position and..
  571.     call    cur$first    ; Cursor to top left
  572.     jr    down1a        ; Quit
  573.  
  574. ; Move to top of current column
  575.  
  576. down2:
  577.     call    toc        ; Top of column?
  578.     jr    c,down1b    ; Yes
  579.     ex    de,hl        ; New ring position
  580.     ld    (ringpos),hl
  581.     ld    hl,(curat)    ; Current cursor
  582.     dec    h        ; Up one
  583.     ld    (curat),hl
  584.     jr    down2        ; Try again
  585.  
  586. ; FOR0 - advance routine
  587.  
  588. for0:
  589.     ld    hl,(ringpos)    ; At end of loop yet?
  590.     ld    de,eltsiz    ; I.e., will we be at end of loop?
  591.     add    hl,de
  592.     ex    de,hl
  593.     ld    hl,(locend)
  594.     call    cmpdehl        ; Compare 'present' to 'end'
  595.     jr    nz,forw        ; To next print position
  596.     call    cur$first    ; Position cursor
  597.     ld    hl,(locbeg)    ; Set position pointer to beginning and..
  598.     ld    (ringpos),hl
  599.     ret
  600.  
  601. forw:
  602.     ld    hl,(ringpos)    ; Advance in ring
  603.     ld    de,eltsiz
  604.     add    hl,de
  605.     ld    (ringpos),hl    ; New position
  606.     jp    psn$next    ; Position cursor
  607.  
  608. ; REV0 - Back Up Routine
  609.  
  610. rev0:
  611.     ld    hl,(locbeg)
  612.     ex    de,hl
  613.     ld    hl,(ringpos)    ; See if at beginning of ring
  614.     call    cmpdehl
  615.     jr    nz,rev1        ; Skip position pointer reset if not..
  616.     call    psn$last    ; End of local ring
  617.     ld    hl,(locend)    ; Set to end +1 to backup to end
  618.     ld    de,-eltsiz
  619.     add    hl,de
  620.     ld    (ringpos),hl
  621.     ret
  622.  
  623. rev1:
  624.     call    psn$back    ; Back up 1
  625.     ld    hl,(ringpos)
  626.     ld    de,-eltsiz    ; One ring position..
  627.     add    hl,de        ; Backwards.
  628.     ld    (ringpos),hl
  629.     ret
  630.