The current URL is datacrystal.tcrf.net.
Final Fantasy Tactics Advance/Compression Formats
Final Fantasy Tactics Advance employs several compression formats. Several have been reverse engineered, and information is below:
Main compression methods
Starting around 0x0801F100 in the code is a routine for decompressing some data. The first byte seems to indicate type. Bytes checked for are, in order:
- 0x10
- 0x01
- 0x11
If none of these are matched, it prepares three arguments and then branches with link to 0x08141868.
Mode 0x11
In mode 0x11, the first three bytes after the identifier are compared against the value at 0x0801F26C (0x00FFFFFF in the original ROM). If the bytes match, it jumps to 0x0801F274. The destination is then filled with 0x1000 words of value 0. The following bytes are GBA LZ77 format.
LZSS
Several places in the FFTA ROM, a derivative of the LZSS compression scheme is used. In this format, literals (uncompressed data) and compressed data is mixed. The compressed data comes in several forms, and is identified by the highest bit that is set. Upon reading one compressed byte (and additionally however more are specified by that form), the next byte is read as compressed as well. Bytes are only read as uncompressed when specified by a special byte. The following is the list of all of the compressed data forms:
- Bit 7 set: 0b1XXXXYYY 0bYYYYYYYY
- Track back Y bytes from outputted data and copy X + 3 bytes.
- Bit 6 set: 0b01XXXXXX
- The next compressed byte is in X + 1 bytes
- Bit 5 set: 0b001XXXXX
- Output X + 2 zeros
- Bit 4 set: 0b0001XXXX 0bYYZZZZZZ 0bZZZZZZZZ
- Track back Z bytes from outputted data and copy 4 + 0b00YYXXXX bytes.
- Bit 3 set: 0b00001???
- Ignored.
- Bit 2 set: 0b000001??
- Ignored.
- Bit 1 set: 0b00000010 0bXXXXXXXX
- Output 0xFF byte X + 3 times.
- Bit 0 set: 0b00000001 0bXXXXXXXX
- Output X + 3 zeros
- No bits set: 0b00000000 0bXXXXXXXX 0bYYYYYYYY 0xZZZZZZZZ
- Track back 0bYYYYYYYYZZZZZZZZ bytes from outputted data and copy X + 5 bytes.