home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / z3sys / z33rcplt.lib < prev    next >
Encoding:
Text File  |  1993-06-08  |  5.4 KB  |  259 lines

  1.     page
  2.  
  3. ; RCP-LT.Z80
  4.  
  5. ;=============================================================================
  6. ;
  7. ;    L I S T    A N D    T Y P E    C O M M A N D S
  8. ;
  9. ;=============================================================================
  10.  
  11. ;Command: LIST
  12. ;Modified: August 20, 1989, Gene Pizzetta -- now filters control chars from
  13. ;    console output
  14. ;Function:  Print out specified file on the LST: Device
  15. ;Forms:
  16. ;    LIST <afn>    Print file (NO Paging)
  17. ;Notes:
  18. ;    The flags which apply to TYPE do not take effect with LIST
  19.  
  20.      if    liston
  21. list:
  22. ;
  23. ; CHECK FOR WHEEL APPROVAL IF OPTION ENABLED
  24.  
  25.  
  26.     call    retsave
  27.     ld    a,0ffh        ; Turn on printer flag
  28.     jr    type0
  29.      endif    ;liston
  30.  
  31. ;Command: TYPE
  32. ;Function:  Print out specified file on the CON: Device
  33. ;Forms:
  34. ;    TYPE <afn>    Print file
  35. ;    TYPE <afn> P    Print file with paging flag
  36. ;Notes:
  37. ;    The flag PGDFLG defines the letter which toggles the paging
  38. ;        facility (P in the forms section above)
  39. ;    The flag PGDFLT determines if TYPE is to page by default
  40. ;        (PGDFLT=TRUE if TYPE pages by default); combined with
  41. ;        PGDFLG, the following events occur --
  42. ;            If PGDFLT = TRUE, PGDFLG turns OFF paging
  43. ;            If PGDFLT = FALSE, PGDFLG turns ON paging
  44. ;
  45. type:
  46. ;
  47. ; CHECK FOR WHEEL APPROVAL IF OPTION ENABLED
  48. ;
  49. ;
  50.     call    retsave
  51.     xor    a        ; Turn off printer flag
  52. ;
  53. ; ENTRY POINT FOR CPR LIST FUNCTION (LIST)
  54. ;
  55. type0:
  56.      if    liston
  57.     ld    (prflg),a    ; Set flag
  58.      endif            ; Liston
  59.  
  60.     ld    a,(fcb2+1)    ; Get page flag
  61.     ld    (pgflg),a    ; Save it as a flag
  62.     ld    a,1        ; Select dir files
  63.     call    getdir        ; Allow ambiguous files (HL points to buffer)
  64.     jp    z,prfnf        ; No files
  65.     jr    typex2
  66.  
  67.                 ; Entry point for successive files
  68. typex:
  69.     ld    hl,(nxtfile)    ; Get ptr to next file
  70.     ld    a,(hl)        ; Any files?
  71.     or    a
  72.     jp    z,exit
  73.  
  74.      if    liston
  75.     ld    a,(prflg)    ; Check for list output
  76.     or    a        ; 0=type
  77.     jr    z,typex1
  78.     ld    a,cr        ; Bol on printer
  79.     call    lcout
  80.     ld    a,ff        ; Form feed the printer
  81.     call    lcout
  82.     jr    typex2
  83.      endif            ; Liston
  84.  
  85. typex1:
  86. ;    LDA    PAGCNT        ; If we've just done so,
  87.     push    hl
  88.     ld    hl,(pagcnt)
  89.     ld    a,(hl)
  90.     pop    hl
  91.     cp    nlines-2    ; Don't type another
  92.     call    nz,pagebreak    ; Page break message
  93. typex2:
  94.     ld    de,fcb1+1    ; Copy into fcb1
  95.     ld    b,11        ; 11 bytes
  96.     call    blkmov
  97.     ld    (nxtfile),hl    ; Set ptr to next file
  98.     call    initfcb1    ; Init fcb1
  99.     ld    c,15        ; Open file
  100.     call    bdos
  101.     inc    a        ; Set error flag
  102.     jp    z,prfnf        ; Abort if error
  103. ;    MVI    A,NLINES-2    ; Set line count
  104. ;    STA    PAGCNT
  105.     ld    hl,(pagcnt)
  106.     ld    (hl),nlines-2
  107.     ld    a,cr        ; New line
  108.     call    lcout
  109.     ld    a,lf
  110.     call    lcout
  111.     ld    bc,080h        ; Set char position and tab count
  112.                 ; (b=0=tab, c=080h=char position)
  113. ;
  114. ;  MAIN LOOP FOR LOADING NEXT BLOCK
  115. ;
  116. type2:
  117.     ld    a,c        ; Get char count
  118.     cp    80h
  119.     jr    c,type3
  120. ;    PUSH    H        ; Read next block
  121.     push    bc
  122.     ld    de,fcb1        ; Pt to fcb
  123.     ld    c,20        ; Read record
  124.     call    bdos
  125.     or    a        ; Set flags
  126.     pop    bc
  127. ;    POP    H
  128.     jr    nz,typex    ; End of file?
  129.     ld    c,0        ; Set char count
  130.     ld    hl,tbuff    ; Pt to first char
  131. ;
  132. ;  MAIN LOOP FOR PRINTING CHARS IN TBUFF
  133. ;
  134. type3:
  135.     ld    a,(hl)        ; Get next char
  136.     and    7fh        ; Mask out msb
  137.     cp    1ah        ; End of file (^z)?
  138.     jr    z,typex        ; Next file if so
  139. ;
  140. ; OUTPUT CHAR TO CON: OR LST: DEVICE WITH TABULATION
  141. ;
  142. type3x:    cp    cr        ; Reset tab count?
  143.     jr    z,type4
  144.     cp    lf        ; Reset tab count?
  145.     jr    z,type4
  146.     cp    tab        ; Tab?
  147.     jr    z,type5
  148.     cp    ' '        ; is it any other control char?
  149.     jr    c,type6        ; (yes, skip it)
  150. ;
  151. ;  OUTPUT CHAR AND INCREMENT CHAR COUNT
  152. ;
  153.     call    lcout        ; Output char
  154.     inc    b        ; Increment tab count
  155.     jr    type6
  156. ;
  157. ;  OUTPUT <CR> OR <LF> AND RESET TAB COUNT
  158. ;
  159. type4:
  160.     call    lcout        ; Output <cr> or <lf>
  161.     ld    b,0        ; Reset tab counter
  162.     jr    type6
  163. ;
  164. ;  TABULATE
  165. ;
  166. type5:
  167.     ld    a,' '        ; <sp>
  168.     call    lcout
  169.     inc    b        ; Incr pos count
  170.     ld    a,b
  171.     and    7
  172.     jr    nz,type5
  173. ;
  174. ; CONTINUE PROCESSING
  175. ;
  176. type6:
  177.     inc    c        ; Increment char count
  178.     inc    hl        ; Pt to next char
  179.     call    break        ; Check for abort
  180.     jp    z,typex        ; Skip
  181.     jr    type2
  182. ;
  183. ; SEND OUTPUT TO LST: OR CON:, AS PER THE FLAG
  184. ;   RETURN WITH Z IF ABORT
  185. ;
  186. lcout:
  187.     push    hl        ; Save regs
  188.     push    bc
  189.     ld    e,a        ; Char in e
  190.     ld    c,2        ; Output to con:
  191.      if    liston
  192. prflg    equ    $+1        ; Pointer for in-the-code modification
  193.     ld    a,0        ; 2nd byte is the print flag
  194.     or    a        ; 0=type
  195.     jr    z,lc1
  196.     ld    c,5        ; Output to lst:
  197.      endif            ; Liston
  198.  
  199. lc1:
  200.     push    de        ; Save char
  201.     call    bdos        ; Output char in e
  202.     pop    de        ; Get char
  203.     ld    a,e
  204.     cp    lf
  205.     jr    nz,lc2
  206.      if    liston
  207.     ld    a,(prflg)    ; Output to lst:?
  208.     or    a        ; Nz = yes
  209.     jr    nz,lc2
  210.      endif            ; Liston
  211. ;
  212. ; CHECK FOR PAGING
  213. ;
  214. ;    LXI    H,PAGCNT    ; Count down
  215.     ld    hl,(pagcnt)
  216.     dec    (hl)
  217.     jr    nz,lc2        ; Jump if not end of page
  218.     ld    (hl),nlines-2    ; Refill counter
  219. pgflg    equ    $+1        ; Pointer to in-the-code buffer
  220.     ld    a,0        ; 2nd byte is the paging flag
  221.     cp    pgdflg        ; Page default override option wanted?
  222. ;
  223.      if    pgdflt        ; If paging is default
  224. ;
  225.     jr    z,lc2        ; Pgdflg means no paging
  226. ;
  227.      else
  228. ;
  229.     jr    nz,lc2        ; Pgdflg means page
  230. ;
  231.      endif            ; Pgdflt
  232. ;
  233.     call    pagebreak    ; Print page break message
  234.     jp    z,typex        ; Z to skip
  235. lc2:
  236.     pop    bc        ; Restore regs
  237.     pop    hl
  238.     ret
  239. ;
  240. ; PRINT PAGE BREAK MESSAGE AND GET USER INPUT
  241. ;   ABORT IF ^C, RZ IF ^X
  242. ;
  243. pagebreak:
  244.     push    hl        ; Save hl
  245.     call    print
  246.     db    cr,lf,' Typing',' '+80h
  247.     ld    hl,fcb1+1    ; Print file name
  248.     call    prfn
  249.     call    dash        ; Print dash
  250.     call    conin        ; Get input
  251.     pop    hl        ; Restore hl
  252.     push    af
  253.     call    crlf        ; New line
  254.     pop    af
  255.     jp    break1
  256. ;
  257. ; End RCP-LT.Z80
  258.  
  259. .