Field File Section 1: Field Script - niemasd/PyFF7 GitHub Wiki

The Field Script section holds the Field Script logic and Dialog data for the Field File. This wiki is a useful reference for the Field Script section.

4 bytes: Section Length

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

Section Header

2 bytes: Version

  • It is not known what these 2 bytes mean, but it seems like it's a version, and it's always 0x0502.

1 byte: Number of Actors

  • This is a 1-byte unsigned integer denoting the number of actors (characters)

1 byte: Number of Models

  • This is a 1-byte unsigned integer denoting the number of models

2 bytes: String Table Offset

  • This is a 2-byte unsigned integer denoting the offset of the string table

2 bytes: Number of Akao and Tutorial Blocks

  • This is a 2-byte unsigned integer denoting the number of Akao or Tutorial blocks/offsets

2 bytes: Scale of Field

  • This is a 2-byte unsigned integer denoting the scale of the field
  • It is used in movement/talking calculations (9-bit fixed point?)

6 bytes: <NULL> Bytes

  • Just 3 bytes of <NULL> (i.e., 0x0)

8 bytes: Field Creator (never shown)

  • This is a "left-aligned" string: strings shorter than 8 characters are right-padded with <NULL> (i.e., 0x0)

8 bytes: Field Name (never shown)

  • This is a "left-aligned" string: strings shorter than 8 characters are right-padded with <NULL> (i.e., 0x0)
  • This will likely be the same as the filename

Actor Names

  • For each actor (see Number of Actor), there is an actor name that is 8 bytes
    • This is a "left-aligned" string: strings shorter than 8 characters are right-padded with <NULL> (i.e., 0x0)

Akao and Tutorial Block Offsets

Actor Scripts

  • For each actor (see Number of Actor), there is a list of 32 actor script pointers, each a 2-byte unsigned integer
    • Each pointer refers to the first command of the current script

Script Code

The Script Code consists of all bytes starting from right after the Actor Scripts pointers table until just before the the String Table Offset.

String Table

String Table Header

  • The String Table starts at the String Table Offset
  • The first 2 bytes are an unsigned integer denoting the total number of strings
    • For each of these strings, there are 2 bytes representing an unsigned integer denoting the offset of the string

Actual Strings

  • For each of the offsets in the String Table Header, read all bytes from the offset until the first 0xFF

Padding

For some reason, the end of the String Table is padded with <NULL> (i.e., 0x0). Generally speaking, this seems to typically be the way to compute the number of <NULL> bytes you need after your last string and before the Akao/Tutorial Block:

end_of_string_table = string_table_offset + len(string_table)
if end_of_string_table % 4 != 0: # not 32-bit aligned
    number_of_pad_bytes = 4 - (end_of_string_table % 4)

Akao and Tutorial Block

  • The data between each of the offsets in the Akao and Tutorial Block Offsets list is an Akao or Tutorial Block
    • The last one is from the last offset until the end of Section 1
⚠️ **GitHub.com Fallback** ⚠️