Coding - Directory System: description of the directory system for TR-DOS.

Gothiq #01
...Directory System for TR-DOS..:
...................(c)CityAceE..:

...................Documentation for the system......................

     This document is intended for programmers who want to
support the directory system for TR-DOS in your programs.

....................System capabilities......................

     Directory System (DS) is an add-on to
popular TR-DOS system, and removes the restriction on the absence
in TR-DOS directories.  DS allows storage on a standard disk
TR-DOS systems up to 128 files and simultaneously up to 128 directories,
including the root directory.  Directories can be of any degree
nesting, as well as any content. In one directory maybe
contain up to 127 directories and up to 128 files. DS is in
free sectors of the zero track and does not use for its
purposes of another disk space.

........................ Compatibility........................

     DS is fully compatible with most software
support and the TR-DOS system itself.  This means that any
a program that does not support DS will see all files located on
disk, including those located in directories, the directories themselves
will not be visible. The same applies to the standard TR-DOS LIST and
CAT.You can copy, erase and rename files on the disk
with DS any commanders, as well as standard TR-DOS commands
COPY, ERASE and NEW. In this case, when you rename a file, it
the location in the directory will not change, and when creating or
copying a file, the new file will be placed in the root directory.

...........................Limitations........................

     Restrictions on Use of Other Software
together with DS is primarily due to the use of free
sectors of the zero track.  Therefore, conflicts may arise
only with those programs that use these sectors. Although,
for example, the shadow service monitor of the Scorpion computer can
store your settings on a floppy disk with DS without conflict with the system
until the number of directories does not exceed 115.
Burning programs onto a disc from a DS using the MAGIC button will destroy
system, however, some of the information can be
restore.

     Another limitation on the system is imposed by the standard
TR-DOS MOVE command and compaction of the disk using ordinary commanders. B
In this case, the sorting of files into directories will be disrupted. For
disk compaction, you must use programs
supporting DS and taking into account its features.

.............System recovery options..............

     If the system is damaged, butnot its complete destruction
(at least sector 10 of the zero track must be untouched),
the system can be partially restored. Namely, it will remain
sorting all files into directories, as well as sorting the first ones
117 catalogs.

...................Detailed description of the system...................

     The system begins at the beginning of the 10th sector immediately after
system sector (the shift is indicated relative to the beginning of sector 10
zero track):

System descriptor. 11 bytes:

+ [#00]...+ [#01] CRC system, bytes from +[#02] are counted
                    up to +[N*#0B+#10B] inclusive, where N -
                    serial number of the last specified
                    catalogue;
+ [#02]...+ [#07] signature "DirSys" - system identifier;
+ [#08] signature "1" - integer part of the version number
                    systems;
+ [#09]...+ [#0A] signature "00" - fractional part of the version number
                    systems;
                    Current system version 1.00

File and directory allocation table. 256 bytes:

+ [#0B] serial number of the directory to which it belongs
           0th file;
+ [#0С] serial number of the directory to which it belongs
           1st file;
...
+ [#89] serial number of the directory it belongs to
           126th file;
+ [#8A] serial number of the directory to which it belongs
           127th file;

+ [#8B]serial number of the directory to which it belongs
           1st catalogue;
+ [#8C] serial number of the directory to which it belongs
           2nd directory;
...
+ [#108] serial number of the directory to which it belongs
           126th catalog;
+ [#109] serial number of the directory it belongs to
           127th catalog;

+ [#10A] #00 - byte reserved;

List of directory names. Size varies:

+ [#10B]...+ [#115] 11 characters - name of the 1st directory;
+ [#116]...+ [#120] 11 characters - name of the 2nd directory;
...
+ [N*#0B+#100]...+ [N*#0B+#10A] 11 characters - name
                   the last, specified directory with ordinal
                   number N;

+ [N*#0B+#10B] #00 - end of the system.

     The size of the list of directory names depends on the number of specified
catalogues. Minimum size - 1 byte, if there are no directories
on disk (a single zero byte indicates the end of the system).
Maximum size is 1398 bytes, with 127 directories plus specified
one zero byte indicates the end of the system.

     The serial numbers of directories and files are not explicitly specified anywhere,
a are determined by a simple count in order: files from 0 to
127th, catalogs from 1st to 127th.  The root directory has
serial number 0.

     The system is initialized by writing to sectors 10 and 11
track zero (immediately after the system sector)
byte sequences:#19, #D0, DirSys100, 257 bytes of zeros

     Directory names must contain ASCII characters from
#20 to #7F (in the corresponding plug-in by HalfElf for FAR
Manager on PC, directory names are allowed to use
Russian characters in DOS encoding, this was agreed with the author
DirSys). If the first character of the directory name is code #01, then
the directory is considered deleted. Minor directory name characters
filled with ASCII code #20 (space). For example, the directory name is "My
Dir", will be specified in the list of directory names as
byte sequence: #4D #79 #20 #44 #69 #72 #20 #20 #20 #20
#20.

     When compacting a disk to free the disk from removed
files and directories, it is necessary to compact the files as
usually, then compact the list of directory names, then
recalculate and adjust the table accordingly
location of files and directories.

     At its minimum, DS occupies two sectors and can
store complete information about 22 directories. Further increase
number of directories will cause an increase in the number of sectors,
occupied by the system.

     The presence of a system on the disk is determined by the presence of 10
sector of the zero track of the signature "DirSys" with a shift it began
sector +02.  System integrity is verified by coincidence
calculated CRC with the recorded CRC at the very beginning of sector 10.After each change affecting DS (moving
file or directory to another directory, creating a new directory,
renaming or deleting a directory, compacting the system)
the CRC must be corrected and recorded. CRC is calculated
starting from the 2nd byte of the beginning of the system and until the last character
the last directory specified, inclusive.  Null byte
The system end identifier is not taken into account when calculating the CRC.

The CRC is calculated by the following program:

;Input parameters:
;HL - starting address of the block
;DE - end address of the block
;Output data:
;BC - block checksum

CRC PUSH HL
        INC DE
        LD BC,#0000
CRC1 PUSH DE
        LD A,C
        XOR (HL)
        LD E,A
        PUSH BC
        PUSH HL
        LD BC,#0000
        LD D,#08
CRC2 PUSH BC
        LD A,C
        RRA
        LD A,B
        RRA
        LD B,A
        LD A,C
        RRA
        LD C,A
        POP HL
        LD A,E
        XOR L
        AND 1
        JR Z,CRC3
        LD A,B
        XOR #A0
        LD B,A
        LD A,C
        XOR #01
        LD C,A
CRC3 LD A,E
        RRCA
        AND #7F
        LD E,A
        DEC D
        JR NZ,CRC2
        POP HL
        POP DE
        LD A,D
        XOR C
        LD C,A
        LD A,E
        XOR B
        LD B,A
        INC HL
        POP DE
        LD A,H
        CP D
        JR NZ,CRC1
        LD A,LCP E
        JR NZ,CRC1
        DEC DE
        POP HL
        RET

.......................Author's coordinates........................

     For all questions that arise regarding the described system,
contact us at the following coordinates:

690078 Vladivostok
       st. Soyuznaya 17-35
       Yudin Stanislav Anatolyevich

Tel. (4232) 42-99-35 difference from Moscow + 7 hours

e-mail: speccy@softhome.net
FidoNet: 2:5045/78.4
ZXNet: 500:4232/1.1

...................................................................
(C) 2000 Stanislav Yudin
(C) 2000 Dmitry Pyankov
(C) 2000 SIMM


...end...

Share your thoughts about the article