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 / CPMHELP / HJELP.LBR / HJELP.AQM / HJELP.ASM
Assembly Source File  |  2000-06-30  |  30KB  |  1,618 lines

  1.  
  2. ;    --------------------------------------------------------------
  3. ;             HJELP.ASM Copyright (C) 1984
  4. ;            Universidad Autonoma de Puebla
  5. ;
  6. ;    [HELP.xxx (SIG/M xxx.xx) Richard Conn]
  7. ;    [HELP8080.ASM (SIG/M 122.03) = original model]
  8. ;    [squeezed HELP files - Harold V. McIntosh, July 20, 1984]
  9. ;    ["L" backs up to panel 1 - 20 Jul 84 - HVM]
  10. ;    [Library files - 5 October 1984]
  11. ;    --------------------------------------------------------------
  12.  
  13. CR    equ    0DH
  14. VT    equ    0CH
  15. LF    equ    0AH
  16. HT    equ    09H
  17.  
  18. X0004    equ    0004H        ;CP/M Disk Byte
  19. X0005    equ    0005H        ;call point to BDOS
  20. tfcb    equ    005CH        ;CP/M's file control block
  21. tbuf    equ    0080H        ;CP/M's I-O buffer
  22.  
  23. bred    equ    4000H        ;red screen area
  24. bgrn    equ    6000H        ;green screen area
  25. bblu    equ    8000H        ;blue screen area
  26.  
  27. NH    equ    6        ;number of HELP file names to print per line
  28. ND    equ    10        ;maximum node depth
  29. NS    equ    9        ;bytes to save for panel markers
  30.  
  31. csiz    equ    257
  32. psiz    equ    50*NS        ;textpointer pushdown size
  33.  
  34. ;    -------------
  35.     org    0100H
  36. ;    -------------
  37.  
  38. begn:    lxi    h,0000
  39.     dad    sp
  40.     shld    X0D31        ;save stack
  41.     lxi    sp,X0D31    ;stack
  42.     lda    tfcb+1        ;TFCB+1
  43.     cpi    ' '
  44.     jnz    nnul
  45.     lxi    d,tuto        ;'tutorial'
  46. ferm:    call    mssg
  47. gbye:    lhld    X0D31        ;save stack
  48.     sphl
  49.     ret
  50.  
  51. nnul:    lda    X0005+2
  52.     sui    0AH
  53.     sta    X0C63        ;memory pages
  54.     lxi    h,nbuf+1
  55.     mvi    m,' '
  56.     xra    a
  57.     sta    X0C71        ;level #
  58.     lxi    d,X08BE        ;'signon'
  59.     call    mssg        ;message to console
  60.     lda    tfcb+1
  61.     cpi    '('
  62.     jnz    loop
  63.     lxi    h,tbuf
  64.     mov    b,m
  65.     inx    h
  66.     xchg
  67.     lxi    h,obuf
  68.     shld    optr
  69.     call    miuc
  70.     mvi    m,00
  71.     lxi    d,lohf        ;'loading HELP file'
  72.     call    mssg
  73.     call    pafr
  74.     lxi    h,nbuf+1
  75.     mov    a,m
  76.     cpi    ' '
  77.     jnz    ymbr
  78.     lxi    d,tfcb+1
  79.     mvi    b,8
  80.     call    miuc
  81.     call    phlp
  82.     jmp    loop
  83.  
  84. ymbr:    lxi    h,nbuf+9
  85.     mov    a,m
  86.     cpi    ' '
  87.     cz    phlp
  88.  
  89. ;    Loop.
  90.  
  91. loop:    lxi    sp,X0D31    ;stack
  92.     lxi    h,tfcb+9
  93.     mov    a,m
  94.     cpi    ' '
  95.     cz    phlp
  96.     lxi    h,tfcb        ;TFCB
  97.     mvi    m,000H
  98.     lxi    d,000CH
  99.     dad    d
  100.  
  101. ;    Zero out tail of FCB.
  102.  
  103.     mvi    b,018H        ;24
  104. X01C9:    mvi    m,000H
  105.     inx    h
  106.     dcr    b
  107.     jnz    X01C9
  108.  
  109.     lxi    h,0FFFFH
  110.     shld    mlen
  111.  
  112. ldfi:    call    opef
  113.     call    sefl
  114.     mvi    m,1AH        ;^Z
  115.     call    desq
  116.     jmp    gogo
  117.  
  118. sefl:    lxi    h,X0D33        ;beginning of free memory
  119. sefm:    lda    X0C63
  120.     cmp    h
  121.     jz    X04D1        ;'not enough room'
  122.     call    rerb
  123.     jc    sefn
  124.     mov    m,a
  125.     inx    h
  126.     jmp    sefm
  127.  
  128. sefn:    shld    X0C6E        ;ptr end of text
  129.     ret
  130.  
  131. ;    ------------------------------------
  132. ;    opef will open file even within .LBR
  133. ;    ofil will open a normal file
  134.  
  135. ;    Test for .LBR file.
  136.  
  137. opef:    lda    nbuf+1
  138.     cpi    ' '
  139.     jz    ofil
  140.  
  141. ;    -----------------------------------------
  142. ;    Open a .LBR file to the member specified
  143. ;    at nbuf+1 of the .LBR file referenced by
  144. ;    tfcb. Termination results if either item
  145. ;    cannot be found, otherwise the next read
  146. ;    will pick up the desired member.
  147. ;    ----------------------------------------
  148.  
  149. ;    Open .LBR file, read first record.
  150.  
  151. olbr:    mvi    c,15        ;(0F) open file
  152.     lxi    d,tfcb
  153.     call    X0005
  154.  
  155.     inr    a
  156.     jnz    fopn
  157.     lxi    d,nlib        ;'requested library not found'
  158.     jmp    ferm        ;send message to console
  159.  
  160. fopn:    lxi    h,tfcb+32
  161.     mvi    m,00
  162.     lxi    h,0000
  163.     shld    mctr        ;counter for tbuf
  164.     dcx    h
  165.     shld    mlen        ;length (records) of member
  166.  
  167.     call    afil        ;fill "A" buffer
  168.     lhld    abuf+14        ;length of LBR dir
  169.     shld    mlen        ;length (records) of member
  170.     dad    h
  171.     dad    h
  172.     shld    rlen        ;length (32-byte lines) of directory
  173.  
  174. ;    Library member was requested, so look it up in directory.
  175.  
  176. tmem:    lhld    rlen        ;length (32-byte lines) of directory
  177.     dcx    h
  178.     shld    rlen        ;length (32-byte lines) of directory
  179.     mov    a,h
  180.     ora    l
  181.     jnz    tmen
  182.     lxi    d,nfil        ;'requested file not present'
  183.     call    ferm        ;message to console
  184.  
  185. tmen:    call    afil        ;read a directory line
  186.     mvi    b,11
  187.     lxi    d,abuf+1
  188.     lxi    h,nbuf+1    ;member name buffer
  189.     call    ciuc        ;block compare
  190.     jnz    tmem
  191.  
  192. ;    Record length and whether 'Q' in extension.
  193.  
  194.     lhld    abuf+14
  195.     shld    mlen        ;length (records) of member
  196.     lxi    h,dens        ;z/nz=un/squeezed
  197.     mvi    m,0
  198.     lda    abuf+10
  199.     cpi    'Q'
  200.     jnz    sefi
  201.     dcr    m
  202.  
  203. ;    Advance to the proper section of the library.
  204. ;    This is not an elegant way to do it, but it avoids
  205. ;    computing with CP/M extents and record sizes.
  206.  
  207. sefi:    mvi    c,15        ;(0F) open file
  208.     lxi    d,tfcb
  209.     call    X0005
  210.     xra    a
  211.     sta    tfcb+32
  212.  
  213. ;    Skip up to (but don't read) beginning of member.
  214.  
  215. sefj:    lhld    abuf+12
  216.     mov    a,h
  217.     ora    l
  218.     jz    sefk
  219.     dcx    h
  220.     shld    abuf+12
  221.     mvi    c,20        ;(14) read one record
  222.     lxi    d,tfcb
  223.     call    X0005
  224.     jmp    sefj
  225.  
  226. sefk:    lxi    h,0000
  227.     shld    mctr
  228.     ret
  229.  
  230. ;    Fill the "A" buffer, which holds .LBR directory lines.
  231.  
  232. afil:    mvi    c,20H
  233.     lxi    h,abuf        ;"A" buffer = line of LBR dir
  234. afim:    call    rerb
  235.     mov    m,a
  236.     inx    h
  237.     dcr    c
  238.     jnz    afim
  239.     ret
  240.  
  241. ;    Read a byte from tbuf, replenishing as necessary.
  242. ;    Carry signifies End of File.
  243.  
  244. rerb:    push    h
  245.     lhld    mctr        ;counter for tbuf
  246.     mov    a,h
  247.     ora    l
  248.     stc
  249.     cz    rerx        ;read one record
  250.     cmc
  251.     dcx    h
  252.     shld    mctr        ;counter for tbuf
  253.     lhld    mptr        ;pointer for tbuf
  254.     mov    a,m
  255.     inx    h
  256.     shld    mptr        ;pointer for tbuf
  257.     pop    h
  258.     ret
  259.  
  260. ;    Read another record, but don't read past the number
  261. ;    allocated to the member. Likewise, we have to be careful
  262. ;    about an ASCII file which ends exactly on a record boundary.
  263.  
  264. rerx:    lhld    mlen        ;length (records) of member
  265.     mov    a,h
  266.     ora    l
  267.     jz    rery
  268.     dcx    h
  269.     shld    mlen        ;length (records) of member
  270.     push    b
  271.     push    d
  272.     mvi    c,20        ;(14) read one record
  273.     lxi    d,tfcb
  274.     call    X0005
  275.     pop    d
  276.     pop    b
  277.     ora    a
  278.     jnz    rery
  279.     lxi    h,tbuf
  280.     shld    mptr        ;pointer for tbuf
  281.     lxi    h,0080H
  282.     stc
  283.     ret
  284.  
  285. ;    Squeezed files should end with a special end
  286. ;    of file marker (non-1-byte 100H), which has to be seen
  287. ;    to terminate the file. ASCII files normally terminate with
  288. ;    a ^Z, but this may be implicit if the file exactly fills a
  289. ;    record.
  290.  
  291. rery:    lxi    h,tbuf
  292.     shld    mptr
  293.     mvi    m,1AH        ;^Z
  294.     lxi    h,0001H
  295.     stc
  296.     cmc
  297.     ret
  298.  
  299. ;    Open an ordinary file. If not found, try for a squeezed
  300. ;    version instead.
  301.  
  302. ofil:    lxi    h,0000
  303.     shld    mctr
  304.     dcx    h
  305.     shld    mlen
  306.     xra    a
  307.     sta    tfcb+32
  308.     sta    dens
  309. ofim:    lxi    d,tfcb        ;TFCB
  310.     mvi    c,15        ;(0F) open file
  311.     call    X0005        ; B D O S
  312.     inr    a
  313.     rnz
  314.     lxi    h,tfcb+10
  315.     mov    a,m
  316.     mvi    m,'Q'
  317.     cmp    m
  318.     jnz    ofim
  319.     lxi    d,nfil        ;'no file'
  320.     jmp    ferm
  321.  
  322. ;    ------------------------
  323.  
  324. ;    Decide whether it is a squeezed file.
  325.  
  326. desq:    lxi    h,X0D33
  327.     shld    tptr        ;text pointer
  328.     shld    xptr        ;ptr to bgn of HELP file
  329.     lxi    h,dens        ;z/nz = normal/squeezed file
  330.     mvi    m,0
  331.     lxi    h,wflg        ;z/nz = no/byte left waiting by abyt
  332.     mvi    m,0
  333.     call    gbyt        ;one byte, direct or through onsq
  334.     cpi    076H
  335.     jnz    unjj
  336.     call    gbyt        ;one byte, direct or through onsq
  337.     cpi    0FFH
  338.     jz    unii
  339. unjj:    lxi    h,X0D33
  340.     shld    tptr        ;text pointer
  341.     ret
  342.  
  343. ;    Squeezed, so go through initialization
  344.  
  345. unii:    lxi    h,rcnt        ;repetition count
  346.     mvi    m,0
  347.     lxi    h,roco        ;bit rotation counter
  348.     mvi    m,1
  349.  
  350. ;    The "squeezed" marker is followed by a two-byte checksum,
  351. ;    which is the simple sum of all the one-byte characters in
  352. ;    the source file, carried as a two byte sum modulo 2**16.
  353.  
  354. rchk:    call    iwor        ;fetch two bytes from input stream
  355.     shld    cksm        ;checksum
  356.  
  357. ;    Unsqueezed file name. It is an ASCII sequence, may be lower
  358. ;    case if SQ.COM received it in response to a prompt, ending
  359. ;    with a zero byte.
  360.  
  361. luup:    call    gbyt        ;fetch one byte from input stream
  362.     ora    a
  363.     jnz    luup
  364.  
  365. ;    Load code dictionary. It is preceded by its two-byte length,
  366. ;    and consists of a series of pairs of two-byte addresses. For
  367. ;    each bit in the code, select the first element (0) or the
  368. ;    second (1) element of the pair. If the pair is positive, it
  369. ;    is the table entry (code + 4*index) at which to continue with
  370. ;    the next bit. If the pair is negative, it is the complement
  371. ;    of the coded ASCII character (low order byte except for [end]).
  372.  
  373. ldic:    call    iwor        ;fetch two bytes from input stream
  374.     dad    h
  375.     dad    h
  376.     xchg
  377.     lhld    tptr        ;text pointer
  378.     shld    cptr        ;Huffman code table
  379.     dad    d
  380.     shld    tptr        ;text pointer
  381.     shld    xptr        ;ptr to bgn of HELP file
  382.     lxi    h,dens
  383.     mvi    m,0FFH
  384.     ret
  385.  
  386. ;    Scan the HELP text to find and record the section headings.
  387.  
  388. gogo:    lxi    h,pudl
  389.     shld    pptr        ;pushdown pointer
  390.     lxi    h,mopt
  391.     mvi    m,'A'        ;A, not @, to make <cmp m, jnc> work
  392.     call    abyt        ;lookahead one byte
  393.     cpi    ':'
  394.     jz    gogu
  395. gugu:    call    rbyt        ;fetch one byte
  396.     cpi    LF
  397.     jnz    gigi
  398.     call    rbyt        ;fetch one byte
  399.     cpi    ':'
  400.     jz    gege
  401. gigi:    cpi    1AH
  402.     jz    gogu
  403.     jmp    gugu
  404.  
  405. gege:    call    pupu
  406.     lxi    h,mopt        ;maximum option
  407.     inr    m
  408.     jmp    gugu
  409.  
  410. gogu:    lhld    pptr        ;pushdown pointer
  411.     shld    zptr        ;ptr to bgn of info sect
  412.     lhld    xptr        ;ptr to bgn of HELP file
  413.     shld    tptr        ;text pointer
  414.     lxi    h,roco        ;bit rotation counter
  415.     mvi    m,1
  416.     lxi    h,wflg        ;z/nz = no/byte left waiting by abyt
  417.     mvi    m,0
  418.  
  419. ;    Display menu. Here we distinguish between a simple HELP
  420. ;    file which begins with a colon and has only one section,
  421. ;    and an indexed HELP file, which starts out with a list of
  422. ;    section descriptors.
  423.  
  424. X0342:    lxi    sp,X0D31    ;stack
  425.     mvi    a,000H
  426.     sta    X0C72        ;panel #
  427.     call    abyt        ;lookahead one byte
  428.     cpi    '!'
  429.     jc    xxxx
  430.     cpi    ':'
  431.     jnz    X036A        ;show menu, request option
  432.     call    rbyt        ;fetch one byte
  433. xxxx:    call    X05E5        ;initialize new section
  434.     lda    X0C71        ;level #
  435.     ora    a
  436.     jz    gbye        ;return to CP/M
  437.     jmp    X07ED        ;go up one level
  438.  
  439. ;    Return to CP/M
  440.  
  441. ;    Show menu, request option.
  442.  
  443. X036A:    call    X058D        ;run through the menu
  444.     push    b
  445.     call    crlf        ;CR,LF
  446.     call    X0859        ;type level I.D.
  447.     lxi    d,X0C19        ;'Type [^C]'
  448.     call    mssg        ;message to console
  449.     lxi    d,X0C27        ;'Type [level or root]'
  450.     lda    X0C71        ;level #
  451.     ora    a
  452.     jz    X0387
  453.     call    mssg        ;message to console
  454. X0387:    lxi    d,X0C37        ;'Enter Selection'
  455.     call    mssg        ;message to console
  456.     pop    b
  457.     call    X046B        ;read char from console
  458.     cpi    003H        ;^C
  459.     jz    gbye        ;return to CP/M
  460.     cpi    '.'
  461.     jz    X07E1        ;back to root
  462.     cpi    '^'
  463.     jz    X07ED        ;go up one level
  464.     push    psw
  465.     call    crlf        ;CR,LF
  466.     pop    psw
  467.     lxi    h,mopt        ;maximum option
  468.     cmp    m
  469.     jnc    X03AE
  470.     sui    '@'
  471.     jc    X03AE
  472.     jz    X03AE
  473.     call    anth        ;access nth option
  474.     call    X05E5        ;initialize new section
  475.     jmp    X036A        ;show menu, request option
  476.  
  477. X03AE:    lxi    d,X0AC6        ;'Invalid Response'
  478.     call    mssg        ;message to console
  479.     jmp    X036A        ;show menu, request option
  480.  
  481. ;    Insert extension .HLP
  482.  
  483. phlp:    mvi    m,'H'
  484.     inx    h
  485.     mvi    m,'L'
  486.     inx    h
  487.     mvi    m,'P'
  488.     ret
  489.  
  490. ;    Read a character from the console.
  491.  
  492. X046B:    push    b
  493.     push    d
  494.     push    h
  495.     mvi    c,1        ;(01) console input
  496.     call    X0005        ; B D O S
  497.     pop    h
  498.     pop    d
  499.     pop    b
  500.     push    psw
  501.     call    crlf        ;CR,LF
  502.     pop    psw
  503. X047B:    ani    07FH        ;upper case fold
  504.     cpi    'a'
  505.     rc
  506.     cpi    '{'
  507.     rnc
  508.     ani    05FH
  509.     ret
  510.  
  511. ;    CR, LF.
  512.  
  513. crlf:    mvi    a,CR
  514.     call    cona        ;char to console
  515.     mvi    a,LF
  516.     jmp    cona        ;char to console
  517.  
  518. ;    Character to console.
  519.  
  520. cona:    push    psw
  521.     push    b
  522.     push    d
  523.     push    h
  524.     mvi    c,2        ;(02) console output
  525.     mov    e,a
  526.     call    X0005        ; B D O S
  527.     pop    h
  528.     pop    d
  529.     pop    b
  530.     pop    psw
  531.     ret
  532.  
  533. ;    Message to Console.
  534.  
  535. mssg:    push    b
  536.     push    d
  537.     push    h
  538.     mvi    c,9        ;(09) print string to $
  539.     call    X0005        ; B D O S
  540.     pop    h
  541.     pop    d
  542.     pop    b
  543.     ret
  544.  
  545. ;    Type file name.
  546.  
  547. tyfn:    mov    a,m
  548.     cpi    ' '
  549.     rz
  550.     mvi    b,8
  551.     call    tyfo
  552.     mov    a,m
  553.     cpi    ' '
  554.     rz
  555.     mvi    a,'.'
  556.     call    cona
  557.     mvi    b,3
  558. tyfo:    mov    a,m
  559.     inx    h
  560.     cpi    ' '
  561.     cnz    cona
  562.     dcr    b
  563.     jnz    tyfo
  564.     ret
  565.  
  566. ;    Compare B bytes between (HL) and (DE)
  567.  
  568. ciuc:    ldax    d
  569.     cmp    m
  570.     rnz
  571.     inx    d
  572.     inx    h
  573.     dcr    b
  574.     jnz    ciuc
  575.     ret
  576.  
  577. ;    Move B bytes from (DE) to (HL).
  578.  
  579. miuc:    ldax    d
  580.     mov    m,a
  581.     inx    d
  582.     inx    h
  583.     dcr    b
  584.     jnz    miuc
  585.     ret
  586.  
  587. ;    Move B bytes from (HL) to (DE)
  588.  
  589. mduc:    dcx    h
  590.     dcx    d
  591.     mov    a,m
  592.     stax    d
  593.     dcr    b
  594.     jnz    mduc
  595.     ret
  596.  
  597. ;    Initialize pudl.
  598.  
  599. izpu:    mvi    b,NS
  600.     lxi    d,lach
  601.     lhld    zptr        ;ptr to bgn of info sect
  602.     call    miuc
  603.     shld    yptr        ;zptr+NS
  604.     shld    pptr        ;pushdown pointer
  605.     lxi    h,X0C72        ;panel #
  606.     mvi    m,1
  607.     ret
  608.  
  609. ;    Restore to the head of pudl.
  610.  
  611. rspu:    mvi    b,NS
  612.     lhld    yptr        ;zptr+NS
  613.     shld    pptr        ;pushdown pointer
  614.     lxi    d,lach+NS
  615.     call    mduc
  616.     lxi    h,X0C72        ;panel #
  617.     mvi    m,0
  618.     ret
  619.  
  620. ;    Access nth option.
  621.  
  622. anth:    mov    e,a
  623.     mvi    d,0
  624.     mov    l,e
  625.     mov    h,d
  626.     dad    h
  627.     dad    h
  628.     dad    h
  629.     dad    d
  630.     lxi    d,pudl
  631.     dad    d
  632.     lxi    d,lach+NS
  633.     mvi    b,NS
  634.     call    mduc
  635.     lhld    zptr        ;ptr to bgn of info sect
  636.     shld    pptr        ;pushdown pointer
  637.     lxi    h,X0C72
  638.     mvi    m,1
  639.     ret
  640.  
  641. ;    Push state onto pudl.
  642.  
  643. pupu:    lhld    pptr        ;pushdown pointer
  644.     lxi    d,pudl+psiz
  645.     mov    a,l
  646.     sub    e
  647.     mov    a,h
  648.     sbb    d
  649.     rnc
  650.     mvi    b,NS
  651.     lxi    d,lach
  652.     call    miuc
  653.     shld    pptr        ;pushdown pointer
  654.     lxi    h,X0C72        ;panel #
  655.     inr    m
  656.     ret
  657.  
  658. ;    Pop state from pudl.
  659.  
  660. popu:    lhld    zptr
  661.     xchg
  662.     lhld    pptr        ;pushdown pointer
  663.     mov    a,e
  664.     sub    l
  665.     mov    a,d
  666.     sbb    h
  667.     rnc
  668.     mvi    b,NS
  669.     lxi    d,lach+NS
  670.     call    mduc
  671.     shld    pptr        ;pushdown pointer
  672.     lxi    h,X0C72        ;panel #
  673.     mov    a,m
  674.     ora    a
  675.     rz
  676.     dcr    m
  677.     ret
  678.  
  679. X04D1:    lxi    d,X0BDC        ;'Not Enough Room'
  680.     jmp    ferm
  681.  
  682. onsq:    lda    rcnt        ;repetition count
  683.     ora    a
  684.     jnz    onsr
  685.     call    dnch        ;decode next character
  686.     jc    vchk        ;verify the checksum
  687.     cpi    090H        ;repeat last character
  688.     jnz    onsu        ;normal character
  689.     call    dnch        ;decode next character
  690.     ora    a
  691.     jz    onss
  692.     dcr    a
  693. onsr:    dcr    a
  694.     sta    rcnt        ;repetition count
  695.     lda    lach
  696.     jmp    achk
  697.  
  698. onss:    mvi    a,090H
  699.     jmp    achk
  700.  
  701. onsu:    sta    lach        ;last character typed
  702.     jmp    achk
  703.  
  704. ;    Decode next character.
  705.  
  706. dnch:    lhld    cptr        ;Huffman code table
  707. dncr:    call    ibit        ;read next bit
  708.     jnc    dncs        ;skip for 1, stay for 0
  709.     inx    h
  710.     inx    h
  711. dncs:    mov    e,m        ;get next offset
  712.     inx    h
  713.     mov    d,m
  714.     mov    a,d
  715.     cpi    0FEH        ;FEFF means [end]
  716.     jz    dnct
  717.     ora    a
  718.     jp    dncu        ;p means new offset
  719.     mov    a,e        ;m means complemented char
  720.     cma
  721.     stc
  722.     cmc
  723.     ret
  724.  
  725. dnct:    stc            ;flag [end] with carry bit
  726.     ret
  727.  
  728. ;    Calculate <code>+4*<offset>.
  729.  
  730. dncu:    lhld    cptr        ;Huffman code table
  731.     dad    d
  732.     dad    d
  733.     dad    d
  734.     dad    d
  735.     jmp    dncr
  736.  
  737. ;    Read one bit at a time.
  738.  
  739. ibit:    push    h
  740.     lxi    h,roco        ;bit rotation counter
  741.     dcr    m
  742.     jnz    ibiu
  743.     mvi    m,8
  744.     call    ibyt        ;fetch one byte from input stream
  745.     sta    roby        ;rotating byte
  746. ibiu:    lda    roby        ;rotating byte
  747.     rar
  748.     sta    roby        ;rotating byte
  749.     pop    h
  750.     ret
  751.  
  752. ;    Read one word.
  753.  
  754. iwor:    call    ibyt        ;fetch one byte from input stream
  755.     mov    l,a
  756.     push    h
  757.     call    ibyt        ;fetch one byte from input stream
  758.     pop    h
  759.     mov    h,a
  760.     ret
  761.  
  762. ;    Accumulate checksum.
  763.  
  764. achk:    lxi    h,cksm
  765.     mov    b,a
  766.     mov    a,m
  767.     sub    b
  768.     mov    m,a
  769.     inx    h
  770.     mov    a,m
  771.     sbi    0
  772.     mov    m,a
  773.     mov    a,b
  774.     stc
  775.     cmc
  776.     ret
  777.  
  778. ;    Verify the checksum.
  779.  
  780. vchk:    lhld    cksm        ;checksum
  781.     mov    a,l
  782.     ora    h
  783.     stc
  784.     rz            ;return to CP/M
  785.     lxi    d,chno        ;'Checksum failure.'
  786.     jmp    ferm        ;fatal error message
  787.  
  788. abyt:    push    h
  789.     lxi    h,wflg        ;z/nz = no/byte left waiting by abyt
  790.     mov    a,m
  791.     ora    a
  792.     jz    abyy
  793.     lda    wbyt        ;byte left waiting by abyt
  794.     jmp    abyr
  795. abyy:    dcr    m
  796.     call    gbyt        ;one byte, direct or through onsq
  797.     sta    wbyt        ;byte left waiting by abyt
  798. abyr:    pop    h
  799.     ret
  800.  
  801. rbyt:    lda    wflg        ;z/nz = no/byte left waiting by abyt
  802.     ora    a
  803.     jz    gbyt        ;one byte, direct or through onsq
  804.     mvi    a,0
  805.     sta    wflg        ;z/nz = no/byte left waiting by abyt
  806.     lda    wbyt        ;byte left waiting by abyt
  807.     ret
  808.  
  809. gbyt:    lda    dens        ;one byte, direct or through onsq
  810.     ora    a
  811.     jz    ibyt
  812.     push    h
  813.     call    onsq        ;one byte from squeezed file
  814.     pop    h
  815.     ret
  816.  
  817. ibyt:    push    h        ;fetch byte from the input stream
  818.     push    d
  819.     lhld    X0C6E        ;ptr end of text
  820.     xchg
  821.     lhld    tptr        ;text pointer
  822.     mov    a,l
  823.     sub    e
  824.     mov    a,h
  825.     sbb    d
  826.     mov    a,m
  827.     inx    h
  828.     shld    tptr        ;text pointer
  829.     cmc
  830.     pop    d
  831.     pop    h
  832.     ret
  833.  
  834. ;    Type line, solicit option.
  835.  
  836. X04DA:    call    rbyt        ;fetch one byte
  837.     cpi    CR
  838.     jz    X04F4        ;type options at bottom of panel
  839.     cpi    LF
  840.     jz    X04F5        ;type options at bottom of panel
  841.     cpi    01AH        ;^Z
  842.     jz    X04F5        ;type options at bottom of panel
  843.     call    cona        ;char to console
  844.     jmp    X04DA        ;type line, solicit option
  845.  
  846. ;    Type the options at bottom of panel.
  847. ;    Entry point according to how line ended.
  848.  
  849. X04F4:    call    rbyt        ;decomission following LF
  850. X04F5:    call    crlf        ;CR,LF
  851.     lxi    h,X0C6B        ;console remaining lines
  852.     dcr    m
  853.     rnz
  854.  
  855. ;    Solicit options (without marking or incrementing line).
  856.  
  857. X0504:    call    X0859        ;type level I.D.
  858.     lxi    d,X097A        ;'^C = Exit'
  859.     call    mssg        ;message to console
  860. X050D:    lxi    d,X0983        ;'[level, root]'
  861.     lda    X0C71        ;level #
  862.     ora    a
  863.     jz    X0521
  864.     call    mssg        ;message to console
  865. X0521:    lxi    d,X0993        ;'[option list]'
  866.     call    mssg        ;message to console
  867.     call    X046B        ;read char from console
  868.     sta    char        ;char read from console
  869.     cpi    'M'
  870.     jnz    pnla
  871.     jmp    X0342        ;display menu
  872.  
  873. pnla:    cpi    003H        ;^C
  874.     jnz    pnlb
  875.     jmp    gbye        ;return to CP/M
  876.  
  877. pnlb:    cpi    'P'
  878.     jnz    pnlc
  879.     jmp    X06FE        ;fulfil PRINT request
  880.  
  881. pnlc:    cpi    '.'
  882.     jnz    pnld
  883.     jmp    X07E1        ;back to root
  884.  
  885. pnld:    cpi    '^'
  886.     jnz    pnle
  887.     jmp    X07ED        ;go up one level
  888.  
  889. pnle:    cpi    'L'
  890.     jnz    pnlf
  891.     call    popu
  892.     call    popu
  893.     jmp    pnlg
  894.  
  895. pnlf:    cpi    'S'
  896.     jnz    pnlg
  897.     call    rspu        ;restore start of info section
  898. pnlg:    call    pupu        ;save reference to section head
  899.     call    X0587        ;reset line count
  900.     jmp    crlf        ;CR,LF
  901.  
  902. ;    Reset line count.
  903.  
  904. X0587:    mvi    a,23        ;lines per screen panel
  905.     sta    X0C6B        ;console remaining lines
  906.     ret
  907.  
  908. ;    Run through the menu.
  909.  
  910. X058D:    mvi    a,000H
  911.     sta    X0C72        ;panel #
  912.     lhld    xptr        ;ptr to bgn of HELP file
  913.     shld    tptr        ;text pointer
  914.     lxi    h,roco        ;bit rotation counter
  915.     mvi    m,1
  916.     lxi    h,wflg        ;z/nz = no/byte left waiting by abyt
  917.     mvi    m,0
  918.     call    X0587        ;reset line count
  919.     lxi    h,X0C6B        ;console remaining lines
  920.     dcr    m
  921.     mvi    a,'A'
  922.     sta    X0C68        ;option letter
  923.     lxi    d,X0954        ;'Selections are ...'
  924.     call    mssg        ;message to console
  925.     mvi    c,000H
  926. X05AC:    call    abyt        ;lookahead one byte
  927.     cpi    ':'
  928.     jz    X05D4        ;finish panel w/CR,LF's
  929.     cpi    01AH        ;^Z
  930.     jz    gbye        ;return to CP/M
  931.     inr    c
  932.     lda    X0C68        ;option letter
  933.     call    cona        ;char to console
  934.     inr    a
  935.     sta    X0C68        ;option letter
  936.     mvi    a,'.'
  937.     call    cona        ;char to console
  938.     mvi    a,' '
  939.     call    cona        ;char to console
  940.     call    X04DA        ;type line, solicit option
  941.     jmp    X05AC
  942.  
  943. ;    Finish out panel with CR, LF's.
  944.  
  945. X05D4:    lda    X0C6B        ;console remaining lines
  946.     mov    b,a
  947.     ora    a
  948.     rz
  949. X05DD:    call    crlf        ;CR,LF
  950.     dcr    b
  951.     jnz    X05DD
  952.     ret
  953.  
  954. ;    A loop which will print out an information section. It calls
  955. ;    X04DA, which will count out lines as it types them. If the
  956. ;    line it has just typed is the last one of the panel, it
  957. ;    will pause for the panel to be read, having solicited some
  958. ;    indication of whether it should procede, repeat the last panel,
  959. ;    go back to the beginning, or go back to the menu.
  960.  
  961. X05E5:    call    X075D        ;is section disk file?
  962.     call    izpu
  963.     call    X0587        ;reset line count
  964. X05FA:    call    abyt        ;lookahead one byte
  965.     cpi    01AH        ;^Z
  966.     jz    X0624        ;mark panel, type legend, read option
  967.     cpi    ':'
  968.     jz    X0624        ;mark panel, type legend, read option
  969.     cpi    VT        ;form feed
  970.     jz    X05FB
  971.     call    X04DA
  972.     jmp    X05FA
  973.  
  974. X05FB:    call    rbyt        ;fetch one byte
  975.     lda    X0C6B        ;console remaining lines
  976. X061A:    push    psw
  977.     call    X04F5        ;type options at bottom of panel
  978.     pop    psw
  979.     dcr    a
  980.     jnz    X061A
  981.     jmp    X05FA
  982.  
  983. ;    Mark panel, type legend, select option.
  984.  
  985. X0624:    call    rbyt        ;fetch one byte
  986. X0628:    call    crlf        ;CR,LF
  987.     lxi    h,X0C6B        ;console remaining lines
  988.     dcr    m
  989.     jnz    X0628
  990. X0635:    call    X0859        ;type level I.D.
  991.     lxi    d,X0976        ;'EOI & ^C'
  992.     call    mssg        ;message to console
  993.     call    X050D
  994.     lda    char        ;char read from console
  995.     cpi    'L'
  996.     jz    X05FA
  997.     cpi    'S'
  998.     jz    X05FA
  999.     cpi    'P'
  1000.     jz    X05FA
  1001.     ret
  1002.  
  1003. ;    Send line to LST:, check for interrupt request.
  1004.  
  1005. X06B3:    call    rbyt        ;fetch one byte
  1006.     cpi    CR
  1007.     jz    X06CE        ;list CR, LF's at end of line
  1008.     cpi    LF
  1009.     jz    X06CF        ;list CR, LF's at end of line
  1010.     cpi    01AH        ;^Z
  1011.     jz    X06CF        ;list CR, LF's at end of line
  1012.     call    X06E4        ;list output, read status
  1013.     jnz    X06B3        ;line to LST:
  1014.     ret
  1015.  
  1016. ;    Type CR, LF at end of line. Entry point according
  1017. ;    to whether CR, LF, or ^Z was encountered.
  1018.  
  1019. X06CE:    call    rbyt        ;decomission following LF
  1020. X06CF:    mvi    a,CR
  1021.     call    X06E4        ;list output, read status
  1022.     rz            ;to catch a ^C between CR, LF
  1023.     mvi    a,LF
  1024. X06E4:    push    h
  1025.     push    d
  1026.     push    b
  1027.     mov    e,a
  1028.     mvi    c,5        ;(05) list output
  1029.     call    X0005        ; B D O S
  1030.     mvi    e,0FFH
  1031.     mvi    c,6        ;(06) direct console I/O
  1032.     call    X0005        ; B D O S
  1033.     pop    b
  1034.     pop    d
  1035.     pop    h
  1036.     cpi    003H
  1037.     ret
  1038.  
  1039. ;    Respond to PRINT request.
  1040.  
  1041. X06FE:    lxi    d,X09DE        ;'Set Top-of-Form'
  1042.     call    mssg        ;message to console
  1043.     xra    a
  1044.     sta    X0C61        ;z/nz = panel/section (P)
  1045.     call    popu
  1046.     call    pupu
  1047.     call    X046B        ;read char from console
  1048.     cpi    003H        ;^Z
  1049.     jz    X071B
  1050.     cpi    'S'
  1051.     jz    X0718
  1052.     call    rspu
  1053.     call    pupu
  1054.     mvi    a,0FFH
  1055.     sta    X0C61        ;z/nz = panel/section (P)
  1056. X0718:    call    X0730
  1057. X071B:    call    popu
  1058.     jmp    pnlg
  1059.  
  1060. X0730:    lxi    d,X09B2        ;'Printing in Progress ...'
  1061.     call    mssg        ;message to console
  1062.     call    X0587        ;reset line count
  1063. X0739:    call    X06B3        ;line to LST:
  1064.     cpi    003H        ;^C
  1065.     rz
  1066.     call    abyt        ;lookahead one byte
  1067.     cpi    01AH        ;^Z
  1068.     rz
  1069.     cpi    ':'
  1070.     rz
  1071.     cpi    VT        ;Form Feed
  1072.     cz    X06CF        ;list CR, LF's at end of line
  1073.     lda    X0C61        ;z/nz = panel/section (P)
  1074.     ora    a
  1075.     jnz    X0739
  1076.     lxi    h,X0C6B        ;console remaining lines
  1077.     dcr    m
  1078.     jnz    X0739
  1079.     ret
  1080.  
  1081. ;    Check whether section is a disk file.
  1082.  
  1083. X075D:    call    abyt        ;lookahead one byte
  1084.     cpi    ':'
  1085.     rnz
  1086.     call    rbyt
  1087.     lda    X0C71        ;level #
  1088.     cpi    ND        ;maximum node depth
  1089.     jnz    X0776        ;read file, type name
  1090.     lxi    d,X0B4A        ;'Node Limit'
  1091.     call    mssg        ;message to console
  1092.     jmp    gbye        ;return to CP/M
  1093.  
  1094. ;    Type name, read file.
  1095.  
  1096. X0776:    call    X0845        ;locate file name on stack
  1097.     lxi    d,tfcb+1    ;TFCB+1
  1098.     mvi    b,11        ;bytes in file name
  1099.     call    miuc
  1100.     mvi    b,11
  1101.     lxi    d,nbuf+1
  1102.     call    miuc
  1103.     lxi    h,X0C71        ;level #
  1104.     inr    m
  1105.  
  1106. ;    If there can be several color overlays and the like,
  1107. ;    we have to set aside the panel defining them so that
  1108. ;    the space it occupies can be used for loading.
  1109.  
  1110.     mvi    b,0
  1111.     lxi    d,0000
  1112.     lxi    h,obuf
  1113.     shld    optr
  1114. olay:    call    rbyt
  1115.     jc    loaz
  1116.     cpi    1AH        ;^Z
  1117.     jz    loaz
  1118.     cpi    ':'
  1119.     jnz    olax
  1120.     mvi    a,LF
  1121.     cmp    b
  1122.     jz    loaz
  1123.     mvi    a,':'
  1124. olax:    mov    m,a
  1125.     mov    b,a
  1126.     inx    d
  1127.     inx    h
  1128.     cpi    ':'
  1129.     jnz    olay
  1130.     call    rbyt
  1131.     cpi    ':'
  1132.     jnz    loaz
  1133.     jmp    olay
  1134.  
  1135. loaz:    xchg
  1136.     shld    octr
  1137.     jmp    colo
  1138.  
  1139. ;    Subroutine which will read out the bytes saved from
  1140. ;    the instruction panel when overlays are to be used.
  1141.  
  1142. obyt:    push    h
  1143. ;    lhld    octr
  1144. ;    mov    a,h
  1145. ;    ora    l
  1146. ;    jz    obyz
  1147. ;    dcx    h
  1148. ;    shld    octr
  1149.     lhld    optr
  1150.     mov    a,m
  1151.     inx    h
  1152.     shld    optr
  1153. obyz:    pop    h
  1154.     ret
  1155.  
  1156. ;    Load any requested overlays.
  1157.  
  1158. colo:    lxi    d,lohf        ;'Loading HELP File'
  1159.     call    mssg        ;message to console
  1160.  
  1161.     lxi    h,dest
  1162.     mvi    m,' '
  1163.  
  1164.     call    pafr        ;parse file reference.
  1165.     jmp    coov        ;execute it
  1166.  
  1167. ;    Parse a file reference, and type it.
  1168.  
  1169. pafr:    mvi    a,' '
  1170.     sta    nbuf+1
  1171. paff:    call    obyt
  1172.     cpi    ' '
  1173.     jz    paff
  1174.     cpi    '('
  1175.     jz    ylbr
  1176.     lxi    h,tfcb
  1177.     call    pars
  1178.     cpi    ')'
  1179.     jz    wlbr
  1180.     lxi    h,tfcb+1
  1181.     jmp    tyfn
  1182.  
  1183. ylbr:    lxi    h,tfcb
  1184.     call    part
  1185. wlbr:    lxi    h,nbuf
  1186.     call    part
  1187.  
  1188. ;    Insert extension .LBR if none was given.
  1189.  
  1190.     lxi    h,tfcb+9
  1191.     mov    a,m
  1192.     cpi    ' '
  1193.     jnz    ylbs
  1194.     mvi    m,'L'
  1195.     inx    h
  1196.     mvi    m,'B'
  1197.     inx    h
  1198.     mvi    m,'R'
  1199.  
  1200. ylbs:    mvi    a,'('
  1201.     call    cona
  1202.     lxi    h,tfcb+1
  1203.     call    tyfn
  1204.     mvi    a,')'
  1205.     call    cona
  1206.     mvi    a,' '
  1207.     call    cona
  1208.     lxi    h,nbuf+1
  1209.     jmp    tyfn
  1210.  
  1211. ;    Check for color overlay.
  1212.  
  1213. coov:    lxi    h,dest
  1214.     mov    a,m
  1215.     mvi    m,' '
  1216.     cmp    m
  1217.     jnz    coow
  1218.     call    crlf
  1219.     jmp    loop        ;loop
  1220.  
  1221. coow:    cpi    'R'
  1222.     jnz    gree
  1223.     call    opef
  1224.     call    sefl
  1225.     call    desq
  1226.     lxi    h,bred        ;red screen area
  1227.     call    lcbf
  1228.     jmp    colo
  1229.  
  1230. gree:    cpi    'G'
  1231.     jnz    blue
  1232.     call    opef
  1233.     call    sefl
  1234.     call    desq
  1235.     lxi    h,bgrn        ;green screen area
  1236.     call    lcbf
  1237.     jmp    colo
  1238.  
  1239. blue:    cpi    'B'
  1240.     jnz    colo
  1241.     call    opef
  1242.     call    sefl
  1243.     call    desq
  1244.     lxi    h,bblu        ;blue screen area
  1245.     call    lcbf
  1246.     jmp    colo
  1247.  
  1248. ;    Load color buffer. HL designates the buffer.
  1249.  
  1250. lcbf:    lda    oper
  1251.     cpi    '='
  1252.     jnz    ocbf
  1253. ldbf:    call    rbyt
  1254.     jc    colo
  1255.     mov    m,a
  1256.     inx    h
  1257.     jmp    ldbf
  1258.  
  1259. ocbf:    cpi    '+'
  1260.     jnz    xcbf
  1261. odbf:    call    rbyt
  1262.     jc    colo
  1263.     ora    m
  1264.     mov    m,a
  1265.     inx    h
  1266.     jmp    odbf
  1267.  
  1268. xcbf:    cpi    '-'
  1269.     jnz    colo
  1270. xdbf:    call    rbyt
  1271.     jc    colo
  1272.     xra    m
  1273.     mov    m,a
  1274.     inx    h
  1275.     jmp    xdbf
  1276.  
  1277. ;    ---------------------------------------------
  1278. ;    Parse disk, filename, extension. HL points to
  1279. ;    FCB, new characters arrive via <call obyt>.
  1280. ;    ---------------------------------------------
  1281.  
  1282. ;    Pass over leading blanks.
  1283. ;      <call part> to ignore A
  1284. ;      <call pars> to test A first
  1285.  
  1286. part:    call    obyt
  1287. pars:    cpi    ' '
  1288.     jz    part
  1289.  
  1290.     call    term
  1291.     rz            ;null buffer
  1292.  
  1293. ;    Insert filename field. If a disk unit is specified,
  1294. ;    record it in the first byte of the FCB, then try again
  1295. ;    for the filename. Likewise, if a destination is given,
  1296. ;    note it.
  1297.  
  1298.     mvi    m,0
  1299. infn:    inx    h
  1300. infi:    push    h
  1301.     mvi    b,8
  1302.     call    stof
  1303.     call    oprn
  1304.     jnz    dsku
  1305.     sta    oper
  1306.     pop    h
  1307.     mov    a,m
  1308.     sta    dest
  1309.     call    obyt
  1310.     cpi    '('
  1311.     jnz    infi
  1312.     call    obyt
  1313.     jmp    infi
  1314.  
  1315. dsku:    cpi    ':'
  1316.     jnz    inxt
  1317.     pop    h
  1318.     mov    a,m
  1319.     sui    '@'
  1320.     mov    m,a
  1321.     dcx    h
  1322.     call    obyt
  1323.     jmp    infn
  1324.  
  1325. ;    Insert extension field.
  1326.  
  1327. inxt:    inx    sp
  1328.     inx    sp
  1329.     mvi    b,3
  1330.     cpi    '.'
  1331.     jnz    shof
  1332.     call    obyt
  1333.  
  1334. ;    Store field.
  1335.  
  1336. stof:    mov    m,a
  1337.     inx    h
  1338.     dcr    b
  1339.     jz    lonf
  1340.     call    obyt
  1341.     call    term        ;z=terminator
  1342.     jnz    stof
  1343.  
  1344. ;    Complete short field with blanks.
  1345.  
  1346. shof:    mvi    m,' '
  1347.     inx    h
  1348.     dcr    b
  1349.     jnz    shof
  1350.     ret
  1351.  
  1352. ;    Ignore remainder of long field.
  1353.  
  1354. lonf:    call    obyt
  1355.     call    term        ;z=terminator
  1356.     jnz    lonf
  1357.     ret
  1358.  
  1359. ;    Check for a field terminator (z).
  1360. ;    Check for an operation (z).
  1361.  
  1362. term:    cpi    '.'
  1363.     rz
  1364.     cpi    ' '
  1365.     rz
  1366.     cpi    ':'
  1367.     rz
  1368.     cpi    ')'
  1369.     rz
  1370.     cpi    CR
  1371.     rz
  1372.     ora    a
  1373.     rz
  1374. oprn:    cpi    '='
  1375.     rz
  1376.     cpi    '+'
  1377.     rz
  1378.     cpi    '-'
  1379.     ret
  1380.  
  1381. ;    ------------------------
  1382.  
  1383. ;    Go back to root.
  1384.  
  1385. X07E1:    lda    X0C71        ;level #
  1386.     ora    a
  1387.     jz    X0342        ;display menu
  1388.     mvi    a,000H
  1389.     jmp    X07FE
  1390.  
  1391. ;    Go up one level.
  1392.  
  1393. X07ED:    lda    X0C71        ;level #
  1394.     ora    a
  1395.     jnz    X07FD        ;revert to last level
  1396.     lxi    d,X0BAD        ;'No Higher Level'
  1397.     call    mssg        ;message to console
  1398.     jmp    X0342        ;display menu
  1399.  
  1400. ;    Revert to upper level, type name.
  1401.  
  1402. X07FD:    dcr    a
  1403. X07FE:    sta    X0C71        ;level #
  1404.     call    X0845        ;locate file name on stack
  1405.     push    h
  1406.     lxi    d,lohf        ;'Loading HELP File'
  1407.     call    mssg        ;message to console
  1408.     call    tyfn        ;type filename
  1409.     call    crlf
  1410.     pop    d
  1411.     lxi    h,tfcb+1    ;TFCB+1
  1412.     mvi    b,11        ;bytes in file name
  1413.     call    miuc
  1414.     mvi    b,11
  1415.     lxi    h,nbuf+1
  1416.     call    miuc
  1417.     jmp    loop        ;loop
  1418.  
  1419. ;    Locate file name on stack.
  1420.  
  1421. X0845:    call    X084D        ;HL=A*22
  1422.     lxi    d,X0C73        ;PDL for HELP file names
  1423.     dad    d
  1424.     ret
  1425.  
  1426. ;    HL = A*22
  1427.  
  1428. X084D:    mov    l,a
  1429.     mvi    h,000H
  1430.     mov    e,l
  1431.     mov    d,h
  1432.     dad    h
  1433.     dad    h
  1434.     dad    h
  1435.     dad    d
  1436.     dad    d
  1437.     dad    d
  1438.     dad    h
  1439.     ret
  1440.  
  1441. ;    Type level identification.
  1442.  
  1443. X0859:    lda    X0C71        ;level #
  1444.     ora    a
  1445.     jz    X0872
  1446.     lxi    d,X0C0C        ;'Level 1'
  1447.     call    mssg        ;message to console
  1448.     lda    X0C71        ;level #
  1449.     call    X0881        ;translate level # to ASCII
  1450.     lxi    d,X0C13        ;'/ '
  1451.     call    mssg        ;message to console
  1452. X0872:    lda    X0C72        ;panel #
  1453.     ora    a
  1454.     rz
  1455.     call    X0881        ;translate level # to ASCII
  1456.     lxi    d,X0C16        ;': '
  1457.     call    mssg        ;message to console
  1458.     ret
  1459.  
  1460. ;    Translate level number to ASCII string.
  1461.  
  1462. X0881:    push    psw
  1463.     xra    a
  1464.     sta    X0C70        ;z/nz = 1/2 digit number
  1465.     pop    psw
  1466.     mvi    b,100        ;one hundred
  1467.     call    X0896        ;type A as decimal number
  1468.     mvi    b,10        ;ten
  1469.     call    X0896        ;type A as decimal number
  1470.     adi    '0'
  1471.     jmp    cona        ;char to console
  1472.  
  1473. ;    Type A as decimal number.
  1474.  
  1475. X0896:    mvi    c,000H
  1476. X0898:    sub    b
  1477.     jc    X08A0
  1478.     inr    c
  1479.     jmp    X0898
  1480.  
  1481. X08A0:    add    b
  1482.     mov    b,a
  1483.     lda    X0C70        ;z/nz = 1/2 digit number
  1484.     ora    a
  1485.     jnz    X08B6
  1486.     mov    a,c
  1487.     sta    X0C70        ;z/nz = 1/2 digit number
  1488.     ora    a
  1489.     jnz    X08B6
  1490.     mvi    a,' '
  1491.     jmp    X08B9
  1492.  
  1493. X08B6:    mov    a,c
  1494.     adi    '0'
  1495. X08B9:    call    cona        ;char to console
  1496.     mov    a,b
  1497.     ret
  1498.  
  1499. X08BE:    db    'HJELP/ICUAP/05-OCT-84',CR,LF,'$'
  1500. tuto:    db    'Many systems feature HELP files containing information',CR,LF
  1501.     db    'about the usage or characteristics of the system itself',CR,LF
  1502.     db    'or the programs which it contains. HELP files are often',CR,LF
  1503.     db    'structured, and require an auxiliary program which will',CR,LF
  1504.     db    'facilitate their consultation. HJELP.COM satisfies this',CR,LF
  1505.     db    'requirement, even if the HELP files have been squeezed',CR,LF
  1506.     db    'or have been placed in a library.',CR,LF
  1507.     db    '        HJELP FILE',CR,LF
  1508.     db    'will display either FILE.HLP or FILE.HQP, using a menu',CR,LF
  1509.     db    'of information sections and a series of prompts which',CR,LF
  1510.     db    'are largely self-explanatory.',CR,LF
  1511.     db    '        HJELP (LIBR) FILE',CR,LF
  1512.     db    'will display FILE.HLP, taken from the library LIBR.LBR.',CR,LF
  1513.     db    'Finally,',CR,LF
  1514.     db    '        HJELP (FILE)',CR,LF
  1515.     db    'will assume that FILE.HLP is a member of FILE.LBR. Such',CR,LF
  1516.     db    'a construction presupposes that FILE.LBR contains many',CR,LF
  1517.     db    'additional files which are referenced through FILE.HLP.',CR,LF
  1518.     db    'In all cases, an explicitly given extension will be',CR,LF
  1519.     db    'respected, even when it is different from the default.',CR,LF
  1520.     db    '$'
  1521. X0954:    db    CR,LF,'  HELP File Selections are --',CR,LF,'$'
  1522. X0976:    db    'EOI '
  1523. X097A:    db    '^C=Exit $'
  1524. X0983:    db    '^=Level .=Root $'
  1525. X0993:    db    'M=Menu S=Start L=Last P=Print $'
  1526. X09B2:    db    'Printing in Progress -- Strike ^C to Quit $'
  1527. X09DE:    db    'Please Set Top-of-Form on Printer',CR,LF
  1528.     db    '  Strike S to Print this Screen Only,'
  1529.     db    ' ^C to Quit, or',CR,LF
  1530.     db    '  Any Other Char to Print Entire Information Section - $'
  1531. X0AC6:    db    CR,LF,'% -- Invalid Response',CR,LF,'$'
  1532. X0AE9:    db    CR,LF,'% -- EOF on HELP File',CR,LF,'$'
  1533. X0B4A:    db    CR,LF,'% -- Node Level Limit Reached'
  1534.     db    ' -- Returning to CP/M',CR,LF,'$'
  1535. X0B81:    db    CR,LF,'% -- Invalid File Name in Load',CR,LF,'$'
  1536. X0BAD:    db    CR,LF,'% -- No Higher Level to Return to',CR,LF,'$'
  1537. X0BDC:    db    CR,LF,'% -- Not Enough Room for HELP File',CR,LF,'$'
  1538. X0C0C:    db    'Level $'
  1539. X0C13:    db    '/ $'
  1540. X0C16:    db    ': $'
  1541. X0C19:    db    'Type  ^C=Exit$'
  1542. X0C27:    db    ' ^=Level .=Root$'
  1543. X0C37:    db    ' or Enter Selection $'
  1544. lohf:    db    CR,LF,'Loading HELP File $'
  1545. chno:    db    CR,LF,'Checksum failure.$'
  1546. nlib:    db    CR,LF,'Requested library not present.$'
  1547. rerr:    db    CR,LF,'Read error.$'
  1548. nfil:    db    CR,LF,'Requested file not present.$'
  1549.  
  1550. mlen:    ds    2        ;length (records) of member
  1551. rlen:    ds    2        ;length (32-byte lines) of directory
  1552. actr:    ds    2
  1553. aptr:    ds    2
  1554. abuf:    ds    32
  1555. nbuf:    ds    12
  1556. mctr:    ds    2
  1557. mptr:    ds    2
  1558. oper:    ds    1        ;color operation
  1559. dest:    ds    1        ;color area
  1560. octr:    ds    2
  1561. optr:    ds    2
  1562. obuf:    ds    80H
  1563. X0C61:    ds    1        ;z/nz = panel/section (P)
  1564. X0C62:    ds    1        ;user code
  1565. X0C63:    ds    1        ;memory pages
  1566. X0C68:    ds    1        ;option letter
  1567. X0C6B:    ds    1        ;console remaining lines
  1568. X0C6E:    ds    2        ;ptr end of text
  1569. X0C70:    ds    1        ;z/nz = 1/2 digit number
  1570. X0C71:    ds    1        ;level #
  1571. X0C72:    ds    1        ;panel #
  1572. X0C73:    ds    ND*22+100    ;PDL for HELP file names/stack
  1573. X0D31:    ds    2        ;save stack pointer
  1574. cksm:    ds    2        ;checksum
  1575. lach:    ds    1        ;%; last character typed    S
  1576. rcnt:    ds    1        ;%; repetition count        E
  1577. roco:    ds    1        ;%; rotating bit counter    Q
  1578. roby:    ds    1        ;%; rotating byte        U
  1579. dens:    ds    1        ;%; z/nz=normal/squeezed file    E
  1580. wflg:    ds    1        ;%; z/nz=no/byte awaiting abyt    N
  1581. wbyt:    ds    1        ;%; byte left waiting by abyt    C
  1582. tptr:    ds    2        ;%; text pointer        E
  1583. xptr:    ds    2        ;ptr to bgn of HELP file
  1584. yptr:    ds    2        ;zptr+NS
  1585. zptr:    ds    2        ;ptr to bgn of info sect
  1586. cptr:    ds    2        ;Huffman code table
  1587. pptr:    ds    2        ;pushdown pointer
  1588. mopt:    ds    1        ;maximum option
  1589. char:    ds    1        ;char read from console
  1590. pudl:    ds    NS*50        ;pushdown for section heads
  1591. X0D33:    ds    0        ;free memory
  1592.  
  1593. ;    Layout of pudl and pointers:
  1594. ;
  1595. ;        pudl:    menu
  1596. ;            ...
  1597. ;            menu
  1598. ;        zptr->    panel 1
  1599. ;        yptr->    panel 2
  1600. ;            ...
  1601. ;        pptr->    panel n
  1602. ;            x
  1603. ;            x
  1604. ;            x
  1605. ;        X0D33:    x
  1606. ;            x
  1607. ;        cptr->    Huffman code
  1608. ;            x
  1609. ;            x
  1610. ;        xptr->    HELPfile text
  1611. ;            x
  1612. ;            x
  1613. ;        tptr->    x
  1614. ;            x
  1615. ;            x
  1616.  
  1617.     end
  1618.