BZMAN

Small library for managing compression on the HP49(+)

This library has one page of commands  Most of it belongs also to OT49(+) but for beginners and those interested in compression only, BZMAN is the right choice It is probably not needed by.more advanced users who know OT49(+) well. You can make self-decompressing programs, graphics or text files and you have them self-evaluating, in addition. Particularly small self-decompressing and self-evaluating objects are realized as code objects. There are two variants: BZMAN is for the 49 and BZMANPlus (internally BZMAN+) is for the 49+.  Store the selected library in a port and attach it with ON_hold_C as usual. The reason for maintaining two versions is that ROM 19-6 for the 49 is not completely compatible with ROM 1.23 for the 49+. For instance, in the original BZ compressor the screen was turned off during compression. This doesn't make sense anymore on the 49+. Attention: The library number has changed from 262 to now 309 in passing from version 3.2002 to 4.2004. This is the only difference between these versions of BZMAN. If somebody used it before 4.2004 and has still BZ-compressed directories in HOME he should decompress these before attaching version 4.2004. Version change does not affect self-decompressing objects made with UBZe, BZC or BZCE. The new (unprotected) decompression rompointer is now the stable XLIB 309 6.


What is new?

Version 4.2004: BZMAN+ for the 49g+ added. Both libraries have library number 309.

Version 3.2002: Some commands faster.

Version 7.2001: Command menu expanded, Text rewritten.


The 6 commands of BZman operate in RPN mode as follows:

bz toggle compression and decompression of any level 1 object. After compressing a special menu for further processing the BZ-string is set, explained below. We recommend to assign bz to a key. This can professionally be made with Keyman.
bzDIR compress a whole directory including its subdirectories. A single file is left in the directory, with the directories' name. Its execution immediately restores the original. Thus, pay attention to a directory with a single and equally named file in it. This probably means the directory is compressed.
?BZ BZ-string filter. Errors except for a BZ-string input (checks for nullcharacters in the string). Other input objects simply pass the filter.
UBZi Append the unnamed BZMAN-decompressor XLIB 309 6 to a BZ-string for decompression. For internal use only, i.e., if BZman is permanently installed.
UBZe Append a small BZ-decompessor to a BZ-string, known to every HP49 independent on the presence of BZMAN. For external use, e.g., for sending a compressed program to hpcalc.org.
ApEVL Append the EVAL-command to a program. E.g., if applied to  « "BZ..." bz  »  one gets  « "BZ..." bz EVAL  ». That means evaluate the decompressed object. Avoid  application of  ApEVL twice. This may later generate an error.

The most important command is bz. The special menu set after compression for further processing the BZstring is shown in the screen-shot.Library BZMAN compressed. The small %CH indicates that it is efficiently programmed Its first 3 belong also to BZMAN's command menu. BZC generates a code object from a BZ-string "BZ..." which decompresses very fast. Moreover, it is 35 bytes smaller than the equivalent program generated from a BZ-string with UBZe and is slightly faster. BZCE behaves like BZC but evals the decompressed object, in addition. The code is difficult to hack and kills two birds with one stone: it makes self-decompression fast and saves the source from being misused. EXIT returns to the previous menu, the one where bz was started. Note that compression pays only for relatively large objects, programs, strings or grobs (though one can produce strings of size 20 only whose compression already pays). The compression rate strongly depends on how "coloured" the object is. The less coloured the higher the compression rate, displayed in the screen as %CH - the first row in the header shows the absolute size saving. For programs or strings "highly coloured" means using many different commands or words and leaving little room for repetition of command or word sequences.

Remark. Code objects made with BZC are hacked with the BZ-toggler ~ from recent versions of OT49(+).

Credits. BZ is due to Mika Heiskanen. The basic idea realized in BZC and BZCE is due to Jurjen Bos.


Wolfgang Rautenberg

 raut@math.fu-berlin.de     www.math.fu-berlin.de/usr/raut