This is a Z80 version of the routine that decompresses streams compressed with Fabrice Bellard's LZEXE program.
It is meant to be generic, not specific to executables. It was written with the idea to use LZEXE as a general purpose compressor (its ratios are fairly decent) for use in Z80 programs.
A sample file with some automatically generated Lorem Ipsum text is included. It is 3010 bytes long and gets compressed by almost 50%, to 1520 bytes.
Note that the compressor may add up to 15 extra padding zero bytes, to make the length a multiple of 16. It's not possible to determine the amount of padding that was inserted without running the decompression algorithm. There's no known easy way to remove it at the moment. The included example stores the actual unpadded length of the compressed stream in address 0A002h.
Requirements to compress:
- LZEXE 0.91, https://bellard.org/lzexe/lzexe91.zip (version 0.91e will probably work as well, but has not been tested).
- DOSBOX, https://www.dosbox.com/ (Alternatively, some means of running x86 MSDOS executables; e.g. DOSEMU might work as well but has not been tested).
To build the sample project you also need:
- GNU Make, https://www.gnu.org/software/make/
- Python 2 or 3
- The Pasmo assembler
Included in this package are two Python programs to convert a raw binary to a format suitable for MSX emulators: one to convert to .BIN (for floppy) and the other to convert to .CAS (for tape). Also a Tcl program that can be used with OpenMSX to save the output of the example program to the file "msx.out", in order to verify that the decompressed output matches the original file.