FAT32 Features/Limitations:
- Supports FAT32 formatted SD cards.
- Only cards formatted with 512B allocation blocks (i.e. 1 sector per cluster) are supported at this time. Support for multiple cluster sizes is probably on the TODO list.
- Only the root directory is supported. A hierarchical file system is on the TODO list.
- Long file names are not supported. Only 8.3 file names are supported. Long file names are NOT on the TODO list unless people really want them.
- IDE and floppy drives are not currently supported (they're on the TODO list)
- Only original SD standard cards are supported (not SDHC or SDXC). This is due to the hardware and will not change unless the hardware does.
- Kernel functions have been added for sector level access to the SD and file level access to the FAT32 file system and directory. Documentation will be added to the wiki soon.
- LOAD <filename> --- Reads a BASIC program from an ASCII text file on the SD card. Because of future plans for the BASIC interpreter, BASIC files are not going to be tokenized.
- SAVE <filename> --- Saves a BASIC program to an ASCII file on the SD card. The file must not exist before using this command. When the file is created, the date and time are taken from the FMX's real time clock, so be sure to set it properly using the SETTIME and SETDATE statements before you save a file (see the BASIC816 manual).
- BLOAD <filename> [, <address>] --- Load a binary file into memory. If an address is provided, the first byte of the file will start at that address. "Executable" file formats do not require a destination address (see below).
- BSAVE <filename>, <start>, <end> --- Save a block of memory from <start> to <end> (inclusive) to a file on the SD card. The file must not already exist on the SD card.
- BRUN <filename> --- Load and begin running an executable binary file on the SD card.
- DIR --- Display a directory listing.
- DEL <filename> --- Delete a file from the SD card.
- RENAME <original filename>, <new filename> --- Rename a file on the SD card changing <original filename> to <new filename>.
- Bytes 0--2: the ASCII text "PGX", serving as a signature.
- Byte 3: the byte 0x01. This is intended as a target version and CPU code. The upper 4 bits are the PGX file format version (0), and the lower 4 bits are the CPU code (1 for 65816).
- Bytes 4--7: the destination address in little endian format. The first byte of binary data will start loading to this address. It is also the location BRUN will call to start execution. So, however your code is laid out, to use PGX, the first byte of data should be executable.
- Bytes 8--EOF: The rest of the bytes are the data to load.
A few words of warning. The kernel calls I'm adding should be considered as moving targets. I intend to keep developing this file system code, which means the calls may have to change. Also you may find that they need improvements in some ways. Let me know! Additionally, I know of at least two other efforts to implement FAT support for the FMX. As those projects mature, we may decide it makes more sense to remove the kernel additions I've made and integrate one of those other libraries. Time will tell.
Also... THERE WILL BE BUGS! Expect things to go horribly wrong and back up all your files as you build them! This should be considered bleeding edge. If you run into a problem, please let me know. If possible, I'd prefer you filed an issue in the BASIC816 Github repository (or the Kernel_FMX repository if you're pretty sure it's a kernel issue). But you can let me know through Discord or the forum, if you prefer.
I wanted to get this rolled out to you, even in its current state, to try to help you get more out of your FMXs and the BASIC interpreter. I'm hoping these changes will make the computer more "real" for you all.
Links
- KERNEL.BIN, the flashable BIN file containing the latest kernel and BASIC
- BASIC816.PDF, the manual for BASIC816 on the C256 Foenix.
- PGXFile, a sample project that builds an executable PGX file.