Info Guide #02

TR-DOS - Programming floppy drive controller.

<b>TR-DOS</b> - Programming floppy drive controller.
                 TR-DOS

           Level 2: KR1818VG93

      Programming the controller.
  AlCo


   IC VG93 - controller drive.
It is the heart of Interface Beta-Disk,
on the basis of which we all loved TR-DOS;)) (Though why ";)"? 
If you think that this is buggy and inconvenient

system, and then you can not imagine how buggy software and 
Windows'95 Microsoft Office! It is one thing - to hear about 
them bug, and quite another - every day suffer from them ...)


   This controller, combined with the Beta disk
interface supports recording to disk
two formats: FM and MFM (the latter is used more widely) to no 
more than 4 drive containing up to 256 tracks and up to two 
golovok.Dlya lamer it is useful to add that the commonly used 
two-way five inch drives with the number of lanes from 83 to 87 
and speed of information transmission about 30k in

seconds (5 times per second at a length
Track 6300 bytes).

   Chip manages the engine and drive heads, removing
signals from sensors on the drive and transfer data back and 
forth through a serial port (no more than one drive 
immediately). 

   For all this, the controller has a number of buffer 
registers and a fairly complex system of commands. 

   Interaction with the computer's processor
interface Beta Disk through these ports, respectively, are 
identified with the registers of the controller: 

  31 = # 1F on record - Command register

  31 = # 1F Read - The Register states

  63 = # 3F bidirectional - Register Track

  95 = # 5F bidirectional - Register sector

  127 = # 7F bidirectional - Data Register


   and a special port address # FF, provided by the Beta Disk 
Interface; This port is called the system registry.

To begin with it (right on the book by Larchenko and
Rodionova "TR-DOS for ..."):


   When reading from the system registry are
meaning only the leading two digits, which
otrazhayt state signal microcontroller DRQ ^ (D6) and INTRQ ^ 
(D7). DRQ ^ - a signal that reflects the data request 
microcontroller, INTRQ ^ - signal the end of the run team.


   To write to the system registry available
five categories.
D0, D1 choice diskovoda.Ustanoviv corresponding
  sponding code, you can choose one of four

  possible drives: 00 to drive A,

  01 for B, C, and 10 for 11 for D;
D2 hard reset of the microcontroller ...

  (If this bit is reset, the execution

  current command is terminated, the motor dis
  kovoda stalls and the light goes out.)
D3 This bit is blocking the signal HLT micro
  controller for the normal functioning of the

  must be recorded unit, (the other

  hand, if you write back unit, then

  chopper drive wound any

  team, after a while smoothly

  stop. And it often leads to

  crash programs read from disk in case
  the case of an error chteniya.Yarky example: boot

  Magic-file in the TR-DOS.)
D4 is the choice of magnetic golovki.Soderzhimoe
  th bit is directly translated into a discrete
  kovod. 0 corresponds to the first magnetic

  head or the bottom of the floppy disks, 1 -

  the second magnetic head or the upper

  side;
D5 choice of areal density. Reset level

  causes the microcontroller to work on

  method of frequency modulation (FM), establish
  BKA - according to the method of the modified frequency
  modulation (MFM). (There is evidence that FM

  majority Beta disk'ov not maintained
  is.)


   Controller commands are transmitted through
instruction register (31). Team (except teams
forced termination) will be executed only if the controller is 
not busy performing other komandy.Samy easy way write command 
in the command register - call the procedure TR-DOS 5.03 with 
the address 12227: 

       LD A, 
OUT_31 LD IX, 12227
DOS PUSH IX

       JP 15663, 15664 does not work anywhere!

   To write to the other controller ports
Use subroutine address 10835 containing OUT (C), A: RET.


       1. Restore command.


   Magnetic head of the current drive
departs at the zero track. Command code:
% 0000hvxx, where h = head position (0 = lift, 1 = lower, and 
for h = 0 engine the drive will not start), v = scan mode

track number (if v = 1, then the disc is read by the track 
number and compare it with the contents of the register lanes), 
xx = velocity head (x = 00 - max). 

   Recommended command code: 8.

   Address sub TR-DOS 5.03: 15768
(Exit after successful completion of the operation,
either BREAK).


      2. Involuntary termination.


   Aborts the current operation
in achieving one of the set of conditions
(Conditions are given by setting the corresponding bits in the 
instruction code:% 1101jjjj): D0 - after the transition from 
low signal CPRDY level high; D1 - on the contrary; D2 - after 
the arrival of the index pulse (ie, observed the beginning of 
track or just drive missing); D3 - immediately. Stops will also 
occur immediately if the reset all of these bits.


   Recommended command code: # D0.

   Address sub TR-DOS 5.03: 12225.


       3. Command position.


   Move the drive heads. Important to
feature is that they do unwind turntable drive (which, 
incidentally, make and restore command).



  Move to the center:% 010ihvxx, where the h-position
head, xx-speed, v-checking, i-whether
change the case of a track. Recommended
instruction code: # 58.


  Step away from the center:% 011ihvxx. Recommended
instruction code: # 68.


  Step in this direction% 001ihvxx.Rekomenduemy command code: # 
38. 


  Track Search:% 0001hvxx.Perehod dorozhku.Nomer required on a 
given track should be placed in the data register (before 
writing the command, otherwise not work on turbocharged SH). 
Recommended command code: # 18. 


        4. Read command.


  Reading the sector (s):% 100msec0, where m = 0
(Otherwise will be treated to all sectors
the end of the track. In this case, the number of each next 
sector to enter in the register sector. Corresponding section 
of sub-TR-DOS can not find), s = number of (0-bottom ,1-upper. 
Fundamentally importantly, used to check), e = 15 ms delay 
between the installation head in the operating position and the 
start of operation, c = the specified number of check number, 
read from the sector header (it is better to lose, because 
usually in the header Incorrect side). Recommended

instruction code: # 80. Address sub TR-DOS
5.03, transferring data from data register
in memory of: 16,341 (HL = addr, C = # 7F, first necessary to 
write command in the command register. If you exit the program 
B = 0, this indicates a read error).



  Reading header Sector:% 11000e00, where
e = delay. Reads 6 bytes from the first
got the title sector:

      track number (0Ў86)

      number of (0)

      sector number (1Ў16)

      length of sector (0,1,2,3, respectively, means 
128,256,512, or 1024 bytes) 

      2-byte control code.
This command is sent to track the contents of register in the 
register sektora.Rekomenduemy command code: # C0. 


  Reading track:% 11100e00, where e = delay. With a track is 
read all the information including spaces, service, the bytes 
and control codes. Thus, the read information is not suitable 
for the command "track record" (see below). Another little 
Trouble: in process command is a loss of synchronization, so a 
few hundred bytes at the end of the track remain unread (each 
time a different number). Recommended operation code: # E0.



         5. Write command.


  Write sector (s):% 100mseca, where m = 0,
s = 0, e = delay, c = 0, a = points to one of
two possible formats sektora.V further reading, this format 
will be indicated by a 5-bit status register. Normally this bit 
is reset at the same time in the field header sector formed a 
special B # FB, otherwise - Byte # F8.Adres sub TR-DOS 5.03, 
the transmission data from memory into the data register: 16,314

(HL = addr, C = # 7F, first necessary to write command in the 
command register). 


  Write (format) tracks% 11110e00
(Where e = the delay, which is quite
to anything). Writes the current track
about 6k range of information, which
will be sent via register
data. To successfully use this
teams need to know the track format. For
example, we can see sub-TR-DOS format at 8189. And for
the beginning of a quotation from the book:


   This command is intended to mark
floppy, that is, to format it. Information sent to the 
microcontroller, must fully comply with the selected 
formatu.Zapis automatically begins the arrival of an index 
pulse that is the beginning of the track. In contrast to the 
recording sector, the number of bytes to write is not fixed, it 
is determined by the specific format floppy disk. Part of bytes 
will simply be recorded, but some of them interpreted in this 
team in a special way. They are intended to form the official 
use, such as address markers or control codes (CC).


Byte FM MFM
# F5 is not allowed to field A1 (INIC-I QC)
# F6 is not allowed to sync C2
# F7 Zap.dvuh bytes QC
# F8ЎFB initialization routine QA bytes
# FC Zap.indeksnoy tags
# FE ini-I spacecraft Adr.metka title


   Track format includes several fields, for the proper 
formation of which must adhere to certain standards ... 

   Consider the track format in more detail. Between 
information fields are of gaps that are essential for 
synchronization schemes vnitrennih microcontroller. Than larger 
than the field gap, the better the controller is synchronized, 
the fewer failures occur during transmission. Table shows the 
recommended values ​​of the lengths of gaps, as well as the 
byte values ​​that they filled. Reduce the length of the gaps 
can be get some benefit in the amount of

expense of reliability. (The value of the last space (the 
latter because it precedes the formation of a track) are 
especially vazhna.Nebolshaya length specified by the author 
TR-DOS, does not allow, inter alia, read the first sector of 
floppy disks on most IBM-compatible computers.) (Not Most, but 
at all - this limitation mi 'Shnogh controller and it does not 
depend on the copyist (AMD, Hobeta, etc.) that you are using! A 
decent length put down the last gap of the program:

FUT, ADS, DCU 2.21 and some others.)

   Each sector is logically divided into two
information fields: a header field and immediately followed by 
a data field. The title is recorded service information about 
the sector, for this use four bytes. The track number and 
sector number identify a specific sector. Accepted

that the tracks are from scratch, and sector
unit .. (Logical sector number is obtained
subtracting one.)

   Each information field ends with two bytes of code.

   As the data formatting
track, you can use any non-service byte, but is usually used 
codes 0 or # FF.


   The sequence of sectors per track
can be arbitrary. Usually it is a multiple
some integer, called interleaving - cheredovanie.Esli this 
number is unity, then the sector are located in sequence: 0,1,2 
... For the two sectors are located at 1, for three - a 2 and 
so on. Alternation sector affects the speed of disk access. 
After graduating from read or write the next sector

program usually needs to perform kakielibo actions, and for 
this spent time during which the disk manages to turn a certain 
ugol.I the time of the next disk access under the magnetic head 
may be the sector are far from predyduschego.Esli sectors are 
consistently, when referring to the next sector program will 
have to wait until the disk will make a turn. With an 
appropriate time, alternating sectors expectations of the next 
sector can be reduced to minimum. (Optimal Interlachen, which 
provides the highest speed through the operation TR-DOS - a 
unit (sector are sequentially). But do not think that

the only possible or best
option. For example, the loader with the music in
Many demonstrations are designed for Interlachen, equal to 2 
(just so Formats TRDOS), and the video disc LOCOMOTION (Speed 
​​Co) sector are generally in reverse order ("pessimal" 
Interlachen). There also a constant mezhtrekovogo interliva: on

tors shifted sequence of sectors from track to track (it
comes to physical paths, which є87).
Normally track Interlachen is zero, but
drives Teac, thanks to built-in
their artificial intelligence to quickly
of turbo-loaders needed track
Interlachen is not less than two. And for the sub-TR-DOS (15635 
= # 3D13) the optimal value - about 5 (so Formats CONSUL).) 


        Track format for MFM.

The last gap: 80x # 4E

                   ў12x0
Field C2: 3x # F6
Index marks: 1x # FC optional
The first gap: ў50x # 4E

                   ў12x0
 Golf A1: 3x # F5
 Adr.metka title: 1x # FE
 Track number
 Number of
 Sector number
 The length of the sector
 Formation of CC: 1x # F7
 Second gap: ў22x # 4E (not less than 12)

                    ў12x0 (not less than 6)
 Golf A1: 3x # F5
 Adr.metka Data: 1x # FB
 These NNxNN
 Formation of CC: 1x # F7
 Third Space: ў54x # 4E (not less than 12)
Fourth blank: NNx # 4E


        Status register # 1F.

D7 - willingness to drive
D6 - protection record (set by all

   teams, except for reading instruction)
D5 - the teams record - indicates an error

   records (to be honest, a thing extremely Ed
   Kai) in the team reading the sector - repeat
   satisfies the bit value of a (see the entry sector
  ditch)
D4 - positioning error (if using
   We used test) or sector not found
D3 - error in the control code (or a disk

   protected, or 2.1 bits read by the disordered
   villa)
D2 - Data loss
D1 - in the command position - index
   LIMITED momentum. The other teams - the signal

   to requests for data or instructions to

   byte of data register
D0 - busy is the command.

   Assume that its state can be more
workaround (special routines read ports in the TR-DOS 5.03 is 
not, and if you find it in yourself, you have a custom firmware 
version). 

   Method Rodionova:
- Write 0 to register the track;
- Record # 0A in the register of the sector;
- Write 1 in the register D;
- Call a subroutine at 16179;
- Taken from ref. B value of reg. states;
- Restore the registers and tracks the sector baseline values.

   Method Petrova:
- Record the number of paths in D;
- Write to (# 5CD8) a number other than 0;
- Call subroutine # 2740;
- Read from (# 5CCD) status register.


   In general, the data is purely encyclopedic. But the 
advanced reader will understand. Some of the details shows the 
source program MonoLoad.H, placed in the junk. 

   Routines TR-DOS easiest to investigate in STS 5.1 (but not 
6.2), choosing Setup: ROM = DOS. Only consider a glitch in the 
STS: a DOS command incorrectly traced LD r, (HL)

and the like.


             Literature.

1. A. Larchenko, N. Rodionov. TR-DOS users and programmers 
(Peter) 2. Max Petrov on the TR-DOS'e (ZX-Format # 5)

3. PAUL ATRIDES. "Doc_help" (Spectrophoby # 6)



Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Advertising - advertising and announcements.
Mosaic - On the advantages toll BBS.
Iron - LSI architecture parallel KP580BB55.

В этот день...   2 May