home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / zcpr33 / vfiler43.lbr / VFSUBS4.LZB / VFSUBS4.LIB
Encoding:
Text File  |  1987-09-09  |  12.9 KB  |  716 lines

  1. ;===========================================================================
  2. ;
  3. ; VFSUBS4.Z80 - General Screen Output Routines
  4. ;
  5. ;===========================================================================
  6.  
  7. ; PRTSPAC - Print spaces - Reg B had number of spaces
  8.  
  9. prtspac:
  10.     inc    b        ; Test for B = 0
  11.     dec    b
  12.     ret    z
  13.     push    af        ; Save AF just in case
  14.     ld    a,' '
  15. prtspac1:
  16.     call    cout
  17.     djnz    prtspac1
  18.     pop    af
  19.     ret
  20.  
  21. ;---------------------------------------------------------------------------
  22.  
  23. ; Video Routines
  24.  
  25. ; VCLS - Clear Screen
  26.  
  27. vcls:
  28.     call    cls        ; Try to clear the screen
  29.     ret    nz        ; Ok if done
  30.     push    hl        ; Save regs
  31.     push    bc
  32.     call    getcrt        ; Get crt data
  33.     inc    hl        ; Get number of lines on screen
  34.     ld    b,(hl)        ; B=number of lines
  35. vcls1:
  36.     call    crlf        ; New line
  37.     djnz    vcls1
  38.     pop    bc        ; Restore regs
  39.     pop    hl
  40.     ret
  41.  
  42.  
  43. ; VEREOL - Erase To End-of-Line
  44.  
  45. vereol:
  46.     call    ereol        ; Try to erase to eol
  47.     ret    nz        ; Ok if done
  48.     push    bc        ; Save count
  49.     ld    a,' '        ; Space out
  50.     call    vereol1        ; Send b spaces
  51.     pop    bc        ; Get count
  52.     ld    a,bs        ; Backspace in
  53. vereol1:
  54.     call    cout        ; Send char
  55.     djnz    vereol1        ; Count down
  56.     ret
  57.  
  58. ;---------------------------------------------------------------------------
  59.  
  60. ; PRDU - Print DU in HL
  61.  
  62. prdu:
  63.     push    hl        ; Save regs
  64.     push    bc
  65.  
  66.      if    revvideo
  67.     call    stndout        ; Dim
  68.      endif
  69.  
  70.     ld    a,h        ; Get drive
  71.     add    a,'A'        ; Convert to letter
  72.     call    cout
  73.     ld    a,l        ; Get user
  74.     ld    b,h        ; Get du in bc
  75.     ld    c,l
  76.     call    pafdc        ; Print user as floating
  77.     ld    a,':'        ; Print colon
  78.     call    cout
  79.     call    dutdir        ; Scan named directory table
  80.     jr    z,prdu2        ; No name?
  81.     ld    b,8        ; Print name
  82. prdu1:
  83.     ld    a,(hl)        ; Get char
  84.     cp    ' '        ; Done if space encountered
  85.     jr    z,prdu3
  86.     call    cout
  87.     inc    hl
  88.     djnz    prdu1
  89.     jr    prdu3
  90.  
  91. prdu2:
  92.     call    vprint
  93.     db    'Noname',0
  94. prdu3:
  95.      if    revvideo
  96.     call    stndend        ; Bright
  97.      endif
  98.  
  99.     pop    bc        ; Restore regs
  100.     pop    hl
  101.     ret
  102.  
  103. ;---------------------------------------------------------------------------
  104.  
  105. ; File Name Printing Routines
  106.  
  107.  
  108. ; DISPCFN - Display file name of current file
  109.  
  110. dispcfn:
  111.     call    ringempt    ; Check ring empty
  112.     ret    z        ; Don't bother
  113.  
  114.      if    fcols eq 5
  115.     ld    hl,fnadr    ; Position cursor for file name print
  116.      else    ; four columns
  117.     ld    hl,fnadr-1    ; One position more to left
  118.      endif
  119.  
  120.     call    gotoxy
  121.     ld    hl,(ringpos)    ; Pt to current file name
  122.     inc    hl        ; Pt to first char
  123.  
  124.      if    revvideo
  125.  
  126.     call    stndout
  127.     call    prfn
  128.     jp    stndend
  129.  
  130.      else
  131.  
  132.     jr    prfn        ; Print file name
  133.  
  134.      endif    ; revvideo
  135.  
  136.  
  137. ; PRFNS - Print File Name Pointed to by HL (saving HL)
  138.  
  139. prfnsx:
  140.     push    hl        ; Save hl
  141.     jr    prfns0
  142.  
  143. ; PRFNSX - Print file name in S$FCB (saving HL)
  144.  
  145. prfns:
  146.     push    hl        ; Affect only psw
  147.     ld    hl,s$fcb+1
  148.  
  149. prfns0:
  150.     push    bc        ; Save bc
  151.     call    prfnskip    ; Print file name with no spaces
  152.     pop    bc        ; Restore
  153.     pop    hl
  154.     ret
  155.  
  156.  
  157. ; PRFN - Print file name pted to by HL
  158.  
  159. prfn:
  160.     xor    a        ; Preset for no char skipping
  161.     jr    prfnsk
  162.  
  163. prfnskip:
  164.     ld    a,' '        ; Preset for skipping spaces
  165.  
  166. prfnsk:
  167.     ld    c,a        ; Save char to skip in C
  168.     ld    b,8        ; 8 chars
  169.     call    prfns1
  170.     ld    a,'.'
  171.     call    cout
  172.     ld    b,3        ; File type and fall thru
  173.  
  174. prfns1:
  175.     ld    a,(hl)        ; Get char
  176.     and    7fh
  177.     cp    c        ; Is it char to skip?
  178.     call    nz,cout
  179.     inc    hl        ; Pt to next
  180.     djnz    prfns1
  181.     ret
  182.  
  183. ;---------------------------------------------------------------------------
  184.  
  185. ; PRINT$FRE - Print free space on disk
  186.  
  187. print$fre:
  188.     call    erclr        ; Position and set flags
  189.     ld    hl,(disksp)
  190.     call    shlfdc        ; # of free k-bytes in hl
  191.     call    vprint
  192.     db    'K Bytes free on Disk '
  193. free$drv:
  194.     db    'X:',0
  195.     ret
  196.  
  197. ;---------------------------------------------------------------------------
  198.  
  199. ; File Screen Display Routines
  200.  
  201.  
  202. ; REBUILD - Build Entire Screen
  203.  
  204. rebuild:
  205.     ld    hl,(curat)    ; Save cursor and ring positions
  206.     ld    (scurat),hl
  207.     ld    hl,(ringpos)
  208.     ld    (sringpos),hl
  209.     call    banner        ; Print banner
  210.     call    dirmore        ; Print current du:dir (and '[more files]' msg).
  211.  
  212.      if    bihelp        ; Built-in help?
  213.     ld    a,(helpdisp)    ; Display help?
  214.     or    a        ; 0=no
  215.     jr    z,reb1
  216.     call    helpmsg        ; Print help message
  217.     jr    reb2
  218. reb1:
  219.      endif            ; Bihelp
  220.  
  221.     call    cur$first    ; Position cursor at first position
  222.     ld    hl,(locbeg)    ; Pt to first file name
  223.     call    dispfiles    ; Display files
  224.     call    cur$first    ; Re-position cursor at first position
  225. reb2:
  226.     ld    hl,cpmadr    ; Command prompt message
  227.     call    gotoxy
  228.     call    vprint        ; Prompt with drive prefix
  229.  
  230.      if    not revvideo
  231.     db    dim
  232.      endif
  233.  
  234.     db    'Command? ('
  235.     db    bright
  236.     db    '/'
  237.  
  238.      if    not revvideo
  239.     db    dim
  240.      endif
  241.  
  242.     db    '=',0
  243.  
  244.     ld    a,(helpdisp)    ; In help now?
  245.     or    a        ; 0=no
  246.     jr    z,reb3
  247.     call    vprint
  248.     db    'Files,',0
  249.     jr    reb4
  250.  
  251. reb3:
  252.     call    vprint
  253.     db    'Help,',0
  254.  
  255. reb4:
  256.     call    vprint
  257.     db    bright,' X'
  258.  
  259.      if    not revvideo
  260.     db    dim
  261.      endif
  262.  
  263.     db    '=Quit): ',bright,0
  264.  
  265. reb5:
  266.     ld    hl,(scurat)    ; Restore cursor and ring positions
  267.     ld    (curat),hl
  268.     ld    hl,(sringpos)
  269.     ld    (ringpos),hl
  270.     call    ringempt    ; Ring empty?
  271.     ret    z        ; No cursor
  272.     jp    setcur        ; Restore cursor on screen and return
  273.  
  274. ;------------------------------
  275.  
  276. ; REFRESH - Refresh Files Portion of Screen
  277.  
  278. refresh:
  279.     ld    hl,(curat)    ; Save cursor and ring positions
  280.     ld    (scurat),hl
  281.     ld    hl,(ringpos)
  282.     ld    (sringpos),hl
  283.     ld    hl,(ring)
  284.     ld    (ringpos),hl    ; Beginning of file display
  285.     call    dirmore        ; Print current du:dir (and '[more files]' msg).
  286.  
  287.      if    bihelp        ; Built-in help?
  288.     ld    a,(helpdisp)    ; Display help?
  289.     or    a        ; 1=yes
  290.     jr    nz,ref1
  291.      endif            ; Bihelp
  292.  
  293.     call    cur$first    ; Set cursor top left
  294.     ld    hl,(locbeg)    ; Beginning of current screen
  295.     call    dispfiles    ; Display files
  296. ref1:
  297.     ld    hl,(scurat)    ; Restore cursor and ring positions
  298.     ld    (curat),hl
  299.     ld    hl,(sringpos)
  300.     ld    (ringpos),hl
  301.     ret
  302.  
  303. ;------------------------------
  304.  
  305. ; BANNER - Print VFILER Banner
  306.  
  307. banner:
  308.     call    vcls        ; Clear screen
  309.  
  310.      if    fcols eq 5
  311.     ld    hl,banadr
  312.      else ; four columns
  313.     ld    hl,banadr-2    ; Two spaces to left
  314.      endif
  315.  
  316.     call    gotoxy
  317.     call    vprint        ; Print banner
  318.     db    'VFILER ',vers/10+'0','.',vers mod 10+'0'
  319.  
  320.      if    subvers eq ' '
  321.  
  322.     db    '  '
  323.  
  324.      else
  325.  
  326.     db    subvers
  327.      if    usestk
  328.     db    's'
  329.      else
  330.     db    'f'
  331.      endif    ; usestk
  332.  
  333.      endif    ; subvers eq ' '
  334.  
  335.     db    '   '
  336.  
  337.      if    not revvideo
  338.     db    dim
  339.      endif
  340.  
  341.     db    'Current File:',bright,0
  342.     ret
  343.  
  344. ;------------------------------
  345.  
  346. ; DIRMORE - Print Current Directory (and Possibly '[More Files]') messages
  347.  
  348. dirmore:
  349.      if    fcols eq 5
  350.     ld    hl,duadr    ; Du screen address
  351.      else    ; four columns
  352.     ld    hl,duadr+2    ; Two columns to right
  353.      endif
  354.  
  355.     call    gotoxy
  356.     ld    hl,(du$req)    ; Get current du
  357.     call    prdu        ; Print du:dir>
  358.  
  359.     call    public
  360.     jr    z,dirmr0    ; Not public
  361.     call    vprint
  362.     db    ' [PUBLIC]',0
  363.  
  364. dirmr0:
  365.      if    fcols eq 5
  366.     ld    hl,moreadr    ; More screen address
  367.      else    ; four columns
  368.     ld    hl,moreadr-1    ; One column more to left
  369.      endif
  370.  
  371.     call    gotoxy
  372.     ld    hl,(ringcnt)    ; Get # files in ring.
  373.     ld    de,eps        ; And maximum number that can be displayed.
  374.     call    cmpdehl
  375.     jr    nc,dirmr1    ; Br if all files will be displayed.
  376.     call    vprint
  377.  
  378.      if    revvideo
  379.     db    '[More Files]',0
  380.      else    ; dimvideo
  381.     db    dim,'[More Files]',bright,0
  382.      endif
  383.  
  384.     ret
  385.  
  386. dirmr1:
  387.     call    vprint
  388.     db    bright,0
  389.     ld    b,12        ; Print 12 spaces
  390.     jp    prtspac        ; And return
  391.  
  392. ;------------------------------
  393.  
  394. ; DISPFILES - Refresh File Display
  395.  
  396. dispfiles:
  397.     ld    (locpos),hl    ; Save local position
  398. dspf1:
  399.     ld    hl,(locend)    ; At end?
  400.     ex    de,hl
  401.     ld    hl,(locpos)
  402.     call    cmpdehl
  403.     ret    z        ; Return if done.
  404.  
  405.     call    vprint
  406.      if    fcols eq 4
  407.     db    '    ',0    ; 4 spaces
  408.      else
  409.     db    '  ',0        ; 2 spaces
  410.      endif
  411.  
  412.     push    hl        ; Save current local position in ring
  413.     call    reffnt        ; Print file name, tag.
  414.     pop    hl        ; Get current local position
  415.     ld    de,eltsiz
  416.     add    hl,de
  417.     ld    (locpos),hl
  418.     call    cur$next    ; Advance cursor
  419.     jr    dspf1
  420.  
  421. ;---------------------------------------------------------------------------
  422.  
  423. ; FINDSCR - Find screen containing file at RINGPOS
  424. ;   Set the screen accordingly and position cursor
  425.  
  426. findscr:
  427.     ld    hl,(ring)    ; Begin at the beginning
  428. fndscr1:
  429.     push    hl        ; Maybe this is it, save it
  430.     ld    de,eps*eltsiz    ; One screen
  431.     add    hl,de        ; Next screen
  432.     ld    de,(ringpos)
  433.     call    cmpdehl
  434.     jr    c,fndscr2    ; Found it
  435.     pop    de        ; Adjust the stack
  436.     jr    fndscr1        ; Try again
  437. fndscr2:
  438.     pop    hl        ; Beginning of this screen
  439.     call    setscr2        ; Set LOCBEG and LOCEND
  440.  
  441. ; Position cursor at RINGPOS
  442.  
  443.     ld    hl,curhome
  444.     ld    (curat),hl    ; First position
  445.     ld    hl,(locbeg)
  446. fndnxt:
  447.     ld    de,(ringpos)
  448.     call    cmpdehl
  449.     ret    z        ; We are there
  450.     ld    de,eltsiz    ; One element length
  451.     add    hl,de
  452.     push    hl
  453.     call    psn$next    ; Advance cursor
  454.     pop    hl
  455.     jr    fndnxt        ; Try again..
  456.  
  457.  
  458. ; SETSCR - Setup Screen Display Variables
  459.  
  460. setscr:
  461.     ld    hl,curhome    ; Set cursor home
  462.     ld    (curat),hl
  463.     ld    hl,(ring)    ; Set ring position
  464.  
  465. ; Entry to Reset Ring Position at HL
  466.  
  467. setscr1:
  468.     ld    (ringpos),hl
  469.  
  470. ; Entry to Reset Local Ring Position at HL
  471.  
  472. setscr2:
  473.     ld    (locbeg),hl    ; Front of ring
  474.     ld    de,eps*eltsiz    ; New end?
  475.     add    hl,de
  476.     ld    de,(ringend)    ; End of ring
  477.     call    cmpdehl
  478.     jr    nc,setscr3
  479.     ex    de,hl
  480. setscr3:
  481.     ld    (locend),hl
  482.     ret
  483.  
  484. ;---------------------------------------------------------------------------
  485.  
  486. ; CUR Subroutines to position the cursor
  487.  
  488.  
  489. ; CUR$FIRST - Home the Cursor
  490.  
  491. cur$first:
  492.     ld    hl,curhome    ; Home address
  493.     ld    (curat),hl    ; Set cursor position
  494.     jp    gotoxy
  495.  
  496.  
  497. ; CUR$LAST - Move Cursor to Last File Position
  498.  
  499. cur$last:
  500.     call    psn$last    ; Position cursor
  501. cur$new:
  502.     ld    hl,(curat)    ; Set new cursor position
  503.     jp    gotoxy
  504.  
  505.  
  506. ; CUR$NEXT - Move Cursor to Next File Position
  507.  
  508. cur$next:
  509.     call    psn$next    ; Position cursor
  510.     jr    cur$new        ; Set new cursor position
  511.  
  512.  
  513. ; CUR$BACK - Move Cursor to Previous File Position
  514.  
  515. cur$back:
  516.     call    psn$back    ; Position cursor
  517.     jr    cur$new        ; Set new cursor position
  518.  
  519.  
  520. ; CUR$DOW - Move Cursor Down a File Position
  521.  
  522. cur$down:
  523.     call    psn$down    ; Position cursor
  524.     jr    cur$new        ; Set new cursor position
  525.  
  526.  
  527. ; PSN Subroutines manipulate the CURAT value without moving cursor
  528.  
  529.  
  530. ; PSN$LAST - Set Last File Position
  531.  
  532. psn$last:
  533.     ld    hl,(ringpos)    ; Advance
  534. pl0:
  535.     ld    de,eltsiz
  536.     add    hl,de
  537.     ex    de,hl
  538.     ld    hl,(locend)    ; End of local ring?
  539.     call    cmpdehl
  540.     ret    z
  541.     call    psn$next    ; Advance cursor position.
  542.     ex    de,hl        ; Get position
  543.     jr    pl0
  544.  
  545.  
  546. ; PSN$NEXT - Advance the Cursor Position
  547.  
  548. psn$next:
  549.     ld    hl,(curat)    ; Compute new position
  550.     ld    a,l        ; Check for new line
  551.     add    a,entsiz    ; Size of each entry
  552.     cp    entsiz*[fcols-1]+2 ; Last column?
  553.     jr    nc,pn1        ; Advance to next line
  554.     ld    l,a        ; New position
  555.     ld    (curat),hl
  556.     ret
  557.  
  558. pn1:
  559.     ld    a,h        ; Get line
  560.     ld    hl,curhome    ; Get col
  561.     ld    h,a        ; Set line and continue with psn$down
  562.     ld    (curat),hl
  563.  
  564. ; PSN$DOWN - Move Cursor Position Down One Line
  565.  
  566. psn$down:
  567.     ld    hl,curhome    ; Get home address
  568.     ld    b,h        ; Line in b
  569.     ld    hl,(curat)    ; Get current address
  570.     inc    h        ; Move down
  571.     ld    a,h        ; Check for too far
  572.     sub    b
  573.     cp    eps/fcols
  574.     jr    c,pd1        ; Ok, so save position
  575.     ld    a,l        ; Get col
  576.     ld    hl,curhome
  577.     ld    l,a
  578. pd1:
  579.     ld    (curat),hl
  580.     ret
  581.  
  582. ; PSN$BACK - Back Up the Cursor Position
  583.  
  584. psn$back:
  585.     ld    de,curhome    ; Get home address
  586.     ld    hl,(curat)
  587.     call    cmpdehl        ; Compare
  588.     jr    z,psn$last    ; Goto end if last
  589.     ld    a,l        ; Check for first col
  590.     cp    e
  591.     jr    z,pb1
  592.     sub    entsiz        ; Back up one col
  593.     ld    l,a
  594.     ld    (curat),hl    ; New pos
  595.     ret
  596.  
  597. pb1:
  598.     ld    a,e        ; Get home col
  599.     add    a,entsiz*[fcols-1] ; Get last col
  600.     ld    l,a
  601.     dec    h        ; Prev line
  602.     ld    (curat),hl
  603.     ret
  604.  
  605. ; SETCUR - Position Cursor at CURAT
  606.  
  607. setcur:
  608.     ld    a,(helpdisp)    ; Nogo if help display is active.
  609.     or    a
  610.     ret    nz
  611.     ld    hl,(curat)
  612.     call    gotoxy
  613.     call    vprint
  614.  
  615.      if    revvideo
  616.  
  617.     db    dim
  618.      if    fcols eq 4
  619.     db    '-->',bright,' '
  620.      else    ; not fcols eq 4
  621.     db    '->',bright
  622.      endif    ; fcols eq 4
  623.  
  624.      else    ; not revvideo
  625.  
  626.      if    fcols eq 4
  627.     db    '--> '
  628.      else    ; not fcols eq 4
  629.     db    '->'
  630.      endif    ; fcols eq 4
  631.  
  632.      endif    ; revvideo
  633.  
  634.     db    0
  635.  
  636.     ret
  637.  
  638. ; CLRCUR - Clear Cursor
  639.  
  640. clrcur:
  641.     ld    a,(helpdisp)    ; Nogo if help display is active.
  642.     or    a
  643.     ret    nz
  644.     ld    hl,(curat)
  645.     call    gotoxy
  646.     call    vprint
  647.      if    fcols eq 4
  648.     db    '    ',0
  649.      else
  650.     db    '  ',0
  651.      endif
  652.     ret
  653.  
  654. ;---------------------------------------------------------------------------
  655.  
  656. ; Command Prompts and Messages
  657.  
  658.  
  659. ; CPRMPT - Command Prompt
  660.  
  661. cprmpt:
  662.     ld    hl,cpadr    ; Get command line cursor address
  663.     push    bc
  664.     ld    a,(cpecnt)    ; Get # chars to erase.
  665. mprint:
  666.     ld    b,a        ; In b.
  667.     push    hl        ; Save cursor address
  668.     call    gotoxy        ; Set cursor.
  669.     call    vereol        ; Erase to eol
  670.     pop    hl        ; Restore address
  671.     pop    bc
  672.     call    gotoxy        ; Position cursor
  673.     jp    vprint        ; Print message and return
  674.  
  675.  
  676. ; ERMSG - Error Message
  677.  
  678. ermsg:
  679.     ld    hl,eradr    ; Get error line cursor address
  680.     push    bc
  681.     ld    a,(erecnt)    ; Get # chars to erase.
  682.     jr    mprint        ; Print message.
  683.  
  684.  
  685. ; WORKMSG - Working Message
  686.  
  687. workmsg:
  688.     call    ermsg
  689.     db    dim,'Working ...',bright,' ',0
  690.     ret
  691.  
  692.  
  693. ; ERCLR - Clear Error Message
  694.  
  695. erclr:
  696.     ld    hl,eradr    ; Position cursor
  697.     call    gotoxy
  698.     push    bc
  699.     ld    a,(erecnt)    ; Get # chars to erase.
  700.     ld    b,a        ; In b.
  701.     call    vereol        ; Erase to eol
  702.     pop    bc
  703.     ret
  704.  
  705. ; ATCMD - Position at Command Prompt and Clear It
  706.  
  707. atcmd:
  708.     ld    hl,cpadr    ; Position cursor
  709.     call    gotoxy
  710.     push    bc
  711.     ld    a,(cpecnt)    ; Get # chars to erase.
  712.     ld    b,a        ; In b.
  713.     call    vereol        ; Clear message
  714.     pop    bc
  715.     ret
  716.