# Reading/Writing Spectrum+3 discs

It is possible to transfer files between an Amstrad CPC and the Spectrum+3 because both systems use 3" floppy discs and a C/PM compatible filesystem.

The "Expanded Disc Parameter Block" (XDPB), which contains the parameters describing a CP/M based disc format, must be setup with the parameters defining the Spectrum+3 disc format.

The Amstrad will then be able to list the directory and read/write the files.

The Amstrad CPC has a XDPB structure per drive. Therefore XDPB of the drive that will be used to read the Spectrum discs must be initialised with the appropiate parameters.

To transfer files to the Amstrad:

- the file must be read using CAS IN CHAR (the Spectrum+3 files do not have a AMSDOS file header, and therefore will not be identified as BINARY and can't be read using CAS IN DIRECT),
- The Spectrum+3 header is not transfered to the output file. The output file is created as binary so that a AMSDOS header is automatically added to the output file. This is followed by the data from the input file.

To transfer files to the Spectrum+3:

- the file on the Amstrad can be read using CAS IN DIRECT if it has a AMSDOS header, or using CAS IN CHAR if it doesn't. The Amstrad header is stripped from the input file.
- A Spectrum+3 compatible header must be created and written to the output file followed by the file's data.

## Spectrum +3 disc file header

The +3 disc file header has the following structure:

Offset | Length | Description
--- | --- | ---
0 | 8 | "PLUS3DOS" identification text
8 | 1 | &1a marker byte (note 1)
9 | 1 | Issue number
10 | 1 | Version number
11 | 4 | Length of the file in bytes (note 2)
15..22 |  | +3 Basic header data
23..126 |  | Reserved (note 3)
127 |  | Checksum (note 4))

Notes:

1. This byte is used by C/PM to mark the end of a file. It is called the "soft end of file". The "hard end of file" describes the length of the file in complete sectors. There may be additional bytes (which are ignored), between the position marked by the "soft end of file" and the position marked by the "hard end of file".
2. The length of the file is a 32 bit number.
   - The byte at offset 11 contains bit 7..0 of the value,
   - The byte at offset 12 contains bits 15..8 of the value,
   - The byte at offset 13 contains bits 23..16 of the value,
   - The byte at offset 14 contains bits 32..24 of the value
3. These bytes are reserved for a future use. Set these bytes to 0 when creating files with this header
4. The checksum is generated from the sum of the bytes 0..126. This value is the low 8 bits (bit 7..0) of the calculated value.