There are a lot of issues I can imagine with this. First of all, some important functions, such as fat16_init and fat16_readRootDirEntry are inlined, so there is no way to call them. In addition, fat16_readRootDirEntry reads the very bottom of the stack for the filename (load_game appears to clobber the bottom of the stack at the very end of RAM by writing the filename---would these last 9 bytes ever be read once a game starts?), and always indicates failure if the file does not end in HEX or EEP.
Also, there is a reference to an external 512-byte buffer called "buff", which I couldn't find. The comment above it says:
- Code: Select all
/* This code has a rather big sector buffer of 512 bytes */
/* with this export, other code can use it, too */
(I couldn't search for it on github because apparently github doesn't search old commits and "buff" isn't found anywhere in current commits.) If this buffer is somehow used by game code, then the bootloader would clobber game data if it writes anything to it. I wasn't clear on what was going on with buff.
These are just a few problems that indicate that this might not work. However, I thought it was an interesting idea. In addition, even if it isn't possible to use directly, could it be possible to refactor the bootloader to expose a function that could be used to read arbitrary bytes from a file at no additional time cost for flashing, without exceeding the space constraints of the bootloader? This would allow games to read data files from the SD card for "free," since it would require almost no additional program code to do this. Could this affect backwards compatibility by changing the addresses of the other functions that are currently called by the Gamebuino library? I suppose it depends on the order of all the functions.
By the way, where is the official location of the bootloader now? I dug back through the commits of the gamebuino repo and found the commit titled "move /hardware to another repo," which deleted the bootloader folder. However, looking through the other repositories under Rodot, I couldn't find a hardware one. The wiki page is out of data too. Where has it gone?