Files
RomWBW/Source/BPBIOS/Z34RCP11/rcplt.lib
2020-02-14 17:22:56 -08:00

256 lines
5.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
page
; Library: RCPLT for Z34RCP
; Author: Carson Wilson
; Version: 1.1
; Date: August 26, 1989
; Changes: Some WordStar characters caused garbage to appear on the
; screen. Now filters control characters other than CR,
; TAB, and LF. Thanks to Gene Pizzetta for this suggestion.
;
; Author: Carson Wilson
; Version: 1.0
; Date: June 15, 1988
;
; Commands: LIST and TYPE
; ----------------------------------------------------------------
;
; Command: LIST
; Function: Print out specified file on the LST: Device
; Forms:
; LIST Do form feed
; LIST <afn> Print file(s) (NO Paging)
; Notes:
; The flags which apply to TYPE do not take effect with LIST
; The tab expansion code is required for LST: output.
if liston
list:
ld a,(fcb1+1) ; Get filename or ' ' from command
ld (prflg),a ; List flag (A can't be 0)
cp ' ' ; Null command?
jp z,lstff ; Yes, do form feed and return
jr type0 ; No, send file to LST:
endif ;liston
; --------------------------------------------------------------------
;
; Command: TYPE
; Function: Print out specified file on the CON: Device
; Forms:
; TYPE <afn> Print file
; TYPE <afn> P Print file with paging flag
; Notes:
; The flag PGDFLG defines the letter which toggles the paging
; facility (P in the forms section above)
; The flag PGDFLT determines if TYPE is to page by default
; (PGDFLT=TRUE if TYPE pages by default); combined with
; PGDFLG, the following events occur --
; If PGDFLT = TRUE, PGDFLG turns OFF paging
; If PGDFLT = FALSE, PGDFLG turns ON paging
type:
if liston
xor a ; Turn off printer flag
ld (prflg),a ; Set flag
endif ; Liston
; Entry point for list function (LIST)
type0: call retsave ; Save return address
ld a,(fcb2+1) ; Get page flag from command
ld (pgflg),a ; Store it
ld a,1 ; Select dir files
call getdir ; Allow ambiguous files (HL points to buffer)
jp z,noflerr ; EH no files error
ld a,(lins) ; Set line count
ld (pagcnt),a
jr typex1
; Entry point for successive files
typex0: pop hl ; Balance stack for skip
pop hl ; ..to next file command (^X)
typex: ld hl,(nxtfile) ; Get ptr to next file
ld a,(hl) ; Any files?
or a
jp z,exit
if liston
ld a,(prflg) ; Check for lst: output
or a ; 0=type
jr z,typex1
ld a,cr ; Bol on printer
call lcout
call lstff ; Form feed the printer
; fall thru
endif ; Liston
; Entry point for 1st file
typex1: ld de,fcb1+1 ; Copy into fcb1
ld b,11 ; 11 bytes
call blkmov
ld (nxtfile),hl ; Set ptr to next file
call initfcb1 ; Init fcb1
ld c,15 ; Open file
call bdos
inc a ; Set error flag
jp z,noflerr ; EH no files error
ld a,cr ; New line
call lcout
ld a,lf
call lcout
ld bc,080h ; Set char position and tab count
; (b=0=tab, c=080h=char position)
; Main loop for loading next block
type2: ld a,c ; Get char count
cp 80h
jr c,type3
call break
push bc ; Read next block
ld de,fcb1 ; Pt to fcb
ld c,20 ; Read record
call bdos
or a ; Set flags
pop bc
jr nz,typex ; End of file?
ld c,0 ; Set char count
ld hl,tbuff ; Pt to first char
; Main loop for printing chars in tbuff
type3: ld a,(hl) ; Get next char
and 7fh ; Mask out msb
cp 1ah ; End of file (^z)?
jr z,typex ; Next file if so
; Output char to CON: or LST: device with tabulation
cp cr ; Reset tab count?
jr z,type4
cp lf ; Reset tab count?
jr z,type4
cp tab ; Tab?
jr z,type5
cp ' ' ; Skip other ctls.
jr c,type6
; Output char and increment char count
call lcout ; Output char
inc b ; Increment tab count
jr type6
; Output <CR> or <LF> and reset tab count
type4: call lcout ; Output <cr> or <lf>
ld b,0 ; Reset tab counter
jr type6
; Tabulate
type5: ld a,' ' ; <sp>
call lcout
inc b ; Incr pos count
ld a,b
and 7
jr nz,type5
; Continue processing
type6:
inc c ; Increment char count
inc hl ; Pt to next char
jr type2
; Send a formfeed to LST:. Assumes PRFLG <> 0.
lstff:
ld a,ff ; formfeed
; fall thru
; Send output to LST: or CON:, as per the flag
; Return with Z if abort
lcout: push hl ; Save regs
push bc
ld e,a ; Char in e
ld c,2 ; Output to con:
if liston
prflg equ $+1 ; Pointer for in-the-code modification
ld a,0 ; 2nd byte is the print flag
or a ; 0=type
jr z,lc1
ld c,5 ; Output to lst:
endif ; Liston
lc1: push de ; Save char
call bdos ; Output char in e
pop de ; Get char
ld a,e
cp lf ; New line?
jr nz,lc2 ; No, return
call break ; Check for abort
jp z,typex0 ; Skip if ^X
if liston
ld a,(prflg) ; Output to lst:?
or a ; Nz = yes
jr nz,lc2
endif ; Liston
; New line, so check for paging
ld hl,pagcnt
dec (hl)
jr nz,lc2 ; Jump if not end of page
ld a,(lins)
ld (hl),a ; Reset counter
pgflg equ $+1 ; Pointer to in-the-code buffer
ld a,0 ; 2nd byte is the paging flag
cp pgdflg ; Page default override option wanted?
if pgdflt ; If paging is default
jr z,lc2 ; Pgdflg means no paging
else
jr nz,lc2 ; Pgdflg means page
endif ; Pgdflt
push hl ; Save hl
call print
db cr,lf,' Typing',' '+80h
ld hl,fcb1+1 ; Print file name
call prfn
call dash ; Print dash
call conin ; Get input
pop hl ; Restore hl
call break1 ; Set Z flag or abort
push af ; Save results
if typecls and clson
call cls ; Clear between screens
else
call crlf
endif
pop af ; Get results
jp z,typex0 ; Control-X, so skip to next file
cp ctrlz ; If Control-Z,
jr nz,lc2
ld a,pgdflg ; Switch to non-default
ld (pgflg),a ; ..paging mode
lc2: pop bc ; Restore regs
pop hl
ret
; Storage for line counter
pagcnt:
ds 1
; End RCPLT.LIB