1990 (124.9 KB) (149.27 KB)

SamDOS 1.1 was the original DOS for the Sam Drive and external drives via the External Drive Interface.

Version 1.1 source of many problems highlighted in one of the most corking ROM bugs in ROM 1.0 that prevented correct bootstapping forcing the user to enter a CALL command (CALL 229385 for 256K or on a 512K CALL 491529) after pressing F9 or typing BOOT.

SamDOS 2.0 was released along with ROM 2.0 and booted correctly, although this episode forced MGT to ship new ROMs to all customers.

Information from Frode Tennebø from the Sam Coupé Scrapbook


SAMDOS has been designed specifically for the SAM Coupe computer. It is similar to G+DOS as used with the MGT Plus D Spectrum disk interface.

Disk Format

We use 80 track per side, giving 160 tracks per disk. A track is made up of 10 data sectors, each giving 512 bytes of storage.

The first 4 tracks of the disk are given up to the SAMDOS directory, leaving 156 tracks available for storage. This leaves available 1560 data sectors of 512 bytes (798720 bytes).

Although each data sector can hold 512 bytes, only 510 bytes of them are available for storage. The last two bytes of the data sector are used by the DOS to locate the next part of the file stored. Byte 511 hold the next track used by the file, while byte 512 holds the next sector.

Disk File Header

At the beginning of each disk file there is a file header. The file header is 9 bytes long:

ByteSAMDOS typePlus D type
0File typeFile type
1-2Modulo lengthLength of file
3-4Offset startStart address
7Number of pages
8Starting page number 

Details of the Plus D header can be found in the technical information for the Plus D.

File Types

Each file type in the SAMDOS is allocated a numeric identifier:

NumberSAMDOS typeDirectory Text
0Erased File
5ZX Snapshot fileSNP 48k
16SAM BASIC programBAS
17Numeric arrayD ARRAY
18String array$ ARRAY
19Code fileC
20Screen fileSCREEN$

Modulo Length & Number of Pages

In the SAMDOS header the length of the file is calculated by multiplying the number of pages (byte 7) by 16384 and adding the modulo length (word 1-2), LSB/MSB, ie the length MOD 16K.

Offset Start & Starting Page Number

Read starting page number (byte 8). AND this with 1FH to get the page number in the range 0 to 31. To find the start, multiply the page number by 16384, add the offset and subtract 4000H (since the ROM occupies 0-3FFFH).

When SAMDOS is paged in it resides at 4000H, and ROM0 is placed at 0-3FFFH.

SAMDOS Directory

The first 4 tracks of the disk are allocated to the disk directory, starting at track 0, sector 1. These 4 tracks give us 40 sectors each split into two 256 bytes entries. Each of these entries will identify one file, thus allowing up to 80 entries in the directory.

The format of each directory entry is as follows:

00Status/File type. This byte is allocated on of the file types listed previously, but is also used as a file status. If the byte is 0 then then file has been erased. If the file is HIDDEN the bit 7 is set. If the file is Protected then bit 6 is set.
1-101-10Filename. This filename can be up to 10 characters.
11 MSB of the number of sectors used in the file.
12 LSB of the number of sectors used in the file.
13 Track number for start of file.
14 Sector number for start of file.
15-209 Sector address map (195 bytes) (detailed further on).
210-219 MGT Future and past (10 bytes). These were used in the PLUS D directory but are not used by the SAMDOS. They are allocated to MGT for future use.
22015Flags (MGT use only).
221-231 File type information
 16-26If the file type is 17 or 18 then these bytes contain the file type/length and name.
 16If the file type is 20 then these bytes contain the screen mode.
 16-18If the file type is 16 then these bytes contain the program length excluding variables.
 19-21If the file type is 16 then these bytes contain the program length plus numeric variables.
 22-24If the file type is 16 then these bytes contain the program lengtrh plus numeric variables and the gap length before string and array variables.
232-23527-30Spare 4 bytes (reserved).
23631Start page number, in bits 4-0, bits 7-5 are undefined.
237-23832-33Page offset (8000H-BFFFH). This is as per file header, although when the ROM passes a file to be saved, it starts it in section C of the addressing map.
23934Number of pages in length (as per file header).
240-24135-36Modulo 0 to 16383 length, ie length of file MOD 16384 (as per file header).
242-24437-39Execution address. Execution address, if CODE file, or line number if an autorunning BASIC program.
245-25340-47Spare 8 bytes.
254-255 For future use by MGT only.

Sector Address Map

SAMDOS allocates 195 bytes to the sector address map, giving 1560 bits, which is the exact number of sectors available for storage on the drive.

A sector address map is calculated for each directory entry. When a field is created a directory entry is made for that file. A sector address map is created by setting the specific bit(s) corresponding to the sector(s) allocated to the file. (Bit 0 of the first byt is allocated to trac4 sector 1). For example, if the file uses 5 sectors then fice corresponding bits in the sector adress map are set and svaed as part of the directory entry.

Bit Address Map (BAM)

The bit address map is not stored on the disk by SAMDOS. It is genereated by performing a bitwise OR of each file’s sector address map. This then gives SAMDOS a usage map of the disk.

When a file is created the first thing SAMDOS does is calculate the BAM and then by looking at the available sectors (ie bits not set), it can work out if there is room for the file. If there is room for the file, then the directory entry is created, including the sector address map specific to the new file, and the file is stored in the sectors which have been specified in the file’s sector address map.