Floppy disk layout.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
eXeCuTeR
Member
Member
Posts: 63
Joined: Tue Dec 09, 2008 12:43 pm

Floppy disk layout.

Post by eXeCuTeR »

As far as I know, the floppy disk layout consists of 4 sections: boot sector, fat tables, root directory, data area.
Now, there's a "formula" of calculating logical sector numbers into physical one which goes: 33 + logical sector - 2....my question is why the minus 2 is included?
The boot sector takes surprisingly 1 sector, 2 fat tables which take 9*2+1 sectors, 1 root directory that takes 33-19 sectors, and the data area goes from that part till the end of sectors...so what's up with this minus 2? as I've heard, it is because that 2 FAT table entries are reserved for the EOC mark and something that I forgot (remind me ;o) but the 2 FAT tables are located back at sectors 1-19, so how does this relate eventually?
User avatar
Firestryke31
Member
Member
Posts: 550
Joined: Sat Nov 29, 2008 1:07 pm
Location: Throw a dart at central Texas
Contact:

Re: Floppy disk layout.

Post by Firestryke31 »

It's because cluster numbering, for some strange reason, starts at 2 instead of 0. Thus, to get the real offset, you have to subtract 2 from the cluster and then can do the cluster to sector conversion.
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?
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: Floppy disk layout.

Post by kop99 »

the floppy disk layout consists of 4 sections
Isn't it fat layout?
And minus 2 is not absolute.
Generally, that value is 2, but follow BR sector's start cluster number field.
eXeCuTeR
Member
Member
Posts: 63
Joined: Tue Dec 09, 2008 12:43 pm

Re: Floppy disk layout.

Post by eXeCuTeR »

Firestryke31 wrote:It's because cluster numbering, for some strange reason, starts at 2 instead of 0. Thus, to get the real offset, you have to subtract 2 from the cluster and then can do the cluster to sector conversion.
That is the point...what is that strange reason that cluster/sector numbering starts at 2 instead of 0?
And another question...what does it exactly mean when saying root directory's sector?
manonthemoon
Member
Member
Posts: 65
Joined: Sat Jul 04, 2009 9:39 pm

Re: Floppy disk layout.

Post by manonthemoon »

Well, I'm assuming you already read FAT. At the very bottom is an external link to the FAT specs directly from Microsoft.
Microsoft wrote: The first data cluster is cluster 2.
@kop99: The first data cluster is always 2, according to the document. It is an absolute constant. What you're thinking of is the offset of the root cluster, which defaults to 2, but can be moved up to skip over bad clusters.
eXeCuTeR wrote:what is that strange reason that cluster/sector numbering starts at 2 instead of 0?
Again, do a little research and actually read the docs.
Microsoft wrote:The first reserved cluster, FAT[0], contains the BPB_Media byte value in its low 8 bits ... ... The second reserved cluster, FAT[1], is set by FORMAT to the EOC mark. ... ... ... (read the doc for more details)
Basically there are two clusters in the FAT that don't correspond to real clusters because they hold codes. You must subtract 2 to get the physical cluster number because the two reserved ones are just placeholders in the FAT.
And another question...what does it exactly mean when saying root directory's sector?
The sector on the disk that holds the root directory. What don't you understand? The root directory is like A:\ or C:\. It holds entries that point to all the other directories and files at the root level.
Post Reply