Kuribo64
Views: 19,854,990 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
03-29-24 07:48 AM
Guest:

0 users reading BCSV format | 1 bot

Main - Trash - BCSV format Hide post layouts | Thread closed


Arisotura
Posted on 07-08-12 03:05 PM (rev. 4 of 08-26-12 12:22 AM) Link | #139
BCSV is a data format that is used a lot in SMG games. It is used to store all the level data, collision data, and lots of other things.

BCSV files can be seen like database tables. They define a number of fields, and then entries (rows) that contain values for the fields defined.

Given their important usage in SMG games, modifying BCSV files is a key part in SMG hacking.

BCSV files start with a header that is 16 bytes long:
OffsetSizeDescription
0x004Number of entries
0x044Number of fields
0x084Offset to data section
0x0C4Entry size
The header is followed by the fields, 12 bytes each:
OffsetSizeDescription
0x004Name hash
0x044Bitmask
0x082Offset of field within entry
0x0A1Shift amount
0x0B1Field type
A field's name hash is a simple hash of the field's name. Hashes are calculated this way:
[source=c#] public static uint FieldNameToHash(string field)
{
uint ret = 0;
foreach (char ch in field)
{
ret *= 0x1F;
ret += ch;
}
return ret;
}[/source]
For a list of known field names, you can look here: https://github.com/Mega-Mario/Whitehole/blob/master/src/Resources/KnownFieldNames.txt

The fields are then followed by the data section. The size of the data section should equal to Entry_size*Number_of_entries. The data section is then followed by the strings section.

Each entry in the data section is parsed accordingly to the fields defined:
* for types 0 and 3, a 32-bit value is read. The value is then ANDed with the bitmask and shifted right by the shift amount.
* for type 4, a 16-bit value is read. The value is then ANDed with the bitmask and shifted right by the shift amount.
* for type 5, a 8-bit value is read. The value is then ANDed with the bitmask and shifted right by the shift amount.
* for type 2, a single-precision float is read. The bitmask and shift aren't used. (note: according to Treeki, floats aren't type-dependent, however from what I've seen they always use type 2)
* for type 6, a 32-bit value is read and used as an offset into the strings section to read the actual string. The bitmask and shift aren't used. The string is encoded in Shift-JIS.

If I missed anything, feel free to let me know :)

____________________
NSMBHD - Kafuka - Jul
melonDS the most fruity DS emulator there is

zafkflzdasd

Arisotura
Posted on 12-09-12 01:31 AM Link | #1649
Trashing this as there is now a wiki page for it.

____________________
NSMBHD - Kafuka - Jul
melonDS the most fruity DS emulator there is

zafkflzdasd


Main - Trash - BCSV format Hide post layouts | Thread closed

Page rendered in 0.026 seconds. (2048KB of memory used)
MySQL - queries: 28, rows: 196/196, time: 0.009 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.