I am trying to load a file from my Floppy into memory. I have everything set up and it works. The only problem I am having is that I don't know how to work out the FAT sector to load when I have the number of the Cluster in the FAT.
ie: I need an algorithm that I can supply the starting cluster number of the file and it gives me the sector of the Disk with that FAT entry in. I tried an algorithm I had but it doesn't work.
FAT Offset Algorithm
FAT Offset Algorithm
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Currently - Busy with FAT12 driver and VFS
Re: FAT Offset Algorithm
Look at MS manual of FAT.
Search with keywords: White paper FAT
Search with keywords: White paper FAT
If you have seen bad English in my words, tell me what's wrong, please.
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: FAT Offset Algorithm
Here's my basic algorithm (if you're looking for what I think you're looking for):
EntriesPerSector = BytesPerSector / BytesPerEntry;
Sector = (ClusterIndex / EntriesPerSector) + StartOfFAT;
Entry = (ClusterIndex % EntriesPerSector);
Keep it integer math and it should work for FAT16 and FAT32.
EntriesPerSector = BytesPerSector / BytesPerEntry;
Sector = (ClusterIndex / EntriesPerSector) + StartOfFAT;
Entry = (ClusterIndex % EntriesPerSector);
Keep it integer math and it should work for FAT16 and FAT32.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?