MB128 protocol documented ? May 20, 2019 20:17:57 GMT
Post by elmer on May 20, 2019 20:17:57 GMT
I didn't know that Private Eye Dol did a scan for free space... but I am wary of the fact that they are using a 2-relative numbering system and everybody else is using 0-relative. I worry that they'd wipe out somebody else's saves.
Nope, from my reading of it, the code is fine, and won't destroy anyone else's data.
I don't think that you're right about those 2 bytes being a first-free-sector marker.
Both mooz (from his github documentation), and I, believe that they're a count of the total number of sectors in use by file data.
It looks like ED includes the 2 directory sectors in that count (and so the value goes from $0002..$0100), wheras Private EyeDol doesn't include the 2 directory sectors (and so the value goes from $0000..$00FE).
The code itself doesn't actually ever *use* that value for anything, it's just information ... all file operations (including finding fragments) are done by parsing the file entries and checking starting-sector and sector-count values vs the next file's starting sector (directory entries are stored in order).
Anyway, that explains why those other games think that when Private EyeDol has just formatted the MB128, that there is no space left.
I expect that those games are just checking the low-byte of the "used" count and are thinking that they're seeing the low-byte of $0100 .. i.e. all sectors used (in ED's counting method).
It also explains why those games will work fine once you've got one-or-more files on the MB128 so that the low-byte isn't zero anymore, and the regular "scan for fragments" logic will apply.
It also explains why the games that warn the user about there being no free space, will actually load/save properly when they go to scan the directory to find enough free space for their file.
Basically ... that total-sectors-used value is absolutely pointless in a file system that can suffer fragmentation, but doesn't allow fragmented file data.
The designers really should have implemented a FAT, IMHO.