NinjaCheetah / libWiiPy

A modern Python library for handling files and formats used by the Wii.
https://ninjacheetah.github.io/libWiiPy/
MIT License
5 stars 1 forks source link

Feat: Add ASH file compression/decompression #18

Open NinjaCheetah opened 3 weeks ago

NinjaCheetah commented 3 weeks ago

A major feature required for libWiiPy to be able to surpass current offerings is the ability to both compress and decompress ASH files. Currently no library has support for this, there's just one Windows tool for extracting standard ASH files, one Python script for extracting only ASH files in My Pokemon Ranch, and then one Windows tool with no source that can compress standard ASH files.

Currently, there isn't any reference code out there for the compression routines, but thanks to the valiant effort of @Garhoogin, we now have modern, readable C code for decompression that can support both standard ASH files and the variant in My Pokemon Ranch, rather that needing two separate variations, which can be found here. It will need to be translated into Python, but then we'll have working decompression code, which is definitely a really great first step.

Work is currently being done to reverse engineer the compression routines.

NinjaCheetah commented 5 days ago

Decompression is now fully working! Standard ASH files can be decompressed with the default options, and My Pokémon Ranch files can be decompressed if the distance tree bits are set to 15.

For the compression side, it's worth noting that ASH files are based on deflate and use Huffman trees to store the data.