home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / enterprs / cpm / utils / f / lbrhlp22.lbr / LBRHLP22.ZZ0 / LBRHLP22.Z80
Text File  |  1992-05-09  |  35KB  |  1,557 lines

  1. ; program name:    LBRHLP.Z80
  2. ; author:    Bob Peddicord
  3. ; date:        Jan 88
  4. ; version:    1.0
  5. ;
  6. ; derivation:  help53 by Richard Conn
  7. ; some help routines from help52
  8. ; I want to thank Steve Greenberg for his uncrunch code
  9. ;
  10. ; Version 2.2 by Gene Pizzetta, 5/10/92.
  11. ; See LBRHLP.HIS for revision history.
  12.  
  13. ver    equ    22
  14. rev    equ    ' '
  15.  
  16. false    equ    0
  17. no    equ    false
  18. n    equ    false
  19. true    equ    not false
  20. yes    equ    not false
  21. y    equ    not false
  22.  
  23. ; Select decompression method
  24.  
  25. .accept    'Enter "Y" for uncrunching or "N" for unsqueezing: ',uncr
  26.  
  27. ;
  28. ; directory of help files if help directory not found
  29. ;
  30. disk    equ    'A'-'A' ; disk
  31. user    equ    15 ; user
  32. ;
  33. ; enter/exit standout mode
  34. ;
  35. dim    equ    1
  36. ndim    equ    2
  37. ;
  38. ; constants
  39. ;
  40. udflag    equ    4    ; address of user/disk flag
  41. bdose    equ    5    ; address of bdos entry point
  42. fcb1    equ    5ch
  43. fcb2    equ    6ch
  44. tbuff    equ    80h    ; address of dma buffer
  45.  
  46. inbufsz    equ    1    ; input buffer size (1 page)
  47.  
  48. tab    equ    9        ; <ht>
  49. cr    equ    0dh    ; <cr>
  50. lf    equ    0ah    ; <lf>
  51. esc    equ    1bh    ; escape
  52. bel    equ    'G'-'@'    ; ^g
  53. ff    equ    'L'-'@'    ; ^l = form feed
  54. ctrlz    equ    'Z'-'@'    ; ^z
  55. ctrlc    equ    'C'-'@'    ; ^c
  56. ;
  57. ; help control characters
  58. ;
  59. ihchar        equ    ';'    ; flag indicating indexed by user
  60. sectchar    equ    ':'    ; defined to be colon
  61. backupchar    equ    'L'    ; back up to previous frame char
  62. strtchar    equ    'S'    ; jump to start of information char
  63. menuchar    equ    'M'    ; char to abort to menu
  64. cpmabortchar    equ    ctrlc    ; char to exit
  65. exitchar    equ    esc    ; char to exit (alternate)
  66. lrchar        equ    '^'    ; return to previous help level
  67. lrchar2        equ    ','    ; return to previous help level (alternate)
  68. rootchar    equ    '.'    ; return to root of help
  69. prchar        equ    'P'    ; print current frame
  70. cprchar        equ    'P'-'@'    ; print current information section
  71. ;
  72.  IF UNCR
  73.  
  74. SIGREV    EQU    20H        ; "significant" revision level (compatibility)
  75.  
  76. NOPRED    EQU    0FFFFH        ; "no predecessor"
  77. IMPRED    EQU    07FFFH        ; Pred that can't be matched or bumped
  78.  
  79.                 ; --- reserved codes ---
  80. EOFCOD    EQU    100H        ; EOF code
  81. RSTCOD    EQU    101H        ; Adaptive reset code
  82. NULCOD    EQU    102H        ; Null code
  83. SPRCOD    EQU    103H        ; Spare code
  84.  
  85.  ENDIF    ; UNCR
  86. ;______________________________________________________________________________
  87. ;
  88. ; Macros to facilitate "horizontal" movement through the table.
  89. ; See "Table structure" comment near "initbl" for more information.
  90. ;
  91. RIGHT1     MACRO
  92.     LD    A,H        ; }
  93.     ADD    A,10H        ; } move "right" one column (same row)
  94.     LD    H,A        ; }
  95.      ENDM
  96. ;
  97. ; external routines
  98. ;
  99.     .request    zslib,z3lib,syslib
  100. ;
  101.     ext    hvtinit,hvdinit,hvcls,hvon,hvoff,hprint,hpstr    ; ZSLIB
  102.     ext    eatspc,gcomnam,comnam
  103.     ext    z3init,z3log,dirtdu,zsyschk,zprsfn,puter2    ; Z3LIB
  104.     ext    getvid,getcrt,getprt,getwhl
  105.     ext    getud,putud,logud,setdma,initfcb,bout,caps    ; SYSLIB
  106.     ext    pfn2,pafdc,f$exist,f$open,f$read,luinit,luread
  107.     ext    luopen,bdos,bios,capin,codend
  108.  
  109.     public    cin,cout
  110.  
  111.     jp    start
  112.  
  113.     db    'Z3ENV'
  114.     db    1
  115. z3eadr:    dw    0
  116. ;
  117. ; Configuration area for ZCNFG
  118. ;
  119. hdu:    db    user
  120.     db    disk        ; A=0,B=1 etc.
  121.     db    'LBRHLP',ver/10+'0',ver mod 10+'0'    ; for ZCNFG
  122. helpdir:
  123.     db    'HELP    '    ; help dir
  124. deffn:    db    'MENU    '    ; help file
  125. deflbr:    db    'HLPFILES'    ; default lbr file name
  126. deftyp:    db    'H?P'
  127. defltyp:
  128.     db    'LBR'
  129. ptrchk:    db    0ffh        ; 0ffh to do printer-ready test
  130. ;
  131. ; start of program -- initialize zcpr3 environment
  132. ;
  133. start:    ld    hl,(z3eadr)    ;pt to zcpr3 environment
  134.     call    zsyschk        ;check for z-system running
  135.     ret    nz        ;exit if not
  136.     ld    sp,stack    ; set local stack
  137.     call    z3init        ;initialize the zcpr3 env
  138.     call    hvtinit        ; initialize the terminal
  139.     ld    hl,(bdose+1)
  140.     ld    (obufhi),hl    ; ptr to end of buffer
  141.     call    membuf        ; Set up pointers to burrers
  142.  
  143.     xor    a        ; a=0
  144.     ld    (hlplvl),a    ; set help level to 0 (no return file)
  145.     ld    (stdaln),a    ; set to not reading standalone file
  146.     ld    (sglhdu),a    ; flag alternate dir not tried yet
  147.     ld    hl,dftnam    ; point to default name
  148.     call    gcomnam        ; get disk name
  149.     ld    a,(fcb1+1)    ; get first char of first arg
  150.     cp    '/'
  151.     jp    nz,nohelp    ; skip help if not /
  152. ;
  153. ; usage screen
  154. ;
  155.     call    hprint
  156. dftnam:    db    'LBRHLP  '
  157.  IF UNCR
  158.     db    'UNCR'
  159.  ELSE    ; UNSQ
  160.     db    'UNSQ'
  161.  ENDIF    ; UNCR else UNSQ
  162.     db    ' Version ',ver/10+'0','.',ver mod 10+'0'
  163.     db    rev,cr,lf
  164.     dc    'Usage:',cr,lf,'  '
  165.     ld    hl,comnam
  166.     call    hpstr
  167.     call    hprint
  168.     db    ' {-{dir:}library} {{dir:}hlpfile}',cr,lf
  169.     db    'The "-" required if LBR is specified.'
  170.     dc    cr,lf,'  Default LBR File: '
  171.     ld    de,deflbr
  172.     call    plib
  173.     call    hprint
  174.     dc    cr,lf,'  Default HLP File: '
  175.     ld    de,deffn
  176.     call    plib
  177.     call    hprint
  178.     dc    cr,lf,'  Alternate DIR   : '
  179.     call    defdu
  180.     jr    z,hlpinf1
  181.     ex    de,hl
  182.     call    plib
  183.     jr    hlpinf2
  184.  
  185. hlpinf1:
  186.     ld    a,b
  187.     add    a,'A'
  188.     call    bout
  189.     ld    a,c
  190.     call    pafdc
  191. hlpinf2:
  192.     call    hprint
  193.     db    ':',cr,lf
  194.     db    'If only "hlpfile" is given, preceded by a directory'
  195.     db    cr,lf
  196.     db    'spec or colon, stand-alone HLP file is displayed.'
  197.     db    cr,lf
  198.     dc    'If file is not found, "Alternate DIR" is also searched.'
  199.     jp    hlpexit
  200.  
  201. nohelp:    ld    hl,tbuff+1    ; get 1st token from command tail
  202.     call    eatspc        ; skip leading spaces
  203.     cp    '-'        ; library specified?
  204.     jr    nz,nolib
  205.  
  206.     ld    (fcb1+1),a    ; indicate that 1st token was lbr name
  207.     inc    hl        ; pt to lbr name
  208.     jr    nolib1
  209. nolib:
  210.     ld    l,tbuff        ; H = 0
  211.     ld    c,(hl)
  212.     ld    b,h        ; B = H = 0, so BC has CPIR leash
  213.     inc    hl        ; Bump past count
  214.     inc    bc        ; Guard against BC = 00
  215.     ld    a,':'        ; Scan for colon
  216.     cpir
  217.     jr    nz,nolib0    ; No colon, check in default LBR
  218.     ld    (stdaln),a    ; Otherwise, flag standalone mode
  219.     ld    de,fcb1        ; Point to default FCB
  220.     call    z3log        ; Log in as per CPR
  221.     call    putud        ; Save directory
  222.     ex    de,hl        ; Pointer to HL
  223.     inc    hl        ; Bump to name
  224.     ld    a,(hl)        ; Grab first character
  225.     cp    ' '        ; Blank?
  226.     jp    z,nofil        ; Yes, use default help file name
  227.     jp    yesfil        ; Otherwise use ours
  228. ;
  229. nolib0:    ld    hl,deflbr    ; pt to default lbr name
  230. ;
  231. ; look in current dir
  232. ;
  233. nolib1:    ld    de,ludfcb
  234.     xor    a        ; dir: before du:
  235.     call    zprsfn        ; parse in lbr name
  236.     or    a        ; A has count of "?"s in LUDFCB
  237.     jr    nz,lfnfnd    ; which must be zero for Z3Plus
  238.     ld    hl,defltyp
  239.     push    de
  240.     ld    de,lbrtyp    ; move "LBR"
  241.     ld    bc,3
  242.     ldir
  243.     pop    de
  244.     call    z3log        ; log into fcb's du
  245.     xor    a        ; clear auto drive select byte in fcb
  246.     ld    (de),a
  247.     call    f$exist        ; is lbr in current du?
  248.     jr    nz,lbrfnd
  249. ;
  250. ; look in help file directory
  251. ;
  252.     call    defdu
  253.     call    logud
  254.     call    f$exist        ; look for file
  255.     jr    nz,lbrfnd
  256. ;
  257. ; library not found
  258. ;
  259. lfnfnd:    call    hprint
  260.     dc    ' Library File '
  261.     inc    de        ; pt to name
  262.     call    plib        ; print library name
  263.  
  264.     jr    nz,amberr
  265.     call    hprint
  266. notfnd:    dc    ' Not Found'
  267.     jr    lfnfn1
  268. amberr:    call    hprint
  269.     dc    ' has ambiguous characters'
  270. lfnfn1:    jp    hlpexit1
  271. ;
  272. ; library found so open it
  273. ;
  274. lbrfnd:    ld    de,lud
  275.     call    luinit
  276. ;
  277. ; check if lbr name given
  278. ;
  279.     ld    hl,fcb1+1    ; pt to default fcb
  280.     ld    a,(hl)        ; get first char of file name
  281.     cp    ' '
  282.     jr    z,nofil        ; if no file or library
  283.  
  284.     cp    '-'        ; was lbr specified?
  285.     jr    nz,chkfil    ; no
  286.  
  287.     ld    hl,fcb2+1    ; get second arg
  288.     ld    a,(hl)
  289. chkfil:    cp    ' '
  290.     jr    z,nofil
  291.  
  292.     cp    '?'        ; is it a wild card?
  293.     jr    nz,yesfil    ; it wasn't
  294.  
  295. ; otherwise load default filename
  296. nofil:    ld    hl,deffn    ; get default filename
  297. yesfil:    ld    de,lfcb        ; move filename in
  298.     ld    bc,8
  299.     ldir
  300. ;
  301. ; start/restart help program (start on initial entry, restart on node load)
  302. ;
  303. strt1:    ld    sp,stack    ; reset the stack
  304.     ld    de,lfcb+8
  305.     ld    hl,deftyp    ; get default type
  306.     ld    bc,3
  307.     ldir            ; move type
  308.     ld    hl,lfcb        ; pt to file name
  309.     ld    a,(stdaln)
  310.     or    a
  311.     jr    nz,strt2
  312.     ld    de,lud        ; pt to lbr buffers
  313.     call    luopen        ; open file
  314.     jp    z,filfnd
  315.     jr    hfnf1
  316. strt2:    ex    de,hl
  317.     dec    de
  318.     call    getud
  319. strt3:    ld    hl,tbuff
  320.     call    nz,setdma
  321.     call    initfcb
  322.     call    f$exist
  323. strt4:    jr    z,hfnfnd
  324.     dec    a
  325.     rrca
  326.     rrca
  327.     rrca
  328.     add    a,l
  329.     ld    l,a
  330.     push    hl
  331.     ld    bc,10
  332.     add    hl,bc
  333.     ld    a,(hl)
  334.     pop    hl
  335.     and    7fh
  336.  IF UNCR
  337.     cp    'Z'
  338.  ELSE    ; UNSQ
  339.     cp    'Q'
  340.  ENDIF    ; UNCR else UNSQ
  341.     jr    z,hfopen
  342.     cp    'L'
  343.     jr    z,hfopen
  344.     ld    c,18
  345.     call    bdos
  346.     ld    hl,tbuff
  347.     inc    a
  348.     jr    strt4
  349.  
  350. hfopen:    ld    de,ludfn-1
  351.     ld    bc,12
  352.     push    de
  353.     push    hl
  354.     ldir
  355.     pop    hl
  356.     ld    de,lfcb-1
  357.     ld    c,12        ; B = 0
  358.     ldir
  359.     pop    de
  360.     call    initfcb
  361.     call    f$open
  362.     jr    z,filfnd    
  363. ;
  364. ; file not found so print file name and exit
  365. ;
  366. hfnfnd:    ld    hl,sglhdu
  367.     ld    a,(hl)
  368.     or    a
  369.     jr    nz,hfnf1
  370.     dec    (hl)
  371.     call    defdu
  372.     call    logud
  373.     xor    a
  374.     jr    strt3    
  375. hfnf1:    call    hprint
  376. hfstr:    dc    ' Help File '
  377.     ld    de,lfcb        ; pt to file name
  378.     call    pfn2        ; print name
  379.     ld    hl,notfnd
  380.     call    hpstr
  381.     ld    a,(stdaln)
  382.     or    a
  383.     jr    nz,hfnf2
  384.     call    hprint
  385.     dc    ' in '
  386.     ld    de,lbrname
  387.     call    pfn2
  388. hfnf2:    jr    jrhlpx
  389. ;
  390. ; check file type for 'Q' or 'Z'
  391. ; if crunched run through uncrunch
  392. ; otherwise write out file to help buffer
  393. ;
  394. filfnd:    ld    a,(ludtyp)
  395.     and    7fh        ; clear any attributes
  396.  IF UNCR
  397.     cp    'Z'
  398.     jp    z,uncrit
  399.  ELSE    ; UNSQ
  400.     cp    'Q'
  401.     jp    z,unsqit
  402.  ENDIF    ; UNCR else UNSQ
  403.     cp    'L'
  404.     jr    z,ncmprs
  405.  
  406.     ld    hl,hfstr
  407.     call    hpstr
  408.     ld    de,ludfn    ; pt to file name
  409.     call    plib        ; print name
  410.     call    hprint
  411.     dc    ' in '
  412.     ld    de,lbrname
  413.     call    pfn2
  414.     call    hprint
  415.     dc    cr,lf,' has the unsupported filetype "'
  416.     call    hvon
  417.     ld    b,3
  418.     ld    hl,ludtyp-1
  419. wrgtyp:    ld    a,(hl)
  420.     call    cout
  421.     inc    hl
  422.     djnz    wrgtyp
  423.     call    hvoff
  424.     ld    a,'"'
  425.     call    cout
  426. jrhlpx:    jr    hlpexit1
  427. ;
  428. ; this is used to extract files and not unsq or uncr
  429. ;
  430. ncmprs:    ld    hl,(obufhi)    ; get highest available memory
  431.     ld    de,-80h        ; .. minus 1 sector
  432.     add    hl,de
  433.     ld    c,l        ; move to bc
  434.     ld    b,h
  435.     call    codend        ; output buffer starts just above program
  436.     ld    (outbuf),hl
  437.     ld    de,lud
  438.  
  439. ; read file directly into output buffer
  440.  
  441. inloop:    call    setdma
  442.     ld    a,(stdaln)
  443.     or    a
  444.     jr    nz,inlp1
  445.     call    luread        ; read a sector from lbr
  446.     jr    inlp2
  447. inlp1:    ld    de,ludfn-1
  448.     call    f$read
  449. inlp2:    jr    nz,help        ; done if end of file
  450.     ld    a,b        ; save B
  451.     ld    b,80h
  452. masklp:    res    7,(hl)        ; clear high bit
  453.     inc    hl        ; ..of each character read
  454.     djnz    masklp
  455.     ld    b,a        ; restore B
  456.     sbc    hl,bc        ; check for overflow
  457.     add    hl,bc        ; restore value in hl without affecting flags
  458.     jr    c,inloop
  459.     jp    toobig
  460. ;
  461. ; start of help program
  462. ;
  463. help:    ld    sp,stack    ; insure good stack
  464.     ld    hl,(outbuf)    ; pt to buffer
  465.     xor    a        ; set no frame
  466.     ld    (frnum),a
  467.     ld    (sglhdu),a    ; Reset alternate dir flag
  468.     ld    a,(hl)        ; no header section?
  469.     and    7fh        ; mask out msb
  470.     cp    sectchar
  471.     jr    nz,help1    ; header section exists
  472.     inc    hl        ; skip over sectchar
  473.     call    clscr        ; new screen
  474.     call    prinfo        ; print help info pted to by hl
  475.     ld    a,(hlplvl)    ; check to see if we are not at level 0
  476.     or    a        ; 0=level 0
  477.     jp    nz,lrurn    ; go to previous level if not
  478. ;
  479. ; exit point for any exit from the rest of the help program
  480. ;
  481. hlpexit:
  482.     xor    a        ; clear error flag
  483.     jr    hlpext2
  484. hlpexit1:
  485.     ld    a,0ffh        ; set error flag
  486. hlpext2:
  487.     call    puter2        ; set or clear error flag
  488.     call    hvdinit
  489.     rst    0        ; reboot because we may have overwritten CCP
  490.  
  491. ; Subroutine to return "Default DIR" du in BC register
  492.  
  493. defdu:    ld    hl,helpdir    ; look for help directory
  494.     push    hl
  495.     call    dirtdu        ; convert to du in bc
  496.     pop    hl
  497.     ret    nz        ; log into du in bc if found
  498.     ld    bc,(hdu)    ; log into help directory
  499.     ret
  500. ;
  501. ; print header information and select an option
  502. ;
  503. help1:    call    prheader    ; print header
  504.     push    bc        ; save c (number of valid selections)
  505.     call    crlf1        ; new line
  506.     call    hvon        ; goto dim
  507.     call    prlevel        ; print level number
  508.     call    hprint
  509.     dc    'Enter Selection  '
  510.     call    prp1        ; print level movement prompt
  511.     call    hvoff        ; goto bright
  512.     pop    bc        ; get c
  513.     call    cin        ; get response
  514.     call    caps        ; capitalize
  515.     push    af
  516.     call    clscr        ; clear screen
  517.     pop    af
  518.     call    ckabort        ; exit?
  519.     jr    z,hlpexit
  520.     cp    rootchar    ; go to root
  521.     jp    z,goroot
  522.     call    cklevel        ; return to previous level?
  523.     jp    z,lrurn
  524.     ld    b,a        ; user input in b
  525.     ld    a,(htype)    ; type of help file
  526.     cp    ihchar        ; indexed by user?
  527.     jr    z,help5        ; find information section via index scan
  528.     ld    a,b        ; find information seciton via count
  529.     sub    'A'-1        ; adjust for count
  530.     ld    b,a        ; save count
  531.     jr    z,badresponse
  532.     jr    nc,help2
  533. ;
  534. ; invalid response
  535. ;
  536. badresponse:
  537.     call    sak        ; ring bell
  538.     jr    help1
  539. ;
  540. ; valid response -- look for and print information section
  541. ;
  542. help2:    inc    c        ; 1 more than number of possible selections
  543.     cp    c        ; greater than number of possible selections?
  544.     jr    nc,badresponse
  545.     ld    hl,(firstentry)    ; get ptr to first entry
  546. ;
  547. ; print information when count is zero
  548. ;
  549. help3:    djnz    help4        ; count down selections
  550.     inc    hl        ; skip over sectchar
  551.     call    prinfo        ; print info pted to by hl
  552.     jr    help1
  553. ;
  554. ; locate next information section
  555. ;
  556. help4:    call    findi        ; skip to next information section
  557.     cp    ctrlz        ; end of file?
  558.     jr    nz,help3    ; continue looping if not else fall thru to helperr
  559. ;
  560. ; error -- reached end of help file
  561. ;
  562. helperr:
  563.     call    hprint
  564.     dc    cr,lf,' EOF on Help File'
  565.     jp    help1
  566. ;
  567. ; locate next information section via index scan
  568. ;
  569. help5:    ld    hl,(firstentry)    ; pt to first entry
  570. ;
  571. ; look for user index
  572. ;
  573. help6:    push    hl        ; save ptr to this line
  574. help7:    inc    hl        ; skip over section char
  575.     ld    a,(hl)        ; get char
  576.     call    caps        ; capitalize
  577.     cp    ' '        ; skip spaces
  578.     jr    z,help7
  579.     cp    sectchar    ; new section?
  580.     jr    z,help8        ; find next section
  581.     cp    cr        ; end of line?
  582.     jr    z,help8        ; find next section
  583.     cp    ctrlz        ; eof?
  584.     jr    z,help8
  585.     cp    b        ; check for user input
  586.     jr    nz,help7
  587.     pop    hl        ; found it -- print it
  588.     inc    hl        ; skip over section char
  589. help7a:    ld    a,(hl)        ; skip to beginning for 1st line
  590.     inc    hl        ; pt to next
  591.     and    7fh
  592.     cp    ctrlz        ; trap eof
  593.     jr    z,badresponse
  594.     cp    sectchar    ; file specified?
  595.     jr    z,help7b    ; process it
  596.     cp    lf        ; begin new line
  597.     jr    z,help7c
  598.     cp    cr        ; at end of index line?
  599.     jr    nz,help7a
  600.     ld    a,(hl)        ; get lf
  601.     and    7fh
  602.     cp    lf        ; skip following lf if any
  603.     jr    nz,help7c
  604.     inc    hl        ; skip lf
  605.     jr    help7c
  606. ;
  607. ; load next help level
  608. ;
  609. help7b:    dec    hl        ; pt to section char
  610. ;
  611. ; process help level or load and process next level pted to by hl
  612. ;
  613. help7c:    call    prinfo        ; print information section
  614.     jp    help1        ; resume
  615. help8:
  616.     pop    hl        ; pt to info section
  617.     call    findi        ; find next info section
  618.     cp    ctrlz        ; eof?
  619.     jr    nz,help6    ; keep looking
  620.     jp    badresponse
  621. ;
  622. ; skip to next information sections
  623. ;   return with a=sectchar if found or a=^z if not
  624. ;
  625. findi:    ld    a,(hl)        ; <ctrl-z>?
  626.     and    7fh        ; mask out msb
  627.     inc    hl        ; pt to next byte
  628.     cp    ctrlz
  629.     ret    z
  630.     cp    lf        ; line feed?
  631.     jr    z,findi1
  632.     cp    cr        ; <cr>?
  633.     jr    nz,findi
  634.     ld    a,(hl)        ; make sure lf
  635.     and    7fh
  636.     cp    lf
  637.     jr    nz,findi1
  638.     inc    hl        ; skip over lf
  639. findi1:    ld    a,(hl)        ; get char
  640.     and    7fh        ; mask out msb
  641.     cp    sectchar    ; new section?
  642.     jr    nz,findi    ; continue looping
  643.     ret
  644. ;
  645. ; help support routine section
  646. ;
  647. ; print one line of info section; hl pts to line upon entry;
  648. ;    hl pts to first char of next line upon exit
  649. ;
  650. prline:    ld    a,(hl)        ; get char
  651.     and    7fh        ; mask out msb
  652.     cp    cr        ; eol?
  653.     jr    z,crlf
  654.     cp    lf        ; line feed? (ws file)
  655.     jr    z,crlf0
  656.     cp    ctrlz        ; end of file?
  657.     jr    z,crlfc        ; done if so
  658.     inc    hl        ; pt to next
  659.     cp    dim        ; goto standout mode?
  660.     jr    z,prldim
  661.     cp    ndim        ; goto normal mode?
  662.     jr    z,prlndim
  663.     call    bout        ; print char
  664.     jr    prline
  665. prldim:
  666.     call    hvon        ; enter standout mode
  667.     jr    prline
  668. prlndim:
  669.     call    hvoff        ; end standout mode
  670.     jr    prline
  671. ;
  672. ; print crlf, pt to first char of next line, and page if necessary
  673. ;
  674. crlf:    inc    hl        ; pt to lf
  675. crlf0:    inc    hl        ; pt to 1st char of next line
  676. crlfc:    call    crlf1        ; print crlf
  677.     ld    a,(lcount)    ; get line count
  678.     dec    a
  679.     ld    (lcount),a
  680.     ret    nz        ; ok -- continue
  681.     ld    a,(hl)        ; get next char
  682.     and    7fh
  683.     cp    sectchar    ; new section?
  684.     ret    z        ; don't page if so
  685.     cp    ff        ; formfeed?
  686.     ret    z
  687.     cp    ctrlz        ; eof
  688.     ret z
  689. crlfc1:
  690.     set    7,(hl)        ; set msb of first char of next line
  691.     call    prprompt    ; print prompt and process common options
  692.     cp    backupchar    ; back up?
  693.     jp    z,fbackup
  694.     cp    strtchar    ; jump to start of info
  695.     jp    z,infostrt
  696. fresume:
  697.     ld    (strtframe),hl
  698.     jp    setlcount
  699. ;
  700. ; print prompt and process common options
  701. ;
  702. prprompt:
  703.     call    hvon        ; goto dim
  704.     call    prlevel        ; print level number
  705.     ld    a,(frnum)    ; increment frame number
  706.     inc    a
  707.     ld    (frnum),a
  708.     call    prp1        ; print fundamental level data prompt
  709.     call    hprint
  710.     db    menuchar,'=Menu ' ; abort to menu char
  711.     db    strtchar,'=Start ' ; jump to start of information char
  712.     dc    backupchar,'=Last ' ; back up to previous frame char
  713.     call    getwhl
  714.     jr    z,prpr1
  715.     call    hprint
  716.     dc    prchar,'=Print ' ; print current frame
  717. prpr1:    call    hvoff        ; goto bright
  718.     call    capin        ; get response
  719.     push    af
  720.     call    clscr        ; clear screen
  721.     pop    af
  722.     pop    de        ; clear stack
  723.     call    ckabort        ; abort to os?
  724.     jp    z,hlpexit
  725.     ld    b,a        ; save command char
  726.     call    getwhl
  727.     ld    a,b
  728.     jr    z,prpr2
  729.     cp    prchar        ; print frame?
  730.     jp    z,list0info
  731.     cp    cprchar        ; print information section?
  732.     jp    z,list1info
  733. prpr2:
  734.     cp    rootchar    ; go to root
  735.     jp    z,goroot
  736.     call    cklevel        ; return to higher level?
  737.     jp    z,lrurn
  738.     push    de        ; restore stack
  739.     cp    menuchar    ; redisply menu?
  740.     ret    nz
  741.  
  742.     ld    hl,(outbuf)    ; pt to buffer
  743.     ld    a,(hl)        ; no header section?
  744.     and    7fh        ; mask out msb
  745.     cp    sectchar
  746.     jp    z,lrurn        ; go to higher level if no header section
  747.     jp    help        ; else start from header section at this level
  748. ;
  749. ; print fundamental level prompt
  750. ;
  751. prp1:    call    hprint
  752.     dc    'ESC=Exit '
  753.     ld    a,(hlplvl)    ; don"t print if at level 0
  754.     or    a
  755.     ret    z
  756.     call    hprint
  757.     db    lrchar2,'=^Level ' ; return to higher node
  758.     dc    rootchar,'=Root ' ; return to root
  759.     ret
  760. ;
  761. ; jump to start of information
  762. ;
  763. infostrt:
  764.     ld    hl,(strtinfo)    ; pt to start of info
  765.     ld    a,1        ; reset frame count
  766.     ld    (frnum),a
  767.     jp    fresume        ; continue processing
  768. ;
  769. ; back up to previous frame
  770. ;
  771. fbackup:
  772.     call    boicheck    ; at beginning of information?
  773.     jr    z,infostrt
  774. fb1:
  775.     dec    hl        ; back up until byte with msb set is found
  776.     bit    7,(hl)
  777.     jr    z,fb1
  778.     ld    a,(frnum)    ; decrement frame number
  779.     dec    a        ; back up to current frame number
  780.     dec    a        ; back up to previous frame number
  781.     ld    (frnum),a
  782.     jp    fresume        ; continue processing
  783. ;
  784. ; Clear screen; print crlf if no TCAP
  785. ;
  786. clscr:    push    hl
  787.     call    getvid
  788.     jr    z,nocls
  789.     push    de
  790.     ld    de,17h
  791.     add    hl,de
  792.     ld    a,(hl)
  793.     pop    de
  794.     or    a
  795. nocls:    pop    hl
  796.     jp    nz,hvcls
  797.                 ; fall thru to crlf1 if no cls function
  798. ;
  799. ; print cr and lf only
  800. ;
  801. crlf1:    ld    a,cr        ; print cr
  802.     call    bout
  803.     ld    a,lf        ; print lf
  804.     jp    bout
  805. ;
  806. ; set lcount variable to screen size
  807. ;
  808. setlcount:
  809.     push    hl
  810.     call    getcrt
  811.     inc    hl        ; get number of lines on crt
  812.     ld    a,(hl)
  813.     dec    a        ; 1 less for prompt
  814.     ld    (lcount),a
  815.     pop    hl
  816.     ret
  817. ;
  818. ; print the header section and load firstentry ptr
  819. ;   on return, c=number of possible selections
  820. ;
  821. prheader:
  822.     xor    a        ; set no frame
  823.     ld    (frnum),a
  824.     call    setlcount
  825.     sub    3        ; -3 lines for top and bottom
  826.     ld    (lcount),a
  827.     ld    a,'A'        ; init selection char
  828.     ld    (selchar),a
  829.     call    clscr        ; clear screen
  830.     call    hprint
  831.     db    'Lbrhlp '
  832.     db    (ver/10)+'0','.',(ver mod 10)+'0'
  833.     dc    rev,'   '
  834.     ld    de,ludfn    ; pt to fcb
  835.     call    plib        ; print with no spaces
  836.     call    hprint
  837.     dc    ' Index',cr,lf,lf
  838.     ld    c,0        ; count number of selections
  839.     ld    hl,(outbuf)    ; pt to buffer
  840.     ld    a,(hl)        ; get first char
  841.     ld    (htype),a    ; set type of help file
  842.     cp    ihchar        ; indexed help type?
  843.     jr    nz,ph1
  844.     inc    hl        ; skip over index help type flag
  845. ;
  846. ; print line until first information section found
  847. ;
  848. ph1:    ld    a,(hl)        ; get char
  849.     and    7fh        ; mask out msb
  850.     cp    sectchar
  851.     jr    z,ph2
  852.     cp    ctrlz        ; eof? -- abort
  853.     jp    z,hlpexit
  854.     inc    c        ; increment selection count
  855.     ld    a,(htype)    ; check for index
  856.     cp    ihchar
  857.     jr    z,ph1a        ; skip letters if indexed
  858.     ld    a,(selchar)    ; display selection char
  859.     call    bout
  860.     inc    a        ; incr char
  861.     ld    (selchar),a
  862.     call    hprint
  863.     dc    '. '
  864. ph1a:    call    prline        ; print header line
  865.     jr    ph1
  866. ;
  867. ; save ptr to first entry
  868. ;
  869. ph2:    ld    (firstentry),hl
  870.     ld    a,(lcount)    ; get count of remaining lines
  871.     ld    b,a        ; ... in b
  872.     or    a        ; any left?
  873.     ret    z
  874. skipout:
  875.     call    crlf1        ; new line
  876.     djnz    skipout
  877.     ret
  878. ;
  879. ; print an information section
  880. ;   information section is pted to by hl
  881. ;
  882. prinfo:    ld    (strtinfo),hl    ; set start of information pointer
  883.     call    ldnod        ; load new node if dual sectchar
  884.     ld    (strtframe),hl    ; set frame pointer
  885.     set    7,(hl)        ; set msb
  886.     call    setlcount
  887.     ld    a,1        ; a=1
  888.     ld    (frnum),a    ; set frame number
  889. pi1:    call    prline        ; print line from info file
  890.     ld    a,(hl)        ; done?
  891.     and    7fh        ; mask out msb
  892.     cp    ctrlz        ; eof?
  893.     jr    z,pi2
  894.     cp    sectchar    ; next section
  895.     jr    z,pi2
  896.     cp    ff        ; form feed?
  897.     jr    nz,pi1
  898.     inc    hl        ; pt to char after form feed
  899.     call    formfeed    ; feed screen
  900.     jr    pi1
  901. ;
  902. ; form feed screen
  903. ;
  904. formfeed:
  905.     ld    a,(lcount)    ; get line count
  906.     ld    b,a        ; ... in b
  907.     or    a        ; 0 already?
  908.     call    nz,skipout    ; print blank lines if not
  909.     jp    crlfc1        ; go to end of screen processing
  910. ;
  911. ; end of info
  912. ;
  913. pi2:    set    7,(hl)        ; set msb of next byte
  914.     ld    a,(lcount)    ; get line count
  915.     or    a
  916.     ld    b,a
  917.     call    nz,skipout
  918. pi2msg:
  919.     call    hprint        ; print end of information indicator
  920.     dc    'EOI '
  921.     call    prprompt    ; print prompt and process common options
  922.     cp    backupchar    ; back up from eoi?
  923.     jr    z,pi2backup
  924.     cp    strtchar    ; start of info?
  925.     jr    z,pi2strt
  926.     jp    setlcount    ; reset line count in case of all
  927. ;
  928. ; jump to start of info from eoi
  929. ;
  930. pi2strt:
  931.     ld    hl,(strtinfo)    ; pt to start of info
  932.     call    fresume        ; reset pointers
  933.     ld    a,1        ; reset frame count
  934.     ld    (frnum),a
  935.     jr    pi1        ; continue processing
  936. ;
  937. ; back up to previous frame from eoi
  938. ;
  939. pi2backup:
  940.     call    boicheck    ; at beginning of information?
  941.     jr    z,pi2strt
  942. pi2back:
  943.     call    fb1        ; back up to previous frame
  944.     jr    pi1        ; continue processing
  945. ;
  946. ; check for position at beginning of information section
  947. ;   if so, print backup error msg and return w/zero set
  948. ;
  949. boicheck:
  950.     ld    hl,(strtinfo)    ; start address
  951.     ex    de,hl        ; ... in de
  952.     ld    hl,(strtframe)    ; frame address
  953.     ld    a,d        ; equal?
  954.     cp    h
  955.     ret    nz
  956.     ld    a,e
  957.     cp    l
  958.     ret    nz
  959.     call    sak        ; error bell
  960.     xor    a        ; zero flag set
  961.     ld    (frnum),a    ; set frame number
  962.     ret
  963. ;
  964. ; this body of code lists information from help2 to the
  965. ; printer
  966. ;
  967. ; list one line of info section; hl pts to line upon entry;
  968. ;    hl pts to first char of next line upon exit
  969. ;    z flag set if user aborts
  970. ;
  971. listline:
  972.     ld    a,(hl)        ; get char
  973.     and    7fh        ; mask out msb
  974.     cp    cr        ; eol?
  975.     jr    z,lcrlf
  976.     cp    lf        ; line feed? (ws file)
  977.     jr    z,lcrlf0
  978.     cp    ctrlz        ; end of file?
  979.     jr    z,lcrlfc    ; done if so
  980.     inc    hl        ; pt to next
  981.     cp    tab
  982.     jr    z,ltab        ; expand tab
  983.     cp    ctrlc
  984.     jr    c,listline    ; don't print highlight control chars
  985.     inc    b        ; bump char count
  986.     call    lstout        ; print char
  987.     ret    z        ; abort
  988.     jr    listline
  989. ;
  990. ; expand tabs
  991. ;
  992. ltab:    ld    a,' '
  993.     call    lstout        ; print a space
  994.     ret    z        ; user abort?
  995.     inc    b        ; bump char count
  996.     ld    a,b
  997.     and    7        ; at tab stop?
  998.     jr    nz,ltab        ; no, print more spaces
  999.     jr    listline
  1000. ;
  1001. ; list crlf, pt to first char of next line, and page if necessary
  1002. ;
  1003. lcrlf:    inc    hl        ; pt to lf
  1004. lcrlf0:    inc    hl        ; pt to 1st char of next line
  1005. lcrlfc:    call    lcrlf1        ; print crlf
  1006.     ret    z        ; abort
  1007.     ld    a,(lcount)    ; get line count
  1008.     dec    a
  1009.     ld    (lcount),a
  1010.     ret    nz        ; ok -- continue
  1011.     call    lformfeed    ; advance to next page
  1012. setplc:    push    hl        ; save hl
  1013.     call    getprt        ; pt to printer info in env
  1014.     inc    hl
  1015.     inc    hl        ; pt to lines of text
  1016.     ld    a,(hl)
  1017.     ld    (lcount),a    ; set line count
  1018.     pop    hl        ; restore hl
  1019.     ret
  1020. lcrlf1:
  1021.     ld    a,cr        ; send <crlf> to printer
  1022.     call    lstout
  1023.     ret    z        ; abort
  1024.     ld    a,lf        ; fall thru to lstout
  1025. ;
  1026. ; print character in a on printer; affect no registers
  1027. ;
  1028. lstout:    push    hl        ; save regs
  1029.     push    de
  1030.     push    bc
  1031.     ld    e,a        ; char in e
  1032.     ld    c,5        ; bdos prer output routine
  1033.     call    bdose
  1034.     ld    e,0ffh        ; conditional input
  1035.     ld    c,6        ; direct console i/o
  1036.     call    bdose
  1037.     pop    bc        ; restore regs
  1038.     pop    de
  1039.     pop    hl
  1040.     call    ckabort        ; abort?
  1041.     ret
  1042. ;
  1043. ; list the current information section
  1044. ;   information section is pted to by strtinfo
  1045. ;
  1046. ; list0info -- list current frame only
  1047. ; list1info -- list current information section
  1048. ;
  1049. list0info:
  1050.     ld    hl,(strtframe)    ; list current frame only
  1051.     ld    a,0ffh        ; set flag
  1052.     ld    (lfrflag),a    ; list frame only
  1053.     jr    list2info
  1054. list1info:
  1055.     ld    hl,(strtinfo)    ; prepare to list entire info section
  1056.     xor    a        ; clear frame list flag
  1057.     ld    (lfrflag),a
  1058. list2info:
  1059.     call    listinfo    ; do print
  1060.     call    clscr        ; clear screen
  1061.     ld    a,(ffflg)    ; did we just do a formfeed?
  1062.     or    a
  1063.     call    z,lformfeed    ; form feed printer if not
  1064.     ld    sp,stack-2    ; fix stack pointer
  1065.     ld    hl,(strtframe)    ; return to frame we were on
  1066.     call    fresume
  1067.     ld    a,(frnum)    ; adjust frame numbering
  1068.     dec    a
  1069.     ld    (frnum),a
  1070.     jp    pi1        ; resume at pi1
  1071. ;
  1072. ; main print routine
  1073. ; z flag set on exit if user aborts
  1074. ;
  1075. listinfo:
  1076.     ld    a,(ptrchk)    ; do printer check?
  1077.     or    a
  1078.     jr    z,prtrdy    ; no, assume printer is ready
  1079.     ld    a,15        ; bios list status
  1080.     call    bios        ; check for printer ready
  1081.     or    a
  1082.     jr    nz,prtrdy
  1083.     dec    a
  1084.     ld    (ffflg),a    ; set no form feed if no printer...
  1085.     call    hprint
  1086.     db    bel
  1087.     db    cr,lf,'Printer Off Line - Press Any Key To Recheck'
  1088.     db    ' (Q=Quit)',0
  1089.     call    capin
  1090.     cp    'Q'        ; an escape route, if needed
  1091.     jr    nz,listinfo    ; try again
  1092.     ret
  1093. ;
  1094. prtrdy:    call    clscr        ; print frame or info section
  1095.     call    hprint
  1096.     dc    cr,lf,' Printing '
  1097.     call    setplc        ; set printer line count
  1098.     xor    a
  1099.     ld    (ffflg),a    ; clear formfeed flag
  1100. li1:    ld    b,0        ; init count of chars on line for tab expansion
  1101.     call    listline    ; list line from info file
  1102.     ret    z        ; feed printer and exit if abort
  1103.     ld    a,(hl)        ; done?
  1104.     and    7fh        ; mask out msb
  1105.     cp    ctrlz        ; eof?
  1106.     ret    z        ; resume if at end of info
  1107.     cp    sectchar    ; next section
  1108.     ret    z        ; resume if at end of info
  1109.     cp    ff        ; form feed?
  1110.     jr    nz,li1
  1111.     ld    a,(lfrflag)    ; list frame only?
  1112.     or    a        ; 0=no
  1113.     ret    nz
  1114.     inc    hl        ; pt to char after form feed
  1115.     call    lcrlfc        ; new line
  1116.     ret    z        ; abort
  1117.     ld    b,10        ; print separator
  1118. li2:    ld    a,'-'        ; dashes
  1119.     call    lstout
  1120.     ret    z        ; abort?
  1121.     djnz    li2
  1122.     call    lcrlfc        ; 2 new lines
  1123.     ret    z
  1124.     call    lcrlfc
  1125.     ret    z
  1126.     jr    li1
  1127. ;
  1128. ; form feed printer
  1129. ;
  1130. lformfeed:
  1131.     call    lcrlf1        ; new line
  1132.     ld    a,ff        ; output form feed
  1133.     ld    (ffflg),a    ; set formfeed flag
  1134.     jp    lstout
  1135. ;
  1136. ; end of body of code which lists information from help2 to
  1137. ; the printer
  1138. ;
  1139. ; at the beginning of an information section (hl pts to first char)
  1140. ;   check to see if another sectchar follows, and, if so, load the
  1141. ;   specified file as a new node and begin processing it
  1142. ;
  1143. ldnod:    ld    a,(hl)        ; get it
  1144.     and    7fh        ; mask msb
  1145.     cp    sectchar    ; another one?
  1146.     ret    nz        ; process normally if not
  1147. ;
  1148. ; we have a new node -- check to see if we can nest again
  1149. ;
  1150.     ld    a,(hlplvl)    ; get current help level
  1151.     cp    25        ; at maximum?
  1152.     jr    nz,ldnod1
  1153.     call    hprint
  1154.     dc    cr,lf,' Node Level Limit'
  1155.     jp    hlpexit1
  1156. ;
  1157. ; we have not reached level limit, so continue
  1158. ; at this time, a=help level index and hl = ptr to current section (::)
  1159. ;
  1160. ldnod1:
  1161. ;
  1162. ; save current help file name for return
  1163. ;
  1164.     inc    hl        ; now pointing to file name
  1165.     push    hl        ; save ptr
  1166.     call    comptr        ; hl=pointer to stack elt indexed by a
  1167.     ex    de,hl        ; de=address of next element
  1168. ;
  1169. ; copy current node element name into next stack element
  1170. ;
  1171.     ld    hl,lfcb        ; pt to file name
  1172.     ld    bc,8        ; 8 bytes
  1173.     ldir
  1174. ;
  1175. ; increment help level
  1176. ;
  1177.     inc    a        ; set new level
  1178.     ld    (hlplvl),a
  1179. ;
  1180. ; set up fcb for new file
  1181. ;
  1182.     pop    hl        ; get ptr to new file name
  1183.     ld    de,lfcb        ; pt to fcb name
  1184.     ld    b,8        ; 8 chars max
  1185.     call    ldfcb        ; place into fcb with error checking
  1186. ;
  1187. ; print loading help file message
  1188. ;
  1189. plhfm:    call    hprint
  1190.     dc    cr,lf,' Loading HELP File '
  1191.     ld    de,lfcb        ; print file name
  1192.     call    plib
  1193.     call    crlf1
  1194.     jp    strt1        ; load new help file
  1195. ;
  1196. ; load fcb pted to by de with "normal" file name pted to by hl for b bytes
  1197. ;
  1198. ldfcb:    ld    a,(hl)        ; get char
  1199.     inc    hl        ; pt to next
  1200.     cp    '.'        ; done if decimal
  1201.     jr    z,ldfcb2
  1202.     cp    ' '+1        ; done if <= <sp>
  1203.     jr    c,ldfcb2
  1204.     call    caps        ; capitalize
  1205.     ld    (de),a        ; store char
  1206.     inc    de        ; pt to next
  1207.     djnz    ldfcb
  1208. ldfcb1:
  1209.     ld    a,(hl)        ; check for error
  1210.     and    7fh        ; mask msb
  1211.     inc    hl        ; pt to next char
  1212.     cp    '.'        ; ok if '.'
  1213.     ret    z
  1214.     cp    ' '+1        ; ok if <= <sp>
  1215.     ret    c
  1216.     jr    ldfcb1
  1217.  
  1218. ldfcb2:    ld    c,a        ; save char that terminated string
  1219. ldfcb3:    ld    a,' '        ; <sp> fill rest of fcb
  1220.     ld    (de),a        ; store <sp>
  1221.     inc    de        ; pt to next
  1222.     djnz    ldfcb3
  1223.     ld    a,c        ; get char that terminated string
  1224.     ret
  1225. ;
  1226. ; go to root
  1227. ;
  1228. goroot:    ld    a,(hlplvl)    ; at root?
  1229.     or    a        ; 0=yes
  1230.     jp    z,help        ; return to help
  1231.     xor    a        ; set root index
  1232.     jr    goret
  1233. ;
  1234. ; return to previous help level
  1235. ;
  1236. lrurn:    ld    a,(hlplvl)    ; are we at the lowest level?
  1237.     or    a        ; 0=yes
  1238.     jr    nz,lret
  1239.     call    sak        ; error bell
  1240.     jp    help
  1241. ;
  1242. ; set new help level
  1243. ;
  1244. lret:    dec    a        ; down 1 and fall thru to goret
  1245. ;
  1246. ; go to help level indexed in a
  1247. ;
  1248. goret:    ld    (hlplvl),a    ; set new help level
  1249.     call    comptr        ; hl=pointer to target help file name
  1250.     ld    de,lfcb        ; copy element into fcb
  1251.     ld    bc,8        ; 8 bytes
  1252.     ldir
  1253.     jr    plhfm        ; print loading message and load
  1254. ;
  1255. ; compute pointer to help name entry indexed by help level in a
  1256. ;
  1257. comptr:    ld    l,a        ; value in hl
  1258.     ld    h,0        ; compute offset as index*11
  1259.     add    hl,hl        ; *2
  1260.     add    hl,hl        ; *4
  1261.     add    hl,hl        ; *8
  1262.     ld    de,hlpns    ; pt to base of help names
  1263.     add    hl,de        ; add in offset
  1264.     ret
  1265. ;
  1266. ; print level number
  1267. ;
  1268. prlevel:
  1269.     ld    a,(hlplvl)    ; dont print level 0
  1270.     or    a        ; 0?
  1271.     jr    z,prframe
  1272.     call    hprint
  1273.     dc    'Level '
  1274.     call    pafdc        ; print as decimal
  1275.     ld    a,(frnum)    ; get frame number
  1276.     or    a        ; set flags
  1277.     ld    a,'/'        ; prep to print slash
  1278.     call    nz,bout        ; print slash if frame is non-zero
  1279. prframe:
  1280.     ld    a,(frnum)    ; get number
  1281.     or    a
  1282.     ld    a,' '        ; prep to print space on exit
  1283.     jp    z,bout
  1284.     ld    a,(frnum)    ; get frame number again
  1285.     call    pafdc        ; print as decimal
  1286.     call    hprint
  1287.     dc    ': '
  1288.     ret
  1289. ;
  1290. ; check for user abort via ^C or ESC characters (returns Z if so)
  1291. ;
  1292. ckabort:
  1293.     cp    cpmabortchar    ; aborting?
  1294.     ret    z        ; (yes)
  1295.     cp    exitchar    ; aborting via alternate character?
  1296.     ret
  1297. ;
  1298. ; check for request to move up a level (returns Z if so)
  1299. ;
  1300. cklevel:
  1301.     cp    lrchar        ; up a level?
  1302.     ret    z        ; (yes)
  1303.     cp    lrchar2        ; up via alternate character?
  1304.     ret
  1305.  
  1306. ;===============================
  1307.  IF UNCR
  1308. ;-------------------------------
  1309. uncrit:                ; main uncrunch routine
  1310.     ld    hl,(endall)
  1311.     call    setup
  1312.     call    uncrel
  1313.     jp    nc,help
  1314.  
  1315.     dec    a
  1316.     jr    z,toonew
  1317.     call    HPRINT
  1318.     dc    ' Invalid crunched file'
  1319.     jr    errexit
  1320. toonew:
  1321.     call    HPRINT
  1322.     dc    ' File needs newer revision'
  1323. errexit:
  1324.     jp    hlpexit1
  1325. ;-------------------------------
  1326.  ELSE    ; UNSQ
  1327. ;-------------------------------
  1328. unsqit:                ; main unsqueeze routine
  1329.     ld    hl,(endall)
  1330.     call    setup
  1331.     call    usqrel
  1332.     jp    nc,help
  1333.     call    HPRINT
  1334.     dc    ' Unsqueeze Error: '
  1335.     cp    1
  1336.     jr    z,dcoderr
  1337.     cp    3
  1338.     jr    z,chksumerr
  1339.     cp    4
  1340.     jr    z,notsqed
  1341.     call    HPRINT
  1342.     dc    'Premature EOF'
  1343.     jr    errexit
  1344.  
  1345. dcoderr:
  1346.     call    HPRINT
  1347.     dc    'Decode Size'
  1348.     jr    errexit
  1349.  
  1350. chksumerr:
  1351.     call    HPRINT
  1352.     dc    'Checksum'
  1353. errexit:
  1354.     jp    hlpexit1
  1355.  
  1356. notsqed:
  1357.     call    hprint
  1358.     dc    'Not a valid squeezed file'
  1359.     jr    errexit
  1360. ;-------------------------------
  1361.  ENDIF    ; UNCR else UNSQ
  1362. ;===============================
  1363. ;
  1364. ; "a" <-- next byte from ("physical") input stream.
  1365. ;      returns with carry set on eof.
  1366.  
  1367. getchr    equ    $
  1368. getbyt    equ    $
  1369.  
  1370.     exx            ; switch to i/o regs
  1371.     or    a        ; be sure carry is clear
  1372.     inc    l        ; point to next char loc in buffer
  1373.     call    z,rdsec        ; read another sector if at 0
  1374.     ld    a,(hl)        ; get byte to return (garbage if eof)
  1375.     exx            ; back to normal regs & rtn
  1376.     ret            ;
  1377. ;................................
  1378. ;
  1379. ; subr for [ non multi-] reload, reads 128 bytes to default dma
  1380. ;
  1381. rdsec:    push    de        ; save de before clobbering it with fcb
  1382.     ld    a,(stdaln)
  1383.     or    a
  1384.     jr    nz,rdsec1
  1385.     ld    de,lud        ; input fcb
  1386.     call    luread        ; read a record
  1387.     jr    rdsec2
  1388. rdsec1:    ld    de,ludfn-1
  1389.     call    f$read
  1390. rdsec2:    pop    de        ; restore de to value on entry
  1391.     ld    hl,tbuff
  1392.     ret    z        ; return if successful
  1393.     scf            ; indicate eof reached
  1394.     ret
  1395.  
  1396. ;______________________________________________________________________________
  1397. ;
  1398. ; output char in 'A' to the output buffer.
  1399. ;
  1400. out:    exx            ; switch to i/o regs
  1401.     and    7fh        ; clear high bit
  1402.     ld    (de),a        ; put byte into the next avail position
  1403.     inc    de        ; pt to next position in buffer
  1404.     push    hl
  1405.     ld    hl,(obufhi)    ; highest memory available
  1406.     sbc    hl,de        ; compare
  1407.     pop    hl
  1408.     exx            ; flip regs
  1409.     ret    nz        ; Return if limit not reached
  1410.  
  1411. toobig:    call    hprint
  1412.     dc    ' Memory Overflow, File too large'
  1413.     jp    hlpexit1
  1414.  
  1415. ;-----------------------------------------------------------------------------
  1416.  
  1417. ; enter with hl pointing to first byte of output buffer area
  1418. ; Setup - used to init buffers
  1419. setup:    ld    (outbuf),hl    ; this points to the proper place
  1420.     exx
  1421.     ld    hl,0ffh
  1422.     ld    de,(outbuf)
  1423.     exx
  1424.     ret
  1425.  
  1426. plib:    push    af
  1427.     push    bc
  1428.     push    de
  1429.     ld    b,8    ; prt 8 chars only
  1430. plib1:    ld    a,(de)
  1431.     and    7fh
  1432.     cp    ' '
  1433.     call    nz,bout
  1434.     inc    de
  1435.     djnz    plib1
  1436.     pop    de
  1437.     pop    bc
  1438.     pop    af
  1439.     ret
  1440.  
  1441. sak:    ld    a,bel
  1442.  
  1443. cout:    jp    bout
  1444.  
  1445. ; get a char from console via dos dconio
  1446.  
  1447. cin:    push    hl
  1448.     push    de
  1449.     push    bc
  1450. cin1:    ld    c,6        ; direct console i/o
  1451.     ld    e,0ffh        ; get character
  1452.     call    bdose
  1453.     or    a        ; got a character?
  1454.     jr    z,cin1        ; no, try again
  1455.     pop    bc
  1456.     pop    de
  1457.     pop    hl
  1458.     ret
  1459. ;
  1460. ;===============================
  1461.  IF UNCR
  1462.  
  1463.     include    lh-uncr        ; uncrunch routines
  1464.  
  1465.  ELSE    ; UNSQ
  1466.  
  1467.     include    lh-unsq        ; unsqueeze routines
  1468.  
  1469.  ENDIF    ; UNCR else UNSQ
  1470. ;===============================
  1471. ;
  1472.  
  1473.     DSEG
  1474.  
  1475.  IF UNCR
  1476. ; the  following  ram locs must be re-initialized each time the program is
  1477. ; executed (for each file when wildcards are used). the area called  "shadow"
  1478. ; in LH-UNCR.LIB is used to accomplish this.
  1479.  
  1480. ram    equ    $
  1481.  
  1482. fulflg:    ds    1        ; becomes "ff" when table is full
  1483. lastpr:    ds    2        ; "last pred"
  1484. entflg:    ds    1        ; flag prevents duplicating entries
  1485. entry:    ds    2        ; current entry (code) number.
  1486. csave:    ds    1
  1487. codlen:    ds    1        ; current code length, in bits.
  1488. trgmsk:    ds    1        ; mask contains "1" bit in pos of next code len
  1489. ;..............................................................................
  1490. ;______________________________________________________________________________
  1491. char:    ds    1        ; last char of the previously decoded string
  1492. avail:    ds    2        ; *
  1493. ffflag:    ds    1        ; *
  1494. disp:    ds    2        ;
  1495. ;................................
  1496.  
  1497. table:    ds    1
  1498. tablhi:    ds    1
  1499. eotbl:
  1500. xlatbl:    ds    1
  1501. xlatbh:    ds    1
  1502. exlatb:
  1503. botstk:    ds    2
  1504. topstk:
  1505. endall:    ds    2
  1506. stklim:    ds    2
  1507. hasher:    ds    2
  1508.  
  1509.  ELSE    ; UNSQ
  1510.  
  1511. table:    ds    1
  1512. tablhi:    ds    1
  1513. tabtop:
  1514. stkbot:    ds    2
  1515. stktop:
  1516. endall:    ds    2
  1517.  
  1518.  ENDIF    ; UNCR else UNSQ
  1519.  
  1520. stdaln:    ds    1
  1521. sglhdu:    ds    1
  1522. ffflg:    ds    1    ; formfeed indicator
  1523. htype:    ds    1    ; type of help file (if = ihchar, it is indexed by usr)
  1524. lfrflag:
  1525.     ds    1    ; list frame only flag (for print function)
  1526. strtinfo:
  1527.     ds    2    ; ptr to start of current information block
  1528. strtframe:
  1529.     ds    2    ; ptr to start of current frame
  1530. selchar:
  1531.     ds    1    ; selection table option char
  1532. firstentry:
  1533.     ds    2    ; ptr to first entry of information section
  1534. lcount:    ds    1    ; line count buffer
  1535. hlplvl:    ds    1    ; number of help level current node is at (0=bottom)
  1536. frnum:    ds    1    ; number of current frame
  1537. obufhi:    ds    2    ; hi byte of output buffer
  1538. outbuf:    ds    2    ; ptr to output buffer
  1539. lud:    ds    2    ; length of du dir
  1540.     ds    2    ; index
  1541.     ds    2    ; length of current entry
  1542. ludfn:    ds    8    ; filename
  1543.     ds    1    ; first byte of type
  1544. ludtyp:    ds    2    ; ptr to type for 'Q' or 'Z'
  1545. ludfcb:    ds    1
  1546. lbrname:
  1547.     ds    8
  1548. lbrtyp:    ds    27
  1549. lfcb:    ds    11    ; name of current help file
  1550.     ds    22    ; extra room for search first/next calls
  1551. stksav:    ds    2    ; uncrunch stack location
  1552. hlpns:    ds    200    ; room for 25 help file names
  1553.     ds    60
  1554. stack:    ds    2
  1555. ;
  1556.     end
  1557.