BCSV (File Format)

From Wexos's Wiki
Jump to navigationJump to search

BCSV (Binary Comma Seperated Values) is a simple format for storing data tables. It is used a lot in Super Mario Galaxy and Super Mario Galaxy 2. The data is represented by rows, and the data is described by the columns.

File Format

Header

Offset Type Description
0x00 UInt32 Number of rows.
0x04 UInt32 Number of columns.
0x08 UInt32 Data offset. Points to the row data.
0x0C UInt32 Row data size. Size of the data of each row.

Column

After the header comes all the columns. Each has the following structure:

Offset Type Description
0x00 UInt32 Name hash.
0x04 UInt32 Mask.
0x08 UInt16 Row offset. Offset into each row which specify the data for this field. To get the actual data, if valid, first mask the data, then shift it right.
0x0A Byte Shift.
0x0B Byte Data type.
ID Type Description
0x00 Int32 32-bit signed integer.
0x02 Float 32-bit floating-point number.
0x03 UInt32 32-bit unsigned integer.
0x04 Int16 16-bit signed integer.
0x05 Byte 8-bit unsigned integer.
0x06 String 32-bit offset, relative to the start of the string table, which points to a Shift JIS encoded null-terminated string.

Hash

A list of known hashes can be found here respectively here. The hash algorithm is demonstrated by the following C# code:

public static uint CalculateHash(string Name)
{
  ushort Hash = 0;

  for (int i = 0; i < Name.Length; i++)
  {
    Hash *= 0x1F;
    Hash += Name[i];
  }

  return Hash;
}

Row

The rows consist of data. The data is specified by the columns. The string table comes after all row entries.

Tools

The following tools can handle BCSV files:

  • Whitehole, by StapleButter