Common nn::util: Difference between revisions

Watertoon (talk | contribs)
Add category.
Watertoon (talk | contribs)
Cleanup, add NWPtr<T> and NWString to use as helpers in the other NW file format pages.
 
Line 1: Line 1:
These are file structures common to multiple NintendoWare file formats. Namely the nn::gfx file formats [[Bntx]] and [[Bnsh]], the nn::g3d file formats [[Bfres]], and [[Bfsha]], and the nn::bezel file formats [[Bea]], [[Bnbshpk]], and [[Nbmap]].
These are file structures common to multiple NintendoWare file formats. Namely the nn::gfx file formats [[Bntx]] and [[Bnsh]], the nn::g3d file formats [[Bfres]], and [[Bfsha]], the nn::vg file format [[Bnvg]], and the nn::bezel file formats [[Bea]], [[Bnbshpk]], and [[Nbmap]].


=== Headers ===
== Headers ==


==== nn::util::BinaryFileHeader ====
=== nn::util::BinaryFileHeader ===
The base struct of almost if not every file format using nn::util file structures.
The base struct of almost if not every file format using nn::util file structures.
{| class="wikitable"
{| class="wikitable"
Line 72: Line 72:
|}
|}


==== nn::util::BinaryBlockHeader ====
=== nn::util::BinaryBlockHeader ===
A common base struct of sub sections in nn::util based files.
A common base struct of sub sections in nn::util based files.
{| class="wikitable"
{| class="wikitable"
Line 102: Line 102:
|}
|}


=== Relocation Tables ===
== Relocation Table ==
Relocation tables are iterated to relocate pointers all throughout the BinaryFileHeader derived file. Converting the file into just a collection of structs in memory.
Relocation tables are iterated to relocate pointers all throughout the BinaryFileHeader derived file. Converting the file into just a collection of structs in memory.


==== nn::util::RelocationTable ====
=== NWPtr<T> ===
A template type to a pointer to type T that is relocatable by the relocation table. The size should match the address size in the file header, in Switch games this is almost always 64-bits.
 
=== nn::util::RelocationTable ===
{| class="wikitable"
{| class="wikitable"
!Offset
!Offset
Line 167: Line 170:
|}
|}


==== nn::util::RelocationTable::Entry (unofficial name) ====
===== nn::util::RelocationTable::Entry (unofficial name) =====
Immediately following the Section array is an array of information about relocation entries. Each entry defines a set of continuous pointer arrays with a stride between each array.
Immediately following the Section array is an array of information about relocation entries. Each entry defines a set of continuous pointer arrays with a stride between each array.
{| class="wikitable"
{| class="wikitable"
Line 196: Line 199:
|}
|}


=== Dictionaries ===
== Dictionary ==
 
=== nn::util::ResDic ===
A dictionary, each element must have a unique string key.
{| class="wikitable"
!Offset
!Size
!Type
!Description
|-
|0x0
|0x4
|u32
|Magic ("_DIC" in big-endian or 0x0)
|-
|0x4
|0x4
|u32
|Count (does not count root node, which is part of the header)
|-
|0x8
|0x10
|nn::util::ResDic::Node
|Root node (null key)
|-
|0x18
|0x10 * Count
|nn::util::ResDic::Node[Count]
|Node array
|}


==== nn::util::ResDic::ResDicNode (unofficial name) ====
==== nn::util::ResDic::Node (unofficial name) ====
An array of nodes immediately following the ResDic. The ref bit is used for a radix tree style lookup.
The ref bit is used for a radix tree style lookup.
{| class="wikitable"
{| class="wikitable"
!Offset
!Offset
Line 227: Line 259:
|}
|}


==== nn::util::ResDic ====
== StringPool ==
 
=== NWString ===
NintendoWare file string pointers are preceded by a u16 string length. The strings are also aligned to 2 bytes.
{| class="wikitable"
{| class="wikitable"
|+
!Offset
!Offset
!Size
!Size
Line 235: Line 271:
|-
|-
|0x0
|0x0
|0x4
|0x2
|u32
|u16
|Magic ("_DIC" in big-endian or 0x0)
|String Length
|-
|-
|0x4
|0x2
|0x4
|0x1 * String Length
|u32
|char[String Length]
|ResDicNode count (does not count root node, which is part of the header)
|String Data
|-
|0x8
|0x
|nn::util::ResDic::ResDicNode
|Root node (null key)
|}
|}


=== StringPool ===
=== nn::util::StringPool ===
 
Header that precedes the deduplicated string table.
==== nn::util::StringPool ====
Header that precedes string arrays in nn::util based files. Strings pointed to in nn::util files actually start with a u16 of the string length, to access the string "string + sizeof(u16)" must be performed.
{| class="wikitable"
{| class="wikitable"
!Offset
!Offset
Line 278: Line 307:
|0x4
|0x4
|u32
|u32
|String count
|String Count
|-
|-
|0x10
|0x10
Line 284: Line 313:
|u32
|u32
|Empty String entry (0x0000, 0x00)
|Empty String entry (0x0000, 0x00)
|-
|0x14
|
|NWString[StringCount]
|String region
|}
|}
[[Category:File formats]]
[[Category:File formats]]