Battletoads text decompression (huffman)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
Posts: 7824
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada

Post by rainwarrior » Mon Feb 13, 2012 12:24 pm

Yeah, I had a few ideas about how to adapt it, but I figured someone must have worked out a decent method for it already. Thanks for finding that.

Posts: 35
Joined: Fri Mar 02, 2012 11:10 pm

Post by furrykef » Fri Mar 02, 2012 11:21 pm

By an amusing coincidence, I'd done exactly this last December. :) I'd never seen a Huffman tree in ASM form before, so I was quite baffled at first until I realized a table indexing into itself must be a tree, and then it all fell into place.

This repository contains the Python file I wrote to extract the script as well as batch files that supply the offsets for the US and Japanese versions of the ROM.
koitsu wrote:Here's an alternate theory, which I think is much more likely: did this game come out in Japan? If so, that would probably explain their choice of Huffman, which compresses Japanese amazingly well
Japanese text has much less a need to be compressed in the first place than English text, because, assuming one byte per kana, it's much more efficient in the first place. I think maybe the uncompressed Japanese script is in the neighborhood of the size of the compressed English script. (I'm too lazy to check, though.) I also didn't notice anything particularly interesting about the compression ratio of the Japanese text compared to the English text; in fact, I'm fairly sure the compression ratio was higher for English.

Post Reply