Scheduled system upgrade on Sunday 21 April 2024 15:00-16:00 UTC - On that day, the wiki and other services might go down for 5-15 minutes.

ResourceSizeTable.product.rsizetable and Draft:Content/Actor: Difference between pages

From ZeldaMods (Breath of the Wild)
(Difference between pages)
Jump to navigation Jump to search
imported>BravelyPeculiar
No edit summary
 
imported>BravelyPeculiar
 
Line 1: Line 1:
<onlyinclude>
<onlyinclude>
{{Resloc|path=System/Resource/ResourceSizeTable.product.rsizetable}}
The '''Actor''' directory contains files defining [[Actor|actors]].
'''ResourceSizeTable.product.rsizetable''' is the file where the [[resource size table]] is stored.
</onlyinclude>
</onlyinclude>
== Content/Actor ==
{{cs|target=ActorInfo.product.sbyml}}
{{cs|target=Content/Actor/Pack|text=Pack}}


== Editing ==
== [[TitleBG.pack]]/Actor ==
The resource size table must be edited when making game files larger than they originally were, in order to avoid crashes. It can be edited using [https://github.com/leoetlino/rstb <code>rstb</code>].
{{cs|target=Content/Actor/AS#TitleBG.pack/Actor/AS|text=AS}}
{{cs|target=Content/Actor/Pack#TitleBG.pack/Actor/Pack|text=Pack}}


== Structure ==
== [[Bootup.pack]]/Actor ==
Sections are listed in the order they appear in the file.
=== [[ActorParam directories]] ===
Contains dummy ActorParam configuration files containing default values. They are used as a fallback when loading actors. The "ActorLink" directory is not present here.


=== Header (optional) ===
=== AIDef ===
<syntaxhighlight lang="c++">
Directory containing [[AIDef_Game.product.sbyml]].
struct RstbHeader {
=== Effect ===
  u32 magic;          // 'RSTB'
Directory containing [[EffectInfo.sbyml]].
  u32 crc32TableSize;  // number of entries - can be 0 to indicate there is no crc32 table
=== Sound ===
  u32 nameTableSize;  // number of entries - can be 0 to indicate there is no name table
Directory containing [[Sound.sbyml]].
}; // sizeof() = 12
=== XLink ===
</syntaxhighlight>
Directory containing [[XLinkInfo.sbyml]].
 
{{cs|target=Content/Actor/Pack#Bootup.pack/Actor/Pack|text=Pack}}
If the header is missing or if the magic is not correct, the game will assume there is simply no header. In that case, the game will use the size of the RSTB file, divide it by 8 to get the number of crc32 table entries and assume the whole file is a crc32 table.  
 
=== CRC32 table (optional) ===
This is a mapping of CRC32 values to resource sizes. The table must be sorted; otherwise the game will not be able to search for entries properly.
 
<syntaxhighlight lang="c++">
struct RstbCrc32TableEntry {
  u32 crc32;
  u32 size;
};  // sizeof() = 8
</syntaxhighlight>
 
=== Name table (optional) ===
This is a mapping of resource paths (strings) to resource sizes. This table is optional and is used whenever there would be conflicts in the crc32 table. Only usable if there is a RSTB header.
 
<syntaxhighlight lang="c++">
struct RstbCrc32NameEntry {
  char name[128];
  u32 size;
};  // sizeof() = 132
</syntaxhighlight>
 
== Game usage ==
The table is loaded very early in the app init process by ResourceInfoContainer (part of [[res::ResourceMgrTask]]) when the resource task starts and queried by the resource system and several other [[subsystems]] afterwards.
 
=== Lookup logic ===
<code>ResourceInfoContainer::getResourceSize</code> (non official name) starts by computing the CRC32 for the resource name/path.
 
Note: Resources that are ''explicitly'' loaded from the add-on content file device will have <code>Aoc/0010/</code> prepended to their resource path on Switch and Wii U as explained in the [[resource system]] article.
 
If a CRC32 table is present, the game will perform a binary search to find an entry for the calculated hash. If an entry is found, <code>entry.size</code> is returned.
 
Otherwise, if a name table is present, the game will go down the table until an entry that matches the specified resource name is found. If an entry is found, <code>entry.size</code> is returned.
 
Otherwise, the game returns 0.
 
=== Checks ===
The RSTB is queried by several subsystems:
* TipsMgr and EventResource use it only to check if the file they want to load exists (by checking if ret != 0).
* EffectResource, when loading Effect/Game.esetlist: must not be zero.
* VfxResourceMgr, when loading Effect/%s.esetlist files: must not be zero.
* bfres loading code at 0x7100FE3978 (v1.5.0): unclear, but must not be zero. It appears to check whether the file size listed in the RSTB is larger than the heap size.
* res::ResourceMgrTask::getHeapSizeForResLoad (0x710120BDE0 in v1.5.0): called during resource load.<syntaxhighlight lang="c++">
constant = 0x128 + 0x40;
if (auto* entry_factory = dynamic_cast<res::EntryFactoryBase*>(factory))
  resSize2 = entry_factory->getResourceSize(param->factory) + constant;
else
  resSize2 = sizeof(sead::DirectResource) + constant; // 0x20 + 0x168 = 0x188
 
totalSize = in->allocSize + resSize2;  // in this branch, in->allocSize seems to be always zero...
if (totalSize <= sizeInTable)
  out->readHeapSize = loadDataAlignment + sizeInTable + sizeof(void*);
else
  out->readHeapSize = (unsigned int)(float)(loadDataAlignment + totalSize + sizeof(void*));
</syntaxhighlight>
* 0x7100FE1630 (v1.5.0): unclear. If the file is loaded by the resource memory or loading thread, or if the file size listed in the RSTB is larger than a TempResourceLoader field, the game prints: "Texture archive size: %u MB" (translated from Japanese).
 
[[Category:Content (BotW)]]
[[Category:File formats]]

Revision as of 12:57, 2 April 2019

The Actor directory contains files defining actors.

Content/Actor

ActorInfo.product.sbyml

This file is not listed in the game's resource size table.

ActorInfo.product.sbyml (found in the Actor directory) is a Yaz0-compressed BYML file which contains general information about all actors in the game. It is used when constructing actors, and also used to access actor data efficiently when loading the full actor pack is unnecessary (e.g. on menu screens). Therefore, in order to add new actors, or to change items' parameters on menu screens, this file must be edited.

ActorInfo is a machine generated file. It is not meant to be edited directly; much of the information it includes are either automatically generated or copied from ActorParam files (which can be found in the game content) and other source-only files.

Pack

Contains archives defining parameters for actors.

TitleBG.pack/Actor

AS

The Actor/AS directory contains bas animation reference files used by actors. The actual animations are not stored here.

Pack

Contains archives defining parameters for actors.

Bootup.pack/Actor

ActorParam directories

Contains dummy ActorParam configuration files containing default values. They are used as a fallback when loading actors. The "ActorLink" directory is not present here.

AIDef

Directory containing AIDef_Game.product.sbyml.

Effect

Directory containing EffectInfo.sbyml.

Sound

Directory containing Sound.sbyml.

XLink

Directory containing XLinkInfo.sbyml.

Pack

Contains archives defining parameters for actors.