MsbtLib

MSBT Library by GingerAvalanche on GitHub.

About MsbtLib

MSBT (Message Standard Binary Table) is Nintendo's text container format. This library parses the binary format into editable C# classes that can be serialized to a pseudo HTML markup or back to binary.

Usage

Usage examples for reading, writing, and editing MSBT files using MsbtLib.

Reading

Reading from a FileStream

using MsbtLib;

using FileStream fileStream = File.OpenRead("C:/ExtractedMsbt/Msg_USen.product/ActorType/ArmorHead.msbt");
MSBT msbt = new(fileStream);

Reading from a byte[] (example from a SarcFile)

using MsbtLib;
using Nintendo.Sarc;
using Nintendo.Yaz0;

SarcFile bootup = new(File.ReadAllBytes("D:/Botw/Update/content/Pack/Bootup_USen.pack"));
SarcFile langPack = new(Yaz0.Decompress(bootup.Files["Msg_USen.product.ssarc"]));
MSBT msbt = new(langPack.Files["ActorType/ArmorHead.msbt"]);

Reading from a pseudo HTML string

Documentation in progress.

Editing

using MsbtLib;

.. .. ..

// Deserialize the texts into a generic Dictionary
Dictionary<string, MsbtEntry> texts = msbt.GetTexts();

// Setting an attribute
texts["Armor_001_Head_Name"].Attribute = "NewHylianHoodAttribute";

// Setting localized text
texts["Armor_001_Head_Name"].Value = "New Hylian Hood Name";

// Adding a new entry
texts["Armor_001_Head_Name_New"] = new("", "New Head Armor Name");

// Set the modified texts
msbt.SetTexts(texts);

Writing

Writing to pseudo HTML

using MsbtLib;

.. .. ..

// Using texts from 'ActorType/ArmorHead.msbt'
Console.WriteLine(texts["Armor_063_Head_Desc"].Value);
Zora headgear made from dragon scales.
Increases swimming speed and allows you to
<color=Blue>spin</color> to attack underwater. A Great Fairy has
increased its defense by three levels.

Valid HTML Tags:

  • Animation - <animation=[name] />

  • Auto-Advance - <auto_advance=[num_frames] />

  • Font - <font=[face] /> (Only Normal and Hylian)

  • Icon - <icon=[character] /> (Some characters require numbers, e.g. A(10))

  • Pause for a number of frames - <pauseframes=[num_frames] />

  • Pause for a duration - <pauselength=[duration] /> (Only Short, Long, or Longer)

  • Set Text Color - <color=[color]> (Only Red, LightGreen1, Blue, Grey, LightGreen4, Orange, or LightGrey)

  • Reset Text Color to Default - </color>

  • Text Size - <textsize percent=[num] /> (Use <textsize percent=100 /> to reset)

Extra Info

Writing to a file

using MsbtLib;

.. .. ..

msbt.Write("C:/ExtractedMsbt/Msg_USen.product/ActorType/ArmorHead_edited.msbt");

Writing to a byte[] (continued example from 'Reading from a byte[]')

using MsbtLib;
using Nintendo.Sarc;
using Nintendo.Yaz0;

.. .. ..

langPack.Files["ActorType/ArmorHead.msbt"] = msbt.Write();
bootup.Files["Msg_USen.product.ssarc"] = Yaz0.Compress(langPack.ToBinary());
File.WriteAllBytes(bootup.ToBinary());

Download

The C# implementation of MSBT can be downloaded from GitHub - Direct Download

Credits @Kyle Clemens - Original Rust Implementation @GingerAvalanche - C# Implementation and Usage Instructions

Last updated