The directory track is contained totally on track 18. Sectors 1…18 contain the directory entries whilst sector 0 contains the BAM (Block Availability Map) and disk name/ID.
Since the directory is only 18 sectors large (19 less one for the BAM), and each sector can contain only 8 entries (32 bytes per entry), the maximum number of directory entries is 18 * 8 = 144.
The first directory sector is always 18/1, even though the t/s pointer at 18/0 (first two bytes) might point somewhere else.
It then follows the same chain structure as a normal file, using a sector interleave of 3. This makes the chain links go 18/1, 18/4, 18/7 etc.
Byte | Content | ||||||||
---|---|---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ||
00 | 15 | Location of next directory sector, 0x0000=end | 8 | First Directory entry | |||||
01 | 7 | 0 | |||||||
02 | Closed | Locked | Save | 30File Type | |||||
03 | 15 | Location of first sector of file | 8 | ||||||
04 | 7 | 0 | |||||||
05 | Filename in PETASCII padded with 0xA0 | ||||||||
06 | |||||||||
07 | |||||||||
08 | |||||||||
09 | |||||||||
0A | |||||||||
0B | |||||||||
0C | |||||||||
0D | |||||||||
0E | |||||||||
0F | |||||||||
10 | |||||||||
11 | |||||||||
12 | |||||||||
13 | |||||||||
14 | |||||||||
15 | 15 | Location of first side-sector block | 8 | ||||||
16 | 7 | 0 | |||||||
17 | REL file record length, max value 254 | ||||||||
18 | Unused in CBM DOS, GEOS only | ||||||||
19 | |||||||||
1A | |||||||||
1B | |||||||||
1C | |||||||||
1D | |||||||||
1E | 7 | File size in sectors | 0 | ||||||
1F | 15 | 8 | |||||||
20 | Must be set to 0x0000 | Second Directory entry | |||||||
21 | |||||||||
22 | Closed | Locked | Save | 30File Type | |||||
23 | 15 | Location of first sector of file | 8 | ||||||
24 | 7 | 0 | |||||||
25 | Filename in PETASCII padded with 0xA0 | ||||||||
26 | |||||||||
27 | |||||||||
28 | |||||||||
29 | |||||||||
2A | |||||||||
2B | |||||||||
2C | |||||||||
2D | |||||||||
2E | |||||||||
2F | |||||||||
30 | |||||||||
31 | |||||||||
32 | |||||||||
33 | |||||||||
34 | |||||||||
35 | 15 | Location of first side-sector block | 8 | ||||||
36 | 7 | 0 | |||||||
37 | REL file record length, max value 254 | ||||||||
38 | Unused in CBM DOS, GEOS only | ||||||||
39 | |||||||||
3A | |||||||||
3B | |||||||||
3C | |||||||||
3D | |||||||||
3E | 7 | File size in sectors | 0 | ||||||
3F | 15 | 8 | |||||||
Sector pointers
The sector pointers at offset 0x00, 0x03 & 0x15 are Track/Sector values.
The track number is in the first byte, sector number in the second.
Next directory sector pointer
The next directory sector pointer at offset 0 points to the next directory sector in the chain. If it's the last entry in the chain then it is set to 0x0000.
It is only valid for the first directory entry. On file entries other than the first one in the sector this pointer is unused & is set to 0x0000.
File Type
7 | 3 | 2 | 1 | 0 | Name | File Type |
---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | Scratched, deleted file entry | |
1 | 0 | 0 | 0 | 0 | DEL | Deleted |
1 | 0 | 0 | 0 | 1 | SEQ | Sequential |
1 | 0 | 0 | 1 | 0 | PRG | Program |
1 | 0 | 0 | 1 | 1 | USR | User |
1 | 0 | 1 | 0 | 0 | REL | Rel |
All other values are illegal and will produce strange results.
Some routines use all 4 lower bits, some ignore bit 3.
All file types require the Closed
flag (bit 7) to be set.
Only DEL
is valid with Closed
cleared when it indicates a deleted file entry.
File length
The file length is a little endian value with the lsb first, msb last. It is a sector count, not the file count.
REL files
Bytes with offset 0x15…0x17 are only used for REL files.