Difference between revisions of "PAT0 (File Format)"
m |
AlmostTWD98 (talk | contribs) m |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | == Overview == | ||
This page describes the [[Mario Kart Wii]] '''PAT0''' file format, as found within [[BRRES (File Format)|BRRES files]]. PAT0 files are texture <b>pat</b>tern animation files. | This page describes the [[Mario Kart Wii]] '''PAT0''' file format, as found within [[BRRES (File Format)|BRRES files]]. PAT0 files are texture <b>pat</b>tern animation files. | ||
− | = | + | == General File Format == |
− | |||
This table descibes the general file format for all [[BRRES]] sub files: | This table descibes the general file format for all [[BRRES]] sub files: | ||
{{BRRES sub file header|PAT0}} | {{BRRES sub file header|PAT0}} | ||
− | = File Format PAT v4 = | + | == File Format PAT v4.0 == |
− | + | The following information is only valid for PAT version 4. For other versions it is unknown. | |
− | The following | ||
− | |||
Version 4 use 6 sections (numbered from 0 to 5). In [[Mario Kart Wii]] a PAT0 file of version 4 have 4 relevant data areas: | Version 4 use 6 sections (numbered from 0 to 5). In [[Mario Kart Wii]] a PAT0 file of version 4 have 4 relevant data areas: | ||
Line 18: | Line 16: | ||
The section #2, #4 and #5 are always empty. | The section #2, #4 and #5 are always empty. | ||
− | == PAT v4 Header == | + | === PAT v4.0 Header === |
− | |||
The '''File Header''' is followed by a '''PAT Header''' (you can also see it as an extension of the file header above). The offset relative to file begin is 0x2c. | The '''File Header''' is followed by a '''PAT Header''' (you can also see it as an extension of the file header above). The offset relative to file begin is 0x2c. | ||
Line 25: | Line 22: | ||
! offset !! size !! description | ! offset !! size !! description | ||
|- | |- | ||
− | | 0x00 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x00 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x02 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x02 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x04 || 2 || '''Frame count'''; values between 2 and 179 in | + | | 0x04 || 2 || '''Frame count'''; values between 2 and 179 in Mario Kart Wii. |
|- | |- | ||
− | | 0x06 || 2 || '''N_BASE''' := number of base entries of section #0; 1 or 2 in | + | | 0x06 || 2 || '''N_BASE''' := number of base entries of section #0; 1 or 2 in Mario Kart Wii. |
|- | |- | ||
− | | 0x08 || 2 || '''N_STR''' := number of strings in section #1 and #3; values between 2 and 12 in | + | | 0x08 || 2 || '''N_STR''' := number of strings in section #1 and #3; values between 2 and 12 in Mario Kart Wii. |
|- | |- | ||
− | | 0x0A || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x0A || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x0C || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x0C || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x0E || 2 || Cyclic (0=disabled, 1=enabled, other values not used in | + | | 0x0E || 2 || Cyclic (0=disabled, 1=enabled, other values not used in Mario Kart Wii). |
|- | |- | ||
| 0x10 || colspan=2 {{unknown|End of this header}} | | 0x10 || colspan=2 {{unknown|End of this header}} | ||
|} | |} | ||
− | == Section #0: Animation data == | + | === Section #0: Animation data === |
− | |||
The animation data consists of 2 blocks: The base data and a string reference. Both blocks have an included list. | The animation data consists of 2 blocks: The base data and a string reference. Both blocks have an included list. | ||
− | === Base Header === | + | ==== Base Header ==== |
− | |||
{| class="wikitable" | {| class="wikitable" | ||
|+ Section #0: Base Header | |+ Section #0: Base Header | ||
Line 56: | Line 51: | ||
| 0x00 || 4 || '''HEAD_SIZE''' := Size of this structure = 0x18 + N_BASE*0x10 | | 0x00 || 4 || '''HEAD_SIZE''' := Size of this structure = 0x18 + N_BASE*0x10 | ||
|- | |- | ||
− | | 0x04 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x04 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x06 || 2 || '''N_BASE''' := number of base entries of this section. In | + | | 0x06 || 2 || '''N_BASE''' := number of base entries of this section. In Mario Kart Wii always the same value as N_BASE of PAT header. |
|- | |- | ||
− | | 0x08 || 2 || {{Unknown-left|'''Unknown'''. Always 0xFFFF in | + | | 0x08 || 2 || {{Unknown-left|'''Unknown'''. Always 0xFFFF in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x0A || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x0A || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
| 0x0C || 2 || '''N_UNKNOWN'''. Mostly same as ''N_BASE''. Only in 2 tracks (old_heyho_gba/model and old_koopa_gba/vrcorn), N_BASE is set to 2 and N_UNKNOWN to 1. | | 0x0C || 2 || '''N_UNKNOWN'''. Mostly same as ''N_BASE''. Only in 2 tracks (old_heyho_gba/model and old_koopa_gba/vrcorn), N_BASE is set to 2 and N_UNKNOWN to 1. | ||
|- | |- | ||
− | | 0x0E || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x0E || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x10 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x10 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x12 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x12 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x14 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x14 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x16 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x16 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
| 0x18 || N_BASE*0x10 || A list with base data: | | 0x18 || N_BASE*0x10 || A list with base data: | ||
Line 80: | Line 75: | ||
! offset !! size !! description | ! offset !! size !! description | ||
|- | |- | ||
− | | 0x00 || 2 || {{Unknown-left|'''Unknown'''. Values between 0x19 and 0x96 in | + | | 0x00 || 2 || {{Unknown-left|'''Unknown'''. Values between 0x19 and 0x96 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x02 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in | + | | 0x02 || 2 || {{Unknown-left|'''Unknown'''. Always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x04 || 2 || {{Unknown-left|'''Unknown'''. Values between 0 and 2 in | + | | 0x04 || 2 || {{Unknown-left|'''Unknown'''. Values between 0 and 2 in Mario Kart Wii. Value is only >0, if N_BASE >1.}} |
|- | |- | ||
− | | 0x06 || 2 || {{Unknown-left|'''Unknown'''. 1 or 2 in | + | | 0x06 || 2 || {{Unknown-left|'''Unknown'''. 1 or 2 in Mario Kart Wii. Value is never the same as the value before (offset 0x04) and only 2, if N_BASE >1.}} |
|- | |- | ||
| 0x08 || 4 || '''Name of element'''. Offset (relative to beginning of this ''Base Header'') into the string pool. | | 0x08 || 4 || '''Name of element'''. Offset (relative to beginning of this ''Base Header'') into the string pool. | ||
Line 97: | Line 92: | ||
|} | |} | ||
− | === Reference List === | + | ==== Reference List ==== |
− | |||
The base header is followed by the string reference list. | The base header is followed by the string reference list. | ||
The string reference list itself have 2 separated parts: | The string reference list itself have 2 separated parts: | ||
Line 111: | Line 105: | ||
| 0x00 || 4 || '''Name of element'''. Offset (relative to beginning of this ''Reference Header'') into the string pool. | | 0x00 || 4 || '''Name of element'''. Offset (relative to beginning of this ''Reference Header'') into the string pool. | ||
|- | |- | ||
− | | 0x04 || 2 || {{Unknown-left|'''Unknown'''. Maybe MSB of ''type'', always 0 in | + | | 0x04 || 2 || {{Unknown-left|'''Unknown'''. Maybe MSB of ''type'', always 0 in Mario Kart Wii.}} |
|- | |- | ||
− | | 0x06 || 2 || '''type''', always 5 in | + | | 0x06 || 2 || '''type''', always 5 in Mario Kart Wii. |
|- | |- | ||
| 0x08 || 4 || Offset (relative to beginning of this ''Reference Header'') to the related '''String List'''. | | 0x08 || 4 || Offset (relative to beginning of this ''Reference Header'') to the related '''String List'''. | ||
Line 149: | Line 143: | ||
|} | |} | ||
− | == Section #1: String list == | + | === Section #1: String list === |
− | |||
Section #1 contains '''N_STR''' u32 string offsets. Each offset is relative to the start of this section. Each points to a string at the end of the [[BRRES (File Format)|BRRES file]]. This is used to store the names of the textures to swap. | Section #1 contains '''N_STR''' u32 string offsets. Each offset is relative to the start of this section. Each points to a string at the end of the [[BRRES (File Format)|BRRES file]]. This is used to store the names of the textures to swap. | ||
− | == Section #3: String related attributes | + | === Section #3: String Related Attributes === |
+ | Section #3 contains '''N_STR''' u32 attributes. The assumption is, that each attributes is related to a string of section #1. All attributes are NULL at Mario Kart Wii. | ||
− | + | == Tools == | |
+ | The following tools can handle PAT0 files: | ||
+ | * [[BrawlBox]], by Kryal & BlackJax. | ||
+ | * [[BrawlCrate]], by soopercool101. | ||
+ | == Links == | ||
{{BRRES links}} | {{BRRES links}} | ||
[[Category:File Format/Wii]] | [[Category:File Format/Wii]] |
Latest revision as of 01:51, 11 January 2022
Overview
This page describes the Mario Kart Wii PAT0 file format, as found within BRRES files. PAT0 files are texture pattern animation files.
General File Format
This table descibes the general file format for all BRRES sub files:
Offset | Type | Description |
---|---|---|
0x00 | String | The magic "PAT0" to identify the sub file. See »BRRES Sub Files« for other magics. |
0x04 | UInt32 | Length of the sub file. |
0x08 | UInt32 | Sub file version number. The number of sections (N) is dependent of this version number. See »BRRES Sub Files« for details. |
0x0C | Int32 | Offset to outer BRRES File. |
0x10 | Int32[N] | N section offsets. N is implied in the version number (offset 0x08). |
0x10+N*4 | Int32 | String offset to the name of this sub file. This name equal to the name of the entry name of the BRRES Index Group pointing to this data. |
0x14+N*4 | End of this header |
File Format PAT v4.0
The following information is only valid for PAT version 4. For other versions it is unknown.
Version 4 use 6 sections (numbered from 0 to 5). In Mario Kart Wii a PAT0 file of version 4 have 4 relevant data areas:
- A header with 16 bytes (8 16-bit values?)
- Section #0 with the animation data.
- Section #1 with a string offset list.
- Section #3 with a attributes for each string.
The section #2, #4 and #5 are always empty.
PAT v4.0 Header
The File Header is followed by a PAT Header (you can also see it as an extension of the file header above). The offset relative to file begin is 0x2c.
offset | size | description |
---|---|---|
0x00 | 2 | Unknown. Always 0 in Mario Kart Wii. |
0x02 | 2 | Unknown. Always 0 in Mario Kart Wii. |
0x04 | 2 | Frame count; values between 2 and 179 in Mario Kart Wii. |
0x06 | 2 | N_BASE := number of base entries of section #0; 1 or 2 in Mario Kart Wii. |
0x08 | 2 | N_STR := number of strings in section #1 and #3; values between 2 and 12 in Mario Kart Wii. |
0x0A | 2 | Unknown. Always 0 in Mario Kart Wii. |
0x0C | 2 | Unknown. Always 0 in Mario Kart Wii. |
0x0E | 2 | Cyclic (0=disabled, 1=enabled, other values not used in Mario Kart Wii). |
0x10 | End of this header |
Section #0: Animation data
The animation data consists of 2 blocks: The base data and a string reference. Both blocks have an included list.
Base Header
offset | size | description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | 4 | HEAD_SIZE := Size of this structure = 0x18 + N_BASE*0x10 | |||||||||||||||||||||
0x04 | 2 | Unknown. Always 0 in Mario Kart Wii. | |||||||||||||||||||||
0x06 | 2 | N_BASE := number of base entries of this section. In Mario Kart Wii always the same value as N_BASE of PAT header. | |||||||||||||||||||||
0x08 | 2 | Unknown. Always 0xFFFF in Mario Kart Wii. | |||||||||||||||||||||
0x0A | 2 | Unknown. Always 0 in Mario Kart Wii. | |||||||||||||||||||||
0x0C | 2 | N_UNKNOWN. Mostly same as N_BASE. Only in 2 tracks (old_heyho_gba/model and old_koopa_gba/vrcorn), N_BASE is set to 2 and N_UNKNOWN to 1. | |||||||||||||||||||||
0x0E | 2 | Unknown. Always 0 in Mario Kart Wii. | |||||||||||||||||||||
0x10 | 2 | Unknown. Always 0 in Mario Kart Wii. | |||||||||||||||||||||
0x12 | 2 | Unknown. Always 0 in Mario Kart Wii. | |||||||||||||||||||||
0x14 | 2 | Unknown. Always 0 in Mario Kart Wii. | |||||||||||||||||||||
0x16 | 2 | Unknown. Always 0 in Mario Kart Wii. | |||||||||||||||||||||
0x18 | N_BASE*0x10 | A list with base data:
| |||||||||||||||||||||
HEAD_SIZE | End of this header |
Reference List
The base header is followed by the string reference list. The string reference list itself have 2 separated parts:
- The Reference Header: A list with info and an offset to the string list.
- The String List. The list has also an additional header element.
The Reference Header starts at the offset declared by the Base Header:
offset | size | description |
---|---|---|
0x00 | 4 | Name of element. Offset (relative to beginning of this Reference Header) into the string pool. |
0x04 | 2 | Unknown. Maybe MSB of type, always 0 in Mario Kart Wii. |
0x06 | 2 | type, always 5 in Mario Kart Wii. |
0x08 | 4 | Offset (relative to beginning of this Reference Header) to the related String List. |
0x0C | End of this header |
Each String List starts at the offset declared by the Reference Header. Each element contains 8 bytes. The very first element is the list header:
offset | size | description |
---|---|---|
0x00 | 2 | N_ELEM := number of following elements. |
0x02 | 2 | Padding (always 0). |
0x04 | 4 | A factor (float) := 1.0/(MAX-MIN). MIN and MAX are the minimal and maximal time values found in the following list. Probably it is used to normalize the range from 0.000 – 1.000. A fine analysis of all Nintendo PAT files shows up, that Nintendo used 0.9999999/(MAX-MIN) to get little smaller values (and never 1.0 for the maximum). |
0x08 | End of this header |
The following elements have this format:
offset | size | description |
---|---|---|
0x00 | 4 | Probably a time (float). All floats of the list are in ascending order. The first value is mostly 0.000, and sometimes negative (-1.000). |
0x04 | 2 | Zero based String index into section #1 and #3. |
0x08 | 2 | Padding (always 0). |
0x08 | End of this element |
Section #1: String list
Section #1 contains N_STR u32 string offsets. Each offset is relative to the start of this section. Each points to a string at the end of the BRRES file. This is used to store the names of the textures to swap.
Section #3: String Related Attributes
Section #3 contains N_STR u32 attributes. The assumption is, that each attributes is related to a string of section #1. All attributes are NULL at Mario Kart Wii.
Tools
The following tools can handle PAT0 files:
- BrawlBox, by Kryal & BlackJax.
- BrawlCrate, by soopercool101.