BFT Sprite File Data Structure ============================== by: SilSinn9801 (a.k.a. Silent Sinner in Scarlet), 2019.05.01 This data structure applies to sprite files with the following file extensions: .BB1 .BB2 .BB3 .BB4 .BFT Offset Length Value Type +-------+-------+---------------+------------------------------------------------ 0x0000 0x0004 0x42464E54 FourCC = 'BFNT' 0x0004 0x0001 0x1A ??? 0x0005 0x0001 0xpi Nibble field: 0xp# (4 MSB) Indicates presence of a palette: 0x0# Has no color palette (or uses external palette) 0x8# Has internal palette 0x#i (4 LSB) Palette index's bitdepth (in bits minus one): 0x#0 monochrome (1-bit; used for gaiji font) 0x#3 16 colors (4-bit; the majority use this) 0x0006 0x0001 0x16 ??? 0x0007 0x0001 0x00 ??? 0x0008 0x0002 0xwwww Sprite width (in pels; little endian) 0x000A 0x0002 0xhhhh Sprite height (in pels; little endian) 0x000C 0x0002 0x0000 ??? 0x000E 0x0001 0xss Number of sprites (minus one): 0x00 1 sprite 0x02 3 sprites 0xFF 256 sprites (0xFF = 255) 0x000F 0x0001 0x00 ??? 0x0010 0x0008 0xnnnnnnnn... Filename (null-terminated, up to 7 bytes long; unused bytes after 0x00 set to 0x20) 0x0018 0x0008 (random data) Unknown purpose (contents differ among all examples studied by me) +-------+-------+---------------+------------------------------------------------ If file has internal palette (most-significant 4-bit nibble p @ 0x0005 = 8): Offset Length Value Type +-------+-------+---------------+------------------------------------------------ 0x0020 0x0003m 0xb0r0g0(×m) m = 2^(i+1) where i = least-significant 4-bit nibble @ 0x0005 b = Blue value (4-bit) r = Red value (4-bit) g = Green value (4bit) +-------+-------+---------------+------------------------------------------------ Bitmap pixel data immediately follows header (and internal palette, if any); pixels run from left to right within a line (with no zero padding at the end of each line, as in Windows BMP where lines have to be 16-bit-word-aligned); pixel lines run from top to bottom (unlike BMP where lines actually run from bottom to top). With no palette, bitmap data starts at 0x0020. With 4-bit palette (3×16 bytes long), bitmap data starts at 0x0050.