Sam Coupe Scrapbook

Technical Section
- SamDOS - Sam Disk Operating System

Information provided by: Frode Tennebo

Introduction

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 Drive

The internal SAM disk drive is a Citizen 3.5" slimline drive. Each drive is cased and fitted with the MGT disk controller interface, which utilises a VL-1772-02 floppy disk controller. By default the disks are formatted as double sided, 80 track per side, 10 sectors per track, to the IBM 3740 standard.

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:

	SAMDOS type		Plus D type

0	File tyep		File type
1-2	Modulo length		Length of file
3-4	Offset start		Start address
5-6	Unused
7	Number of pages
8	Starting page number

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

File Type

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

	 5	- ZX Snapshot file	SNP 48k
	16	- SAM BASIC program	BAS
	17	- Numeric array		D ARRAY
	18	- String array		$ ARRAY
	19	- Code file		C
	20	- Screen file		SCREEN$

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:

(The User Information File Area (UIFA) will be described later - NOT! (FT:-)).


   Byte	  UIFA	
      0      0	Status/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-10	  1-10	Filename.
		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.
    220	    15	Flags (MGT use only).
221-231	 	File type information
	 16-26	If the file type is 17 or 18 then these
		bytes contain the file type/length and
		name.
	    16	If the file type is 20 then these bytes
		contain the screen mode.
	 16-18	If the file type is 16 then these bytes
		contain the program length excluding
		variables.
	 19-21	If the file type is 16 then these bytes
		contain the program length plus	numeric
		variables.
	 22-24	If 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-235	 27-30	Spare 4 bytes (reserved).
    236	    31	Start page number, in bits 4-0, bits 7-5
		are undefined.
237-238	 32-33	Page 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.
    239	    34	Number of pages in length
		(as per file header).
240-241	 35-36	Modulo 0 to 16383 length, ie length of
		file MOD 16384 (as per file header).
242-244	 37-39	Execution address.
		Execution address, if CODE file, or line
		number if an autorunning BASIC program.
245-253	 40-47	Spare 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.


Previous Site Sam Coupe Web Ring Site List Next Site

Scrapbook Hosted by: Monochrome
"Scrapbook" Graphical Design: Morse Design
This page last modified: 19990803-22:51.16(BST)