Resource system: Difference between revisions

Jump to navigation Jump to search
m
imported>Leoetlino
imported>Leoetlino
Line 69: Line 69:


=== Resource size table ===
=== Resource size table ===
The ''Resource Size Table'' (RSTB) contains information about game resource file sizes. It is loaded from [[ResourceSizeTable.product.rsizetable]] and used to determine how much memory should be allocated when loading a resource.
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 simple factories only used to allocate the file loading buffer (which is as large as the file to load), the C++ resource class and some extra bytes to ensure data is aligned correctly in memory.
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.


So a formula that should work for modifying the listed size is:
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 total amount of memory is not listed anywhere.
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)]]
Anonymous user

Navigation menu