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