BZ Compressor V1.2, SX/GX ^^^^^^^^^^^^^^^^^^^^^^^^^ --> S/SX/G/GX [Note: This is now the standard HP48 object packer/unpacker. It's *very* efficient. It obsoletes everything else, except maybe UPK which is a tad faster at unpacking. BZ is included in the HACK library, but if you don't want to load that whole library, here is BZ by itself. -jkh-] (C) Mika Heiskanen, mheiskan@delta.hut.fi Stack: ( ob --> $bz | $bz --> ob ) Keys: ON-key aborts compression. Memory: Fast compression requires using buffering to find matches fast. Two different BZ versions are provided for the user to select from based on the configuration of his calculator. For more details see the 'Programs' section below. Decompression requires no extra memory. Algorithm: LZ77 class compressor with bit-level codes for matches and literal lenght fields. Literals themselves are stored as is at the end of output for decompression speed. Matches are found by separate chaining in a ring buffer. More details in the source code. Note that several of the variables are assembly time only, eg you may not be able to decompress with another BZ program if you change the values. Programs ^^^^^^^^ BZ4 uses a hash buffer of size #400 and thus requires 11264 bytes (11K) of memory for the internal buffers. Intended for HP48 GX and other versions when 128K RAM is available. This is the version of BZ that's in the HACK library. BZ1 uses a hash buffer of size #100 and thus requires 7424 bytes (7.25K) of memory for the internal buffers. Intended for HP48 S/SX/GX when in 32K RAM configuration. When you load the one you want, rename it to 'BZ'. For the effects of hash buffer size on speed see bz.s. If you desire to use another buffer size then just modify HSHSIZE to one of the listed values, change the BZ version message accordingly and compile the source. HSHSIZE only effects compression speed, not the efficiency. UBZ is the extracted uncompressor code which can be freely used in non-commercial programs. [Note: You won't need to load UBZ into your HP48, since BZ packs *and* unpacks objects automatically. Only load UBZ to include it in home-made libraries, etc. -jkh-] Compression Efficiency Comparison Tables ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ All measurements were done on a GX with ~75K of free memory. Most of the compressors can be found from seq.uncwil.edu:/hp48/Uploads.Dec/compress/ GZ and PK compressors are replaced by the new BZ compressor. Input: GZ.S 13444 bytes ( SRPL/ML source code ) Size %CH CTime UTime BZ 6205 -53.85 18.00 1.45 GZ 1.2 6637.5 -50.63 13.48 0.45 PK 15 6741 -49.86 46.62 0.92 (w/ upk) PK 0 6771 -49.64 25.27 0.92 (w/ upk) LZ8B 8079 -39.91 39.11 1.40 (lzss library w/ unpk) LZ10 8115 -39.64 213.75 2.64 (lzss library w/ unpk) CMPR 8795.5 -34.58 98.27 1.89 (compress.lib w/ dcmpr) RFPG 8796 -34.57 82.72 1.92 (w/ rfug) Next input produced by: << ERASE 'PPAR' PURGE 'SIN(X)' STEQ DRAW DRAX PICT RCL >> Input: grob 1098 bytes Size %CH CTime UTime BZ 241.5 -78.01 5.49 0.08 GZ 1.2 265.5 -75.82 4.56 0.03 PK 15 268 -75.69 5.40 0.08 (w/ upk) CMPR 285 -74.04 5.23 0.14 (compress.lib w/ dcmpr) RFPG 286 -73.95 2.34 0.17 (w/ rfug) PK 0 293.5 -73.27 1.94 0.08 (w/ upk) LZ8B 299 -72.77 5.88 0.08 (lzss library w/ unpk) LZ10 356.5 -67.53 5.98 0.21 (lzss library w/ unpk) PGROB 383 -65.12 0.19 fail (w/ upgrob) Input: BZ 1506 bytes (BZ compressor binary) Size %CH CTime UTime BZ 1352 -10.23 2.22 0.14 LZ10 1352.5 -10.19 49.05 0.29 (lzss library w/ unpk) PK 15 1378 -8.50 3.64 0.04 (w/ upk) PK 0 1378 -8.50 3.61 0.04 (w/ upk) GZ 1.2 1380.5 -8.33 1.68 0.05 CMPR 1384.5 -8.07 19.05 0.17 (compress.lib w/ dcmpr) RFPG 1385 -8.03 14.47 0.21 (w/ rfug) LZ8B - 0 7.44 - (lzss library w/ unpk) Input: Lem.lib 11412.5 bytes ("Library 1213: Lemmings .. V1.2") Size %CH CTime UTime BZ 10153.5 -11.03 22.70 0.82 PK 15 10219.5 -10.45 113.69 0.31 (w/ upk) PK 0 10226 -10.40 30.34 0.31 (w/ upk) GZ 1.2 10281.5 -9.91 12.60 0.28 LZ10 10361.5 -9.21 401.98 2.06 (lzss library w/ unpk) CMPR 10394.5 -8.92 137.23 0.96 (compress.lib w/ dcmpr) RFPG 10395 -8.92 118.00 1.26 (w/ rfug) LZ8B 11103 -2.71 55.68 0.80 (lzss library w/ unpk)