? SmileBASIC file format ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

SmileBASIC file format

Okay, one thing to note first: I didn't figure out the format of SB files. That was Trinitro21 who did that. I just wrote this document, which sums everything up in a easy to view and public way. Alright, so SmileBASIC has its own format for storing its files. There's 2 main formats of files, TXT and DAT. Both have a common header and a footer, but DAT files have a secondary header after the common header to store metadata like how many dimensions it has, how large each dimension is, and what kind of data it stores. All files are stored in SmileBASIC's ExtData archive stored on the SD card. The default folder is stored as ### in the ExtData, and filenames are prefixed with T or B, for Text and Binary, respectively.

Common Header

The basic part of every SB file is the common header. This contains things such as the username of who wrote it, how large the data stored is, and when it was last modified. The common header is 80 bytes long, but 16 bytes at the end are always zero, so it's assumed it's reserved space for extra stuff to be added later. All values are little-endian. Offset | Size (bytes) | Description ----------------------------------- &H00 | 2 | Always &H0100, probably a magic number of some sort &H02 | 1 | File type (00 = TXT, 01 = DAT) &H06 | 1 | Icon shown in the file chooser. For TXT files, 00 = TXT and 01 = PRG. For DAT, 00 = DAT and 01 = GRP &H08 | 4 | 32-bit value storing the size of the file, not including the common header or the footer &H0C | 2 | 16-bit value storing the year the file was last modified &H0E | 1 | 8-bit value storing the month the file was last modified &H0F | 1 | 8-bit value storing the day of the month the file was last modified &H10 | 1 | 8-bit value storing the hour the file was last modified &H11 | 1 | 8-bit value storing the minute the file was last modified &H12 | 1 | 8-bit value storing the second the file was last modified &H13 | 1 | If set to 04, the data after the header is zlib-compressed &H14 | 18 | The first author's NNID. This one isn't shown &H26 | 18 | The second author's NNID. This one is displayed in the project browser &H38 | 4 | The first author's blacklist ID. Used for controlling the blacklist editable in the project download area &H3C | 4 | The second author's blacklist ID

DAT Secondary Header

TXT and PRG files just put the text in the content area. The DAT and GRP files need a bit more info, of course. This secondary header stores information required by SB to understand the DAT file properly. Offset | Size (bytes) | Description ----------------------------------- &H50 | 8 | Always "PCBN0001", is the magic number for the DAT header &H58 | 1 | Data type (03 = 16 bit unsigned (colors), 04 = Signed 32 bit integers, 05 = 64-bit double (real)) &H5A | 1 | Number of dimensions (1-4) &H5C | 4 | 32-bit value storing the size of the first dimension &H60 | 4 | 32-bit value storing the size of the second dimension if applicable, otherwise anything (usually random data) &H64 | 4 | 32-bit value storing the size of the third dimension if applicable, otherwise anything (usually random data) &H68 | 4 | 32-bit value storing the size of the fourth dimension if applicable, otherwise anything (usually random data)

Footer

This is a 20-byte area at the end of the file. It appears to be a hash of some sort. It doesn't really matter (this area can be full of zeroes or just random data) until you try to upload the file to the server. This is why files imported through SBFM must be opened and saved before uploading. This definitely needs to be looked into, and if anyone has any ideas that make sense, be sure to comment.
Author
MasterR3C0RD
Updated
Rating
10 votes
Categories
Keywords
  • fileformat
  • sbfm
  • smilebasic
  • files
  • format
  • file
  • compression
  • dat
  • txt
  • prg
  • grp
9 Comment(s) CyberYoshi64 CyberYoshi64 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Well, that explains the 28 bytes on any DAT file when looking at their size in the file browser. dankrause dankrause Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Second Year My account is over 2 years old Website So I don't have access to any files exported from SmileBASIC, but if someone can provide me with a handful, I can probably figure out what that 20 byte footer is. JustGreat JustGreat First Month Joined in the very first month of SmileBASIC Source Website Avatar Taboo I didn't change my avatar for 180 days Website Night Person I like the quiet night and sleep late. Express Yourself Petit Movie Player's converter program has the exported PRG of the Movie Player included in the download. http://rei.to/PetitMovieCreator1.0.0.zip dankrause dankrause Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Second Year My account is over 2 years old Website Looks like it doesn't contain a 20 byte footer though. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself I'll get you one right now, should only take a second. EDIT: Here's 4, two of each file type: http://oboy.smilebasicsource.com:49000/brokenr3c0rd/sbfiles.zip Lemme know if you need any more. dankrause dankrause Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Second Year My account is over 2 years old Website My money is on an sha1 signature, meaning we'd need the signing key that SmileBASIC is using if we wanted to generate it. It should be possible to extract it from the .cia or .3ds file, but I'm not sure that's going to be easy. MasterR3C0RD MasterR3C0RD Helper Received for being very helpful around SmileBASIC Source Achievements Third Year My account is over 3 years old Website osu! Is Awesome! I love osu! Express Yourself I was trying to get someone to look through the code.bin in IDA Pro and find where the footer was, but they never ended up doing it sadly. snail_ snail_ QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Helper Received for being very helpful around SmileBASIC Source Achievements Amazing Contributor Someone thinks I'm an awesome person who has done so much for the community! Achievements The footer isn't apparently a SHA-1 of the file contents from what I can gather; no idea what you guys are on about a signature though. Yttria Yttria Head Admin SmileBASIC spends five years shuffling registers around with 1732584193 -271733879 -1732584194 271733878 -1009589776 loaded when saving files. "I ran a SHA-1 on it and it didn't work" isn't really helpful.