home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
enterprs
/
cpm
/
utils
/
f
/
lbrhlp22.lbr
/
LBRHLP22.ZZ0
/
LBRHLP22.Z80
Wrap
Text File
|
1992-05-09
|
35KB
|
1,557 lines
; program name: LBRHLP.Z80
; author: Bob Peddicord
; date: Jan 88
; version: 1.0
;
; derivation: help53 by Richard Conn
; some help routines from help52
; I want to thank Steve Greenberg for his uncrunch code
;
; Version 2.2 by Gene Pizzetta, 5/10/92.
; See LBRHLP.HIS for revision history.
ver equ 22
rev equ ' '
false equ 0
no equ false
n equ false
true equ not false
yes equ not false
y equ not false
; Select decompression method
.accept 'Enter "Y" for uncrunching or "N" for unsqueezing: ',uncr
;
; directory of help files if help directory not found
;
disk equ 'A'-'A' ; disk
user equ 15 ; user
;
; enter/exit standout mode
;
dim equ 1
ndim equ 2
;
; constants
;
udflag equ 4 ; address of user/disk flag
bdose equ 5 ; address of bdos entry point
fcb1 equ 5ch
fcb2 equ 6ch
tbuff equ 80h ; address of dma buffer
inbufsz equ 1 ; input buffer size (1 page)
tab equ 9 ; <ht>
cr equ 0dh ; <cr>
lf equ 0ah ; <lf>
esc equ 1bh ; escape
bel equ 'G'-'@' ; ^g
ff equ 'L'-'@' ; ^l = form feed
ctrlz equ 'Z'-'@' ; ^z
ctrlc equ 'C'-'@' ; ^c
;
; help control characters
;
ihchar equ ';' ; flag indicating indexed by user
sectchar equ ':' ; defined to be colon
backupchar equ 'L' ; back up to previous frame char
strtchar equ 'S' ; jump to start of information char
menuchar equ 'M' ; char to abort to menu
cpmabortchar equ ctrlc ; char to exit
exitchar equ esc ; char to exit (alternate)
lrchar equ '^' ; return to previous help level
lrchar2 equ ',' ; return to previous help level (alternate)
rootchar equ '.' ; return to root of help
prchar equ 'P' ; print current frame
cprchar equ 'P'-'@' ; print current information section
;
IF UNCR
SIGREV EQU 20H ; "significant" revision level (compatibility)
NOPRED EQU 0FFFFH ; "no predecessor"
IMPRED EQU 07FFFH ; Pred that can't be matched or bumped
; --- reserved codes ---
EOFCOD EQU 100H ; EOF code
RSTCOD EQU 101H ; Adaptive reset code
NULCOD EQU 102H ; Null code
SPRCOD EQU 103H ; Spare code
ENDIF ; UNCR
;______________________________________________________________________________
;
; Macros to facilitate "horizontal" movement through the table.
; See "Table structure" comment near "initbl" for more information.
;
RIGHT1 MACRO
LD A,H ; }
ADD A,10H ; } move "right" one column (same row)
LD H,A ; }
ENDM
;
; external routines
;
.request zslib,z3lib,syslib
;
ext hvtinit,hvdinit,hvcls,hvon,hvoff,hprint,hpstr ; ZSLIB
ext eatspc,gcomnam,comnam
ext z3init,z3log,dirtdu,zsyschk,zprsfn,puter2 ; Z3LIB
ext getvid,getcrt,getprt,getwhl
ext getud,putud,logud,setdma,initfcb,bout,caps ; SYSLIB
ext pfn2,pafdc,f$exist,f$open,f$read,luinit,luread
ext luopen,bdos,bios,capin,codend
public cin,cout
jp start
db 'Z3ENV'
db 1
z3eadr: dw 0
;
; Configuration area for ZCNFG
;
hdu: db user
db disk ; A=0,B=1 etc.
db 'LBRHLP',ver/10+'0',ver mod 10+'0' ; for ZCNFG
helpdir:
db 'HELP ' ; help dir
deffn: db 'MENU ' ; help file
deflbr: db 'HLPFILES' ; default lbr file name
deftyp: db 'H?P'
defltyp:
db 'LBR'
ptrchk: db 0ffh ; 0ffh to do printer-ready test
;
; start of program -- initialize zcpr3 environment
;
start: ld hl,(z3eadr) ;pt to zcpr3 environment
call zsyschk ;check for z-system running
ret nz ;exit if not
ld sp,stack ; set local stack
call z3init ;initialize the zcpr3 env
call hvtinit ; initialize the terminal
ld hl,(bdose+1)
ld (obufhi),hl ; ptr to end of buffer
call membuf ; Set up pointers to burrers
xor a ; a=0
ld (hlplvl),a ; set help level to 0 (no return file)
ld (stdaln),a ; set to not reading standalone file
ld (sglhdu),a ; flag alternate dir not tried yet
ld hl,dftnam ; point to default name
call gcomnam ; get disk name
ld a,(fcb1+1) ; get first char of first arg
cp '/'
jp nz,nohelp ; skip help if not /
;
; usage screen
;
call hprint
dftnam: db 'LBRHLP '
IF UNCR
db 'UNCR'
ELSE ; UNSQ
db 'UNSQ'
ENDIF ; UNCR else UNSQ
db ' Version ',ver/10+'0','.',ver mod 10+'0'
db rev,cr,lf
dc 'Usage:',cr,lf,' '
ld hl,comnam
call hpstr
call hprint
db ' {-{dir:}library} {{dir:}hlpfile}',cr,lf
db 'The "-" required if LBR is specified.'
dc cr,lf,' Default LBR File: '
ld de,deflbr
call plib
call hprint
dc cr,lf,' Default HLP File: '
ld de,deffn
call plib
call hprint
dc cr,lf,' Alternate DIR : '
call defdu
jr z,hlpinf1
ex de,hl
call plib
jr hlpinf2
hlpinf1:
ld a,b
add a,'A'
call bout
ld a,c
call pafdc
hlpinf2:
call hprint
db ':',cr,lf
db 'If only "hlpfile" is given, preceded by a directory'
db cr,lf
db 'spec or colon, stand-alone HLP file is displayed.'
db cr,lf
dc 'If file is not found, "Alternate DIR" is also searched.'
jp hlpexit
nohelp: ld hl,tbuff+1 ; get 1st token from command tail
call eatspc ; skip leading spaces
cp '-' ; library specified?
jr nz,nolib
ld (fcb1+1),a ; indicate that 1st token was lbr name
inc hl ; pt to lbr name
jr nolib1
nolib:
ld l,tbuff ; H = 0
ld c,(hl)
ld b,h ; B = H = 0, so BC has CPIR leash
inc hl ; Bump past count
inc bc ; Guard against BC = 00
ld a,':' ; Scan for colon
cpir
jr nz,nolib0 ; No colon, check in default LBR
ld (stdaln),a ; Otherwise, flag standalone mode
ld de,fcb1 ; Point to default FCB
call z3log ; Log in as per CPR
call putud ; Save directory
ex de,hl ; Pointer to HL
inc hl ; Bump to name
ld a,(hl) ; Grab first character
cp ' ' ; Blank?
jp z,nofil ; Yes, use default help file name
jp yesfil ; Otherwise use ours
;
nolib0: ld hl,deflbr ; pt to default lbr name
;
; look in current dir
;
nolib1: ld de,ludfcb
xor a ; dir: before du:
call zprsfn ; parse in lbr name
or a ; A has count of "?"s in LUDFCB
jr nz,lfnfnd ; which must be zero for Z3Plus
ld hl,defltyp
push de
ld de,lbrtyp ; move "LBR"
ld bc,3
ldir
pop de
call z3log ; log into fcb's du
xor a ; clear auto drive select byte in fcb
ld (de),a
call f$exist ; is lbr in current du?
jr nz,lbrfnd
;
; look in help file directory
;
call defdu
call logud
call f$exist ; look for file
jr nz,lbrfnd
;
; library not found
;
lfnfnd: call hprint
dc ' Library File '
inc de ; pt to name
call plib ; print library name
jr nz,amberr
call hprint
notfnd: dc ' Not Found'
jr lfnfn1
amberr: call hprint
dc ' has ambiguous characters'
lfnfn1: jp hlpexit1
;
; library found so open it
;
lbrfnd: ld de,lud
call luinit
;
; check if lbr name given
;
ld hl,fcb1+1 ; pt to default fcb
ld a,(hl) ; get first char of file name
cp ' '
jr z,nofil ; if no file or library
cp '-' ; was lbr specified?
jr nz,chkfil ; no
ld hl,fcb2+1 ; get second arg
ld a,(hl)
chkfil: cp ' '
jr z,nofil
cp '?' ; is it a wild card?
jr nz,yesfil ; it wasn't
; otherwise load default filename
nofil: ld hl,deffn ; get default filename
yesfil: ld de,lfcb ; move filename in
ld bc,8
ldir
;
; start/restart help program (start on initial entry, restart on node load)
;
strt1: ld sp,stack ; reset the stack
ld de,lfcb+8
ld hl,deftyp ; get default type
ld bc,3
ldir ; move type
ld hl,lfcb ; pt to file name
ld a,(stdaln)
or a
jr nz,strt2
ld de,lud ; pt to lbr buffers
call luopen ; open file
jp z,filfnd
jr hfnf1
strt2: ex de,hl
dec de
call getud
strt3: ld hl,tbuff
call nz,setdma
call initfcb
call f$exist
strt4: jr z,hfnfnd
dec a
rrca
rrca
rrca
add a,l
ld l,a
push hl
ld bc,10
add hl,bc
ld a,(hl)
pop hl
and 7fh
IF UNCR
cp 'Z'
ELSE ; UNSQ
cp 'Q'
ENDIF ; UNCR else UNSQ
jr z,hfopen
cp 'L'
jr z,hfopen
ld c,18
call bdos
ld hl,tbuff
inc a
jr strt4
hfopen: ld de,ludfn-1
ld bc,12
push de
push hl
ldir
pop hl
ld de,lfcb-1
ld c,12 ; B = 0
ldir
pop de
call initfcb
call f$open
jr z,filfnd
;
; file not found so print file name and exit
;
hfnfnd: ld hl,sglhdu
ld a,(hl)
or a
jr nz,hfnf1
dec (hl)
call defdu
call logud
xor a
jr strt3
hfnf1: call hprint
hfstr: dc ' Help File '
ld de,lfcb ; pt to file name
call pfn2 ; print name
ld hl,notfnd
call hpstr
ld a,(stdaln)
or a
jr nz,hfnf2
call hprint
dc ' in '
ld de,lbrname
call pfn2
hfnf2: jr jrhlpx
;
; check file type for 'Q' or 'Z'
; if crunched run through uncrunch
; otherwise write out file to help buffer
;
filfnd: ld a,(ludtyp)
and 7fh ; clear any attributes
IF UNCR
cp 'Z'
jp z,uncrit
ELSE ; UNSQ
cp 'Q'
jp z,unsqit
ENDIF ; UNCR else UNSQ
cp 'L'
jr z,ncmprs
ld hl,hfstr
call hpstr
ld de,ludfn ; pt to file name
call plib ; print name
call hprint
dc ' in '
ld de,lbrname
call pfn2
call hprint
dc cr,lf,' has the unsupported filetype "'
call hvon
ld b,3
ld hl,ludtyp-1
wrgtyp: ld a,(hl)
call cout
inc hl
djnz wrgtyp
call hvoff
ld a,'"'
call cout
jrhlpx: jr hlpexit1
;
; this is used to extract files and not unsq or uncr
;
ncmprs: ld hl,(obufhi) ; get highest available memory
ld de,-80h ; .. minus 1 sector
add hl,de
ld c,l ; move to bc
ld b,h
call codend ; output buffer starts just above program
ld (outbuf),hl
ld de,lud
; read file directly into output buffer
inloop: call setdma
ld a,(stdaln)
or a
jr nz,inlp1
call luread ; read a sector from lbr
jr inlp2
inlp1: ld de,ludfn-1
call f$read
inlp2: jr nz,help ; done if end of file
ld a,b ; save B
ld b,80h
masklp: res 7,(hl) ; clear high bit
inc hl ; ..of each character read
djnz masklp
ld b,a ; restore B
sbc hl,bc ; check for overflow
add hl,bc ; restore value in hl without affecting flags
jr c,inloop
jp toobig
;
; start of help program
;
help: ld sp,stack ; insure good stack
ld hl,(outbuf) ; pt to buffer
xor a ; set no frame
ld (frnum),a
ld (sglhdu),a ; Reset alternate dir flag
ld a,(hl) ; no header section?
and 7fh ; mask out msb
cp sectchar
jr nz,help1 ; header section exists
inc hl ; skip over sectchar
call clscr ; new screen
call prinfo ; print help info pted to by hl
ld a,(hlplvl) ; check to see if we are not at level 0
or a ; 0=level 0
jp nz,lrurn ; go to previous level if not
;
; exit point for any exit from the rest of the help program
;
hlpexit:
xor a ; clear error flag
jr hlpext2
hlpexit1:
ld a,0ffh ; set error flag
hlpext2:
call puter2 ; set or clear error flag
call hvdinit
rst 0 ; reboot because we may have overwritten CCP
; Subroutine to return "Default DIR" du in BC register
defdu: ld hl,helpdir ; look for help directory
push hl
call dirtdu ; convert to du in bc
pop hl
ret nz ; log into du in bc if found
ld bc,(hdu) ; log into help directory
ret
;
; print header information and select an option
;
help1: call prheader ; print header
push bc ; save c (number of valid selections)
call crlf1 ; new line
call hvon ; goto dim
call prlevel ; print level number
call hprint
dc 'Enter Selection '
call prp1 ; print level movement prompt
call hvoff ; goto bright
pop bc ; get c
call cin ; get response
call caps ; capitalize
push af
call clscr ; clear screen
pop af
call ckabort ; exit?
jr z,hlpexit
cp rootchar ; go to root
jp z,goroot
call cklevel ; return to previous level?
jp z,lrurn
ld b,a ; user input in b
ld a,(htype) ; type of help file
cp ihchar ; indexed by user?
jr z,help5 ; find information section via index scan
ld a,b ; find information seciton via count
sub 'A'-1 ; adjust for count
ld b,a ; save count
jr z,badresponse
jr nc,help2
;
; invalid response
;
badresponse:
call sak ; ring bell
jr help1
;
; valid response -- look for and print information section
;
help2: inc c ; 1 more than number of possible selections
cp c ; greater than number of possible selections?
jr nc,badresponse
ld hl,(firstentry) ; get ptr to first entry
;
; print information when count is zero
;
help3: djnz help4 ; count down selections
inc hl ; skip over sectchar
call prinfo ; print info pted to by hl
jr help1
;
; locate next information section
;
help4: call findi ; skip to next information section
cp ctrlz ; end of file?
jr nz,help3 ; continue looping if not else fall thru to helperr
;
; error -- reached end of help file
;
helperr:
call hprint
dc cr,lf,' EOF on Help File'
jp help1
;
; locate next information section via index scan
;
help5: ld hl,(firstentry) ; pt to first entry
;
; look for user index
;
help6: push hl ; save ptr to this line
help7: inc hl ; skip over section char
ld a,(hl) ; get char
call caps ; capitalize
cp ' ' ; skip spaces
jr z,help7
cp sectchar ; new section?
jr z,help8 ; find next section
cp cr ; end of line?
jr z,help8 ; find next section
cp ctrlz ; eof?
jr z,help8
cp b ; check for user input
jr nz,help7
pop hl ; found it -- print it
inc hl ; skip over section char
help7a: ld a,(hl) ; skip to beginning for 1st line
inc hl ; pt to next
and 7fh
cp ctrlz ; trap eof
jr z,badresponse
cp sectchar ; file specified?
jr z,help7b ; process it
cp lf ; begin new line
jr z,help7c
cp cr ; at end of index line?
jr nz,help7a
ld a,(hl) ; get lf
and 7fh
cp lf ; skip following lf if any
jr nz,help7c
inc hl ; skip lf
jr help7c
;
; load next help level
;
help7b: dec hl ; pt to section char
;
; process help level or load and process next level pted to by hl
;
help7c: call prinfo ; print information section
jp help1 ; resume
help8:
pop hl ; pt to info section
call findi ; find next info section
cp ctrlz ; eof?
jr nz,help6 ; keep looking
jp badresponse
;
; skip to next information sections
; return with a=sectchar if found or a=^z if not
;
findi: ld a,(hl) ; <ctrl-z>?
and 7fh ; mask out msb
inc hl ; pt to next byte
cp ctrlz
ret z
cp lf ; line feed?
jr z,findi1
cp cr ; <cr>?
jr nz,findi
ld a,(hl) ; make sure lf
and 7fh
cp lf
jr nz,findi1
inc hl ; skip over lf
findi1: ld a,(hl) ; get char
and 7fh ; mask out msb
cp sectchar ; new section?
jr nz,findi ; continue looping
ret
;
; help support routine section
;
; print one line of info section; hl pts to line upon entry;
; hl pts to first char of next line upon exit
;
prline: ld a,(hl) ; get char
and 7fh ; mask out msb
cp cr ; eol?
jr z,crlf
cp lf ; line feed? (ws file)
jr z,crlf0
cp ctrlz ; end of file?
jr z,crlfc ; done if so
inc hl ; pt to next
cp dim ; goto standout mode?
jr z,prldim
cp ndim ; goto normal mode?
jr z,prlndim
call bout ; print char
jr prline
prldim:
call hvon ; enter standout mode
jr prline
prlndim:
call hvoff ; end standout mode
jr prline
;
; print crlf, pt to first char of next line, and page if necessary
;
crlf: inc hl ; pt to lf
crlf0: inc hl ; pt to 1st char of next line
crlfc: call crlf1 ; print crlf
ld a,(lcount) ; get line count
dec a
ld (lcount),a
ret nz ; ok -- continue
ld a,(hl) ; get next char
and 7fh
cp sectchar ; new section?
ret z ; don't page if so
cp ff ; formfeed?
ret z
cp ctrlz ; eof
ret z
crlfc1:
set 7,(hl) ; set msb of first char of next line
call prprompt ; print prompt and process common options
cp backupchar ; back up?
jp z,fbackup
cp strtchar ; jump to start of info
jp z,infostrt
fresume:
ld (strtframe),hl
jp setlcount
;
; print prompt and process common options
;
prprompt:
call hvon ; goto dim
call prlevel ; print level number
ld a,(frnum) ; increment frame number
inc a
ld (frnum),a
call prp1 ; print fundamental level data prompt
call hprint
db menuchar,'=Menu ' ; abort to menu char
db strtchar,'=Start ' ; jump to start of information char
dc backupchar,'=Last ' ; back up to previous frame char
call getwhl
jr z,prpr1
call hprint
dc prchar,'=Print ' ; print current frame
prpr1: call hvoff ; goto bright
call capin ; get response
push af
call clscr ; clear screen
pop af
pop de ; clear stack
call ckabort ; abort to os?
jp z,hlpexit
ld b,a ; save command char
call getwhl
ld a,b
jr z,prpr2
cp prchar ; print frame?
jp z,list0info
cp cprchar ; print information section?
jp z,list1info
prpr2:
cp rootchar ; go to root
jp z,goroot
call cklevel ; return to higher level?
jp z,lrurn
push de ; restore stack
cp menuchar ; redisply menu?
ret nz
ld hl,(outbuf) ; pt to buffer
ld a,(hl) ; no header section?
and 7fh ; mask out msb
cp sectchar
jp z,lrurn ; go to higher level if no header section
jp help ; else start from header section at this level
;
; print fundamental level prompt
;
prp1: call hprint
dc 'ESC=Exit '
ld a,(hlplvl) ; don"t print if at level 0
or a
ret z
call hprint
db lrchar2,'=^Level ' ; return to higher node
dc rootchar,'=Root ' ; return to root
ret
;
; jump to start of information
;
infostrt:
ld hl,(strtinfo) ; pt to start of info
ld a,1 ; reset frame count
ld (frnum),a
jp fresume ; continue processing
;
; back up to previous frame
;
fbackup:
call boicheck ; at beginning of information?
jr z,infostrt
fb1:
dec hl ; back up until byte with msb set is found
bit 7,(hl)
jr z,fb1
ld a,(frnum) ; decrement frame number
dec a ; back up to current frame number
dec a ; back up to previous frame number
ld (frnum),a
jp fresume ; continue processing
;
; Clear screen; print crlf if no TCAP
;
clscr: push hl
call getvid
jr z,nocls
push de
ld de,17h
add hl,de
ld a,(hl)
pop de
or a
nocls: pop hl
jp nz,hvcls
; fall thru to crlf1 if no cls function
;
; print cr and lf only
;
crlf1: ld a,cr ; print cr
call bout
ld a,lf ; print lf
jp bout
;
; set lcount variable to screen size
;
setlcount:
push hl
call getcrt
inc hl ; get number of lines on crt
ld a,(hl)
dec a ; 1 less for prompt
ld (lcount),a
pop hl
ret
;
; print the header section and load firstentry ptr
; on return, c=number of possible selections
;
prheader:
xor a ; set no frame
ld (frnum),a
call setlcount
sub 3 ; -3 lines for top and bottom
ld (lcount),a
ld a,'A' ; init selection char
ld (selchar),a
call clscr ; clear screen
call hprint
db 'Lbrhlp '
db (ver/10)+'0','.',(ver mod 10)+'0'
dc rev,' '
ld de,ludfn ; pt to fcb
call plib ; print with no spaces
call hprint
dc ' Index',cr,lf,lf
ld c,0 ; count number of selections
ld hl,(outbuf) ; pt to buffer
ld a,(hl) ; get first char
ld (htype),a ; set type of help file
cp ihchar ; indexed help type?
jr nz,ph1
inc hl ; skip over index help type flag
;
; print line until first information section found
;
ph1: ld a,(hl) ; get char
and 7fh ; mask out msb
cp sectchar
jr z,ph2
cp ctrlz ; eof? -- abort
jp z,hlpexit
inc c ; increment selection count
ld a,(htype) ; check for index
cp ihchar
jr z,ph1a ; skip letters if indexed
ld a,(selchar) ; display selection char
call bout
inc a ; incr char
ld (selchar),a
call hprint
dc '. '
ph1a: call prline ; print header line
jr ph1
;
; save ptr to first entry
;
ph2: ld (firstentry),hl
ld a,(lcount) ; get count of remaining lines
ld b,a ; ... in b
or a ; any left?
ret z
skipout:
call crlf1 ; new line
djnz skipout
ret
;
; print an information section
; information section is pted to by hl
;
prinfo: ld (strtinfo),hl ; set start of information pointer
call ldnod ; load new node if dual sectchar
ld (strtframe),hl ; set frame pointer
set 7,(hl) ; set msb
call setlcount
ld a,1 ; a=1
ld (frnum),a ; set frame number
pi1: call prline ; print line from info file
ld a,(hl) ; done?
and 7fh ; mask out msb
cp ctrlz ; eof?
jr z,pi2
cp sectchar ; next section
jr z,pi2
cp ff ; form feed?
jr nz,pi1
inc hl ; pt to char after form feed
call formfeed ; feed screen
jr pi1
;
; form feed screen
;
formfeed:
ld a,(lcount) ; get line count
ld b,a ; ... in b
or a ; 0 already?
call nz,skipout ; print blank lines if not
jp crlfc1 ; go to end of screen processing
;
; end of info
;
pi2: set 7,(hl) ; set msb of next byte
ld a,(lcount) ; get line count
or a
ld b,a
call nz,skipout
pi2msg:
call hprint ; print end of information indicator
dc 'EOI '
call prprompt ; print prompt and process common options
cp backupchar ; back up from eoi?
jr z,pi2backup
cp strtchar ; start of info?
jr z,pi2strt
jp setlcount ; reset line count in case of all
;
; jump to start of info from eoi
;
pi2strt:
ld hl,(strtinfo) ; pt to start of info
call fresume ; reset pointers
ld a,1 ; reset frame count
ld (frnum),a
jr pi1 ; continue processing
;
; back up to previous frame from eoi
;
pi2backup:
call boicheck ; at beginning of information?
jr z,pi2strt
pi2back:
call fb1 ; back up to previous frame
jr pi1 ; continue processing
;
; check for position at beginning of information section
; if so, print backup error msg and return w/zero set
;
boicheck:
ld hl,(strtinfo) ; start address
ex de,hl ; ... in de
ld hl,(strtframe) ; frame address
ld a,d ; equal?
cp h
ret nz
ld a,e
cp l
ret nz
call sak ; error bell
xor a ; zero flag set
ld (frnum),a ; set frame number
ret
;
; this body of code lists information from help2 to the
; printer
;
; list one line of info section; hl pts to line upon entry;
; hl pts to first char of next line upon exit
; z flag set if user aborts
;
listline:
ld a,(hl) ; get char
and 7fh ; mask out msb
cp cr ; eol?
jr z,lcrlf
cp lf ; line feed? (ws file)
jr z,lcrlf0
cp ctrlz ; end of file?
jr z,lcrlfc ; done if so
inc hl ; pt to next
cp tab
jr z,ltab ; expand tab
cp ctrlc
jr c,listline ; don't print highlight control chars
inc b ; bump char count
call lstout ; print char
ret z ; abort
jr listline
;
; expand tabs
;
ltab: ld a,' '
call lstout ; print a space
ret z ; user abort?
inc b ; bump char count
ld a,b
and 7 ; at tab stop?
jr nz,ltab ; no, print more spaces
jr listline
;
; list crlf, pt to first char of next line, and page if necessary
;
lcrlf: inc hl ; pt to lf
lcrlf0: inc hl ; pt to 1st char of next line
lcrlfc: call lcrlf1 ; print crlf
ret z ; abort
ld a,(lcount) ; get line count
dec a
ld (lcount),a
ret nz ; ok -- continue
call lformfeed ; advance to next page
setplc: push hl ; save hl
call getprt ; pt to printer info in env
inc hl
inc hl ; pt to lines of text
ld a,(hl)
ld (lcount),a ; set line count
pop hl ; restore hl
ret
lcrlf1:
ld a,cr ; send <crlf> to printer
call lstout
ret z ; abort
ld a,lf ; fall thru to lstout
;
; print character in a on printer; affect no registers
;
lstout: push hl ; save regs
push de
push bc
ld e,a ; char in e
ld c,5 ; bdos prer output routine
call bdose
ld e,0ffh ; conditional input
ld c,6 ; direct console i/o
call bdose
pop bc ; restore regs
pop de
pop hl
call ckabort ; abort?
ret
;
; list the current information section
; information section is pted to by strtinfo
;
; list0info -- list current frame only
; list1info -- list current information section
;
list0info:
ld hl,(strtframe) ; list current frame only
ld a,0ffh ; set flag
ld (lfrflag),a ; list frame only
jr list2info
list1info:
ld hl,(strtinfo) ; prepare to list entire info section
xor a ; clear frame list flag
ld (lfrflag),a
list2info:
call listinfo ; do print
call clscr ; clear screen
ld a,(ffflg) ; did we just do a formfeed?
or a
call z,lformfeed ; form feed printer if not
ld sp,stack-2 ; fix stack pointer
ld hl,(strtframe) ; return to frame we were on
call fresume
ld a,(frnum) ; adjust frame numbering
dec a
ld (frnum),a
jp pi1 ; resume at pi1
;
; main print routine
; z flag set on exit if user aborts
;
listinfo:
ld a,(ptrchk) ; do printer check?
or a
jr z,prtrdy ; no, assume printer is ready
ld a,15 ; bios list status
call bios ; check for printer ready
or a
jr nz,prtrdy
dec a
ld (ffflg),a ; set no form feed if no printer...
call hprint
db bel
db cr,lf,'Printer Off Line - Press Any Key To Recheck'
db ' (Q=Quit)',0
call capin
cp 'Q' ; an escape route, if needed
jr nz,listinfo ; try again
ret
;
prtrdy: call clscr ; print frame or info section
call hprint
dc cr,lf,' Printing '
call setplc ; set printer line count
xor a
ld (ffflg),a ; clear formfeed flag
li1: ld b,0 ; init count of chars on line for tab expansion
call listline ; list line from info file
ret z ; feed printer and exit if abort
ld a,(hl) ; done?
and 7fh ; mask out msb
cp ctrlz ; eof?
ret z ; resume if at end of info
cp sectchar ; next section
ret z ; resume if at end of info
cp ff ; form feed?
jr nz,li1
ld a,(lfrflag) ; list frame only?
or a ; 0=no
ret nz
inc hl ; pt to char after form feed
call lcrlfc ; new line
ret z ; abort
ld b,10 ; print separator
li2: ld a,'-' ; dashes
call lstout
ret z ; abort?
djnz li2
call lcrlfc ; 2 new lines
ret z
call lcrlfc
ret z
jr li1
;
; form feed printer
;
lformfeed:
call lcrlf1 ; new line
ld a,ff ; output form feed
ld (ffflg),a ; set formfeed flag
jp lstout
;
; end of body of code which lists information from help2 to
; the printer
;
; at the beginning of an information section (hl pts to first char)
; check to see if another sectchar follows, and, if so, load the
; specified file as a new node and begin processing it
;
ldnod: ld a,(hl) ; get it
and 7fh ; mask msb
cp sectchar ; another one?
ret nz ; process normally if not
;
; we have a new node -- check to see if we can nest again
;
ld a,(hlplvl) ; get current help level
cp 25 ; at maximum?
jr nz,ldnod1
call hprint
dc cr,lf,' Node Level Limit'
jp hlpexit1
;
; we have not reached level limit, so continue
; at this time, a=help level index and hl = ptr to current section (::)
;
ldnod1:
;
; save current help file name for return
;
inc hl ; now pointing to file name
push hl ; save ptr
call comptr ; hl=pointer to stack elt indexed by a
ex de,hl ; de=address of next element
;
; copy current node element name into next stack element
;
ld hl,lfcb ; pt to file name
ld bc,8 ; 8 bytes
ldir
;
; increment help level
;
inc a ; set new level
ld (hlplvl),a
;
; set up fcb for new file
;
pop hl ; get ptr to new file name
ld de,lfcb ; pt to fcb name
ld b,8 ; 8 chars max
call ldfcb ; place into fcb with error checking
;
; print loading help file message
;
plhfm: call hprint
dc cr,lf,' Loading HELP File '
ld de,lfcb ; print file name
call plib
call crlf1
jp strt1 ; load new help file
;
; load fcb pted to by de with "normal" file name pted to by hl for b bytes
;
ldfcb: ld a,(hl) ; get char
inc hl ; pt to next
cp '.' ; done if decimal
jr z,ldfcb2
cp ' '+1 ; done if <= <sp>
jr c,ldfcb2
call caps ; capitalize
ld (de),a ; store char
inc de ; pt to next
djnz ldfcb
ldfcb1:
ld a,(hl) ; check for error
and 7fh ; mask msb
inc hl ; pt to next char
cp '.' ; ok if '.'
ret z
cp ' '+1 ; ok if <= <sp>
ret c
jr ldfcb1
ldfcb2: ld c,a ; save char that terminated string
ldfcb3: ld a,' ' ; <sp> fill rest of fcb
ld (de),a ; store <sp>
inc de ; pt to next
djnz ldfcb3
ld a,c ; get char that terminated string
ret
;
; go to root
;
goroot: ld a,(hlplvl) ; at root?
or a ; 0=yes
jp z,help ; return to help
xor a ; set root index
jr goret
;
; return to previous help level
;
lrurn: ld a,(hlplvl) ; are we at the lowest level?
or a ; 0=yes
jr nz,lret
call sak ; error bell
jp help
;
; set new help level
;
lret: dec a ; down 1 and fall thru to goret
;
; go to help level indexed in a
;
goret: ld (hlplvl),a ; set new help level
call comptr ; hl=pointer to target help file name
ld de,lfcb ; copy element into fcb
ld bc,8 ; 8 bytes
ldir
jr plhfm ; print loading message and load
;
; compute pointer to help name entry indexed by help level in a
;
comptr: ld l,a ; value in hl
ld h,0 ; compute offset as index*11
add hl,hl ; *2
add hl,hl ; *4
add hl,hl ; *8
ld de,hlpns ; pt to base of help names
add hl,de ; add in offset
ret
;
; print level number
;
prlevel:
ld a,(hlplvl) ; dont print level 0
or a ; 0?
jr z,prframe
call hprint
dc 'Level '
call pafdc ; print as decimal
ld a,(frnum) ; get frame number
or a ; set flags
ld a,'/' ; prep to print slash
call nz,bout ; print slash if frame is non-zero
prframe:
ld a,(frnum) ; get number
or a
ld a,' ' ; prep to print space on exit
jp z,bout
ld a,(frnum) ; get frame number again
call pafdc ; print as decimal
call hprint
dc ': '
ret
;
; check for user abort via ^C or ESC characters (returns Z if so)
;
ckabort:
cp cpmabortchar ; aborting?
ret z ; (yes)
cp exitchar ; aborting via alternate character?
ret
;
; check for request to move up a level (returns Z if so)
;
cklevel:
cp lrchar ; up a level?
ret z ; (yes)
cp lrchar2 ; up via alternate character?
ret
;===============================
IF UNCR
;-------------------------------
uncrit: ; main uncrunch routine
ld hl,(endall)
call setup
call uncrel
jp nc,help
dec a
jr z,toonew
call HPRINT
dc ' Invalid crunched file'
jr errexit
toonew:
call HPRINT
dc ' File needs newer revision'
errexit:
jp hlpexit1
;-------------------------------
ELSE ; UNSQ
;-------------------------------
unsqit: ; main unsqueeze routine
ld hl,(endall)
call setup
call usqrel
jp nc,help
call HPRINT
dc ' Unsqueeze Error: '
cp 1
jr z,dcoderr
cp 3
jr z,chksumerr
cp 4
jr z,notsqed
call HPRINT
dc 'Premature EOF'
jr errexit
dcoderr:
call HPRINT
dc 'Decode Size'
jr errexit
chksumerr:
call HPRINT
dc 'Checksum'
errexit:
jp hlpexit1
notsqed:
call hprint
dc 'Not a valid squeezed file'
jr errexit
;-------------------------------
ENDIF ; UNCR else UNSQ
;===============================
;
; "a" <-- next byte from ("physical") input stream.
; returns with carry set on eof.
getchr equ $
getbyt equ $
exx ; switch to i/o regs
or a ; be sure carry is clear
inc l ; point to next char loc in buffer
call z,rdsec ; read another sector if at 0
ld a,(hl) ; get byte to return (garbage if eof)
exx ; back to normal regs & rtn
ret ;
;................................
;
; subr for [ non multi-] reload, reads 128 bytes to default dma
;
rdsec: push de ; save de before clobbering it with fcb
ld a,(stdaln)
or a
jr nz,rdsec1
ld de,lud ; input fcb
call luread ; read a record
jr rdsec2
rdsec1: ld de,ludfn-1
call f$read
rdsec2: pop de ; restore de to value on entry
ld hl,tbuff
ret z ; return if successful
scf ; indicate eof reached
ret
;______________________________________________________________________________
;
; output char in 'A' to the output buffer.
;
out: exx ; switch to i/o regs
and 7fh ; clear high bit
ld (de),a ; put byte into the next avail position
inc de ; pt to next position in buffer
push hl
ld hl,(obufhi) ; highest memory available
sbc hl,de ; compare
pop hl
exx ; flip regs
ret nz ; Return if limit not reached
toobig: call hprint
dc ' Memory Overflow, File too large'
jp hlpexit1
;-----------------------------------------------------------------------------
; enter with hl pointing to first byte of output buffer area
; Setup - used to init buffers
setup: ld (outbuf),hl ; this points to the proper place
exx
ld hl,0ffh
ld de,(outbuf)
exx
ret
plib: push af
push bc
push de
ld b,8 ; prt 8 chars only
plib1: ld a,(de)
and 7fh
cp ' '
call nz,bout
inc de
djnz plib1
pop de
pop bc
pop af
ret
sak: ld a,bel
cout: jp bout
; get a char from console via dos dconio
cin: push hl
push de
push bc
cin1: ld c,6 ; direct console i/o
ld e,0ffh ; get character
call bdose
or a ; got a character?
jr z,cin1 ; no, try again
pop bc
pop de
pop hl
ret
;
;===============================
IF UNCR
include lh-uncr ; uncrunch routines
ELSE ; UNSQ
include lh-unsq ; unsqueeze routines
ENDIF ; UNCR else UNSQ
;===============================
;
DSEG
IF UNCR
; the following ram locs must be re-initialized each time the program is
; executed (for each file when wildcards are used). the area called "shadow"
; in LH-UNCR.LIB is used to accomplish this.
ram equ $
fulflg: ds 1 ; becomes "ff" when table is full
lastpr: ds 2 ; "last pred"
entflg: ds 1 ; flag prevents duplicating entries
entry: ds 2 ; current entry (code) number.
csave: ds 1
codlen: ds 1 ; current code length, in bits.
trgmsk: ds 1 ; mask contains "1" bit in pos of next code len
;..............................................................................
;______________________________________________________________________________
char: ds 1 ; last char of the previously decoded string
avail: ds 2 ; *
ffflag: ds 1 ; *
disp: ds 2 ;
;................................
table: ds 1
tablhi: ds 1
eotbl:
xlatbl: ds 1
xlatbh: ds 1
exlatb:
botstk: ds 2
topstk:
endall: ds 2
stklim: ds 2
hasher: ds 2
ELSE ; UNSQ
table: ds 1
tablhi: ds 1
tabtop:
stkbot: ds 2
stktop:
endall: ds 2
ENDIF ; UNCR else UNSQ
stdaln: ds 1
sglhdu: ds 1
ffflg: ds 1 ; formfeed indicator
htype: ds 1 ; type of help file (if = ihchar, it is indexed by usr)
lfrflag:
ds 1 ; list frame only flag (for print function)
strtinfo:
ds 2 ; ptr to start of current information block
strtframe:
ds 2 ; ptr to start of current frame
selchar:
ds 1 ; selection table option char
firstentry:
ds 2 ; ptr to first entry of information section
lcount: ds 1 ; line count buffer
hlplvl: ds 1 ; number of help level current node is at (0=bottom)
frnum: ds 1 ; number of current frame
obufhi: ds 2 ; hi byte of output buffer
outbuf: ds 2 ; ptr to output buffer
lud: ds 2 ; length of du dir
ds 2 ; index
ds 2 ; length of current entry
ludfn: ds 8 ; filename
ds 1 ; first byte of type
ludtyp: ds 2 ; ptr to type for 'Q' or 'Z'
ludfcb: ds 1
lbrname:
ds 8
lbrtyp: ds 27
lfcb: ds 11 ; name of current help file
ds 22 ; extra room for search first/next calls
stksav: ds 2 ; uncrunch stack location
hlpns: ds 200 ; room for 25 help file names
ds 60
stack: ds 2
;
end