Resource system: Difference between revisions
Jump to navigation
Jump to search
m
→Resource size table
imported>Leoetlino |
imported>Leoetlino |
||
Line 69: | Line 69: | ||
=== Resource size table === | === Resource size table === | ||
The ''Resource Size Table'' (RSTB) contains | The ''Resource Size Table'' (RSTB) contains a list of canonical resource names and their sizes. It is loaded from [[ResourceSizeTable.product.rsizetable]] and used to determine how much memory should be allocated when loading a resource. | ||
It is currently unknown how Nintendo has determined the values in the RSTB. However by REing the resource system it was found that the resource loading heap is for | It is currently unknown how Nintendo has determined the values in the RSTB. However by REing the resource system it was found that the resource loading heap is, for most factories, only used to allocate the file loading buffer (which is as large as the file to load), the C++ resource class, extra allocations depending on the resource class and some extra bytes to ensure data is aligned correctly in memory. | ||
Therefore, the following formula should give a correct size value for all resource types: | |||
(size rounded up to multiple of 32) + CONSTANT + sizeof(ResourceClass) + PARSE_SIZE | (size rounded up to multiple of 32) + CONSTANT + sizeof(ResourceClass) + PARSE_SIZE | ||
Line 79: | Line 79: | ||
CONSTANT is 0x168 in the Switch version and 0xe4 on Wii U. | CONSTANT is 0x168 in the Switch version and 0xe4 on Wii U. | ||
PARSE_SIZE is the amount of memory allocated from the resource heap in the <code>Resource::parse</code> function. Determining the exact value of PARSE_SIZE requires reversing that function and tracking calls to <code>operator new()</code> because the | PARSE_SIZE is the amount of memory allocated from the resource heap in the <code>Resource::parse</code> function. Determining the exact value of PARSE_SIZE requires reversing that function and tracking calls to <code>operator new()</code> because the amount of dynamically allocated memory depends on the resource. | ||
[[Category:Internals]] | [[Category:Internals]] | ||
[[Category:Subsystems (BotW)]] | [[Category:Subsystems (BotW)]] |