Sixpack - Image converter and packer
Mic, 2009
micol972@gmail.com

Website: http://jiggawatt.org/badc0de/sixpack/



Commandline options
	-autocomp		Automatically choose the best settings for the LZSS encoder.
	-base n			Specify the base color. For example if the image uses 4 colors and the base color is 2, the image colors will be mapped
				to palette entries 2..5.
	-bg x,y			The color referenced by the pixel at x,y will be treated as the background color.
				When this option isn't used x,y will be set to 0,0.
	-code			Generate an assembly code file containing the proper defines for decoding the pattern data (only valid when -pack and
				-image are used).
	-dict n			Set the LZSS dictionary size in bytes. Valid values are 1024, 2048 and 4096.
	-dither			Enable dithering.
	-format f		Set the output format for tile data. f can be p1 (1-bit planar), p2, p4 or l4 (4-bit linear), but which of those that are
				valid also depends on the target.
	-height n		Specify a new height for the image.
	-image			Treat the input file as an image file. If not specified the input file will be treated as a plain binary file.
	-o filename		Specify the output filename.
	-opt			Enable tile optimisation (redundant tiles will be excluded).
	-pack			Encode data before generating the output file.
	-planes n		Specify the desired number of bitplanes to use for storing each pixel. At least n planes will be used.
				A value of 0 means that the smallest possible number of bitplanes will be used. The default value is 4, which is
				also the maximum.
	-preview filename	Create a .BMP file with a preview of what the processed image will look like.
	-q n			Quantise the image to use n colors. The limits are 2 <= n <= 16.
	-sizefilter n		If n==1 smooth filtering will be used when resizing the image (when -width and/or -height is used).
				Otherwise nearest neighbor sampling will be used.
	-t			Enable transparency. When this option is used, all pixels using the background color (see -bg) will be mapped to color 0.
	-target name		Specify the output target. This determines the format of the output data.
				The targets currently supported are sms (SEGA Master System), sgg (SEGA Game Gear), smd (SEGA Megadrive) and snes (SNES).
	-threshold n		Set the threshold parameter for the LZSS codec. This can usually be left at the default value (2).
	-unpack			Decode the input file (not valid when -image is used).
	-v			Verbose mode.
	-width n		Specify a new width for the image.


Processing binary files

To LZSS encode a file:

sixpack.exe -pack filename.ext
sixpack.exe -pack -o filename.ext another_filename.ext

To LZSS decode a file:

sixpack.exe -unpack filename.ext
sixpack.exe -unpack -o filename.ext another_filename.ext


Processing images

Resize an image to 256*192, quantise it to 8 colors, remove redundant tiles and output pattern data for the SMS:

sixpack.exe -image -opt -width 256 -height 192 -q 8 -target sms image.ext

Remove redundant tiles from an image, use the smallest possible number of bitplanes, enable transparency,
use the color from the pixel at 2,5 as the background color and LZSS encode the resulting pattern data:

sixpack.exe -pack -image -opt -planes 0 -t -bg 2,5 -target sgg image.ext


 Building the examples

The SMS/SGG examples and LZSS decoder require WLA-DX to assemble and link.
You can find prebuilt binaries for Windows at http://www.villehelin.com/wla.html (or here, or here).

The SNES example requires WLA-DX to assemble and link.

The SMD example requires the GNU binutils for m68k to assemble and link.
You can find prebuilt binaries for Windows of m68k-elf-binutils here.


Sixpack uses code and algorithms from the following people:

CxImage by Davide Pizzolato
NeuQuant algorithm by Anthony Dekker
LZSS algorithm by James Storer and Thomas Szymanski