1

The Spectrum+3 uses a version of the Amstrad and CP/M disk layout.

The Speccy version has a directory at the start of the disk after any reserved tracks and it can hold up to 64 files.

Each directory entries has a 32-byte structure. On most disk images I have there is a blank entry after the last entry in the directory, with all 32 bytes either zero or 'e'.

St F0 F1 F2 F3 F4 F5 F6 F7 E0 E1 E2 Xl Bc Xh Rc
Al Al Al Al Al Al Al Al Al Al Al Al Al Al Al Al

But some other disks have an entry that looks like random garbage:

FF FF FF FF FF BF BD A5 FF FF FF FF FF 7F 55 5D
FF FF FF FF FF FF FF AB FF FF FF FF FF FF FF F7

Yet in the Spectrum emulators, none show any corrupt entry or report any errors. The St field is status, which tells if the file belongs to a certain user, is deleted, etc. But nothing mentions a special meaning if it's equal to FFh or if it flags an entry entry.

I'm looking at the +3DOS ROM disassembly and all the docs I can find but none seem to mention anything that would cover this case. Most code refers to an in-RAM structure the OS reads to see how many entries there should be. But I can't locate the code that sets this number. I also can't find it in source code for tools I can find that read or write +3DOS disks or images.

How does the Speccy tell from the disk's layout how many entries are in the directory or which is the last one?

1 Answer 1

3

There is no 'end marker' for a CP/M directory in the same way that there is for MS-DOS. When searching the directory, you need to look at all entries.

To get the size of the directory for a PCW / +3 disc, start with the number of directory blocks in the disc specification. Multiply that by block size and divide by 32 to get the number of directory entries. For the CPC System and Data formats, there are always 64 directory entries.

CP/M only defines meanings for the first byte of the directory entry being:

00h-0Fh: File
10h-1Fh: Password
20h:     Disk label
21h:     Timestamp
0E5h:    Blank or deleted entry

The meaning of other values is not specified and it's probably best to ignore entries starting with them.

3
  • Hmm I've found in the Spectrum+3 manual that the password, disk label, and timestamp are not used. I'll see if I can spot what exactly the ROM does when looking at the St field. May 12, 2020 at 8:50
  • 1
    +3DOS doesn't use passwords, disk labels or timestamps, but it has to be able to cope with disks that have them. (Though I believe there's at least one bug in this support. When my primary computer was a +3, I recall that reading headerless files read from 720k disks with timestamps would scramble the first 128 bytes).
    – john_e
    May 16, 2020 at 21:03
  • Yes when I've been reading about the ROMs I've come across mentions of a bug in the ROM timestamp code. Another odd thing, the code I've made actually works with a pair of disk images I downloaded that do not work on any of my Speccy or Amstrad emulators. The Speccies show garbled junk when you do "cat". Maybe my code has the same mistake as whatever tool made those images (-: May 16, 2020 at 21:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .