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.
- This is a 4-byte unsigned integer denoting the total length (in bytes) of this section
- This is a 1-byte unsigned integer denoting the number of actors (characters)
- This is a 1-byte unsigned integer denoting the number of models
- This is a 2-byte unsigned integer denoting the offset of the string table
- This is a 2-byte unsigned integer denoting the number of Akao or Tutorial blocks/offsets
- This is a 2-byte unsigned integer denoting the scale of the field
- It is used in movement/talking calculations (9-bit fixed point?)
- Just 3 bytes of
<NULL>
(i.e.,0x0
)
- This is a "left-aligned" string: strings shorter than 8 characters are right-padded with
<NULL>
(i.e.,0x0
)
- 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
- 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
)
- This is a "left-aligned" string: strings shorter than 8 characters are right-padded with
- For each Akao/Tutorial Block offset (see Number of Akao and Tutorial Blocks), there is a 4-byte unsigned integer representing its offset
- 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
The Script Code consists of all bytes starting from right after the Actor Scripts pointers table until just before the the String Table Offset.
- 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
- For each of the offsets in the String Table Header, read all bytes from the offset until the first
0xFF
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)
- 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