Thomson floppy formats

Bad news first: over the existence of the Thomson computer range, various disk formats were used. While they all work the same way, the format was extended several times to work with new floppies:

  • Floppies may have either 128 byte (single density) or 256 byte (double density) sectors.
  • They may have 40 or 80 tracks.
  • There are 16 sectors per track, numbered from 1 to 20.
  • Floppies are always single sided. The second side, for controllers and drives that supports one, is handled as a separate drive.

The disk directory is always on track 20. The structure is as follows:

  • Sector 1: disk label for icon-DOS (8 characters, space padded)
  • Sector 2: block allocation table
  • Sectors 3 to 16: file directory

File directory

Each entry is 32 bytes wide, which makes it possible to store at most 112 files per DD disk side (56 per SD disk).

  • The first 8 bytes are the space padded file name. If the first byte is 0, this entry is unused (deleted file). If the entry is FF, this is the end of the catalog, all following entries are unused.
  • The following 3 bytes are the file extension (also space padded).
  • 11th byte is the file type.
TypeDescription
0BASIC file
1ASCII text file
2Binary executable
3Assembler source
4Paragraphe (TO9 built-in word processor) text

* 12th byte is an application-specific flag. For BASIC files (type 0), it is set to 0 for tokenized files, and FF for ASCII listings.

  • 13th byte is the block number of the first block of this file. The block allocation table is then used as a linked list to find the following ones.
  • 14th and 15th bytes hold the number of bytes used in the last sector. If the last sector is exactly full, an extra sector is allocated and this is set to 0.
  • The remaining 16 bytes are used by the icon-DOS to store the file comment, modification date, and some flags for CHG resident applications.

Block allocation table

The floppy is allocated by units of 8 sectors (half a track). This is 1KiB on SD disks, and 2KiB on DD disks. The FAT sector stores one byte for each block, starting at byte 1 (byte 0 is unused). A 80 track floppy can only store up to 320KiB of data, so not all the sector is used.

The bytes are valued as follows:

ValueMeaning
FFFree block
FEReserved block (probably belongs to track 20)
00 to BFBlock number of next block in file
C1 to C8File end marker (the low nyble is the number of sectors actually used by the file)

In-memory representation

When working with the filesystem sectors (block table and file directory), the floppy controller ROM uses the 6809 8-bit offset addressing mode. This relative addressing is signed, so things happens as follows:

  • The pointer register is set to the middle of the working buffer (buffer + 128)
  • The first half of the sector is put in the last half of the buffer
  • The offset overflows, and the second half of the sector is stored in the first half of the buffer.

Since the floppy ROM code always access these sectors using the same addressing mode, including when writing them back to disk, everything stays in the right order on disk. SD disks aren't affected by this, as they use only 128 byte long sectors.

File access procedures

The floppy ROM entry points are rather low-level. Here are some hints on how to perform some basic disk operations.

Reading a file

  • Read the FAT
  • Open the file in mode 1
  • Read the data

Saving a file

  • Read the FAT
  • Open the file in mode 2 (this will fail if the file already exists) or 3 (this will use a temporary file, and overwrite the old one on closing)
  • Write the data
  • Close the file

If you need to remember the exact file size:

  • Open the file again in mode 1
  • Update the catalog structure with the used bytes in last sector
  • Close the file

Erasing a file

  • Read the FAT
  • Open file in mode 2 (this will fail, because the file exists)
  • Erase file
  • Close file
documentations/floppy/format.txt ยท Last modified: 2015/03/02 13:13 by admin
CC0 1.0 Universal
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0