Mac Buster wrote:
> Hello!
>
> Could someone explain me what is where in SamDOS file descriptor ?
Certainly. Here is an extract from the SAM Coupe Technical Manual
version 3.0 (pages 78-81):
====
_SAM_DISK_OPERATING_SYSTEM_
_INTRODUCTION_
SAMDOS has been designed specifically for the SAM Copue
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 tracks 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 holds 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 type 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.
SAM Coupe Technical Manual version 3.0 78
====
- 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.
SAM Coupe Technical Manual version 3.0 79
====
- 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 byte 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).
Byte UIFA Description
0 0 STATUS/FILE TYPE.
This byte is allocated one of the file
types listed previously, but is also
used as a file status. If the byte is 0
then the file has been erased. If the
file is HIDDEN then 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 NUBMER FOR START OF FILE
15-209 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 byes
contain the program length plus numeric
variables and the gap length before
string and array variables.
232-235 27-30 SPARE 4 BYTES (reserved).
SAM Coupe Technical Manual version 3.0 80
====
236 31 START PAGE NUMBER, in bits 4-0, bits 7-5
are undefined.
237-238 32-33 PAGE OFFSET (8000-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 file 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 byte is allocated to track 4 sector 1). For example,
if the file uses 5 sectors then five corresponding bits in the
sector address map are set and saved as part of the directory
entry.
- BIT ADDRESS MAP (BAM) -
The bit address map is not stored on the disk by SAMDOS. It is
generated 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.
SAM Coupe Technical Manual versionn 3.0 81
====
I think that about covers it. Why do you ask, by the way?
--
James Gasson