Field File Section 6: Tile Map - niemasd/PyFF7 GitHub Wiki

The Tile Map stores information about the tiles in Field Files. It seems to be unused in Final Fantasy VII PC. This wiki is a useful reference for the Tile Map section.

4 bytes: Section Length

  • This is a 4-byte unsigned integer denoting the total length (in bytes) of this section

Section Header

Subsection Offsets

  • The first 4 bytes of this section are an unsigned integer denoting the starting offset of Subsection 2 (Layer 1 Information)
  • The next 4 bytes of this section are an unsigned integer denoting the starting offset of Subsection 3 (Texture Page Data)
  • The next 4 bytes of this section are an unsigned integer denoting the starting offset of Subsection 4 (Sprite Layer Information)
  • The next 4 bytes of this section are an unsigned integer denoting the starting offset of Subsection 5 (Layer 3 Information)
  • Note that Subsection 1 (List of Data Structures) begins immediately after this header (at offset 16)

Subsection 1: List of Data Structures

This code and my own code might help decode this section. Basically, it's a list of data structures that are either 2 bytes (composed of one 2-byte unsigned int) or 6 bytes (composed of three 2-byte unsigned ints):

  • The first 2-byte unsigned integer is a number that indicates some form of "type"
    • Type 0x7FFE implies a sprite (use Section 3 to find information about the corresponding sprite)
    • Type 0x7FFF implies "end of layer information data record"
  • I'm not to sure how to parse this section: I relied heavily on this code

Subsection 2: Layer 1 Tiles

Each entry in this section is 8 bytes total. To find the number of entries, simply divide the length of subsection 2 (which is subsection 3 offset - subsection 2 offset) by 8. Each entry has the following items:

2 bytes: Destination X

  • This is a 2-byte signed integer

2 bytes: Destination Y

  • This is a 2-byte signed integer

1 byte: Tex Page Source X

  • This is a 1-byte unsigned integer

1 byte: Tex Page Source Y

  • This is a 1-byte unsigned integer

2 bytes: Tile Clut Data

  • This is a 2-byte unsigned integer
  • From leftmost (i.e., most-significant) bit to rightmost (i.e., least-significant) bit, it has the following information:
    • The leftmost (i.e., most-significant) 6 bits represent ZZ1
    • The next 2 bits represent the Clut Number
    • The rightmost (i.e., least-significant) 6 bits represent ZZ2

Subsection 3: Sprite TP Blends

Each entry in this section is 2 bytes total. To find the number of entries, simply divide the length of subsection 3 (which is subsection 4 offset - subsection 3 offset) by 2. Note that, in the 2 bytes representing an entry, multiple items of information are stored in the bits. Each entry has the following items (in order from left to right, i.e., most-significant bits to least-significant bits):

7 bits: ZZ

  • This is an unsigned integer comprised of the 7 leftmost (i.e., most-significant) bits of the entry

2 bits: Deph

  • This is an unsigned integer comprised of the next 2 bits of the entry

2 bits: Blending Mode

  • This is an unsigned integer comprised of the next 2 bits of the entry

1 bit: Page Y

  • This is an unsigned integer comprised of the next 1 bit of the entry

4 bits: Page X

  • This is an unsigned integer comprised of the 4 rightmost (i.e., least-significant) bits of the entry

Subsection 4: Sprite Data

Each entry in this section is 14 bytes total. To find the number of entries, simply divide the length of subsection 4 (which is subsection 5 offset - subsection 4 offset) by 14. Each entry has the following items:

2 bytes: Destination X

  • This is a 2-byte signed integer

2 bytes: Destination Y

  • This is a 2-byte signed integer

1 byte: Tex Page Source X

  • This is a 1-byte unsigned integer

1 byte: Tex Page Source Y

  • This is a 1-byte unsigned integer

2 bytes: Tile Clut Data

  • This is a 2-byte unsigned integer
  • From leftmost (i.e., most-significant) bit to rightmost (i.e., least-significant) bit, it has the following information:
    • The leftmost (i.e., most-significant) 6 bits represent ZZ1
    • The next 2 bits represent the Clut Number
    • The rightmost (i.e., least-significant) 6 bits represent ZZ2

2 bytes: Sprite TP Blend

  • This is a 2-byte unsigned integer
  • See Section 6 Subsection 3 for information of how information is stored in the Sprite TP Blend

2 bytes: Group

  • This is a 2-byte unsigned integer
  • It seems like it's only the 12 rightmost (i.e., least-significant) bits, implying its value is between 0 and 4,095 (inclusive)

1 byte: Parameter

  • This is a 1-byte unsigned integer
  • It has the following information:
    • The leftmost (i.e., most-significant) 1 bits represent the Blending
    • The rightmost (i.e., least-significant) 7 bits represent the Parameter ID

1 byte: State

  • This is a 1-byte unsigned integer

Subsection 5: Additional Layer

This subsection looks similar to subsection 4, and it's used for additional layers (not all Field Files use it). Each entry in this section is 10 bytes total. To find the number of entries, simply divide the length of subsection 5 (which is End of File offset - subsection 5 offset) by 10. Each entry has the following items:

2 bytes: Destination X

  • This is a 2-byte signed integer

2 bytes: Destination Y

  • This is a 2-byte signed integer

1 byte: Tex Page Source X

  • This is a 1-byte unsigned integer

1 byte: Tex Page Source Y

  • This is a 1-byte unsigned integer

2 bytes: Tile Clut Data

  • This is a 2-byte unsigned integer
  • From leftmost (i.e., most-significant) bit to rightmost (i.e., least-significant) bit, it has the following information:
    • The leftmost (i.e., most-significant) 6 bits represent ZZ1
    • The next 2 bits represent the Clut Number
    • The rightmost (i.e., least-significant) 6 bits represent ZZ2

1 byte: Parameter

  • This is a 1-byte unsigned integer
  • It has the following information:
    • The leftmost (i.e., most-significant) 1 bits represent the Blending
    • The rightmost (i.e., least-significant) 7 bits represent the Parameter ID

1 byte: State

  • This is a 1-byte unsigned integer