Position within a file. So if you have a filesystem structure set up to read the file, you can jump around in that file using positions obtained by these functions. This may become important in games with huge data files (several megabytes), since with FAT, you can only seek from the beginning, and forward, which is slow if you need something far inside the file (at every cluster boundary, the FAT has to be checked for the next cluster's location, so for example to position at 1Mb in a file with a typical cluster size of 4K requires 256 SD sector reads). So if you have a multi-megabyte data file, you might need this to cache positions to reduce loading times.nicksen782 wrote: ↑Sun Aug 12, 2018 5:22 pmI've got the memory swaps working. I have a question about FS_Get_Pos() and FS_Set_Pos(). Do they store the start position of the file or do they store a position within a file?
What it exactly is isn't that important, rather how it has to be used. Normally it is indeed a cluster, but if only the old bootloader is present, that will actually be a sector (as the fragmentation-unaware code doesn't even have the concept of clusters). You get this value by FS_Get_File_Cluster() or FS_Find, to use it as a parameter to FS_Select_Cluster to start accessing a file. Of course you can store it away during the game, but you shouldn't ever save it into a data file or EEPROM (regardless of the bootloader, the file might be elsewhere on the card next time).nicksen782 wrote: ↑Sun Aug 12, 2018 5:22 pmWhat is t32 here? Is this the first cluster of the file? I just want to make sure since it appears that way and it is not part of sd_struct.
So combined with the above, if you want to cache multiple files and pointer within them during a game, you stash away the cluster obtained by FS_Get_File_Cluster() or FS_Find() to allow you quickly selecting the file again any time later by FS_Select_Cluster(). If your files are large, you can use FS_Get_Pos() to extract positions other than the beginning of the file, which you can stash away for later use by FS_Set_Pos(). When using FS_Set_Pos(), the correct file has be selected with FS_Select_Cluster() first (regard them like fancy offsets into the file which have no meaning without the right file being selected, also, don't save these either to permanent storage).
Yes, that's it.nicksen782 wrote: ↑Sun Aug 12, 2018 5:22 pmLet's say you seek to a sector (multiple of 512) and you want byte 500. You would need to get that whole sector and skip bytes until byte 500, right? It looks like the sector gets written to ->bufp. Could I just do sd_struct.bufp[500]? Again, I just want to make sure.