|
Description |
sf_crunch and sf_decrunch are compression and decompression utilities for the
graphics data in Star Fox and Star Fox 2. This format was used for most of the
background and sprite graphics, as well as the tilemaps (also known as
"name tables"). It does not apply to any of the 3D graphics in the game.
Star Fox and Star Fox 2 both use the same format, which is a variant of LZW
compression.
I was motivated to make this utility after the source code became available via
the recent Nintendo source code leak. This utility obviously doesn't contain
any of the leaked code, but I did use the decompression source code to help
reverse engineer the format. The decompression subroutine in the ROM runs on
the Super FX chip, and its source code is in a file called MDECRU.MC which was
apparently written by Krister Wombell. I liked the name "decrunch" that Krister
used, so I used it for this utility.
The compressed graphics data was also included in the leak. The files have
extension .CCR (compressed graphics) and .PCR (compressed tilemap/name table
data). The filenames from the source code are listed in readme.txt along with their
location in the U.S. version of the Star Fox ROM.
This compression format is unique in that control sequences are stored _after_
the data sequences that they correspond to, so the decompressor must parse the
data backwards, starting at the end of the compressed stream and progressing to
the beginning.
Because of this quirk, I added a command-line option for the decompressor to
specify the offset of the _end_ of a compressed data segment in a file. The
offsets of the compressed data segments in the U.S. version of the Star Fox ROM
are listed below. I didn't include an option to specify an offset for the
compressor because it would ostensibly be used to compress an entire file.
The only other utility that I'm aware of which supports this format is FuSoYa's
Lunar Compress library, but since it is closed source and only for Windows, I
wanted to make an open source utility that could be compiled on a computer
running any operating system.
With that in mind, this archive does not contain any executable files. It only
contains the C++ source files for the compressor (sf_crunch.cpp) and
decompressor (sf_decrunch.cpp). They are very simple programs, so they should
be easy to compile with any C++ compiler. You are also free to use and modify
this code if you would like to use it in your own work. I've tested both
programs pretty thoroughly, but please let me know if you find any problems. |
|