-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added FAT32 Saving, File creation and deletion, and full-sector writes. #5
base: master
Are you sure you want to change the base?
Conversation
I tried this, but it doesn't quite work yet.
Like I said earlier, none of this code is tested yet, but here it is.
it requires another 512-byte buffer called "buffer" though...
also, the diffs aren't rendering correctly... |
Nice! I'll check it out when I can. I actually recently wrote some FAT32 writing code for a 6502 machine, but in BASIC - it'll be interesting to compare! I think for that I used two 512-byte buffers, mostly for safety reasons so that I could compare the FAT with its backup before writing anything. I can't think of a case where you definitively need more than one buffer though. |
Yeah, so what happened was I needed to write the cluster data, and then right after, update the FAT in memory. And at the end, I would update the SD card's FAT from that second buffer. For the most part, it just speeds up the process a ton, instead of having to write the FAT over and over again.
Awesome! I haven't yet set up the backup table, for now, it just writes to the first one. |
Actually, should I merge |
I wouldn't merge them - extending a cluster chain is a useful operation in its own right, e.g. for extending a directory you want to allocate an extra cluster and extend the chain, but you don't update a dirent. In my implementation I allocate my clusters first (writing the FATs), then update the directory entry to point to the new cluster chain. But my use case is simple as I'm only creating new files, and I know up front how many clusters to allocate. From what I've seen, Windows seems to silently update the backup FAT(s) without registering any errors or requiring a manual filesystem check/repair. But it's fairly easy to support this - just whenever you're writing a sector to the FAT, if mirroring is enabled, also write it to the backups which are at consistent offsets from the primary FAT. |
Great Ideas! I'll experiment with those things at some point soon... |
ok. I'll start experimenting with this now in this file: https://github.com/liaminventions/XPL-32/tree/main/xa/libfat32.a65 |
alright, I added fat mirroring (if numfats=2) and finally got rid of "buffer"! I just need to change the syntax to match how it is here... |
OK! That's done. Now I'll update the MD files and restore the example back to how it was before. |
Done! Should I add a saving/deleting example program? |
hold on, this may or may not have a bug in it, it seems the SD is not readable by other computers and I cant RM? (one moment) It was fine yesterday... |
Thanks! I was also actually working on a DOS too. (it doesn't have a repo yet, just made for the XPL-32 for now.) its here |
Cool man, we should chat - the code for my ebadger6502 is here: https://github.com/ebadger/msbasic My project is documented here: and here: @gfoot George, thinking maybe we should make a stand alone SD-DOS for the BE6502 |
whoops! i'll fix that now... |
.done | ||
rts | ||
|
||
; FAT32/SD interface library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any idea why the diff is completely broken? Did you change file format or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, it must have changed when I pulled to linux (that's what I suspect anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that's probably what it is. since this was pulled to ext4 instead of nfts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's a utf-8 vs utf-16 thing? Would be nice to fix so we get real diffs. I'm pulling into VScode to diff for my own purposes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just checked this, all the files are in utf-8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, maybe that's not the issue. when I cloned the original repo, it was in utf-8 as well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, yes I have figured out why. line endings. these files used to have DOS line endings
there is one bug here that I can't quite track down yet. It might be just on the XPL-32, or it might be here. it seems that if I load this file and then save it, it gets strangly distorted. as in, 256 bytes were removed at index 0x200-0x2f0, and then 256 0x00s added at the end. i had been investigating this bug all day though, so I'll come back to it soon (gn) |
I have added a saving example program called |
by the way, I'm now sure that that bug (the file-distorting one) is here and not just on the xpl. I wrote a program that uses the libraries from this PR and it fails in the same way... |
all right! I've fixed the bug! I just forgot a |
sorry for the absence, I've been busy with many other things. hopefully I'll get back to this soon. |
This is fully functional and has been tested on my homebrew 6502 laptop (the XPL-32).
It does need another 512-byte buffer for the FAT in the RAM though...
Is this out of the scope of this project?