PAK (Metroid Prime 3): Difference between revisions

>Aruki
(Created page with "''See PAK (File Format) for the other revisions of this format.'' The '''.pak format''' in Metroid Prime 3 and Donkey Kong Country Returns is a new version of the pak for...")
 
>Aruki
 
(12 intermediate revisions by 3 users not shown)
Line 5: Line 5:
Note that the Metroid Prime 3 E3 prototype uses a slightly modified version of the Metroid Prime pak format, not this one. See the [[PAK (Metroid Prime)]] page for more info on that revision of the format.
Note that the Metroid Prime 3 E3 prototype uses a slightly modified version of the Metroid Prime pak format, not this one. See the [[PAK (Metroid Prime)]] page for more info on that revision of the format.


{{researchminor
{{research|1|Research needs to be done on how to order files to optimize loads. Also, the very first part of the header is mostly unknown.}}
|reason = Research needs to be done on how to order files to optimize loads. Also, the very first part of the header is mostly unknown.
}}


__TOC__
__TOC__
Line 28: Line 26:
| 0x4
| 0x4
| 4
| 4
| {{unknown|'''Unknown'''. Always 0x40.}}
| '''Header size'''
|-
|-
| 0x8
| 0x8
| 16
| 16
| {{unknown|'''Unknown'''; appears to be a hash of some kind.}}
| '''MD5 hash''' of the entire pak after the first 64 bytes.
|-
|-
| 0x18
| 0x18
Line 138: Line 136:
== Compression ==
== Compression ==


Some pak files are compressed; in Prime 3, files are compressed with segmented LZO1X, just like Prime 2. In DKCR, on the other hand, files are compressed as a single zlib stream, like Prime 1. In either game, every compressed file is formatted the same way, starting with some metadata detailing the structure of the compressed data.
Some files within paks are compressed; in Prime 3, files are compressed with segmented LZO1X, just like Prime 2. In DKCR, on the other hand, files are compressed as a single zlib stream, like Prime 1. In either game, every compressed file is formatted the same way, starting with some metadata detailing the structure of the compressed data.


{| class="wikitable"
{| class="wikitable"
Line 154: Line 152:
|}
|}


Each compressed block is structured as follows. Note that the first byte of each size value appears to actually be a completely different value, so the three bytes following are what makes up the actual size value.
Each compressed block is structured as follows.


For each block, if the compressed and decompressed sizes match, that indicates the block is uncompressed.
For each block, if the compressed and decompressed sizes match, that indicates the block is uncompressed.
Line 165: Line 163:
| 0x0
| 0x0
| 1
| 1
| {{unknown|'''Unknown'''}}
| '''Flag'''
|-
|-
| 0x1
| 0x1
Line 172: Line 170:
|-
|-
| 0x4
| 0x4
| 1
| 4
| {{unknown|'''Unknown'''}}
|-
| 0x5
| 3
| '''Decompressed size'''  
| '''Decompressed size'''  
|-
|-
Line 182: Line 176:
| colspan=2 {{unknown|End of entry}}
| colspan=2 {{unknown|End of entry}}
|}
|}
The flag value can be set to the following possible values:
* If the block count is 1, it will be 0xA0 on block 1.
* If blocks 2/3 are compressed, they will have it set to 0xC0.
* If blocks 2/3 are uncompressed, they will have it set to 0x40.
* 0 in all other circumstances.
Files are left uncompressed if the compressed data is larger than the uncompressed data. Barring that, the following formats are always compressed:
* [[TXTR (Metroid Prime)|TXTR]]
* [[CMDL (Metroid Prime)|CMDL]]
* [[CSKR (File Format)|CSKR]]
* [[CHAR (File Format)|CHAR]]
* [[SAND (File Format)|SAND]]
* [[ANIM (File Format)|ANIM]]
* [[SCAN (Metroid Prime 2)|SCAN]]
* [[FONT (File Format)|FONT]]
* [[CSMP (File Format)|CSMP]]
* [[STRG (File Format)|STRG]]
* [[CAAD (File Format)|CAAD]]
* [[DCLN (File Format)|DCLN]]
* [[USRC (File Format)|USRC]]
The following formats are compressed when their uncompressed size is at least 0x80 bytes:
* [[PART (File Format)|PART]]
* [[ELSC (File Format)|ELSC]]
* [[SWHC (File Format)|SWHC]]
* [[WPSC (File Format)|WPSC]]
* [[CRSC (File Format)|CRSC]]
* [[BFRC (File Format)|BFRC]]
* [[SPSC (File Format)|SPSC]]
* [[DPSC (File Format)|DPSC]]
== File Order ==
File order matters significantly and easily makes the difference between a pak loading quickly and optimally, or taking 30+ seconds on every door. While more research is required to figure out exactly how files should be ordered to optimize loading, the game generally clusters together resources that are used together, and a file's dependencies generally appear directly before the file itself. The game also often duplicates assets that are used multiple times within the same pak; there might be 10-11 copies of the same model file in order to allow the game to more easily find and load that file when it needs it.
== Tools ==
* [https://www.dropbox.com/s/bba2n9jzj719by4/PakTool.rar?dl=0 PakTool] by Aruki


[[Category:File Formats]]
[[Category:File Formats]]
[[Category:Metroid Prime 3: Corruption]]
[[Category:Metroid Prime 3: Corruption]]
[[Category:Donkey Kong Country Returns]]
[[Category:Donkey Kong Country Returns]]
Anonymous user