STRG (Metroid Prime): Difference between revisions

From Retro Modding Wiki
Jump to navigation Jump to search
>Aruki
mNo edit summary
>Aruki
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:


The '''STRG format''' is used to store string tables. Each STRG file can contain any number of strings, as well as variations for different languages; the Prime series supports English, French, German, Spanish, Italian, Dutch, and Japanese.
The '''STRG format''' is used to store string tables. Each STRG file can contain any number of strings, as well as variations for different languages; the Prime series supports English, French, German, Spanish, Italian, Dutch, and Japanese.
{{todo|Could do with documentation of the formatting tags that can be found inside the strings}}


__TOC__
__TOC__


== 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}}
|}
 
Possible language codes:
 
{| 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
|}
|}


=== String Names ===
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, 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.
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'''
|}
|}


== Tools ==
== Tools ==


* [https://drive.google.com/file/d/0B9MLV21H7SDvSjBIY3BKRkQyZlk/edit?usp=sharing STRG Editor] by Parax - supports creating/editing and resaving STRG files in Metroid Prime 1/2's formats
* [https://drive.google.com/file/d/0B9MLV21H7SDvSjBIY3BKRkQyZlk/edit?usp=sharing STRG Editor] by Aruki - supports creating/editing and resaving STRG files in Metroid Prime 1/2's formats


[[Category:File Formats]]
[[Category:File Formats]]
[[Category:Metroid Prime]]
[[Category:Metroid Prime]]
[[Category:Metroid Prime 2 Demo]]
[[Category:Metroid Prime 2: Echoes]]
[[Category:Metroid Prime 2: Echoes]]
[[Category:Metroid Prime 3: Corruption]]
[[Category:Metroid Prime 3 Prototype]]
[[Category:Donkey Kong Country Returns]]

Latest revision as of 06:13, 28 March 2017

See STRG (File Format) for the other revisions of this format.

The STRG format is used to store string tables. Each STRG file can contain any number of strings, as well as variations for different languages; the Prime series supports English, French, German, Spanish, Italian, Dutch, and Japanese.


To do:
Could do with documentation of the formatting tags that can be found inside the strings

Format

Offset Type Count Name Notes MP1 MP2
0x0 u32 1 Magic Always 0x87654321.
0x4 u32 1 Version See hub article for a list of possible version numbers.
0x8 u32 1 Language Count Number of languages that this table has strings for.
0xC u32 1 String Count Number of strings contained in the file per language.
0x10 Language Language Count Language Table Table that defines the languages that are present in the file.
Name Table 1 Name Table Associates each string in the file with a name.
String Table Language Count String Tables Contains the actual string data. There is one table per language.
End of file

Language

Offset Type Count Name Notes MP1 MP2
0x0 char 4 Language ID This is a fourCC that indicates which language this is. See below for a list of possible fourCCs.
0x4 u32 1 Language Strings Offset Offset relative to the start of the string tables array.
0x8 u32 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.
0xC Language entry end

Possible language codes:

ID Language
ENGL English
FREN French
GERM German
SPAN Spanish
ITAL Italian
DUTC Dutch
JAPN 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.

Offset Type Count Name Notes
0x0 u32 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 u32 1 Name Table Size Relative to after this size value.
0x8 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.
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'.
End of name table

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.

Offset Type Count Name Notes
0x0 u32 1 Name Offset Relative to after the name table size value.
0x4 u32 1 String Index The index of the string that the name is associated with
0x8 End of entry

String Table

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.

Offset Type Count Name Notes MP1 MP2
0x0 u32 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.
0x4 u32 String Count String Offsets Each offset is relative to after the size value.
wstring String Count Strings Array This is an array of zero-terminated UTF-16 Unicode strings.
End of string table

Tools

  • STRG Editor by Aruki - supports creating/editing and resaving STRG files in Metroid Prime 1/2's formats