Final Fantasy Tactics Advance/Compression Formats: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
Line 22: Line 22:
:Output X + 2 zeros
:Output X + 2 zeros
*Bit 4 set: 0b0001XXXX 0bYYZZZZZZ 0bZZZZZZZZ
*Bit 4 set: 0b0001XXXX 0bYYZZZZZZ 0bZZZZZZZZ
:Tract back Z bytes from outputted data and copy 4+(Y<<8)|X bytes
:Track back Z bytes from outputted data and copy 4 + 0b00YYXXXX bytes.
*Bit 3 set: 0b00001???{{User:Archaemic/Templates/NeedVer}}
*Bit 3 set: 0b00001???
:'''Not observed'''
:'''Ignored.'''
*Bit 2 set: 0b000001??{{User:Archaemic/Templates/NeedVer}}
*Bit 2 set: 0b000001??{{User:Archaemic/Templates/NeedVer}}
:'''Not observed'''
:'''Ignored.'''
*Bit 1 set: 0b0000001? 0bXXXXXXXX{{User:Archaemic/Templates/NeedVer}}
*Bit 1 set: 0b0000001? 0bXXXXXXXX{{User:Archaemic/Templates/NeedVer}}
:Output 0xFF some-odd times
:Output 0xFF byte X + 3 times.
::The number of X + 3 times.
*Bit 0 set: 0b00000001 0bXXXXXXXX{{User:Archaemic/Templates/NeedVer}}
*Bit 0 set: 0b00000001 0bXXXXXXXX{{User:Archaemic/Templates/NeedVer}}
:Output X + 3 zeros
:Output X + 3 zeros
*No bits set: 0b00000000{{User:Archaemic/Templates/NeedVer}}
*No bits set: 0b00000000 0bXXXXXXXX 0bYYYYYYYY 0xZZZZZZZZ{{User:Archaemic/Templates/NeedVer}}
:'''Not observed'''
:Track back 0bYYYYYYYYZZZZZZZZ bytes from outputted data and copy X + 5 bytes.

Revision as of 11:18, 27 March 2014

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??[need verification]
Ignored.
  • Bit 1 set: 0b0000001? 0bXXXXXXXX[need verification]
Output 0xFF byte X + 3 times.
  • Bit 0 set: 0b00000001 0bXXXXXXXX[need verification]
Output X + 3 zeros
  • No bits set: 0b00000000 0bXXXXXXXX 0bYYYYYYYY 0xZZZZZZZZ[need verification]
Track back 0bYYYYYYYYZZZZZZZZ bytes from outputted data and copy X + 5 bytes.