+3DOS File Header
Categories:
Tape files have headers which contain some system information. +3DOS files may, or may not, have headers. All files created by BASIC's SAVE command will have headers.
The +3DOS header mechanism provides a dedicated 8 byte area in each headed file reserved for BASIC's use. The remainder of the header is reserved for +3DOS. This 8 byte header is utilised in files created by BASIC commands (see DOS OPEN description).
+3DOS files may have a single header in the first 128 bytes of the file - the header record. These headers are detected by a 'signature' and checksum. If the signature and checksum are as expected, then a header is present; if not, there is no header. Thus, it is possible, but unlikely, that a file without a header could be mistaken for one with a header.
Bytes | Length | Content | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
0 | 7 | 8 | +3DOS Signature | "PLUS3DOS" | ||||||
8 | 1 | Soft-EOF | 0x1A | |||||||
9 | 1 | Issue | 0x01 | |||||||
10 | 1 | Version | 0x00 | |||||||
11 | 14 | 4 | Length of file including header | |||||||
15 | 22 | 8 | +3 BASIC Header | |||||||
23 | 126 | 104 | Reserved | 0x00 | ||||||
127 | 1 | Checksum | Sum bytes 0…126 AND 0xFF |
Bytes | Length | Content | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | File Type | ||||||||
1 | 2 | 2 | File Length | |||||||
3 | 4 | 2 | Param 1 | |||||||
5 | 6 | 2 | Param 2 | |||||||
7 | 1 | Unused = 0x00 |
Type | File Description | Param 1 | Param 2 | ||||||
---|---|---|---|---|---|---|---|---|---|
0 | BASIC Program | Line number to start | Start of variable area relative to program start | ||||||
1 | Number Array |
Variable name, e.g. if DIM a() then this is 0x80 a=0x81, y=0x99
|
|||||||
2 | Character Array |
Variable name, e.g. if DIM a$() then this is 0x80 a=0xC1, y=0xD9
|
|||||||
3 | CODE | Start when saved | 32768 |
Notes
- The file header is the first 128 bytes of the file on disk.
- The Length at bytes 11 is a 32-bit number, the max file size is 8Mb. This includes the 128 byte header.
- The BASIC header at byte 15 is what IX points to after a call to DOS_READ_HEAD so (IX+0) is the File Type.
- The length in the BASIC header is the actual length of the file, without the 128 byte header.
- For File Type 0 - BASIC, Param 1 is either the line number to start execution or 0x8000 for none. Param 2 is the offset of variables. For most purposes this can be the length of the program so no variables.
- For File Type 3 - CODE, Param 1 is the load address. Param 2 is unused
- The checksum byte 127 in the header is the sum of the rest of the header, not XOR like tape files.