PAK (Metroid Prime): Difference between revisions

>Aruki
>Aruki
 
(5 intermediate revisions by the same user not shown)
Line 15: Line 15:
{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| int16
| '''Version number'''. Always 0x00030005.
| '''Version Number Major'''
| Always 3
|-
| 0x2
| int16
| '''Version Number Minor'''
| Always 5
|-
|-
| 0x4
| 0x4
| 4
| int32
| '''Unused'''; always 0
| '''Unused'''
| Always 0
|-
|-
| 0x8
| 0x8
| colspan=2 {{unknown|End of header}}
| colspan=3 {{unknown|End of header}}
|}
|}


Line 38: Line 46:
{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Count
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| {{FourCC}}
| '''File type''' fourCC.
| 1
| '''Asset Type'''
| Indicates the type of asset (texture, model, area, etc) and usually doubles as the asset's cooked file extension.
|-
|-
| 0x4
| 0x4
| 4
| int32
| '''File ID'''.
| 1
| '''Asset ID'''
| Unique identifier for this asset.
|-
|-
| 0x8
| 0x8
| 4
| int32
| '''Name length''' (NL)
| 1
| '''Name Length'''
| Length of the name string
|-
|-
| 0xC
| 0xC
| NL
| char
| '''Name'''; not zero-terminated
| ''Name Length''
| '''Name String'''
| Name of the asset. Not zero-terminated. This name usually corresponds to a hardcoded string that the game uses to look up the asset, so this generally can't be changed.
|-
|-
| 0xC + NL
| colspan=5 {{unknown|End of entry}}
| colspan=2 {{unknown|End of entry}}
|}
|}


Line 67: Line 84:
{| class="wikitable"
{| class="wikitable"
! Offset
! Offset
! Size
! Type
! Description
! Name
! Notes
|-
|-
| 0x0
| 0x0
| 4
| int32
| '''Compression flag'''; this will either be 0 or 1, with 1 denoting a compressed file.
| '''Compression Flag'''
| Value will be either 0 or 1, with 1 denoting that the asset is compressed.
|-
|-
| 0x4
| 0x4
| 4
| {{FourCC}}
| '''File type''' fourCC.
| '''Asset Type'''
| Indicates the type of asset (texture, model, area, etc) and usually doubles as the asset's cooked file extension.
|-
|-
| 0x8
| 0x8
| 4
| int32
| '''File ID'''
| '''Asset ID'''
| Unique identifier for this asset. This ID is used by other assets to reference this one.
|-
|-
| 0xC
| 0xC
| 4
| int32
| '''Size''' (note: always a multiple of 32. The end of the file is padded with 0xFF in order to be 32-byte aligned.)
| '''Size'''
| Size of the asset data in the pak. This is always 32-byte-aligned. The end of the asset is padded with 0xFF.
|-
|-
| 0x10
| 0x10
| 4
| int32
| '''Offset'''
| '''Offset'''
| Offset of the asset data within the pak. This is an absolute offset.
|-
|-
| 0x14
| 0x14
| colspan=2 {{unknown|End of entry}}
| colspan=4 {{unknown|End of entry}}
|}
|}


Line 118: Line 141:
* [[CRSC (File Format)|CRSC]]
* [[CRSC (File Format)|CRSC]]


Additionally, in Prime 2 any files can be left uncompressed if the compressed file is larger than the uncompressed one. This is not the case in Prime 1 (although custom repacking implementations should probably do this regardless).
Additionally, in Prime 2 any files can be left uncompressed if the compressed file is larger than the uncompressed one. This is not the case in Prime 1 (although custom repacking implementations should probably do this regardless, as there's no benefit to the compression in this scenario).


== Optimizing Load Times ==
== Optimizing Load Times ==
Line 131: Line 154:
* First the game goes down the area dependency list in the [[MLVL (File Format)|MLVL]] file and loads every file in the list for every active layer. The game follows the exact order specified by the list.
* First the game goes down the area dependency list in the [[MLVL (File Format)|MLVL]] file and loads every file in the list for every active layer. The game follows the exact order specified by the list.
* After loading all area dependencies, the area itself is loaded.
* After loading all area dependencies, the area itself is loaded.
* Finally the game loads assets being used by the new area that are missing from the list. This primarily means [[SCAN (File Format)|SCAN]] files (in MP1), the skybox model, and assets being used by PlayerActor animsets (this avoids loading PlayerActor assets for suits that the player doesn't have). If anything else is missing from the list, they will still be loaded, but this step will cause the game to hang until the load is finished.
* Finally the game loads assets being used by the new area that are missing from the list. This primarily means [[SCAN (File Format)|SCAN]] files (in MP1), the skybox model, and assets being used by PlayerActor animsets (this avoids loading PlayerActor assets for suits that the player doesn't have). If any other assets were missing from the list, they are loaded here. It's very important to know that contrary to the previous steps, assets that still aren't in memory at this point are loaded ''synchronously'', which means the game will hang until loading is complete; therefore, you want as few assets as possible to be left to load at this point. (You can observe this hang even in the base game - there is a small freeze towards the end of loading Artifact Temple.)
* Note that any assets that are already in memory will be skipped.
* Note that any assets that are already in memory will be skipped.


Line 138: Line 161:
== Tools ==
== Tools ==


* [https://drive.google.com/file/d/0B9MLV21H7SDvcGc1QjRfSTFJNk0/view?usp=sharing PakTool] by Aruki
* [https://www.dropbox.com/s/bba2n9jzj719by4/PakTool.rar?dl=0 PakTool] by Aruki


[[Category:File Formats]]
[[Category:File Formats]]
[[Category:Metroid Prime]]
[[Category:Metroid Prime]]
[[Category:Metroid Prime 2: Echoes]]
[[Category:Metroid Prime 2: Echoes]]
Anonymous user