Views: 9,020,390 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
12-18-18 10:10 PM
Guest:

0 users reading BCSV format | 1 bot

Main - Trash - BCSV format Thread closed


StapleButter
Posted on 07-08-12 11:05 AM (rev. 4 of 08-25-12 08:22 PM) 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

tonks

StapleButter
Posted on 12-08-12 08:31 PM Link | #1649
Trashing this as there is now a wiki page for it.

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

tonks


Main - Trash - BCSV format Thread closed

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