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 / ENTERPRS / CPM / UTILS / S / UNZIP18.LBR / UNZIP18.ZZ0 / UNZIP18.Z80
Text File  |  1992-04-16  |  24KB  |  1,624 lines

  1. ; UNZIP.Z80
  2. ;
  3. ;    Dissolves MS-DOS ZIP files.
  4. ;
  5. Vers    equ    18
  6. ;
  7. ;
  8. ; Version 1.8 -- April 16, 1992 -- Howard Goldstein
  9. ;    Fixed "unreducing" code which I inadvertently broke in version
  10. ;    1.6.
  11. ; Version 1.7 -- April 8, 1992 -- Howard Goldstein
  12. ;    Fixed problem where long ZIP comments were clobberiog data and
  13. ;    causing strange errors.  Fixed typo in help screen.  Can now be
  14. ;    assembled with M80 again.
  15. ; Version 1.6 -- April 3, 1992 -- Howard Goldstein
  16. ;    Improved performance by incorporating an 8k output buffer and a
  17. ;    dynamically allocated input buffer of up to 8k.  The program no
  18. ;    longer expands and checks the CRC of a Zipfile member that is
  19. ;    being skipped.  The keyboard is checed for control-c less
  20. ;    frequently which also speeds things up a bit.  All console output
  21. ;    is now done via direct console IO making control-c checking more
  22. ;    reliable.  I also made the program reentrant and changed the order
  23. ;    of events so that the destination directory is checked for a
  24. ;    file's existence AFTER it has been determined that the file is to
  25. ;    be extracted, not before as was the case previously.
  26. ; Version 1.5 -- june 1, 1991 -- Howard Goldstein
  27. ;    Fixed bug at WILDLP which was causing an output spec of "dir:"
  28. ;    not to work correctly.  Corrected problems that were causing
  29. ;    writes to disk when a non-matching member file was being skipped.
  30. ;    Changed "disk full" logic to close and erase partial output file
  31. ;    and abort the program immediately.  Made several minor changes to
  32. ;    allow assembly with ZMAC or M80.
  33.  
  34. ; Version 1.4 -- May 16, 1991 -- Bruce Morgen
  35. ;    Fixed bug at "setusr" and added output filename wildcard
  36. ;    support.  If the selected output filespec is NOT wild,
  37. ;    (and d: or dir: alone IS wild) UNZIP will exit after the
  38. ;    first extraction.  Boy, do I have a headache....
  39.  
  40. ; Version 1.3 -- May 12, 1991 -- Gene Pizzetta
  41. ;    Some quick and dirty mods to make this utility more useful.
  42. ;    The original has to be the most God-awful source code I've
  43. ;    ever come across.  It is totally uncommented, and I have
  44. ;    no idea what kind of strange assembler it was written for.
  45. ;    This code now assembles with SLR's Z80ASM and it's a little
  46. ;    more orderly.
  47. ;
  48. ;    New syntax:
  49. ;        UNZIP {dir:}zipfile {dir:}{afn}
  50. ;    Under ZCPR3 "dir" can be a DU or DIR spec; otherwise, just
  51. ;    a drive.  If no destination is given, member files are checked
  52. ;    and listed.  If a destination is given, member files are
  53. ;    extracted if they match "afn" if given, otherwise the entire
  54. ;    ZIPfile is extracted.
  55. ;
  56. ;    You can now abort this thing with ^C (and the partial output
  57. ;    file, if any, will be closed and erased).  Usage screen now
  58. ;    responds to "//".  This program still needs a lot of work.
  59. ;    It's probably not bullet-proof and testing has been very
  60. ;    limited, but it seems to work.
  61. ;
  62. ; Version 1.2 -- July 3, 1990 -- David P. Goodenough
  63. ;
  64. ; User equates
  65. ;
  66. obfsiz    equ    32        ; 32-page (8k) fixed output buffer
  67. ibfmax    equ    32        ; 32-page (8k) max. for input buffer
  68. ;
  69. ; System addresses
  70. ;
  71. wboot    equ    0
  72. bdos    equ    5
  73. dfcb    equ    5Ch
  74. altfcb    equ    6Ch
  75. ;
  76. ; BDOS service functions
  77. ;
  78. dircon    equ    6
  79. fsearch    equ    17
  80. getdrv    equ    25
  81. setusr    equ    32
  82. ;
  83. ; Other
  84. ;
  85. STRSIZ    equ    256
  86. DLE    equ    144
  87. max_bits equ    13
  88. init_bits equ    9
  89. hsize    equ    8192
  90. first_ent equ    257
  91. clear    equ    256
  92. maxcmax    equ    1 shl max_bits
  93. maxSF    equ    256
  94. _code    equ    0
  95. _value    equ    2
  96. _bitlength equ    3
  97. _entries equ    0
  98. _maxlength equ    2
  99. _entry    equ    4
  100. _sf_tree_ equ    4 + 4 * maxSF
  101. ;
  102. ; ASCII
  103. ;
  104. CtrlC    equ    03h
  105. CR    equ    0Dh
  106. LF    equ    0Ah
  107. CtrlZ    equ    1Ah
  108. ;
  109.     .request zslib
  110.     ext    fxropen,fxwopen,fxrclose,fxwclose,fxget,fxput
  111. ;
  112.     .request z3lib
  113.     ext    z3log
  114. ;
  115.     .request syslib
  116.     ext    f$close,f$delete,initfcb
  117. ;
  118.     public    $memry
  119. ;
  120.     jp    start
  121. ;
  122.     db    'Z3ENV',1
  123. Z3EAdr:    dw    0
  124. ;
  125. start:    ld    sp,locstk    ; set the stack pointer
  126.     call    ilprt
  127.     db    'UNZIP  Version '
  128.     db    Vers/10+'0','.',Vers mod 10+'0','  -  DPG',CR,LF,0
  129.     ld    a,(dfcb+1)    ; filename?
  130.     cp    ' '
  131.     jp    z,usage
  132.     cp    '/'
  133.     jp    z,usage
  134. ;
  135. wasfil:    ld    hl,0
  136.     ld    (zipeof),hl        ; init "zipeof" and "counting"
  137.     ld    (opnflg),hl    ; init "opnflg" and "conckct"
  138. ;
  139. ; Determine buffer addresses.  Output buffer size is defined by Obfsiz
  140. ; and input buffer size is either remaining memory or Ibfmax, whichever is
  141. ; less.
  142. ;
  143.     ld    hl,($memry)    ; top of dseg
  144.     ld    (opbuf),hl    ; store as output buffer address
  145.     ld    de,obfsiz shl 8    ; output buffer size (pages)
  146.     ld    a,d
  147.     add    a,a        ; convert to records
  148.     ld    (ocb),a        ; and store in output control block
  149.     add    hl,de        ; determine address of input buffer
  150.     ld    (ipbuf),hl
  151.     ex    de,hl        ; get buffer address in de
  152.     inc    d        ; assume 1 page for input buffer
  153.     ld    hl,(bdos+1)    ; top of memory
  154.     xor    a        ; clear accumulator and carry
  155.     sbc    hl,de        ; hl = memory available less 1 page
  156.     jp    c,nomem
  157.     inc    h        ; now = total memory available
  158.     rl    l        ; shift possible extra record to carry
  159.     adc    a,h
  160.     add    a,h        ; a = max input buffer records
  161.     ld    b,ibfmax * 2
  162.     cp    b        ; compare computed to optimum value
  163.     jr    c,sticb        ; computed value smaller, use it
  164.     ld    a,b        ; else use optimum
  165. sticb:    ld    (icb),a        ; store in input control block
  166. ;
  167.     ld    a,(altfcb)
  168.     ld    (mode),a    ; set the mode (non-zero = extract)
  169.     call    getusr        ; set default user if not ZCPR3
  170.     ld    hl,mtchfcb
  171.     ld    bc,11
  172.     ld    de,altfcb + 1
  173.     ld    a,(de)
  174.     cp    20h
  175.     jr    z,wildfill
  176.     ex    de,hl
  177.     ldir
  178.     ld    a,(altfcb)
  179.     or    a
  180.     jr    nz,filldn
  181.     ld    c,getdrv
  182.     call    bdos
  183.     inc    a
  184.     ld    (altfcb),a    ; store it for Z3LOG
  185.     ld    (mode),a    ; set the mode (non-zero = extract)
  186.     jr    filldn
  187. wildfill:
  188.     ld    b,c
  189. wildlp:    ld    (hl),'?'
  190.     inc    hl
  191.     djnz    wildlp
  192. filldn:    ld    a,(dfcb+9)    ; check for filetype
  193.     cp    20h
  194.     jr    nz,wasext
  195.     ld    hl,+('I' shl 8) + 'Z'    ; set default type to ZIP
  196.     ld    (dfcb+9),hl
  197.     ld    a,'P'
  198.     ld    (dfcb+11),a
  199. wasext:    ld    de,dfcb
  200.     call    z3log        ; log input drive/user
  201.     ex    de,hl
  202.     inc    hl
  203.     ld    bc,11
  204.     ld    de,infcb+1
  205.     ldir            ; move filename to working fcb
  206.     ld    de,icb
  207.     call    fxropen        ; try to open zipfile
  208.     jr    nz,openok    ; ok
  209.     call    ilprt
  210.     db    'Couldn''t find ZIP file',CR,LF,0
  211.     jr    exit
  212. ;
  213. nomem:    call    ilprt        ; complain and fall through to exit
  214.     db    'Not enough memory!',cr,lf,0
  215. ;
  216. ; All exits point here for possible future enhancements, such
  217. ; as elimination of warm boot.
  218. ;
  219. exit:    rst    0        ; warmboot
  220. ;
  221. sigerr:    call    ilprt
  222.     db    'Bad signature in ZIP file',CR,LF,0
  223.     jr    exit
  224. ;
  225. openok:    call    getword
  226.     ld    de,-(('K' shl 8) + 'P')
  227.     add    hl,de
  228.     ld    a,h
  229.     or    l
  230.     jr    nz,sigerr
  231.     call    getword
  232.     dec    l
  233.     jr    nz,nocfhs
  234.     dec    h
  235.     dec    h
  236.     jr    nz,sigerr
  237.     call    pcfh
  238.     jr    openok
  239. ;
  240. nocfhs:    dec    l
  241.     dec    l
  242.     jr    nz,nolfhs
  243.     ld    a,h
  244.     sub    4
  245.     jr    nz,sigerr
  246.     call    plfh
  247.     jr    openok
  248. ;
  249. nolfhs:    dec    l
  250.     dec    l
  251.     jr    nz,sigerr
  252.     ld    a,h
  253.     sub    6
  254.     jr    nz,sigerr
  255.     call    pecd
  256. clsxit:    ld    de,icb
  257.     call    fxrclose
  258.     jr    exit
  259. ;
  260. pcfh:    ld    b,12
  261. pcfhl1:    push    bc
  262.     call    getword
  263.     pop    bc
  264.     djnz    pcfhl1
  265.     call    getword
  266.     push    hl
  267.     call    getword
  268.     push    hl
  269.     call    getword
  270.     pop    de
  271.     pop    bc
  272.     push    hl
  273.     push    de
  274.     push    bc
  275.     ld    b,6
  276. pcfhl2:    push    bc
  277.     call    getword
  278.     pop    bc
  279.     djnz    pcfhl2
  280.     pop    hl
  281.     call    skpstring
  282.     pop    hl
  283.     call    skpstring
  284.     pop    hl
  285.     call    skpstring
  286.     ret
  287. ;
  288. pecd:    ld    b,8
  289. pecdl:    push    bc
  290.     call    getword
  291.     pop    bc
  292.     djnz    pecdl
  293.     call    getword
  294.     call    skpstring
  295.     ret
  296. ;
  297. plfh:    ld    de,lfh
  298.     ld    hl,endlfh-lfh
  299.     call    getstring
  300.     ld    de,junk
  301.     ld    hl,(fnl)
  302.     push    de
  303.     call    getstring
  304.     ld    de,junk + 20
  305.     ld    hl,(efl)
  306.     call    getstring
  307.     ld    de,opfcb
  308.     call    initfcb
  309.     ex    de,hl
  310.     inc    hl
  311.     pop    de
  312.     ld    b,8
  313.     call    scanfn
  314.     ld    a,(de)
  315.     cp    '.'
  316.     jr    nz,nodot
  317.     inc    de
  318. nodot:    ld    b,3
  319.     call    scanfn
  320.     ld    hl,init
  321.     ld    de,vars
  322.     ld    bc,endinit-init
  323.     ldir
  324.     ld    a,(mode)
  325. resmod:    ld    (curmode),a
  326.     or    a
  327.     jp    z,pjunk
  328. mtched:    ld    b,11
  329.     ld    hl,opfn
  330.     ld    de,mtchfcb
  331. mtchlp:    ld    a,(de)
  332.     ld    c,(hl)
  333.     inc    hl
  334.     inc    de
  335.     cp    '?'
  336.     jr    z,mtch1
  337.     cp    c
  338.     jr    nz,nomtch
  339. mtch1:    djnz    mtchlp
  340.     call    setout        ; log output drive/user
  341.     ld    de,opfcb    ; see if output file already exists
  342.     ld    c,fsearch
  343.     call    bdos
  344.     inc    a
  345.     jr    nz,exists
  346.     jr    creok
  347. nomtch:    ld    hl,junk
  348.     call    pstr
  349.     call    ilprt
  350.     db    ' doesn''t match',0
  351.     jr    noex
  352. exists:    ld    hl,junk        ; it exists, so skip it
  353.     call    pstr
  354.     call    ilprt
  355.     db    ' exists',0
  356.     xor    a
  357.     ld    (nodest),a
  358. noex:    call    ilprt
  359.     db    ' -- not extracting ',0
  360.     xor    a
  361.     jr    resmod
  362. ;
  363. creok:    ld    de,ocb        ; create output file
  364.     call    fxwopen
  365.     jr    nz,opnok1
  366.     call    ilprt
  367.     db    'Error creating ',0
  368.     ld    hl,junk
  369.     call    pstr
  370.     jr    noex
  371. ;
  372. opnok1:    ld    (opnflg),a
  373.     call    ilprt
  374.     db    'Extracting ',0
  375. pjunk:    ld    hl,junk
  376.     call    pstr
  377. doext:    ld    hl,counting
  378.     inc    (hl)
  379.     ld    a,(curmode)
  380.     or    a
  381.     jr    z,case0x
  382.     call    ilprt
  383.     db    ' -- ',0
  384.     ld    a,(cm)
  385.     or    a
  386.     jr    nz,case1
  387.     jr    case0w
  388. case0x:    ld    a,(nodest)
  389.     or    a
  390.     call    z,wildck
  391. case0w:    ld    a,(zipeof)
  392.     and    1
  393.     jr    nz,closeo
  394. savcs0:    call    getbyte
  395.     call    outbyte
  396.     jr    case0w
  397. ;
  398. case1:    dec    a
  399.     jr    nz,case2p
  400.     call    unshrink
  401.     jr    closeo
  402. ;
  403. case2p:    dec    a
  404.     cp    4
  405.     jr    nc,tryimp
  406.     call    unreduce
  407.     jr    closeo
  408. ;
  409. tryimp:    jr    nz,badzip
  410.     call    unimplode
  411.     jr    closeo
  412. ;
  413. badzip:    call    ilprt
  414.     db    'Unknown compression method',CR,LF,0
  415.     ret
  416. ;
  417. closeo:    ld    hl,zipeof
  418.     dec    (hl)
  419.     inc    hl
  420.     dec    (hl)
  421.     ld    a,(curmode)
  422.     or    a
  423.     jr    nz,close1
  424.     call    ilprt
  425.     db    cr,lf,0
  426.     ret
  427. close1:    ld    de,ocb
  428.     call    fxwclose
  429.     jp    z,wrterr
  430.     xor    a
  431.     ld    (opnflg),a
  432.     ld    hl,crc32
  433.     ld    de,crc
  434.     scf
  435.     ld    bc,4 shl 8
  436. crcclp:    ld    a,(de)
  437.     adc    a,(hl)
  438.     push    af
  439.     or    c
  440.     ld    c,a
  441.     pop    af
  442.     inc    hl
  443.     inc    de
  444.     djnz    crcclp
  445.     ld    a,c
  446.     or    a
  447.     jr    z,crcok
  448.     call    ilprt
  449.     db    'CRC error',CR,LF,0
  450.     jr    wildck
  451. ;
  452. crcok:    call    ilprt
  453.     db    'CRC OK',CR,LF,0
  454. wildck:    ld    hl,mtchfcb
  455.     ld    bc,11
  456.     ld    a,'?'
  457.     cpir
  458.     jp    nz,clsxit
  459.     ret
  460. ;
  461. getchla:
  462.     call    getcode
  463.     ld    (code),hl
  464.     ld    a,(zipeof)
  465.     and    1
  466.     ret
  467. ;
  468. savstk:    ld    hl,(stackp)
  469.     dec    hl
  470.     ld    (stackp),hl
  471.     ld    (hl),a
  472.     ret
  473. ;
  474. getcode:
  475.     ld    a,(codesize)
  476. readbits:
  477.     ld    hl,8000h
  478. bitlp:    push    af
  479.     push    hl
  480. getbit:    ld    hl,bleft
  481.     dec    (hl)
  482.     jp    m,readbt
  483.     dec    hl
  484.     rr    (hl)
  485.     pop    hl
  486.     rr    h
  487.     rr    l
  488.     pop    af
  489.     dec    a
  490.     jr    nz,bitlp
  491. finbit:    srl    h
  492.     rr    l
  493.     jr    nc,finbit
  494.     ld    a,l
  495.     ret
  496. ;
  497. readbt:    push    hl
  498.     call    getbyte
  499.     pop    hl
  500.     ld    (hl),8
  501.     dec    hl
  502.     ld    (hl),a
  503.     jr    getbit
  504. ;
  505. scanfn:    ld    a,(de)
  506.     cp    '.'
  507.     jr    z,nocopy
  508.     or    a
  509.     jr    z,nocopy
  510.     inc    de
  511.     dec    b
  512.     jp    m,scanfn
  513.     and    7fh
  514.     ld    (hl),a
  515.     inc    hl
  516.     jr    scanfn
  517. ;
  518. nocopy:    dec    b
  519.     ret    m
  520.     ld    (hl),' '
  521.     inc    hl
  522.     jr    nocopy
  523. ;
  524. ilprt:    pop    hl
  525.     call    pstr
  526.     jp    (hl)
  527. ;
  528. pstr:    ld    a,(hl)
  529.     or    a
  530.     ret    z
  531.     push    hl
  532.     ld    e,a
  533.     ld    c,dircon
  534.     call    bdos
  535.     pop    hl
  536.     inc    hl
  537.     jr    pstr
  538. ;
  539. getstring:
  540.     ld    a,h
  541.     or    l
  542.     ld    (de),a
  543.     ret    z
  544.     push    de
  545.     push    hl
  546.     call    getbyte
  547.     pop    hl
  548.     pop    de
  549.     ld    (de),a
  550.     inc    de
  551.     dec    hl
  552.     jr    getstring
  553. ;
  554. skpstring:
  555.     ld    a,h
  556.     or    l
  557.     ret    z
  558.     push    hl
  559.     call    getbyte
  560.     pop    hl
  561.     dec    hl
  562.     jr    skpstring
  563. ;
  564. getword:
  565.     call    getbyte
  566.     push    af
  567.     call    getbyte
  568.     pop    hl
  569.     ld    l,h
  570.     ld    h,a
  571.     ret
  572. ;
  573. getbyte:
  574.     ld    a,(zipeof)
  575.     and    1
  576.     ld    a,CtrlZ
  577.     ret    nz
  578.     ld    a,(counting)
  579.     or    a
  580.     jr    z,skpdci
  581.     ld    hl,(cs)
  582.     ld    de,(cs + 2)
  583.     ld    a,d
  584.     or    e
  585.     or    h
  586.     or    l
  587.     jr    nz,noteof
  588.     ld    hl,zipeof
  589.     inc    (hl)
  590.     ld    a,CtrlZ
  591.     ret
  592. ;
  593. noteof:    ld    a,h
  594.     or    l
  595.     dec    hl
  596.     ld    (cs),hl
  597.     jr    nz,skpdci
  598.     dec    de
  599.     ld    (cs + 2),de
  600. skpdci:    call    ckcon        ; check console for abort
  601.     ld    de,icb
  602.     call    fxget
  603.     ret    nz
  604.     ld    a,CtrlZ
  605.     ret
  606. ;
  607. outb:    ld    hl,(outpos)
  608.     push    hl
  609.     push    af
  610.     ld    a,h
  611.     and    1fh
  612.     ld    h,a
  613.     pop    af
  614.     ld    de,outbuf
  615.     add    hl,de
  616.     ld    (hl),a
  617.     pop    hl
  618.     inc    hl
  619.     ld    (outpos),hl
  620.     push    af
  621.     ld    a,h
  622.     or    l
  623.     jr    nz,nopos
  624.     ld    hl,(outpos + 2)
  625.     inc    hl
  626.     ld    (outpos + 2),hl
  627. nopos:    pop    af
  628. outbyte:
  629.     push    af
  630.     ld    c,a
  631.     ld    a,(curmode)
  632.     or    a
  633.     call    nz,updcrc
  634.     ld    hl,(ucs)
  635.     ld    de,(ucs + 2)
  636.     ld    a,h
  637.     or    l
  638.     dec    hl
  639.     ld    (ucs),hl
  640.     jr    nz,tsthl0
  641.     dec    de
  642.     ld    (ucs + 2),de
  643. tsthl0:    ld    a,h
  644.     or    l
  645.     or    d
  646.     or    e
  647.     jr    nz,noeof
  648.     ld    hl,zipeof
  649.     inc    (hl)
  650. noeof:    ld    a,(curmode)
  651.     or    a
  652.     jr    nz,noeof1
  653.     pop    af
  654.     ret
  655. ;
  656. noeof1:    pop    af
  657.     ld    de,ocb
  658.     call    fxput
  659.     ret    nz
  660. wrterr:    call    ilprt
  661.     db    'Write Error (Disk full)',CR,LF,0
  662.     jp    ckcon0
  663. ;
  664. ;
  665. updcrc:    ld    hl,(crc32)
  666.     ld    de,(crc32 + 2)
  667.     ld    b,8
  668. crclp:    ld    a,l
  669.     xor    c
  670.     srl    c
  671.     srl    d
  672.     rr    e
  673.     rr    h
  674.     rr    l
  675.     rra
  676.     jr    nc,noxor
  677.     ld    a,d
  678.     xor    0edh
  679.     ld    d,a
  680.     ld    a,e
  681.     xor    0b8h
  682.     ld    e,a
  683.     ld    a,h
  684.     xor    83h
  685.     ld    h,a
  686.     ld    a,l
  687.     xor    20h
  688.     ld    l,a
  689. noxor:    djnz    crclp
  690.     ld    (crc32),hl
  691.     ld    (crc32 + 2),de
  692.     ret
  693. ;
  694. unshrink:
  695.     ld    a,init_bits
  696.     ld    (codesize),a
  697.     ld    hl,+(1 shl init_bits) - 1;
  698.     ld    (maxcode),hl
  699.     ld    hl,first_ent
  700.     ld    (free_ent),hl
  701.     ld    hl,prefix_of
  702.     ld    de,prefix_of + 1
  703.     ld    bc,512
  704.     ld    (hl),c
  705.     ldir
  706.     ld    bc,16386 - 512
  707.     ld    (hl),-1
  708.     ldir
  709.     ld    hl,suffix_of
  710. sol:    ld    (hl),c
  711.     inc    hl
  712.     inc    c
  713.     jr    nz,sol
  714.     call    getchla
  715.     ld    (oldcode),hl
  716.     ret    nz
  717.     ld    a,l
  718.     ld    (finchar),a
  719.     call    outbyte
  720. unshlp:    ld    hl,stack
  721.     ld    (stackp),hl
  722.     ld    a,(zipeof)
  723.     and    1
  724.     ret    nz
  725. clrlp:    call    z,getchla
  726.     ret    nz
  727.     ld    a,h
  728.     dec    a
  729.     or    l
  730.     jr    nz,noclr
  731.     call    getchla
  732.     ld    a,h
  733.     or    a
  734.     jr    nz,clrlp
  735.     dec    l
  736.     jr    z,bumpcs
  737.     dec    l
  738.     call    z,partial_clear
  739.     jr    clrlp
  740. ;
  741. bumpcs:    ld    hl,codesize
  742.     inc    (hl)
  743.     ld    a,(hl)
  744.     cp    max_bits
  745.     ld    hl,maxcmax
  746.     jr    z,atmax
  747.     ld    hl,1
  748. maxclp:    add    hl,hl
  749.     dec    a
  750.     jr    nz,maxclp
  751.     dec    hl
  752. atmax:    ld    (maxcode),hl
  753.     jr    clrlp
  754. ;
  755. noclr:    ld    (incode),hl
  756.     add    hl,hl
  757.     ld    de,prefix_of
  758.     add    hl,de
  759.     ld    a,(hl)
  760.     inc    hl
  761.     and    (hl)
  762.     inc    a
  763.     ld    hl,(code)
  764.     jr    nz,noKwKw
  765.     ld    a,(finchar)
  766.     call    savstk
  767.     ld    hl,(oldcode)
  768. noKwKw:    ex    de,hl
  769. staklp: ld    hl,suffix_of
  770.     add    hl,de
  771.     ld    a,(hl)
  772.     call    savstk
  773.     ld    hl,100h
  774.     or    a
  775.     sbc    hl,de
  776.     jr    nc,unstak
  777.     ld    hl,prefix_of
  778.     add    hl,de
  779.     add    hl,de
  780.     ld    e,(hl)
  781.     inc    hl
  782.     ld    d,(hl)
  783.     jr    staklp
  784. ;
  785. unstak:    ld    (finchar),a
  786.     ld    de,(stackp)
  787. unslp:    ld    hl,stack
  788.     or    a
  789.     sbc    hl,de
  790.     jr    z,newent
  791.     ld    a,(de)
  792.     inc    de
  793.     push    de
  794.     call    outbyte
  795.     pop    de
  796.     jr    unslp
  797. ;
  798. newent:    ld    hl,(free_ent)
  799.     ld    (code),hl
  800.     ex    de,hl
  801.     ld    hl,1fffh
  802.     or    a
  803.     sbc    hl,de
  804.     jr    c,full
  805.     ld    hl,prefix_of
  806.     add    hl,de
  807.     add    hl,de
  808.     ld    bc,(oldcode)
  809.     ld    (hl),c
  810.     inc    hl
  811.     ld    (hl),b
  812.     ld    hl,suffix_of
  813.     add    hl,de
  814.     ld    a,(finchar)
  815.     ld    (hl),a
  816. getfre:    inc    de
  817.     ld    hl,1fffh
  818.     or    a
  819.     sbc    hl,de
  820.     jr    c,full1
  821.     ld    hl,prefix_of
  822.     add    hl,de
  823.     add    hl,de
  824.     ld    a,(hl)
  825.     inc    hl
  826.     and    (hl)
  827.     inc    a
  828.     jr    nz,getfre
  829. full1:    ld    (free_ent),de
  830. full:    ld    hl,(incode)
  831.     ld    (oldcode),hl
  832.     jp    unshlp
  833. ;
  834. partial_clear:
  835.     ld    de,first_ent
  836. l8:    ld    hl,(free_ent)
  837.     or    a
  838.     sbc    hl,de
  839.     jr    z,br8
  840.     ld    hl,prefix_of + 1
  841.     add    hl,de
  842.     add    hl,de
  843.     set    7,(hl)
  844.     inc    de
  845.     jr    l8
  846. ;
  847. br8:    ld    de,first_ent
  848. l9:    ld    hl,(free_ent)
  849.     or    a
  850.     sbc    hl,de
  851.     jr    z,br9
  852.     ld    hl,prefix_of
  853.     add    hl,de
  854.     add    hl,de
  855.     push    de
  856.     ld    e,(hl)
  857.     inc    hl
  858.     ld    d,(hl)
  859.     res    7,d
  860.     ld    hl,first_ent - 1
  861.     or    a
  862.     sbc    hl,de
  863.     jr    nc,ei10
  864.     ld    hl,prefix_of + 1
  865.     add    hl,de
  866.     add    hl,de
  867.     res    7,(hl)
  868. ei10:    pop    de
  869.     inc    de
  870.     jr    l9
  871. ;
  872. br9:    ld    de,first_ent
  873. l10:    ld    hl,(free_ent)
  874.     or    a
  875.     sbc    hl,de
  876.     jr    z,br10
  877.     ld    hl,prefix_of + 1
  878.     add    hl,de
  879.     add    hl,de
  880.     bit    7,(hl)
  881.     jr    z,ei11
  882.     ld    (hl),-1
  883.     dec    hl
  884.     ld    (hl),-1
  885. ei11:    inc    de
  886.     jr    l10
  887. ;
  888. br10:    ld    de,first_ent
  889. l11:    ld    hl,maxcmax
  890.     or    a
  891.     sbc    hl,de
  892.     jr    z,br11
  893.     ld    hl,prefix_of
  894.     add    hl,de
  895.     add    hl,de
  896.     ld    a,(hl)
  897.     inc    hl
  898.     and    (hl)
  899.     inc    a
  900.     jr    z,br11
  901.     inc    de
  902.     jr    l11
  903. br11:    ld    (free_ent),de
  904.     ret
  905. ;
  906. loadfollowers:
  907.     ld    hl,Slen + 255
  908.     ld    b,0
  909. lflp:    push    bc
  910.     push    hl
  911.     ld    a,6
  912.     call    readbits
  913.     pop    hl
  914.     pop    de
  915.     ld    (hl),a
  916.     push    de
  917.     push    hl
  918.     dec    d
  919.     ld    hl,followers
  920.     call    shftadd
  921.     ld    b,a
  922.     or    a
  923.     jr    z,nofoll
  924. ldfllp:    push    hl
  925.     push    bc
  926.     ld    a,8
  927.     call    readbits
  928.     pop    bc
  929.     pop    hl
  930.     ld    (hl),a
  931.     inc    hl
  932.     djnz    ldfllp
  933. nofoll:    pop    hl
  934.     pop    bc
  935.     dec    hl
  936.     djnz    lflp
  937.     ret
  938. ;
  939. unreduce:
  940.     ld    e,a
  941.     ld    d,0
  942.     ld    hl,_L_table
  943.     add    hl,de
  944.     ld    a,(hl)
  945.     ld    (L_table),a
  946.     ld    hl,_D_shift
  947.     add    hl,de
  948.     ld    a,(hl)
  949.     ld    (D_shift),a
  950.     xor    a
  951.     ld    (ExState),a
  952.     ld    (lchar),a
  953.     call    loadfollowers
  954. ur1:    ld    a,(zipeof)
  955.     and    1
  956.     ret    nz
  957.     call    slenlch
  958.     or    a
  959.     jr    nz,ur2
  960. ur4:    ld    a,8
  961.     call    readbits
  962.     jr    ur3
  963. ;
  964. ur2:    ld    a,1
  965.     call    readbits
  966.     dec    l
  967.     jr    z,ur4
  968.     call    slenlch
  969.     dec    a
  970.     or    1
  971.     ld    l,a
  972.     xor    a
  973. btlp:    inc    a
  974.     srl    l
  975.     jr    nz,btlp
  976.     call    readbits
  977.     ld    de,followers
  978.     add    hl,de
  979.     ld    de,(lchar - 1)
  980.     call    shftadd
  981.     ld    a,(hl)
  982. ur3:    ld    (nchar),a
  983.     ld    l,a
  984.     ld    a,(ExState)
  985.     or    a
  986.     jr    nz,ur5
  987.     ld    a,l
  988.     cp    DLE
  989.     jr    nz,ur9
  990.     ld    a,1
  991.     ld    (ExState),a
  992.     jr    ur6
  993. ;
  994. ur5:    dec    a
  995.     jr    nz,ur7
  996.     ld    a,l
  997.     or    a
  998.     jr    z,ur10
  999.     ld    (V),a
  1000.     ld    a,(L_table)
  1001.     ld    h,a
  1002.     and    l
  1003.     cp    h
  1004.     ld    l,a
  1005.     ld    h,0
  1006.     ld    (Len),hl
  1007.     jr    nz,ur12
  1008.     ld    a,2
  1009.     jr    ur11
  1010. ;
  1011. ur10:    ld    (ExState),a
  1012.     ld    a,DLE
  1013. ur9:    call    outb
  1014.     jr    ur6
  1015. ;
  1016. ur7:    dec    a
  1017.     jr    nz,ur8
  1018.     ld    a,l
  1019.     ld    hl,Len
  1020.     add    a,(hl)
  1021.     ld    (hl),a
  1022.     jr    nc,ur12
  1023.     inc    hl
  1024.     inc    (hl)
  1025. ur12:    ld    a,3
  1026.     jr    ur11
  1027. ;
  1028. ur8:    dec    a
  1029.     jr    nz,ur13
  1030.     ld    a,(D_shift)
  1031.     ld    b,a
  1032.     ld    a,(V)
  1033. ur14:    srl    a
  1034.     djnz    ur14
  1035.     ld    h,a
  1036.     inc    hl
  1037.     ld    bc,(Len)
  1038.     inc    bc
  1039.     inc    bc
  1040.     inc    bc
  1041.     call    callback
  1042. ur13:    xor    a
  1043. ur11:    ld    (ExState),a
  1044. ur6:    ld    a,(nchar)
  1045.     ld    (lchar),a
  1046.     jp    ur1
  1047. ;
  1048. slenlch:
  1049.     ld    hl,(lchar)
  1050.     ld    h,0
  1051.     ld    de,Slen
  1052.     add    hl,de
  1053.     ld    a,(hl)
  1054.     ret
  1055. ;
  1056. shftadd:
  1057.     ld    e,0
  1058.     ld    b,3
  1059. shftloop:
  1060.     srl    d
  1061.     rr    e
  1062.     djnz    shftloop
  1063.     add    hl,de
  1064.     ret
  1065. ;
  1066. callback:
  1067.     push    bc
  1068.     push    hl
  1069.     ld    hl,(outpos)
  1070.     ld    de,(outpos + 2)
  1071.     pop    bc
  1072.     or    a
  1073.     sbc    hl,bc
  1074.     jr    nc,cb2
  1075.     dec    de
  1076. cb2:    pop    bc
  1077. cb3:    bit    7,d
  1078.     jr    z,cb4
  1079.     ld    a,b
  1080.     or    c
  1081.     jr    z,cb4
  1082.     xor    a
  1083.     call    outbp
  1084.     inc    hl
  1085.     ld    a,h
  1086.     or    l
  1087.     jr    nz,cb5
  1088.     inc    de
  1089. cb5:    dec    bc
  1090.     jr    cb3
  1091. ;
  1092. cb4:    ex    de,hl
  1093. cb6:    ld    a,b
  1094.     or    c
  1095.     ret    z
  1096.     ld    a,d
  1097.     and    1fh
  1098.     ld    d,a
  1099.     ld    hl,outbuf
  1100.     add    hl,de
  1101.     ld    a,(hl)
  1102.     call    outbp
  1103.     inc    de
  1104.     dec    bc
  1105.     jr    cb6
  1106. ;
  1107. outbp:    push    hl
  1108.     push    de
  1109.     push    bc
  1110.     call    outb
  1111.     pop    bc
  1112.     pop    de
  1113.     pop    hl
  1114.     ret
  1115. ;
  1116. readlengths:
  1117.     ld    a,8
  1118.     call    readbits
  1119.     ld    d,h
  1120.     ld    e,d
  1121.     inc    hl
  1122.     ld    b,h
  1123.     ld    c,l
  1124.     ld    (ix + _maxlength),e
  1125.     ld    (ix + _maxlength + 1),d
  1126.     push    ix
  1127.     pop    hl
  1128.     inc    hl
  1129.     inc    hl
  1130.     inc    hl
  1131. rl1:    ld    a,b
  1132.     or    c
  1133.     ret    z
  1134.     push    bc
  1135.     push    de
  1136.     push    hl
  1137.     ld    a,4
  1138.     call    readbits
  1139.     inc    a
  1140.     push    af
  1141.     ld    a,4
  1142.     call    readbits
  1143.     inc    a
  1144.     ld    b,a
  1145.     pop    af
  1146.     ld    c,a
  1147.     pop    hl
  1148.     pop    de
  1149.     ld    a,(ix + _maxlength)
  1150.     cp    c
  1151.     jr    nc,rl2
  1152.     ld    (ix + _maxlength),c
  1153. rl2:    inc    hl
  1154.     inc    hl
  1155.     inc    hl
  1156.     ld    (hl),e
  1157.     inc    hl
  1158.     ld    (hl),c
  1159.     inc    e
  1160.     djnz    rl2
  1161.     pop    bc
  1162.     dec    bc
  1163.     jr    rl1
  1164. ;
  1165. sortlengths:
  1166.     ld    h,(ix + _entries + 1)
  1167.     ld    l,(ix + _entries)
  1168.     ld    b,h
  1169.     ld    c,l
  1170.     ld    (entrs),hl
  1171. sl7:    srl    b
  1172.     rr    c
  1173. sl1:    ld    a,b
  1174.     or    c
  1175.     ret    z
  1176.     ld    (noswps),a
  1177.     push    ix
  1178.     ld    de,4
  1179.     add    ix,de
  1180.     push    ix
  1181.     pop    iy
  1182.     add    iy,bc
  1183.     add    iy,bc
  1184.     add    iy,bc
  1185.     add    iy,bc
  1186.     ld    hl,(entrs)
  1187.     or    a
  1188.     sbc    hl,bc
  1189. sl2:    ld    a,(ix + _bitlength)
  1190.     cp    (iy + _bitlength)
  1191.     jr    c,sl4
  1192.     jr    nz,sl3
  1193.     ld    a,(iy + _value)
  1194.     cp    (ix + _value)
  1195.     jr    nc,sl4
  1196. sl3:    ld    d,e
  1197. sl5:    ld    a,(ix)
  1198.     push    af
  1199.     ld    a,(iy)
  1200.     ld    (ix),a
  1201.     pop    af
  1202.     ld    (iy),a
  1203.     inc    ix
  1204.     inc    iy
  1205.     dec    d
  1206.     jr    nz,sl5
  1207.     ld    a,d
  1208.     ld    (noswps),a
  1209.     jr    sl6
  1210. ;
  1211. sl4:    add    ix,de
  1212.     add    iy,de
  1213. sl6:    dec    hl
  1214.     ld    a,h
  1215.     or    l
  1216.     jr    nz,sl2
  1217.     pop    ix
  1218.     ld    a,(noswps)
  1219.     or    a
  1220.     jr    nz,sl7
  1221.     jr    sl1
  1222. ;
  1223. generatetrees:
  1224.     ld    l,(ix + _entries)
  1225.     ld    h,(ix + _entries + 1)
  1226.     ld    c,l
  1227.     ld    b,h
  1228.     push    ix
  1229.     pop    de
  1230.     add    hl,hl
  1231.     add    hl,hl
  1232.     add    hl,de
  1233.     push    hl
  1234.     pop    iy
  1235.     xor    a
  1236.     ld    d,a
  1237.     ld    e,a
  1238.     ld    h,a
  1239.     ld    l,a
  1240.     ld    (lbl),a
  1241. gt1:    ld    a,b
  1242.     or    c
  1243.     ret    z
  1244.     dec    bc
  1245.     add    hl,de
  1246.     ld    a,(lbl)
  1247.     cp    (iy + _bitlength)
  1248.     jr    z,gt2
  1249.     ld    a,(iy + _bitlength)
  1250.     ld    (lbl),a
  1251.     sub    16
  1252.     ex    de,hl
  1253.     ld    hl,1
  1254.     jr    z,gt3
  1255. gt4:    add    hl,hl
  1256.     inc    a
  1257.     jr    nz,gt4
  1258. gt3:    ex    de,hl
  1259. gt2:    ld    (iy + _code),l
  1260.     ld    (iy + _code + 1),h
  1261.     push    de
  1262.     ld    de,-4
  1263.     add    iy,de
  1264.     pop    de
  1265.     jr    gt1
  1266. ;
  1267. ldtrees:
  1268.     ld    a,(gpbf)
  1269.     rra
  1270.     ld    l,a
  1271.     and    1
  1272.     add    a,6
  1273.     ld    (dictb),a
  1274.     ld    a,l
  1275.     rra
  1276.     and    1
  1277.     ld    (ltp),a
  1278.     set    1,a
  1279.     ld    (mml),a
  1280.     ld    ix,lit_tree
  1281.     ld    hl,256
  1282.     call    nz,ld_tree
  1283.     ld    hl,64
  1284.     ld    ix,len_tree
  1285.     call    ld_tree
  1286.     ld    hl,64
  1287.     ld    ix,dist_tre
  1288. ld_tree:
  1289.     ld    (ix + _entries),l
  1290.     ld    (ix + _entries + 1),h
  1291.     call    readlengths
  1292.     call    sortlengths
  1293.     call    generatetrees
  1294. reversebits:
  1295.     push    ix
  1296.     pop    hl
  1297.     ld    e,(hl)
  1298.     inc    hl
  1299.     ld    d,(hl)
  1300. rb1:    inc    hl
  1301.     inc    hl
  1302.     inc    hl
  1303.     ld    c,(hl)
  1304.     ld    b,8
  1305. rb2:    srl    c
  1306.     adc    a,a
  1307.     djnz    rb2
  1308.     push    af
  1309.     inc    hl
  1310.     ld    c,(hl)
  1311.     ld    b,8
  1312. rb3:    srl    c
  1313.     adc    a,a
  1314.     djnz    rb3
  1315.     dec    hl
  1316.     ld    (hl),a
  1317.     pop    af
  1318.     inc    hl
  1319.     ld    (hl),a
  1320.     dec    de
  1321.     ld    a,d
  1322.     or    e
  1323.     jr    nz,rb1
  1324.     ret
  1325. ;
  1326. readtree:
  1327.     push    ix
  1328.     pop    iy
  1329.     ld    de,4
  1330.     add    iy,de
  1331.     ld    b,d
  1332.     ld    e,d
  1333.     ld    h,d
  1334.     ld    l,d
  1335. rt1:    push    hl
  1336.     push    de
  1337.     push    bc
  1338.     ld    a,1
  1339.     call    readbits
  1340.     pop    af
  1341.     push    af
  1342.     or    a
  1343.     jr    z,rt2
  1344. rt3:    add    hl,hl
  1345.     dec    a
  1346.     jr    nz,rt3
  1347. rt2:    pop    bc
  1348.     pop    de
  1349.     add    hl,de
  1350.     ex    de,hl
  1351.     inc    b
  1352.     pop    hl
  1353. rt4:    ld    a,(iy + _bitlength)
  1354.     cp    b
  1355.     jr    nc,rt5
  1356.     push    de
  1357.     ld    de,4
  1358.     add    iy,de
  1359.     pop    de
  1360.     inc    hl
  1361.     ld    a,(ix + _entries)
  1362.     sub    l
  1363.     jr    nz,rt4
  1364.     ld    a,(ix + _entries + 1)
  1365.     sub    h
  1366.     jr    nz,rt4
  1367. rt6:    dec    a
  1368.     ret
  1369. ;
  1370. rt5:    ld    a,(iy + _bitlength)
  1371.     cp    b
  1372.     jr    nz,rt1
  1373.     ld    a,(iy + _code)
  1374.     cp    e
  1375.     jr    nz,rt7
  1376.     ld    a,(iy + _code + 1)
  1377.     cp    d
  1378.     jr    nz,rt7
  1379.     ld    a,(iy + _value)
  1380.     ret
  1381. ;
  1382. rt7:    push    de
  1383.     ld    de,4
  1384.     add    iy,de
  1385.     pop    de
  1386.     inc    hl
  1387.     ld    a,(ix + _entries)
  1388.     sub    l
  1389.     jr    nz,rt5
  1390.     ld    a,(ix + _entries + 1)
  1391.     sub    h
  1392.     jr    nz,rt5
  1393.     jr    rt6
  1394. ;
  1395. unimplode:
  1396.     call    ldtrees
  1397. ui1:    ld    a,(zipeof)
  1398.     and    1
  1399.     ret    nz
  1400.     inc    a
  1401.     call    readbits
  1402.     or    a
  1403.     jr    z,ui2
  1404.     ld    a,(ltp)
  1405.     or    a
  1406.     jr    z,ui3
  1407.     ld    ix,lit_tree
  1408.     call    readtree
  1409.     jr    ui4
  1410. ;
  1411. ui3:    ld    a,8
  1412.     call    readbits
  1413. ui4:    call    outb
  1414.     jr    ui1
  1415. ;
  1416. ui2:    ld    a,(dictb)
  1417.     call    readbits
  1418.     push    hl
  1419.     ld    ix,dist_tre
  1420.     call    readtree
  1421.     ld    bc,(dictb - 1)
  1422. ui5:    add    hl,hl
  1423.     djnz    ui5
  1424.     pop    bc
  1425.     add    hl,bc
  1426.     push    hl
  1427.     ld    ix,len_tree
  1428.     call    readtree
  1429.     ld    l,a
  1430.     ld    h,0
  1431.     cp    63
  1432.     jr    nz,ui6
  1433.     push    hl
  1434.     ld    a,8
  1435.     call    readbits
  1436.     pop    de
  1437.     add    hl,de
  1438. ui6:    ld    de,(mml)
  1439.     ld    d,0
  1440.     add    hl,de
  1441.     ld    b,h
  1442.     ld    c,l
  1443.     pop    hl
  1444.     inc    hl
  1445.     call    callback
  1446.     jr    ui1
  1447. ;
  1448. ; ckcon -- checks console for character; aborts if ^C
  1449. ;
  1450. ckcon:    ld    hl,conckct
  1451.     dec    (hl)        ; decrement console check counter
  1452.     ld    a,(hl)
  1453.     and    7fh
  1454.     ret    nz        ; only check every 128 calls
  1455.     ld    e,0FFh        ; check for character
  1456.     ld    c,dircon
  1457.     call    bdos
  1458.     or    a
  1459.     ret    z
  1460.     cp    CtrlC        ; ^C ?
  1461.     ret    nz        ; (no, continue)
  1462.     ld    a,(opnflg)    ; is a file open?
  1463.     or    a
  1464.     jr    z,ckcon1    ; (no)
  1465. ckcon0:    call    setout
  1466.     ld    de,opfcb
  1467.     call    f$close        ; close it
  1468.     call    f$delete    ; and delete it
  1469.     call    ilprt
  1470.     db    'Partial file erased --',0
  1471. ckcon1:    call    ilprt
  1472.     db    ' Aborted',0
  1473.     jp    clsxit
  1474. ;
  1475. ; getusr -- stuffs current user into default FCBs if not ZCPR3 (for Z3LOG)
  1476. ;
  1477. getusr:    ld    hl,(Z3EAdr)    ; ZCPR3?
  1478.     ld    a,h
  1479.     or    l
  1480.     ret    nz        ; (yes, skip this)
  1481.     ld    c,setusr
  1482.     ld    e,0ffh
  1483.     call    bdos
  1484.     ld    (dfcb+13),a
  1485.     ld    (altfcb+13),a
  1486.     ret
  1487. ;
  1488. ; setout -- set output drive/user
  1489. ;
  1490. setout:    ld    de,altfcb
  1491.     jp    z3log
  1492. ;
  1493. ; usage -- show syntax for ZCPR3 ("dir:") or vanilla CP/M ("d:")
  1494. ;
  1495. usage:    call    ilprt
  1496.     db    'Usage:',CR,LF
  1497.     db    '   UNZIP {d',0
  1498.     ld    hl,(Z3EAdr)
  1499.     ld    a,h
  1500.     or    l
  1501.     push    af
  1502.     jr    z,usage2
  1503.     call    ilprt
  1504.     db    'ir',0
  1505. usage2:    call    ilprt
  1506.     db    ':}zipfile {d',0
  1507.     pop    af
  1508.     jr    z,usage3
  1509.     call    ilprt
  1510.     db    'ir',0
  1511. usage3:    call    ilprt
  1512.     db    ':}{afn.typ}',CR,LF
  1513.     db    'If a destination is given, files are extracted.',CR,LF
  1514.     db    'If not, filenames are listed.',0
  1515.     jp    exit
  1516. ;
  1517. ; data storage . . .
  1518. ;
  1519. init:
  1520.     db    0
  1521.     db    1
  1522.     dw    0,0
  1523.     dw    -1,-1
  1524. endinit:
  1525. _L_table:
  1526.     db    7fh, 3fh, 1fh, 0fh
  1527. _D_shift:
  1528.     db    07h, 06h, 05h, 04h
  1529. $memry:    dw    0
  1530. ;
  1531. ; uninitialized storage
  1532. ;
  1533.     dseg
  1534.  
  1535. mode:    ds    1
  1536. zipeof:    ds    1
  1537. counting:
  1538.     ds    1
  1539. junk:    ds    STRSIZ
  1540. lfh:
  1541. vnte:    ds    2
  1542. gpbf:    ds    2
  1543. cm:    ds    2
  1544. lmft:    ds    2
  1545. lmfd:    ds    2
  1546. crc:    ds    4
  1547. cs:    ds    4
  1548. ucs:    ds    4
  1549. fnl:    ds    2
  1550. efl:    ds    2
  1551. endlfh:    ds    1
  1552. icb:    ds    8
  1553. ipbuf:    ds    2
  1554. infcb:    ds    36
  1555. ocb:    ds    8
  1556. opbuf:    ds    2
  1557. opfcb:    ds    1        ; output file control block
  1558. opfn:    ds    8
  1559. opext:    ds    3
  1560.     ds    24
  1561. bitbuf:    ds    1
  1562. mtchfcb:
  1563.     ds    11
  1564.     ds    1
  1565. vars:
  1566. bleft:    ds    1
  1567. nodest:    ds    1
  1568. outpos:    ds    4
  1569. crc32:    ds    4
  1570. curmode:
  1571.     ds    1
  1572. opnflg:    ds    1
  1573. conckct:
  1574.     ds    1
  1575. L_table:
  1576.     ds    1
  1577. D_shift:
  1578.     ds    1
  1579. V:    ds    1
  1580. nchar:    ds    1
  1581. lchar:    ds    1
  1582. ExState:
  1583.     ds    1
  1584. Len:    ds    2
  1585. ltp:    ds    1
  1586. mml:    ds    1
  1587. dictb:    ds    1
  1588. noswps:    ds    1
  1589. entrs:    ds    2
  1590. lbl:    ds    1
  1591. oldcode:
  1592.     ds    2
  1593. offset:    ds    2
  1594. codesize:
  1595.     ds    1
  1596. maxcode:
  1597.     ds    2
  1598. free_ent:
  1599.     ds    2
  1600. finchar:
  1601.     ds    1
  1602. stackp:    ds    2
  1603. incode:    ds    2
  1604. code:    ds    2
  1605. outbuf:
  1606. suffix_of:
  1607.     ds    8192
  1608. prefix_of:
  1609. Slen:
  1610. lit_tree:
  1611.     ds    _sf_tree_
  1612. len_tree:
  1613.     ds    _sf_tree_
  1614. dist_tre:
  1615.     ds    _sf_tree_
  1616.     ds    16384 + 2 - (3 * _sf_tree_)
  1617. followers:
  1618.     ds    8192
  1619. stack    equ    $
  1620.     ds    60
  1621. locstk    equ    $
  1622.  
  1623.     end
  1624.