« on: September 06, 2013, 08:47:50 pm »
If I understand it correctly, it sounds like a table-based Huffman tree. The ones I've seen before were hard coded, so it's hard to tell.
There appears to be a 4 byte header that sets all of this up, but the intro to the game puts hard/immediate values into place of reading from a header table. But in game, appears to be all called from a header table. Hopefully not too many areas/events are hardcoded.
Edit: Ok, what was throwing me for a loop, was the offsets inside the huffman tree. I figured only variable/values would be there. But that's not the case. Weird. Guess I've never seen it implemented like this (or rather, I never wrote a huffman tree like this). If bit is 1, add the value from the tree to the pointer. If clear, skip two bytes in the table. Actual 'character' is encoded in 3 bytes in the table (pointer accumulators are 2 bytes) and this 'character' also preceded by #$01 - so that the pointer is incremented to align with the char (and not a terminator value of #$ff).
They kind of missed an optimization. They could have added 'words' to the table entries as well, but appears only single characters are in the entry (once a valid character is read, the position into the tree is reset). Maybe 2 and 3 char groups don't lend well to Japanese/hiragana?