Wednesday, October 17, 2012

Floppy Disk Useful Storage Space

Standard DOS PC Game formats use the following :

160KB Floppy - 40 tracks x 8 sectors x 512 bytes per sector = 163,840 bytes
180KB Floppy - 40 tracks x 9 sectors x 512 bytes per sector = 184,320 bytes
320KB Floppy - 40 tracks x 8 sectors x 2 sides x 512 bytes per sector = 327,680 bytes
360KB Floppy - 40 tracks x 9 sectors x 2 sides x 512 bytes per sector = 368,640 bytes
720KB Floppy - 80 tracks x 9 sectors x 2 sides x 512 bytes per sector = 737,280 bytes
1.2MB Floppy - 80 tracks x 15 sectors x 2 sides x 512 bytes per sector = 1,228,800 bytes
1.44MB Floppy - 80 tracks x 18 sectors x 2 sides x 512 bytes per sector = 1,474,560 bytes

All disks intended for 720KB and lower capacities are referred to as Double Density (DD).  1.2MB and 1.44MB disks are referred to as High Density (HD).  No game ever came on a 2.88MB floppy, which uses 36 sectors per track and Extra High Density Disks.  I am not aware of any games that came on a DMF formatted disk from Microsoft.  The DMF format allowed 1.68MB on a 3.5HD floppy, using 21 sectors per track but having double or quadruple cluster sizes and only 16 root directory entries.

Now the above shows the maximum available disk space using the standard formatted capacities.  These also are the exact sizes for standard img/ima disk image files.  Anything else is under/overdumped, protected or compressed.  However, when a disk is formatted in MS-DOS, the FAT-12 file system takes up a certain amount of space given above.  So, with a standard format, the usable space works out to be the following :

160KB Floppy - 158,720 bytes or 96.875% of theoretical capacity
180KB Floppy - 179,200 bytes or 97.222%
320KB Floppy - 322,560 bytes or 98.438%
360KB Floppy - 362,496 bytes or 98.333%
720KB Floppy - 730,112 bytes or 99.027%
1.2MB Floppy - 1,213,952 bytes or 98.792%
1.44MB Floppy - 1,457,664 bytes or 98.854%

So what takes up all that space that you cannot use?

All floppy and hard disks have their first sector reserved by the file system.  This sector is called the Master Boot Record (MBR) or the Boot Sector.  This tells the system if the disk is bootable and DOS that it is a DOS compatible disk.  Then floppy disks have two copies of the File Allocation Table (FAT) for redundancy.  The FAT indicates on which sector each file starts and how many sectors the file takes on the disk.  Each FAT copy can take 1-9 sectors, with 160K & 320K disks taking 1 sector, 180K and 360K disks 2 sectors, 720K disks 3 sectors, 1.2MB disks 7 sectors and 1.44MB disks taking 9.  The FAT maps all clusters on the disk using a 12-bit number.  .

Finally, the root directory entries have a certain number of sectors allocated to them, from 4-14 sectors.  Each directory entry takes 32 bytes and includes the file name and extension, the file attributes (read only, hidden, system, archive), date and time of creation or last modification, starting cluster and file size in bytes.  Single sided DD disks default to 64 root directory entries (4 sectors used), double sided DD disks 112 entries (7 sectors used) and HD disks 224 entries (14 sectors used).  An entry can be a file or a subdirectory with DOS 2.0 or higher.   This limit only applies to the root directory such as A:\ or B:\, a subdirectory like A:\MYDOCS\ can have any number of files in it.

So, for a 360K disk, 1 sector is used by the MBR, 4 sectors for the FAT and 7 sectors for the root directory entries.  368,640 bytes - (12 sectors x 512 bytes/sector) = 362,496 bytes.

But why cannot I fill every byte of that disk with data?

This is where the FAT cluster size comes into play.  Cluster sizes for all double sided non-HD floppy formats is 2 sectors.  So a file that is one byte large will take 1,024 bytes on the disk, as would a file that is 900 bytes large.  A file that is 1,025 bytes long will take 2,048 bytes on the disk, and the extra space is wasted.  On a 360KB floppy, you could never have more than 354 files on that disk, since 362,496/1,024 is 354.  Single sided DD floppy formats, HD floppy formats, excluding the 2.88MB and DMF floppies, use a cluster size of 1 sector.  So on a 1.44MB floppy, you could have 2,847 files on the disk, if each were no more than 512 bytes large.  The cluster size is not intended to be changeable.

But I need to squeeze just 1KB more!

So, you are finding how tight floppy drive space is, eh?  Well, if you cannot feel you can work without an extra 1-2KB, you need to modify the default format.  The safest was to do this is to reduce the number of root directory entries supported.  If you will never need to put more than 16 files on the disk, then you can gain 3KB extra space and not have to worry about DOS complaining it cannot recognize the disk format.

If you really wanted to push the envelope, you could eliminate the second FAT, but if a bad sector develops in the first FAT, your disk will be unreadable.  Plus you will only gain 1K more on double density media.  So for a 360K disk, if you went to the total extreme of having only 1 FAT table and no more than 16 root directory entries, the usable space would be 366,592 bytes.

How to tell if a disk image is really original :

A disk image will contain a OEM ID string starting with byte 3 in the image file.  It will be something like IBM  3.1, TAN 3.2, MSDOS5.0.  However, images can also contain strings like WINIMAGE or VFD2.1.  These labels are created when the WinImage or Virtual Floppy Drive program makes a new disk image and are obviously not original.  More expert eyes will quickly look at the boot sector to determine whether an image is original or has been modified or recreated.  The boot sector from an MS-DOS 5.0 formatted floppy will look very different from one created by Virtual Floppy Disk.  WinImage may even overwrite the original OEM ID string when imaging disks.  Fortunately the parts of the boot sector which OEMs modify is not essential to disk operation in DOS.

The second way is to look at the volume label.  If there is no volume label for the floppy, it may not be original.  This is far from definitive, because many games did not have volume labels on their disks, because their install programs did not use them.  If someone else tells you that his original disks have a label and your disks do not, then they may not be original.  Some games do look at the volume label for installation or to swap disks, most do not care.

The third way is to look at the File Date and Time.  If the file dates is in the 21st century, then the disk is not original.  Other disks may have most of their files with consistent dates, but one or two relatively or much later dates.  But this is not conclusive, because the disks may have been mastered on a system without a real time clock (which was not ubiquitous in the 1980s), or one which had the wrong date/time set.

The fourth way is to do a binary comparison between the files between your disk and a known good disk.

2 comments:

  1. By coincidence, I recently wrote a utility that can save all the slack space to a new file if you want to see what is crammed in there. Link is http://www.oldskool.org/pc/PADD to snag it.

    ReplyDelete
  2. Simple Floppy emulator.

    www.floppydrive.eu

    ReplyDelete