TSCB and Help:Creating mods: Difference between pages

From ZeldaMods (Breath of the Wild)
(Difference between pages)
Jump to navigation Jump to search
imported>Zephenryus
 
imported>BravelyPeculiar
 
Line 1: Line 1:
<onlyinclude>
Welcome, modders! This page is intended to be a collection of useful information for anybody who wants to create mods. If you want to simply use other people's mods, see [[Help:Playing with mods]].
'''T'''errain '''sc'''ene '''b'''inary (TSCB) files describe terrain areas layout and terrain materials.
</onlyinclude>


== TSCB File Specification ==
== Getting set up ==
To make mods, you'll need to start by dumping the unedited game files from your copy of BotW.
* [[Help:Playing with mods#Wii U/Cemu|Dumping the game files (Wii U)]]
* [[Help:Dumping games|Dumping the game files (Switch)]]


=== Header ===
== Files, Tools and Tutorials ==
{| class="wikitable"
Since BotW uses a lot of Nintendo's own file formats, you'll need tools to be able to edit them. To use leoetlino's tools, you need to install the latest version of Python (64 bit version), and tick the "Add to PATH" / "Add to environment variables" box in the installer. Then, to install the tool, run <code>pip install TOOL_NAME</code> in the command line.
!Offset (h)
!Size
!Data Type
!Description
|-
|<code>0x00</code>
|4
|String
|TSCB file signature (magic) <code>54 53 43 42</code> or "TSCB"
|-
|<code>0x04</code>
|4
|Unsigned Int
|TSCB version? <code>0A 00 00 00</code> or "10.0.0.0"<ref>U-King.elf:0x024D2F8C-0x024D300A holds two error messages: "【データロード】メジャーバージョンの不一致" ("[Data load] Major version mismatch") and "【データロード】マイナーバージョンの不一致" ("[Data Load] Minor version mismatch")</ref><ref>Game crashes on load screen if not equal to <code>0A 00 00 00</code></ref>
|-
|<code>0x08</code>
|4
|Unsigned Int
|Unknown. Always <code>00 00 00 01</code>. Game crashes on load screen if not equal to <code>00 00 00 01</code>.
|-
|<code>0x0c</code>
|4
|Unsigned Int
|<code>file_base</code> table relative offset
|-
|<code>0x10</code>
|4
|Float
|<code>world_scale</code> <code>500.0</code>. Scales the terrain along the x- and z-axis.
|-
|<code>0x14</code>
|4
|Float
|Terrain mesh max height <code>800.0</code>. Used to calculate the actual vertex height with [[HGHT|hght]] data.
|-
|<code>0x18</code>
|4
|Unsigned Int
|<code>material_info_array</code> length (number of elements in the array)
|-
|<code>0x1c</code>
|4
|Unsigned Int
|<code>area_array</code> length (number of elements in the array)
|-
|<code>0x20</code>
|4
|Unsigned Int
|Probably padding
|-
|<code>0x24</code>
|4
|Unsigned Int
|Probably padding
|-
|<code>0x28</code>
|4
|Float
|<code>tile_size</code>. Used by the area array.
|-
|<code>0x2c</code>
|4
|Unsigned Int
|Unknown <code>00 00 00 08</code>. <ref>Values <code>1</code>, <code>2</code>, <code>4</code>, <code>5</code>, <code>6</code>, <code>8</code>, <code>9</code>, <code>10</code>, <code>13</code>, <code>14</code> affects textures. <code>0</code>, <code>3</code>, <code>7</code>, <code>11</code>, <code>12</code>, <code>15</code>, <code>16</code> will crash the game.</ref>
|}


== Material Information Array ==
If you're not sure which tool to use on a file, search for its extension on this wiki to find what file format that extension is used for.
The material information array references texture data contained in <code>content/Model/Terrain.Tex1.sbfres</code>.


=== Header ===
=== Yaz0 compression ===
The material information header is one value, the section size. This includes the index table and the value table.
Many files in the game are compressed with [[Yaz0]] compression. Compressed files generally have the letter <code>s</code> prefixed to their file extension. To decompress and recompress these files, use '''wszst''' (install with <code>pip install wszst-yaz0</code>).
{| class="wikitable"
* <code>wszst decompress INPUT_FILE.sbactorpack OUTPUT_FILE.bactorpack</code>
!Offset (h)
* <code>wszst compress INPUT_FILE.bfres OUTPUT_FILE.sbfres</code>
!Size
!Data Type
!Description
|-
|<code>0x00</code>
|4
|Unsigned Int
|Material info section size in bytes
|}


=== Material Information Array Lookup Table ===
=== SARC archives ===
Following the header is a table of relative offsets to each entry in <code>material_info_array</code>
[[SARC]] archives contain collections of other files and folders, like .zip folders. Unpack, edit and re-pack them with leoetlino's [https://pypi.org/project/sarc/ <code>sarc</code> tool]. This tool automatically decompresses Yaz0-encoded archives, and re-compresses them when you repack if the extension starts with an <code>s</code>.
{| class="wikitable"
* <code>sarc extract INPUT_FILE.pack</code>
!Offset (h)
* <code>sarc create [-b] INPUT_FOLDER OUTPUT_FILE.sbactorpack</code> (Use <code>-b</code>for Wii U only).
!Size
!Data Type
!Description
|-
|<code>0x00</code>
|4
|Unsigned Int
|Relative offset to array entry
|}


=== Material Information Value Table ===
=== BYML files ===
Each entry in the array contains an index and four attributes
[[BYML]] files contain game parameters. Convert them to an editable format (and back) with leoetlino's [https://pypi.org/project/byml/ <code>byml</code> tool]. This tool automatically decompresses Yaz0-encoded files, and re-compresses them if the extension starts with an <code>s</code>.
{| class="wikitable"
* <code>byml_to_yml INPUT_FILE.byml OUTPUT_FILE.yml</code>
!Offset (h)
* <code>yml_to_byml [-b] INPUT_FILE.yml OUTPUT_FILE.sbyml</code> (Use <code>-b</code> for Wii U only).
!Size
!Data Type
!Description
|-
|<code>0x00</code>
|4
|Unsigned Int
|Array index (<code>mat_index</code>) of <code>material_info_array</code>
|-
|<code>0x04</code>
|4
|Float
|Texture u-axis (x-axis)
|-
|<code>0x08</code>
|4
|Float
|Texture v-axis (y-axis)
|-
|<code>0x0c</code>
|4
|Float
|Unknown. values range from 0-1.
|-
|<code>0x10</code>
|4
|Float
|Unknown. values range from 0.2-1.63
|}


== Area Array ==
=== AAMP files ===
[[AAMP]] files also contain game parameters. Convert them to an editable format (and back) with leoetlino's [https://pypi.org/project/aamp/ <code>aamp</code> tool]. Unlike most other files, AAMP files are exactly the same on both Wii U and Switch.
* <code>aamp_to_yml INPUT_FILE.bxml OUTPUT_FILE.yml</code>
* <code>yml_to_aamp INPUT_FILE.yml OUTPUT_FILE.bgparamlist</code>


=== Area Array Lookup Table ===
=== BFRES files ===
Following the material information section is a table of relative offsets to each entry in area_array
[[BFRES]] files contain the game's models and textures. Tutorials on how to edit these for Wii U can be found in [https://drive.google.com/drive/folders/1Z1_A3w0VvPHp22H_Yh_dSdzI5hr4OAv9 Fooni's Tutorials].
{| class="wikitable"
* <code>.sbfres</code> files contain models.
!Offset (h)
* <code>.Tex1.sbfres</code> files contain textures (Wii U).
!Size
* <code>.Tex2.sbfres</code> files contain mipmaps for textures (Wii U). Since we can't edit these on Wii U yet, they need to be disabled.
!Data Type
* <code>.Tex.sbfres</code> files contain both textures and mipmaps (Switch). Unlike on Wii U, mipmaps don't cause any problems here.
!Description
|-
|<code>0x00</code>
|4
|Unsigned Int
|Relative offset to array entry
|}


=== Area Array Value Table ===
== Rules ==
Each entry contains meta data for one tile in the terrain scene. There are multiple levels of detail (lod) for the terrain.


Entries range from <code>0x30</code> to <code>0x54</code> depending on the size of <code>extra_info_array</code>
=== The RSTB file ===
{| class="wikitable"
The file [[ResourceSizeTable.product.rsizetable]] (referred to as the RSTB file) contains a list of size limits for almost every file in the game (calculated from the non-Yaz0-compressed file sizes). If you edit a file to make its filesize bigger, you'll need to edit this file to prevent errors. For details, see [[Help:Editing the RSTB]].
!Offset (h)
!Size
!Data Type
!Description
|-
|<code>0x00</code>
|4
|Float
|X Position
|-
|<code>0x04</code>
|4
|Float
|Z Position
|-
|<code>0x08</code>
|4
|Float
|<code>area_size</code> (length and width)
|-
|<code>0x0c</code>
|4
|Float
|Unknown - Affects grass density.<ref>0 may be default. Higher numbers have increased density.</ref>
|-
|<code>0x10</code>
|4
|Float
|Unknown
|-
|<code>0x14</code>
|4
|Float
|Unknown
|-
|<code>0x18</code>
|4
|Float
|Unknown
|-
|<code>0x1c</code>
|4
|Unsigned Int
|Unknown. Usually <code>0</code>, <code>1</code> or <code>2</code>, crashes on <code>4</code>, <code>16</code>.<ref>May be a flag for grass and water? <code>0</code> seems to indicate no water or grass.</ref>
|-
|<code>0x20</code>
|4
|Unsigned Int
|<code>file_base</code>. Relative offset to file base name string.
|-
|<code>0x24</code>
|4
|Unsigned Int
|Unknown. Usually <code>0</code>.
|-
|<code>0x28</code>
|4
|Unsigned Int
|Unknown. Usually <code>0</code>.
|-
|<code>0x2c</code>
|4
|Unsigned Int
|<code>ref_extra</code>. It seems to be a flag to indicate if there is an attached <code>extra_info_array</code>
|}


==== Parameters ====
=== File names and caching ===
<code>x</code> - Area tile x coordinate (East-West)
The game assumes that any 2 files with the exact same filename also have the exact same contents. If you don't follow this rule when editing files, the game might load the wrong version of the file, leading to errors.
 
<code>z</code> - Area tile z coordinate (North-South)
<code>area_size</code> - Determines the length and width of the area. It can be calculated with:<blockquote><code>(area_size / tile_size * world_scale) * 20</code></blockquote><code>tile_size</code> and <code>world_scale</code> are in the header.
 
=== Extra Information Array ===
if <code>ref_extra</code> does not equal <code>0</code> there is an <code>extra_info_array</code> attached to this area. The array is 4 or 8 values long.
 
Every area includes a [[HGHT|.hght]] and [[MATE|.mate]] file. The <code>extra_info_array</code> indicates if there is an additional [[Water.extm|.water.extm]] and / or [[Grass.extm|.grass.extm]] file
{| class="wikitable"
!Offset (h)
!Size
!Data Type
!Description
|-
|<code>0x30</code>
|4
|Unsigned Int
|extra_info_array length. Number of elements in array.
|-
|<code>0x34</code>
|4
|Unsigned Int
|Unknown. Usually 20 or 3.
|-
|<code>0x38</code>
|4
|Unsigned Int
|Unknown. Usually 0, 1 or 3.
|-
|<code>0x3c</code>
|4
|Unsigned Int
|Unknown. Usually 0 or 1.
|-
|<code>0x40</code>
|4
|Unsigned Int
|Unknown. Usually 0 or 1.
|-
|<code>0x44</code>
|4
|Unsigned Int
|Unknown. Always 0.
|-
|<code>0x48</code>
|4
|Unsigned Int
|Unknown. Always 3
|-
|<code>0x4c</code>
|4
|Unsigned Int
|Unknown. Usually 0 or 1.
|-
|<code>0x50</code>
|4
|Unsigned Int
|Unknown. Always 1.
|}
[20, 3, 0, 1, 0, 3, 1, 1] = water, grass
[20, 3, 1, 1, 0, 3, 0, 1] = water, grass
[ 3, 1, 1, 0]            = water
[ 3, 0, 1, 0]            = grass
It seems that water is <code>[3, 1, 1]</code> and grass is <code>[3, 0, 1]</code>
[20, `3, 0, 1`, 0, `3, 1, 1`] = grass, water
[20, `3, 1, 1`, 0, `3, 0, 1`] = water, grass
[`3, 1, 1`, 0]                = water
[`3, 0, 1`, 0]                = grass
 
== <code>stera</code> File Positions ==
[[File:Stera_File_Positions.png|alt=stera File Positions|thumb|<code>stera</code> File Positions]]
<code>stera</code> files referenced in the area array are positioned using a [[wikipedia:Z-order_curve|z-order curve]] or the [[wikipedia:Moser–de_Bruijn_sequence|Moser-de Bruijn sequence]].
<references />
[[Category:File formats]]
[[Category:File extensions]]
[[Category:File extensions (STERA)]]

Revision as of 15:56, 15 October 2018

Welcome, modders! This page is intended to be a collection of useful information for anybody who wants to create mods. If you want to simply use other people's mods, see Help:Using mods.

Getting set up

To make mods, you'll need to start by dumping the unedited game files from your copy of BotW.

Files, Tools and Tutorials

Since BotW uses a lot of Nintendo's own file formats, you'll need tools to be able to edit them. To use leoetlino's tools, you need to install the latest version of Python (64 bit version), and tick the "Add to PATH" / "Add to environment variables" box in the installer. Then, to install the tool, run pip install TOOL_NAME in the command line.

If you're not sure which tool to use on a file, search for its extension on this wiki to find what file format that extension is used for.

Yaz0 compression

Many files in the game are compressed with Yaz0 compression. Compressed files generally have the letter s prefixed to their file extension. To decompress and recompress these files, use wszst (install with pip install wszst-yaz0).

  • wszst decompress INPUT_FILE.sbactorpack OUTPUT_FILE.bactorpack
  • wszst compress INPUT_FILE.bfres OUTPUT_FILE.sbfres

SARC archives

SARC archives contain collections of other files and folders, like .zip folders. Unpack, edit and re-pack them with leoetlino's sarc tool. This tool automatically decompresses Yaz0-encoded archives, and re-compresses them when you repack if the extension starts with an s.

  • sarc extract INPUT_FILE.pack
  • sarc create [-b] INPUT_FOLDER OUTPUT_FILE.sbactorpack (Use -bfor Wii U only).

BYML files

BYML files contain game parameters. Convert them to an editable format (and back) with leoetlino's byml tool. This tool automatically decompresses Yaz0-encoded files, and re-compresses them if the extension starts with an s.

  • byml_to_yml INPUT_FILE.byml OUTPUT_FILE.yml
  • yml_to_byml [-b] INPUT_FILE.yml OUTPUT_FILE.sbyml (Use -b for Wii U only).

AAMP files

AAMP files also contain game parameters. Convert them to an editable format (and back) with leoetlino's aamp tool. Unlike most other files, AAMP files are exactly the same on both Wii U and Switch.

  • aamp_to_yml INPUT_FILE.bxml OUTPUT_FILE.yml
  • yml_to_aamp INPUT_FILE.yml OUTPUT_FILE.bgparamlist

BFRES files

BFRES files contain the game's models and textures. Tutorials on how to edit these for Wii U can be found in Fooni's Tutorials.

  • .sbfres files contain models.
  • .Tex1.sbfres files contain textures (Wii U).
  • .Tex2.sbfres files contain mipmaps for textures (Wii U). Since we can't edit these on Wii U yet, they need to be disabled.
  • .Tex.sbfres files contain both textures and mipmaps (Switch). Unlike on Wii U, mipmaps don't cause any problems here.

Rules

The RSTB file

The file ResourceSizeTable.product.rsizetable (referred to as the RSTB file) contains a list of size limits for almost every file in the game (calculated from the non-Yaz0-compressed file sizes). If you edit a file to make its filesize bigger, you'll need to edit this file to prevent errors. For details, see Help:Editing the RSTB.

File names and caching

The game assumes that any 2 files with the exact same filename also have the exact same contents. If you don't follow this rule when editing files, the game might load the wrong version of the file, leading to errors.