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 / A-R / RCPPEEP.LBR / RPEEP.LZB / RPEEP.LIB
Text File  |  2000-06-30  |  19KB  |  934 lines

  1. ;=============================================================================
  2. ;
  3. ;        P E E P    C O M M A N D
  4. ;
  5. ;============================================================================
  6.  
  7. ; +++++++    NOT an official RCP segment for Z33RCP.Z80
  8. ;        This is a hacker's module intended to work with Z33RCP.
  9.  
  10. ; Command:    PEEP
  11. ; Function:    Text File Browser and Lister
  12. ; Comments:    The CRT protocol has to be hard coded into this module.
  13. ;        If the TCAP were used, PEEP would not be practical.
  14. ;        PEEPSECURE equate determines where the file is loaded.
  15. ; Author:     Rob Friefeld, 4607 Colorado St., Long Beach, CA 213-434-7338
  16. ; Date:        23 Aug 1987 Version 1.0
  17.  
  18. ;----------------------------------------------------------------------------
  19. ; Usage:    Hands rest on the home row of keys.  Left hand moves ahead,
  20. ;        right hand moves back through file. 
  21. ;                                                            ---
  22. ;                                              Go To Marker | 0 |
  23. ;                                                            ---
  24. ;                      Read More                     Init    Set    Print
  25. ;                  (if memory full)                 Printer Marker (from mark)
  26. ;                         ---                         ---    ---    ---
  27. ;                        | R |                       | I |  | O |  | P |
  28. ;                         ---                         ---    ---    ---
  29. ;    ---    ---    ---    ---    ---    ---    ---    ---    ---    ---
  30. ;   | A |  | S |  | D |  | F |  | G |  | H |  | J |  | K |  | L |  | ; |
  31. ;    ---    ---    ---    ---    ---    ---    ---    ---    ---    ---
  32. ;    End   Scan   Next   Next    Find   Rpt    Prev   Prev  R/Scan  Top
  33. ;  Screen         Line  Screen         Find   Screen  Line         Screen
  34. ;
  35. ;
  36. ;  X - Exit   <sp> - Hop 10 lines   <cr> - Next Screen (F)  </,?> - File Name
  37. ;----------------------------------------------------------------------------
  38.  
  39. ;
  40. ; PEEP EQUATES
  41. ;
  42.  
  43. bell    equ    07h
  44.  
  45. PEEPGO    EQU    NO        ; Permit re-entering with a GO
  46.  
  47.      IF    PEEPGO
  48.     TEXTLOC    EQU    TPA+3    ; There will be a jump instruction at TPA
  49.      ELSE
  50.     TEXTLOC    EQU    TPA    ; File will be read in to TPA
  51.      ENDIF
  52.  
  53. crtrows    equ    24        ; 24 line screen
  54. crtcols    equ    80        ; 80 col screen
  55.  
  56. tabsize    equ    8        ; Tab expansion size
  57. scanspd    equ    2000h        ; Scroll rate - smaller number goes faster
  58.  
  59. scrlns    equ    crtrows-1    ; Don't change these
  60. width    equ    crtcols-1
  61.  
  62. findsz    equ    12        ; Maximum size of "find" string
  63.  
  64. ;
  65. ; PRINITER INITIALIZATION STRING
  66. ; If you wish to send an initialization string with the I command, install
  67. ; it here.  The last byte must have the MSB set.
  68.  
  69. init$str:
  70.     db    cr+80h
  71.  
  72. ;
  73. ; CRT PROTOCOL INSTALLATION SECTION
  74. ;
  75. ; The defaults are standard for Televideo, Wyse, et al.
  76.  
  77.  
  78. ; CODE TO CLEAR SCREEN, HOME CURSOR
  79. clr_scr        macro
  80.     db    1ah+80h        ; Not used if CLSON is true.
  81.         endm
  82.  
  83. ; CODE FOR CLEAR TO END OF LINE
  84. cl_to_eol    macro
  85.     db    esc,'T'+80h
  86.         endm
  87.  
  88. ; CODE FOR HOME CURSOR, DO NOT CLEAR SCREEN.
  89. hom_crs        macro
  90.     db    1eh+80h
  91.         endm
  92.  
  93. ; CODE FOR INSERT LINE
  94. ins_line    macro
  95.     db    esc,'E'+80h
  96.         endm
  97.  
  98. ; CODE FOR RETURNING CURSOR TO START OF BOTTOM LINE OF CRT
  99. ret_crs        macro
  100.     db    esc,'=',scrlns+32,0+32+80h
  101.         endm
  102.  
  103. ; CODE FOR STANDOUT MODE.  MUST NOT TAKE SCREEN SPACE.  USE 0 IF NOT AVAILABLE.
  104. dim_on        macro
  105.     db    esc,')'+80h
  106.         endm
  107.  
  108. ; CODE FOR STANDEND.
  109. dim_off        macro
  110.     db    esc,'('+80h
  111.         endm
  112.  
  113. ;
  114. ;  END OF CRT PROTOCOL INSTALLATION SECTION
  115. ;
  116.  
  117.  
  118. ;
  119. ; CRT ROUTINES USING ABOVE MACROS
  120. ;
  121.  
  122. ; PRINT CR AND CLREOL
  123. cr$clr:    ld    a,cr
  124.     call    conout
  125. clreol:    call    print
  126.     cl_to_eol
  127.     ret
  128.  
  129. ; HOME CURSOR
  130. homcrs:    call    print
  131.     hom_crs
  132.     ret
  133.  
  134. ; INSERT BLANK LINE AT TOP OF SCREEN
  135. inslin:    call    homcrs
  136.     call    print
  137.     ins_line
  138.     jr    clreol
  139.  
  140. ; RETURN CURSOR TO LAST LINE OF SCREEN
  141. retcrs:    call    print
  142.     ret_crs
  143.     ret
  144.  
  145. ; CLEAR SCREEN
  146.      if    [ not CLSON ]
  147. cls:    call    print
  148.     clr_scr
  149.     ret
  150.      endif
  151.  
  152. ;
  153. ; DISPLAY CONTROL CHARACTERS AS ^n
  154. ;
  155.  
  156. outchr:
  157.     cp    20h
  158.     jp    nc,conout    ; Not a control
  159.  
  160. ; WE HAVE A CONTROL
  161.  
  162.     push    af    ;save it
  163.     ld    a,'^'
  164.     call    conout
  165.     pop    af    ;restore it
  166.     add    40h    ;make it printable
  167.     inc    c    ;bump tab expansion counter of "^" char
  168.     jp    conout
  169.  
  170. ; SWITCHING CONOUT
  171.  
  172. plcon:    ld    a,5        ; Switch to list output
  173. plcon1:    ld    (conout+8),a    ; Poke list byte at  ld  c,bdosf
  174.     ret
  175.  
  176. plcoff:    ld    a,2        ; Switch to con output
  177.     jr    plcon1
  178.  
  179. ; START STANDOUT MODE
  180. stndout:
  181.     call    print
  182.     dim_on
  183.     ret
  184.  
  185. ; END STANDOUT MODE
  186. stndend:
  187.     call    print
  188.     dim_off
  189.     ret
  190.  
  191. ;
  192. ; SLOW DOWN SCAN FUNCTIONS
  193. ;
  194.  
  195. wait:    ld    hl,scanspd
  196. wait0:    dec    hl        ; Down count to 0
  197.     ld    a,h
  198.     or    l
  199.     ret    z
  200.     jr    wait0
  201.  
  202. ;
  203. ; WAIT FOR A CHAR THEN ERASE LINE
  204. ;
  205. getchr:
  206.     call    conin
  207.     push    af
  208.     call    cr$clr        ; Erase it
  209.     pop    af
  210.     ret
  211.  
  212. ;
  213. ;  UPCASE CHAR IN A
  214. ;
  215.  
  216. mkupper:
  217.     cp    'a'
  218.     ret    c
  219.     cp    'z'+1
  220.     ret    nc
  221.     and    5fh
  222.     ret
  223.  
  224. ;
  225. ; MAIN PROGRAM
  226. ;
  227.  
  228. peep:    call    retsave        ; Save zcpr return
  229.  
  230. ; A jump instruction to peep is loaded at 100h.  This permits using peep again
  231. ; with a GO, and prevents an object file read in at TPA from starting with a GO
  232.  
  233.      if    peepgo
  234.     ld    a,0c3h        ; Jump code
  235.     ld    (tpa),a
  236.     ld    hl,peep
  237.     ld    (tpa+1),hl
  238.      endif
  239.  
  240.     call    getfil        ; Read the file into memory
  241.     call    cls        ; Clear the screen
  242.  
  243. ; RESTART ENTRY FOR READING IN MORE TEXT ON "MEMORY FULL" MESSAGE
  244.  
  245. resrt:    ld    hl,textloc    ; Set Start Pointer to beginning of file
  246.     ld    (srtptr),hl
  247.     ld    (mrkptr),hl    ; Set place marker to start of text
  248.  
  249.     ld    hl,(eofptr)    ; Set End of Screen Pointer to beginning
  250.     ld    b,scrlns    ;   of last screen
  251.     call    pvline        ; Back up one screen from end
  252.     djnz    $-3
  253.     ld    (eosptr),hl    ; Now set pointer
  254.  
  255. ;
  256. ; PRINT ONE SCREEN OF TEXT
  257. ;
  258.  
  259. prnscr:    call    homcrs
  260.     ld    hl,(srtptr)
  261.     push    hl        ; If near end then print entire last screen
  262.     ld    de,(eosptr)    ; Compute position relative to last screen
  263.     xor    a        ; Reset carry flag
  264.     sbc    hl,de
  265.     pop    hl
  266.     jr    z,prn1        ; We are at or before last screen so go ahead
  267.     jp    nc,last        ; We are past last screen so back up
  268.  
  269. prn1:    ld    b,scrlns    ; Line count in B
  270. prnlp1:    call    clreol
  271.     call    prnline
  272.     djnz    prnlp1        ; Print SCRLNS lines
  273.     ld    (nxtptr),hl    ; And set Next Pointer
  274.     call    retcrs        ; Cursor to prompt line
  275.  
  276. ;
  277. ; COMMAND INPUT ROUTINE
  278. ;
  279.  
  280. command:
  281.     call    getchr        ; Get command
  282.     call    case        ; Scan list of commands
  283.  
  284. ;
  285. ; COMMAND LIST: CHAR TO MATCH FOLLOWED BY ADDRESS
  286. ;
  287.  
  288.     db    'A'        ; Last screen of file
  289.     dw    last
  290.     db    'D'        ; Forward a line
  291.     dw    down
  292.     db    'F'        ; Next screen
  293.     dw    next
  294.     db    'G'        ; Find string
  295.     dw    find
  296.     db    'H'        ; Find string again
  297.     dw    find0
  298.     db    'I'        ; Init printer
  299.     dw    init$prt
  300.     db    'J'        ; Previous screen
  301.     dw    prev
  302.     db    'K'        ; Back a line
  303.     dw    up
  304.     db    'L'        ; Scan backward
  305.     dw    back
  306.     db    'O'        ; Set place marker
  307.     dw    mark
  308.     db    'P'        ; Print from marker
  309.     dw    list
  310.     db    'R'        ; Read in more text
  311.     dw    read
  312.     db    'S'        ; Scan forward
  313.     dw    scan
  314.     db    'X'        ; Exit to CPR
  315.     dw    exit
  316.     db    ';'        ; Top of file
  317.     dw    top
  318.     db    '0'        ; Go to marker
  319.     dw    gomark0
  320.     db    20h        ; <sp> jump ahead 10 lines
  321.     dw    hop
  322.     db    cr        ; <cr> next screen
  323.     dw    next
  324.     db    '/'
  325.     dw    what        ; Show filename
  326.     db    '?'
  327.     dw    what
  328.     db    0        ; table delimiter
  329.  
  330.     jr    command        ; Loop back on invalid input
  331.  
  332. ;
  333. ; CASE - JUMP TABLE SCANNER
  334. ; FORMAT:  CALL CASE    ;CALL WITH VALUE TO MATCH IN A
  335. ;       DB    VAL1    ;FIRST VAL TO MATCH
  336. ;       DW    ADDR1    ;JUMP ADDRESS
  337. ;       ...
  338. ;       DB    0    ;END TABLE
  339. ;       ELSE NEXT INSTUCTION EXECUTES IF NO MATCH
  340.  
  341. case:
  342.     ex    (sp),hl        ;hl -> next addr after call
  343.     ex    af,af'        ;save char
  344.     xor    a
  345. case1:
  346.     ex    af,af'        ;restore char
  347.     cp    (hl)        ;match?
  348.     inc    hl        ;set pointer to val's jump addr
  349.     jr    z,case0        ;if match, jump
  350.     inc    hl        ;point to next val
  351.     inc    hl
  352.     ex    af,af'        ;check for list terminator
  353.     cp    (hl)
  354.     jr    nz,case1    ;keep looking
  355.  
  356.     inc    hl        ;no match, execute next instruction
  357. casex:    ex    (sp),hl
  358.     ret
  359.  
  360. case0:    ld    e,(hl)        ;load address
  361.     inc    hl
  362.     ld    d,(hl)
  363.     ex    de,hl
  364.     jr    casex        ;go
  365.  
  366. ;
  367. ;  PRINT ONE LINE OF TEXT
  368. ;  HL -> first char on entry, next char on exit
  369. ;
  370.  
  371. prnline:
  372.     push    bc        ; Preserve possible loop counter on entry
  373.     xor    a
  374.     ld    c,a        ; Char counter for CRT width and tabs
  375. prnl1:
  376.     ld    a,(hl)        ; Get char
  377.     cp    eof        ; At end?
  378.     jr    z,prnl2        ; Can occur on text smaller than one screen
  379.     call    prnl3        ; Print the character
  380.     cp    lf        ; Are we at end of line?
  381.     inc    hl        ; Bump pointer
  382.     jr    nz,prnl1    ; No
  383. prnl2:    pop    bc
  384.     ret            ; Exit routine
  385.  
  386. ; PRINT THE CHAR IF THE LINE IS NOT FULL
  387.  
  388. prnl3:    cp    cr        ; Always print cr
  389.     jp    z,conout
  390.     cp    lf        ; Always print lf
  391.     jp    z,conout
  392.     cp    tab
  393.     jr    z,prnl5        ; Expand tab
  394.  
  395. prnl4:    ld    e,a        ; Save char
  396.     inc    c        ; Bump char counter
  397.     ld    a,width        ; Exceeded line width?
  398.     cp    c
  399.     ret    c        ; Yes, quit
  400.     ld    a,e        ; Restore char
  401.     jp    outchr        ; Send it out
  402.  
  403. ; TAB EXPANSION
  404.  
  405. prnl5:    ld    a,c        ; Compute char count MOD tabsize
  406.     sub    tabsize
  407.     jr    nc,$-2
  408.     neg            ; Spaces to next tab in A
  409.     ld    b,a        ; Use as loop counter
  410.     ld    a,' '        ; Print space
  411. prnl51:    call    prnl4        ; Send it out if room and update char count
  412.     ret    c        ; Line overflow, quit
  413.     djnz    prnl51
  414.     ret
  415.  
  416. ;
  417. ; PRINT NEXT SCREEN
  418. ;
  419.  
  420. next:    ld    hl,(nxtptr)
  421.     ld    a,eof        ; Is there a next screen?
  422.     cp    (hl)
  423.     jr    z,hop0        ; No
  424.     ld    (srtptr),hl    ; Next screen is new start pointer
  425.     jr    top0        ; Print the screen
  426.  
  427. ;
  428. ; PRINT FIRST SCREEN
  429. ;
  430.  
  431. top:    ld    hl,textloc    ; Start of text
  432.     ld    (srtptr),hl    ; To start pointer
  433. top0:    jp    prnscr
  434.  
  435. ;
  436. ; PRINT LAST SCREEN
  437. ;
  438.  
  439. last:    ld    hl,(eosptr)    ; Top of last screen
  440.     ld    (srtptr),hl    ; Start there
  441.     jr    top0        ; Print the screen
  442.  
  443. ;
  444. ; PRINT NEXT LINE
  445. ;
  446.  
  447. down:    ld    b,1        ; Loop counter = 1 line
  448.     jr    hop1        ; Print the line
  449.  
  450. ;
  451. ; HOP FORWARD 10 LINES
  452. ;
  453.  
  454. hop:    ld    b,10        ; Loop counter = 10 lines
  455. hop1:    push    bc        ; Save it
  456.     call    dnline        ; Print next line
  457.     pop    bc
  458.     djnz    hop1
  459. hop0:    jp    command
  460.  
  461. ;
  462. ; SCROLL CONTINUOUSLY AHEAD UNTIL A KEY PRESSED
  463. ;
  464.  
  465. scan:    call    dnline        ; Print next line
  466.     jr    z,hop0        ; Routine returns 0 on EOF
  467.     call    scstop        ; Check for key press
  468.     call    wait        ; Pause a few msec
  469.     jr    scan
  470.  
  471. ;
  472. ;  CHECK FOR BREAK
  473. ;
  474.  
  475. scstop:    ld    c,CONSTF
  476.     call    bdos
  477.     or    a
  478.     ret    z        ; No character, continue
  479.     pop    af        ; Dispose of return address
  480.     call    getchr        ; Erase screen echo and dispose of char
  481.     jr    hop0        ; Back to command list
  482.  
  483. ;
  484. ; PRINT NEXT LINE
  485. ;
  486.  
  487. dnline:    ld    hl,(nxtptr)    ; Look at start of next line
  488.     ld    a,eof        ; Is it EOF?
  489.     cp    (hl)
  490.     ret    z        ; There is no next line
  491.     call    prnline        ; Print the line
  492.     ld    (nxtptr),hl    ; Advance Next Pointer
  493.     ld    hl,(srtptr)    ; Advance Start Pointer
  494.     call    nxline        ; Find start of next line
  495.     ld    (srtptr),hl    
  496.     xor    a        ; A NZ flag on successful return
  497.     dec    a
  498.     ret
  499.  
  500. ;
  501. ;  SEARCH FOR NEXT LINE OF TEXT
  502. ;  HL -> starting point
  503. ;
  504.  
  505. nxline:    ld    a,(hl)        ; Look at char
  506.     cp    eof
  507.     ret    z        ; No more text
  508.     inc    hl        ; Bump pointer
  509.     cp    lf
  510.     jr    nz,nxline
  511.     ret            ; Returns HL at character after LF
  512.  
  513. ;
  514. ; PRINT PREVIOUS SCREEN
  515. ;
  516.  
  517. prev:    ld    hl,(srtptr)    ; HL-> char at top of screen
  518.     ld    b,scrlns    ; Loop counter SCRLNS lines
  519. prev0:    call    pvline        ; Find start of previous line
  520.     djnz    prev0
  521.     ld    (srtptr),hl    ; Set Start Pointer
  522.     jp    prnscr        ; Print the screen
  523.  
  524. ;
  525. ;  SEARCH FOR START OF PREVIOUS LINE OF TEXT
  526. ;
  527.  
  528. pvline:    push    bc        ; Save possible loop counter on entry
  529.     ld    b,2        ; We need the LF BEFORE the last one
  530. prvlp:    xor    a        ; Reset carry flag
  531.     ld    de,textloc    ; Are we already at beginning of file?
  532.     push    hl
  533.     sbc    hl,de
  534.     pop    hl
  535.     jr    c,prv0        ; Yes, so we are done
  536.     ld    a,(hl)        ; Look for last LF
  537.     cp    lf
  538.     dec    hl        ; Decrement char pointer
  539.     jr    nz,prvlp    ; Haven't found LF yet
  540.     djnz    prvlp        ; Do it once more
  541.     inc    hl        ; Move HL pointer to character after LF
  542. prv0:    inc    hl
  543.     pop    bc
  544.     ret
  545.  
  546. ;
  547. ;  PRINT PREVIOUS LINE
  548. ;
  549.  
  550. up:    call    upline
  551. up0:    jp    command
  552.  
  553. ;
  554. ; SCAN BACKWARDS UNTIL KEY PRESS
  555. ;
  556.  
  557. back:    call    upline        ; Move up a line
  558.     jr    z,up0        ; Returns Z if no more lines
  559.     call    scstop        ; Check for break
  560.     call    wait        ; Give screen time to catch up
  561.     jr    back
  562.  
  563. ;
  564. ; MOVE DISPLAY UP A LINE
  565. ;
  566.  
  567. upline:    ld    de,textloc    ; Are we already at start of text?
  568.     ld    hl,(srtptr)
  569.     xor    a
  570.     sbc    hl,de
  571.     ret    z        ; Yes, quit and return Z
  572.  
  573.     call    inslin        ; Home cursor and insert a blank line
  574.     ld    hl,(srtptr)    ; Back up a line
  575.     call    pvline
  576.     ld    (srtptr),hl    ; Set pointer
  577.     call    prnline        ; Print the line
  578.     ld    hl,(nxtptr)    ; Set Next Pointer
  579.     call    pvline
  580.     ld    (nxtptr),hl
  581.     call    retcrs        ; Return cursor to bottom of screen
  582.     call    cr$clr        ; Erase dead line
  583.     xor    a        ; Return NZ
  584.     dec    a
  585.     ret
  586.  
  587. ;
  588. ; FIND A STRING
  589. ;
  590.  
  591. find:
  592.     call    STNDOUT
  593.     call    print        ; Find string in following pages
  594.     db    'Find ->',' '+80h
  595.     ld    de,finbuf    ; Read string to find
  596.     ld    c,RDBUFF
  597.     call    bdos
  598.     call    STNDEND
  599.     call    cr$clr        ; Erase it from screen
  600.  
  601. find0:    ld    ix,finbuf+1    ; IX points to string length
  602.     ld    a,(ix)        ; Move it to A
  603.     or    a
  604.     jp    z,command    ; 0 length string ... abort
  605.  
  606. ;  UPCASE THE STRING FOR CASE INSENSITIVE SEARCH
  607.  
  608.     ld    b,a        ; Length is loop counter
  609.     ld    hl,findat    ; First char of string
  610. find01:    ld    a,(hl)
  611.     call    mkupper
  612.     ld    (hl),a
  613.     inc    hl
  614.     djnz    find01
  615.  
  616. ; START SEARCH AT NEXT LINE
  617.     ld    hl,(srtptr)
  618.     call    nxline        ; HL now -> next line
  619. finlp0:    ld    iy,findat    ; IY will be string pointer
  620. finlp1:    ld    a,(hl)        ; Get char from text
  621.     call    mkupper        ; Upcase it
  622.     cp    eof
  623.     jr    z,finot        ; Hit end of file before match
  624.     cp    (iy)        ; First char to match
  625.     inc    hl        ; Bump text pointer
  626.     jr    nz,finlp1    ; No match, keep moving through text
  627.  
  628. ; AT THIS POINT, FIRST CHAR IS MATCHED
  629.     ld    b,(ix)        ; IX still has string length
  630.     dec    b        ; We have already found 1
  631.     jr    z,findex    ; Done if only 1 char to match
  632. finlp2:    inc    iy        ; Compare the next chars
  633.     ld    a,(hl)
  634.     call    mkupper
  635.     cp    (iy)
  636.     jr    nz,finlp0    ; No match ... start looking again
  637.     inc    hl        ; So far, so good
  638.     djnz    finlp2        ; Match next chars
  639.  
  640. ; THE STRING IS IN THE CURRENT LINE, MOVE IT TO TOP OF SCREEN
  641.  
  642. findex:    call    pvline        ; Find previous line
  643.     call    nxline        ; Go to beginning of this line
  644.     ld    (srtptr),hl
  645.     jp    prnscr        ; Show the screen
  646.  
  647. ; NO LUCK ON FIND
  648.  
  649. finot:    call    cr$clr        ; String not found - print message
  650.     call    stndout
  651.     call    print
  652.     db    'Not found',' '+80h
  653. finot0:    call    stndend
  654.     jp    command
  655.  
  656.  
  657. ;  BUFFERS FOR FIND
  658.  
  659. finbuf:    db    FINDSZ        ; String to match size
  660.     ds    1        ; Returned char count
  661. findat:    ds    FINDSZ        ; Buffer
  662.  
  663. ;
  664. ;  SHOW FILE NAME COMMAND
  665. ;
  666.  
  667. what:    call    stndout
  668.     ld    hl,fcb1+1
  669.     call    prfn        ; ROUTINE ELSEWHERE IN RCP
  670.     jr    finot0        ; Finish up display
  671.  
  672. ;
  673. ; SET PLACE MARKER
  674. ;
  675.  
  676. mark:
  677.     ld    hl,(srtptr)    ; Top of screen pointer is marker pointer
  678.     ld    (mrkptr),hl
  679.     call    stndout
  680.     call    print
  681.     db    'Marke','d'+80h
  682.     jr    finot0        ; Finish up display
  683.  
  684.  
  685. ;
  686. ; GO TO MARKER
  687. ;
  688.  
  689. gomark0:
  690.     ld    hl,(mrkptr)
  691.     ld    (srtptr),hl
  692.     jp    prnscr
  693.  
  694.  
  695. ;
  696. ;  LIST MARKED PORTION OF FILE
  697. ;
  698.  
  699. list:
  700.     ld    hl,lstmsg
  701.     call    qprompt        ; Are we serious?  (And is printer on?)
  702.     jr    z,list4        ; Abort
  703.  
  704. ; Compute print block size
  705.  
  706.     ld    de,(mrkptr)    ; Beginning of block
  707.     ld    hl,(nxtptr)    ; End of block
  708.     xor    a
  709.     sbc    hl,de        ; Block size now in HL
  710.     jr    c,lsterr    ; If beginning at or after end then no go
  711.     jr    z,lsterr
  712.  
  713. ; Set up pointers
  714.  
  715.     ex    de,hl        ; Block size in DE, start in HL
  716.     push    de
  717.     pop    bc        ; Block size in HL
  718.     ld    de,0        ; Count # lines in DE
  719.     ld    a,lf
  720. list1:    cpir            ; Count line feeds
  721.     jp    po,list11    ; Loop expired
  722.     inc    de
  723.     jr    list1
  724.  
  725. list11:
  726.     call    plcon        ; Switch output to list
  727.     push    de
  728.     pop    bc        ; Count to BC
  729.     inc    bc        ; Actually need 1 more
  730.     ld    hl,(mrkptr)    ; Print BC lines
  731. list3:    call    prnline        ; Output switched to list:
  732.     dec    bc
  733.     ld    a,b
  734.     or    c
  735.     jr    nz,list3
  736.  
  737.     call    plcoff        ; Switch output to con:
  738.  
  739. lsterr:    ld    a,bell        ; Beep on marker error or finish print
  740.     call    conout
  741. list4:    call    cr$clr
  742. listx:    jp    command
  743.  
  744.  
  745.  
  746. lstmsg:    db    'Print from MAR','K'+80h
  747.  
  748. ;
  749. ;  SEND INIT STRING TO PRINTER
  750. ;
  751.  
  752. init$prt:
  753.     ld    hl,initmsg
  754.     call    qprompt
  755.     jr    z,list4
  756.     call    plcon        ; Switch conout to list
  757.     ld    hl,init$str    ; Send string
  758.     call    printhl
  759.     call    plcoff        ; Switch conout to con
  760.     jr    list4
  761.  
  762. initmsg:
  763.     db    'Init LST',':'+80h 
  764.  
  765. ;
  766. ;  READ FILE INTO TPA UNTIL FULL OR EOF
  767. ;
  768.  
  769. getfil:
  770.  
  771. ; SET UP TOP OF MEMORY POINTER
  772.  
  773.     ld    hl,(bdos+1)    ; BDOS location
  774.     ld    de,-905h    ; CCP size + TPA  +  cr,lf,eof at end
  775.     add    hl,de
  776.     ld    (topmem),hl    ; Store as top of memory
  777.  
  778. ; REJECT BLANK FILE SPEC
  779.  
  780. getfil1:
  781.     call    filcheck
  782.  
  783.     CALL    LOGUSR        ; ROUTINE IS IN RCPSUBS.LIB
  784.  
  785. ; OPEN THE FILE
  786.     call    opensource
  787.  
  788. ; RESET EOF FLAG (EOF NOT ENCOUNTERED)
  789.     xor    a
  790.     ld    (eoflag),a
  791.  
  792. ; FILE READ LOOP
  793.  
  794.     ld    hl,textloc    ; Start of text pointer
  795. getlp1:    ld    (srtptr),hl    ; Entry with hl -> input location
  796.     ex    de,hl
  797.  
  798.     ld    hl,(topmem)    ; Check memory full
  799.     xor    a
  800.     sbc    hl,de
  801.     jr    c,toobig    ; Yes
  802.  
  803.     ld    c,SETDMAF    ; File read into current position
  804.     call    bdos
  805.     ld    de,fcb1
  806.     ld    c,readf
  807.     call    bdos
  808.     or    a        ; Check for end of file encountered
  809.     jr    nz,geteof    ; Yes
  810.     ld    hl,(srtptr)    ; Move pointer along one record worth
  811.     ld    de,128
  812.     add    hl,de
  813.     jr    getlp1        ; Keep reading
  814.  
  815. geteof:    ld    (eoflag),a    ; Set EOF flag
  816.     ld    hl,(srtptr)    ; Eof not returned until read after eof!
  817.     ld    de,-128
  818.     add    hl,de        ; Back up a record
  819.     ld    a,eof
  820.     ld    bc,128
  821.     cpir            ; Find the first eof
  822.  
  823. ; SET UP EOF POINTER
  824.  
  825. getmrk:
  826.     dec    hl
  827. getmrk1:
  828.     ld    (hl),cr        ; Works better with CRLF at end of file
  829.     inc    hl
  830.     ld    (hl),lf
  831.     inc    hl
  832.     ld    (hl),eof
  833.     ld    (eofptr),hl    ; Store it for later
  834.     ret
  835.  
  836. ; FILE HAS FILLED AVAILABLE MEMORY, PRINT WARNING
  837.  
  838. toobig:    push    de
  839.     call    print
  840.     db    bell,'Mem full',' '+80h
  841.     call    getchr        ; Wait for key press
  842.     pop    hl
  843.     jr    getmrk1
  844.  
  845.  
  846. ;
  847. ; READ MORE TEXT COMMAND
  848. ;
  849.  
  850. read:    ld    a,(eoflag)    ; Has EOF been encountered?
  851.     or    a
  852.     jr    nz,rdprompt    ; If so, send message
  853.     ld    de,textloc    ; Else, preserve some text and read more
  854.     ld    hl,(eosptr)
  855.     ld    a,eof
  856. rdlp1:    ldi            ; Move last page to beginning of buffer
  857.     cp    (hl)        ; Check for end of file marker
  858.     jr    nz,rdlp1    ; Loop until it is reached
  859.     dec    de        ; Back up over last CR,LF
  860.     dec    de
  861.     ex    de,hl        ; HL now points to read data location
  862.     call    getlp1        ; Fill memory with more of file
  863.     jr    readx        ; Re-initialize pointers and start
  864.  
  865.  
  866. ; PROMPT IF NO MORE TO READ
  867.  
  868. rdmsg:    db    'Start ove','r'+80h
  869. rdprompt:
  870.     ld    hl,rdmsg
  871.     call    qprompt
  872.     push    af        ; Save answer
  873.     call    cr$clr
  874.     pop    af
  875.     jp    z,command    ; No
  876.  
  877.  
  878. ; STARTING OVER, ZERO FCB POSITION POINTERS
  879.  
  880. read1:
  881.     CALL    INITFCB1    ; IN RCPSUBS.LIB
  882.     call    getfil1        ; Read the file
  883. readx:    jp    resrt        ; Restart PEEP
  884.  
  885.  
  886. ; EXAMINE COMMAND LINE FOR FILE SPEC
  887.  
  888. filcheck:
  889.     ld    hl,fcb1+1
  890.     ld    a,' '
  891.     cp    (hl)
  892. filcx:    ret    nz
  893.     call    prfnf        ; ROUNTINE IS ELSEWHERE IN RCP
  894.     jp    exit        ; NO FILE SPEC
  895.  
  896. ; OPEN SOURCE FILE
  897.  
  898. opensource:
  899.     ld    de,fcb1
  900.     ld    c,openf
  901.     call    bdos
  902.     inc    a
  903.     jr    filcx
  904.  
  905.  
  906. ; Enter with HL -> message.  Return Z if answer = N.
  907. qprompt:
  908.     call    stndout
  909.     call    printhl
  910.     call    print
  911.     db    ' ? (Y/n)',' '+80h
  912.     call    stndend
  913.     call    conin
  914.     cp    'N'
  915.     ret
  916.  
  917.  
  918. ;
  919. ; STORAGE
  920. ;
  921.  
  922. eoflag    ds    1        ; EOF encountered flag
  923. srtptr    ds    2        ; Start Pointer -> top of screen
  924. nxtptr    ds    2        ; Next Pointer -> next screen
  925. eosptr    ds    2        ; End of Screen Pointer -> last screen
  926. eofptr    ds    2        ; End of File Pointer -> end of text
  927. topmem    ds    2        ; Top of memory pointer
  928. mrkptr:    dw    textloc        ; Place marker
  929.  
  930. ; End RCP-PEEP.Z80
  931.  
  932. File Pointer -> end of text
  933. topmem    ds    2        ; Top of memory poin