SD card capabilities

Its actually not so bad. There is one bitmap drawing mode that was written in AVR asm that I haven’t converted. Otherwise it works.

2 Likes

I’m laughing right now because I know exactly what you’re talking about: Sprites::drawPlusMask().

It was the source of a recent bug that was particularly hard to squash, and I was one of the ones attempting to fix it.
(In the end the original author came along and fixed it, I only managed to make dents or shift the problem.)
It’s fixed now at least… (I hope.)

The function itself is fairly straight forward, it just looks scary because it’s written in assembly so it ends up being much longer.

When the Pokittos are delivered, if the Arduboy2 source is made public I’d gladly have a crack at porting that function (maybe even in assembly if need be, though the Pokitto doesn’t have the same code size constraints that the Arduboy has).

(I’m assuming it doesn’t run on the simulator because there’s already some ARM assembly being used in it.)


Anyway, long story short, @JuiceLizard’s “The Guy Who Never Complains” doesn’t use Sprites so it’ll run just fine.

2 Likes

All exists in the simulator already. I will add it to the repo.

2 Likes

So currently there is no way to create a file on the SD card? any files need to exist before hand? So a save file for example? or have I misread the info?

2 Likes

That was how I understood it also. You cannot create files because of the limitation of the PetitFS, but you can replace the contents of a file. So when you put your game in SD with your PC, you may want to create an mygame.sav or mygame.cfg there also.

I guess (?) this is the actual software: http://elm-chan.org/fsw/ff/00index_p.html. For pf_write there are these restrictions:

  • Cannot create file. Only existing file can be written.
  • Cannot expand file size.
  • Cannot update time stamp of the file.
  • Write operation can start/stop on the sector boundary only.
  • Read-only attribute of the file cannot block write operation
2 Likes

That library has a lot of restrictions for the sake of being small, but there are other SD libraries that I assume can probably be ported in the future that are more robust. I experimented with 3 or 4 SD libraries on the Gamebuino, and while they were big for the Atmega chip, I assume they shouldn’t be quite as heavyweight on the Pokitto. PetitFatFs is actually a subset of FatFs, which does have file creation abilities, so perhaps that could be ported.

Considering that the Arduino Zero uses a Cortex M0, and the arduino libraries include a full-featured SD library, we know it has already been done with this processor. I don’t know the hardware details of how the Pokitto’s sd card slot compares with how you would hook up an sd card reader to an Arduino Zero, so they may not have any direct compatibility and porting would still be required. Regardless, even if there’s no way to create files on the SD card now, I imagine games in the future will be able to use a different SD library that can do this.

3 Likes

Good to know! There is so much how community can improve Pokitto, when they get the HWs in their hands. I could imagine Pokitto being a very different (better!) animal after a year from now :slight_smile:

3 Likes

Using a different SD library is a piece of cake.

Just google “mbed SD library” and you’ll find almost all of the good ones are already available on the mbed also.

4 Likes

I’ve been thinking a little about the icons and things, if we go with a straight 16bit image, my direct tile function should be able to display them quite quickly. But would the icon and text be compiled into the .bin files, or will we be using a second (or more) file with that info?

1 Like

I’ve noticed, that seeking data from sd is much slower than reading it.

You should not design a system where tiles are constantly read from different parts of rhe sd. Some sort of cache is needed

1 Like

Are you using petitfatfs?

Yes. It’s modded petitfatfs. I added the file write properties.

1 Like

I did a minimal test where I streamed map data from the Gamebuino’s SD card, and it lagged with petitfatfs but not when I switched it to use SdFat instead. The fact that petitfatfs doesn’t have a buffer for file blocks is probably why, so perhaps using a different library will make a difference. I’m planning to do a test with the code when I get my Pokitto.

2 Likes

Yep. SDFat is faster.

3 Likes