STRG (Metroid Prime): Difference between revisions

no edit summary
>Aruki
mNo edit summary
>Aruki
No edit summary
Line 6: Line 6:


== Format ==
== Format ==
=== Header ===


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
! MP1
! MP2
|-
|-
| 0x0
| 0x0
| 4
| u32
| '''Magic'''; always 0x87654321
| 1
| '''Magic'''
| Always <code>0x87654321</code>.
| {{check}}
| {{check}}
|-
|-
| 0x4
| 0x4
| 4
| u32
| '''Version'''; see [[STRG (File Format)|hub article]]
| 1
| '''Version'''
| See [[STRG (File Format)|hub article]] for a list of possible version numbers.
| {{check}}
| {{check}}
|-
|-
| 0x8
| 0x8
| 4
| u32
| '''Language count'''
| 1
| '''Language Count'''
| Number of languages that this table has strings for.
| {{check}}
| {{check}}
|-
|-
| 0xC
| 0xC
| 4
| u32
| '''String count'''
| 1
| '''String Count'''
| Number of strings contained in the file per language.
| {{check}}
| {{check}}
|-
|-
| 0x10
| 0x10
| colspan=2 {{unknown|End of header}}
| [[#Language|Language]]
| ''Language Count''
| '''Language Table'''
| Table that defines the languages that are present in the file.
| {{check}}
| {{check}}
|-
| {{none}}
| [[#Name Table|Name Table]]
| 1
| '''Name Table'''
| Associates each string in the file with a name.
| {{nocheck}}
| {{check}}
|-
| {{none}}
| [[#String Table|String Table]]
| ''Language Count''
| '''String Tables'''
| Contains the actual string data. There is one table per language.
| {{check}}
| {{check}}
|-
| colspan=7 {{unknown|End of file}}
|}
|}


=== Languages ===
=== Language ===
 
Following is a table that describes which languages appear in the file.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
! MP1
! MP2
|-
|-
| 0x0
| 0x0
| char
| 4
| 4
| '''Language''' fourCC
| '''Language ID'''
| This is a fourCC that indicates which language this is. See below for a list of possible fourCCs.
| {{check}}
| {{check}}
|-
|-
| 0x4
| 0x4
| 4
| u32
| '''Language strings offset''' (relative to start of string tables)
| 1
| '''Language Strings Offset'''
| Offset relative to the start of the string tables array.
| {{check}}
| {{check}}
|-
|-
| 0x8
| 0x8
| 4
| u32
| '''Language strings size''' ''(note: this is not in Prime 1)''
| 1
| '''Language Strings Size'''
| Size of the string table for this language. In Prime 1 this value is at the beginning of each string table instead of being part of the language definition.
| {{nocheck}}
| {{check}}
|-
|-
| 0xC
| 0xC
| colspan=2 {{unknown|Language entry end}}
| colspan=7 {{unknown|Language entry end}}
|}
|}


=== String Names ===
Possible language codes:


In Echoes, strings can have names attached to them. Note that this table only appears in the Echoes STRG format; for Prime 1, skip ahead to the string tables.
{| class="wikitable"
! ID
! Language
|-
| <code>ENGL</code>
| English
|-
| <code>FREN</code>
| French
|-
| <code>GERM</code>
| German
|-
| <code>SPAN</code>
| Spanish
|-
| <code>ITAL</code>
| Italian
|-
| <code>DUTC</code>
| Dutch
|-
| <code>JAPN</code>
| Japanese
|}
 
Note that while Dutch doesn't actually appear in any STRG files, the fourCC for it can be found in the dol alongside the other language codes, so the game probably supports it.
 
=== Name Table ===
 
In Echoes, this table is used to attach a name to the strings in the file. The names are used internally to allow the game to look up a particular string from a file using its name rather than having to hardcode a string index to find it. This table only appears in the Echoes STRG format; for Prime 1, skip ahead to the string tables.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| u32
| '''Name count'''
| 1
| '''Name Count'''
| Number of string names in the table. Note this does not necessarily equal the regular string count! It's possible to have a STRG file where some strings have names and some don't.
|-
|-
| 0x4
| 0x4
| 4
| u32
| '''Name table size'''
| 1
| '''Name Table Size'''
| Relative to after this size value.
|-
|-
| 0x8
| 0x8
| colspan=2 {{unknown|Name entries begin}}
| [[#Name Entry|Name Entry]]
| ''Name Count''
| '''String Name Entries'''
| This array doesn't contain the names themselves, but it defines each one and associates it with one of the strings.
|-
| {{none}}
| string
| ''Name Count''
| '''String Name Array'''
| This is an array of zero-terminated ASCII strings. The names are sorted in alphabetical order; the sorting is case-sensitive, so 'Z' will appear before 'a'.
|-
| colspan=5 {{unknown|End of name table}}
|}
|}


Each entry is structured as follows:
==== Name Entry ====
 
This structure is used to point to a name in the ''String Name Array and associate it with one of the strings from the file.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| u32
| '''Name offset''' (relative to after the name table size value)
| 1
| '''Name Offset'''
| Relative to after the name table size value.
|-
|-
| 0x4
| 0x4
| 4
| u32
| '''String index''' - this is the string number that the name is associated with
| 1
| '''String Index'''
| The index of the string that the name is associated with
|-
|-
| 0x8
| 0x8
| colspan=2 {{unknown|End of entry}}
| colspan=5 {{unknown|End of entry}}
|}
|}


After every name entry comes all the names in the form of a large UTF-8 string array. The names are zero-terminated, and they're sorted in alphabetical order; the sorting is case-sensitive, so 'Z' will appear before 'a'.
=== String Table ===
 
=== String Tables ===


Last are the actual string tables themselves. Each table contains some metadata followed by a series of UTF-16 strings. The number of strings is declared in the header; there will be one of these tables present per language present in the file.
The file contains one string table per language. Each table contains some metadata followed by a series of UTF-16 strings. The number of strings included in each table is determined by the ''String Count'' value in the header, which is consistent across every language in the file.


{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
! MP1
! MP2
|-
|-
| 0x0
| 0x0
| 4
| u32
| '''String table size''' ''(note: this is not in Echoes)''
| 1
| '''String Table Size'''
| Size of the string table, not including the size value itself. In Echoes this value was moved inside the language definitions earlier in the file.
| {{check}}
| {{nocheck}}
|-
|-
| 0x4
| 0x4
| 4 &times; string count
| u32
| '''String offsets''' (relative to after the size value)
| ''String Count''
| '''String Offsets'''
| Each offset is relative to after the size value.
| {{check}}
| {{check}}
|-
| {{none}}
| wstring
| ''String Count''
| '''Strings Array'''
| This is an array of zero-terminated UTF-16 Unicode strings.
| {{check}}
| {{check}}
|-
|-
| -
| colspan=7 {{unknown|End of string table}}
| Varies
| '''UTF-16 strings'''
|}
|}


Anonymous user