Changes

Jump to: navigation, search

Exomizer

5,736 bytes added, 20:09, 11 October 2011
Created page with "'''''Exomizer''''' is a file compression utility which is designed so that files can be compressed quickly and efficiently on a PC and decompressed on 8-bit machines, such as the..."
'''''Exomizer''''' is a file compression utility which is designed so that files can be compressed quickly and efficiently on a PC and decompressed on 8-bit machines, such as the Amstrad CPC, where memory and processing power are much more limited. Across the 8-bit programming scene, it is generally regarded as the most efficient compressor that is currently available.

== Tutorial ==

=== Installing Exomizer ===

Firstly, download ''Exomizer'' from the home page; the link is at the bottom of this article. Unzip the ZIP file to a folder of your choice (e.g. <tt>C:\exomizer</tt>). The Windows binaries are located in the <tt>win32\</tt> subfolder. For ease of use, copy the <tt>exomizer.exe</tt> file in this subfolder to the main folder (i.e. <tt>C:\exomizer</tt>).

This tutorial also assumes that ''[[ManageDsk]]'' (a Windows utility for manipulating DSK files) is installed on your PC.

=== Compression ===

For this example, the game code for Mirrorsoft's classic game ''[[Boulder Dash]]'' will be used as the file to decompress. Its start address is &200, its length is &7520 bytes (29,984 bytes in decimal), its execution address is &1F52, and the file name is <tt>BOULDER.BIN</tt>.

Start ''ManageDsk'', and select the DSK file that <tt>BOULDER.BIN</tt> is saved on. Export <tt>BOULDER.BIN</tt> to the ''Exomizer'' folder. You must ensure that you export it <em>without</em> an AMSDOS header.

Now open a command prompt and go to the ''Exomizer'' folder by typing:

<kbd>cd C:\exomizer</kbd>

Then type the following command to compress <tt>BOULDER.BIN</tt> and save the compressed file as <tt>BOULDERC.BIN</tt>:

<kbd>exomizer raw boulder.bin -o boulderc.bin</kbd>

This produces the following output:

<pre>Crunching infile "boulder.bin" to outfile "boulderc.bin".

Phase 1: Instrumenting file
-----------------------------
Length of indata: 29984 bytes.
[building.directed.acyclic.graph.building.directed.acyclic.graph.]
Instrumenting file, done.

Phase 2: Calculating encoding
-----------------------------
pass 1: optimizing ..
[finding.cheapest.path.finding.cheapest.path.finding.cheapest.pat]
size 88005.0 bits ~11001 bytes
pass 2: optimizing ..
[finding.cheapest.path.finding.cheapest.path.finding.cheapest.pat]
size 87512.0 bits ~10939 bytes
pass 3: optimizing ..
[finding.cheapest.path.finding.cheapest.path.finding.cheapest.pat]
size 87512.0 bits ~10939 bytes
Calculating encoding, done.

Phase 3: Generating output file
------------------------------
Encoding: 11222454573A2071,1012,1100233355666788,1232234457819AAD
Length of crunched data: 10968 bytes.
Literal sequences are not used and the safety offset is 2.</pre>

This information shows that ''Exomizer'' has managed to compress <tt>BOULDER.BIN</tt> from 29,984 bytes to just 10,968 bytes (&2AD8 in hexadecimal) - around 37% of its original size! The safety offset refers to the minimum number of bytes that must separate the final byte of the compressed file and the final byte of the decompressed data - more about this below.

=== Decompression ===

Now that the file has been compressed, use ''ManageDsk'' to import <tt>BOULDERC.BIN</tt> back to a DSK file. You must ensure that you import it as a <em>binary</em> file, and not an ASCII file, as ''ManageDsk'' will need to add an AMSDOS header. The program will ask for the start address and entry point of the file.

Remember the safety offset that was mentioned earlier? The game code starts at &200 and is &7520 bytes long, so the final byte is located at address &200 + &7520 - 1 = &771F. As the safety offset for <tt>BOULDERC.BIN</tt> is 2 bytes, this means that the final byte of this file can be located at any address from &771F + 2 = &7721 or above. This means that the lowest start address that the file can be loaded to is &7721 - &2AD8 + 1 = &4C4A (or 0x4C4A), so enter this value as the start address. The entry point should be left at 0x0000.

The Z80 assembler source code for decompressing files is located in the <tt>rawdecrs\z80</tt> subfolder, and the file name is <tt>deexo.asm</tt>. The decompression routine is 198 bytes long, and it also requires a buffer of 156 bytes. The buffer is labelled <code>exo_mapbasebits</code>, and it is located immediately after the decompression routine, but you can alter it (by adding the line <code>exo_mapbasebits equ &xxxx</code>) so that it is located anywhere in memory - as long as it doesn't overwrite the compressed file or the decompressed data! Assemble the decompression routine to a suitable address in memory using an assembler of your choice (e.g. ''Pasmo'' or ''WinAPE'''s built-in assembler); again, ensure that it doesn't overwrite the compressed file or the decompressed data. The code supplied with ''Exomizer'' may need to be edited to suit the syntax of your assembler.

Now you will need to add some code to load <tt>BOULDERC.BIN</tt> into memory and decompress it. Add the following code before the decompression routine:

<pre>load_file:
ld hl,filename ;HL = file name address
ld de,&c000
ld b,12 ;B = length of file name
call &bc77 ;Open the file header
;DE = start address to load file to

ex de,hl ;Now HL = start address
push hl ;Store it
call &bc83 ;Load the file
call &bc7a ;Close the file

decompress_file:
pop hl ;HL = start address of compressed file
ld de,&0200 ;DE = start address of decompressed data
call deexo ;Decompress the data

start_game:
jp &1f52 ;Start the game

filename:
db "BOULDERC.BIN" ;Name of file containing compressed data</pre>

Finally, run this code, and if you have done everything correctly, you should see the ''Boulder Dash'' title screen!

== Links ==

* [http://hem.bredband.net/magli143/exo/ ''Exomizer'' home page]
883
edits