ZX Format #05
11 декабря 1996
  TR-DOS  

Programmers - TR-DOS programmers.

<b>Programmers</b> - TR-DOS programmers.
TR-DOS programmers.

music by DNK
(C) Max Petrov.
________________________________

 I will not repeat in this article describe the different tr-dos
publications, show an example of its use of basica and transfer 
rates sub-ROMs '# 3d13'. My goal is to describe the subtleties 
and complexities which I myself had a meeting, trying to unwind 
motor drive write your boot loader and finally his Commanderie. 
I will try to lucidly explain 'how' to work with the SH 93 and 
drive and give examples of useful protsedurok. 


             SH 93.

 As you should know
communication with the second harmonic occurs through
ports, which you can access _only_ from ROM tr-dos (individual 
copies speccy allow you to display / read from port although 
from memory, but it is only the reluctance of the developer

cause the controller to drive
standard).

 Ports (registers) VG 93:
 Reading:

 # 1f - contains information about
able to chip in
command or the presence of
error performance of the team.
 # 3f - contains the track number
(Physical), which, according to
According to SH, is head of the drive. If you move the head
manually register value is not
change!
 # 5f - contains a number of sectors.
 # 7f - information transmitted
chip in the command (the read next
Disk B).
 # Ff - bit 7 = 1 means the end of
command, bit 6 = 1 means the request to transfer her to the SH
next byte, for example,
recording sector, or get it read from the disk byte that
she placed in the register # 7f.
 Practical application of reading
from ports # 3f # 5f and no, yes
of them can not read
(See 'reading of the ports').

 Record:

 # 1f - command code.
 # 3f and # 5f - the same as reading.
 # 7f - here should be recorded
the next byte after the request of the SH
to write it to disk, or track number for a team position.
 # Ff - bit 6 - bit density
(Fm / mfm). Some controllers (and perhaps all), this bit
not connected, so you should not
try to use it. bit
3 is responsible for stopping the motor.
If it = 1, then the engine some time after the command to stop, 
otherwise it will be spinning forever (I think so).

Bit 2 (nebezizvestnaya book Larchenko Rodionova and gives false 
information about him) - dropping his to 0 you'll get instant

termination of the command and
motor stops. Port # ff has
Three more bits, but attention! SH on
their existence does not know! They
managed directly drive and controller (in particular, the SH 
has no idea of ​​how drive (a, b. ..) it works). Bit 4 - the 
number of floppy disks (1 - bottom), Bits 1,0 - number of the 
drive. Some controllers (and perhaps almost all)

work only with bit 0 and allow you to select only 2 drives.


   How to program the SH 93.

As I have said in our programs can not be directly
apply to the registers of the SH - for
read / write ports of the controller must use the appropriate 
sections of ROM DOS, which is convenient to look through sts 
4.1 (note that sts 4.1 false trace operations ld r, (hl) in the 
ROM tr-dos, where r <> a and 0 <= hl <= # 3fff). By harvested 
areas can then apply a sequence of commands (adr - Address 
site): 

     ld hl, l01

     push hl

     ld hl, adr

     push hl

     jp # 3d2f
l01 ...
More convenient way:

     ld ix, adr

     call dos

     ...

dos push ix

     jp # 3d2f

 Should not be put in place # 3d2f
# 3d30, because There are special
Brake Controllers (?) that do not have time to connect the ROM
tr-dos and require that multiple processor cycles.

 Useful routines ROM DOS:


  entry to any port:

# 2a53 out (c), a

      ret


  write to the disk until the end of the operation of the hl:

# 3fca in a, (# ff)

      and # c0

      jr z, # 3fca

      ret m; bit 7, a = 1 - end

      outi

      jr # 3fca


  reading in hl to drive up to the end
Operations:

# 3fe5, too, only instead of ini outi.


  wait command
(Used for positioning):

# 3ef5 in a, (# ff)

      and # c0

      jr z, # 3ef5

      ei

      ret m

      di

      in a, (# 7f)

      jr # 3ef5

 Anywhere in the article addresses are given for
tr-dos 5.03/04t. For 5.1 addresses
others.

 Now we have everything in order
to get the SH command. However, it must be more to check the 
success of this implementation, ie Read value of register # 1f. 
Developers tr-dos apparently did not anticipate that the 
possibility of their systems can not meet the programmers, so 
this kind of sequence as in a, (# 1f) or in r, (c): ret in ROM 
is not, so read the register values ​​# 3f

and # 5f impossible (though not necessary), and # 1f - is 
difficult. There are several ways (2 or

3). In my opinion the most convenient
and reliable is this: immediately after
command must be
taking the following steps:

   ld d, a track number on which the head of the drive (it
need to know)

   ld (# 5cd8), not 0

   ld ix, # 2740

   call dos

   ld a, (# 5ccd)
here will contain a value
Register # 1f. It should be noted,
that during the mining procedure
# 2740 poll by the key break, so to avoid
misunderstandings should attempt to intercept the output of ROM 
basic (See below).


 Now the tool is, explain
Finally, as to give the SH team
read, for example, a group of sectors. I note that the load / 
store is not unwind motor!, It makes the team positioning. 
Command can only be made when the chip is not busy executing 
the previous team.

 Positioning:
(Explain the concept of physical and
logical paths: Phys. shows only the position of both heads, 
regardless of party. Can be brought into line: number! nat: 0 0 
1 1 ... 80 80 track! log: 0 1 2 3 ... 160 161

Why is it necessary? case that
WG 93 is working with nat. numbers
tracks, because she does not know the number
hand (see port # ff), and we
accustomed to the log. number. Thus
log = nat * 2 + number of (0 -
lower)


     di

     ld a, d; d - a logical but
             ; Measures track

     srl a; calculate the physical.

             ; Room (a / 2)

     ld c, # 7f; here should be a cross between
              ; Tit room until
              ; Horns, which

              And I want otehat.

     call outc

     ld a, # 3c; choice of

     bit 0, d

     jr z, l01

     ld a, # 2c
l01 ld c, # ff

     call outc; set

                ; Needed for

                ; Normal pa; bots bits of port # ff and number
; By case # 3f is established; be interpreted not necessary, it 
must itself ; Currently contain the current number

; Track


     ld a, # 18, instruction code position; Zion.

     call out1

     ld ix, # 3ef5

     call dos; expectation fulfillment
             ; Of

     di; team.

     jp cont

     ...

out1 ld c, # 1f
outc ld ix, # 2a53
dos push ix

     jp # 3d2f

 What makes the SH 93: when receiving
in case # 1f code # 18, it gives
signal to the promotion of the disc. Then
compares the values ​​of registers
# 3f and # 7f, determines the direction and number of steps the 
head and walks, changing the value of reg.

# 3f. In this case, the register value
# 3f may not coincide with the actual position of the heads. 
But about 'll talk later. When values ​​and # 7f # 3f match, SH 
sets bit 7 port # ff = 1 and ready to receive the next command.

 During the positioning of the motor, rotating disk, could not 
manage to spin up to the required speed of 5 rev / sec, so in 
theory should be after the issue command position and to

read / write to pause
(Passport promotion during motor 0.7 sec.). The delay also
need for settling time after head positioning (on
Passport 15 ms). However, experience shows that before the 
reading of the delay can not do at all, before recording the 
same - there's up to you, except to say that in the past two , 
the current Commanderie fpm delay before the recording is done

only the first positioning before recording the first sector of 
the whole group. 


 So, go on a disk, we have
able and the motor is already spinning. Now you can read the 
sector: - Give the command "read sector"

- Read sector
- Check error
then repeat for the other
sectors on this track. When
transition to the next track
should again give the command position. I must say that 
determining whether an error of # 2740 irrationally when 
dealing with group of sectors. There is

another way. Procedure # 2090
allows you to read the sector, then checking whether an error. 
For its call to:


  put in the stack:
1) the return address.
2) the address that points to byte # 01
3) bc = # 17f
4) (# 5cd6) write the number n
(Any)
5) placed in the register number # 5f
Sector
6) enter into the ROM address # 2090
 B hl shall be the address where
read or write from the sector.

cont ld bc, exit

     push hl

     push bc

     ld bc, cont; address, indicating
               ; Yuschy 1

     push bc

     xor a

     ld (# 5cd6), a

     ld a, sector number

     ld c, # 5f

     call outc

     ld bc, # 2090

     push bc

     ld bc, # 17f

     jp # 3d2f
exit di; procedure # 2090 resolution
        , Exceeds the interruption

     pop hl

     ld a, (# 5cd6)

 Here, a is equal to the recorded
earlier (# 5cd6) number if
no error, or 1 more
if there was. If the error was then
must either repeat the operation,
or, if the actions of your program depends on the particular
errors, then use # 2740
to determine the error code. If the error was not, it should be
recalculate the values ​​of hl and
'Facilities sector' for the next
sector, and repeat the operation.

 Subroutine to write the sector
looks a little different:

cont ld bc, exit

     push hl

     push bc

     ld bc, cont; address, pointing out
                ; Schy 1

     push bc

     xor a

     ld (# 5cd6), a

     ld a, sector number

     ld bc, # 15f

     call outc

     push bc; the stack must be written
             ; Write # 01xx

     ld bc, # 2099

     push bc

     ld bc, # 3fca

     push bc

     ld a, # a0; team 'record

              ; Sector '

     call out1

     ld bc, # 17f

     jp # 3d2f
exit di; procedure # 2090 resolution
        , Exceeds the interruption

     pop hl

     ld a, (# 5cd6)

 More similar to boot.

 What might be the error? (Codes
from # 1f)

When reading:

 bit 7 = 1, drive not ready (not
spinning motor.
 bit 5 = 1 does not mind him
attention. At all 'normal'
He drives = 0.
'& Bit 4 = 1 no sector. Usually
something somewhere is not readable.
 bit 3 = 1 sector is read from
error.
 bit 0 = 1 You gave the SH command at
when it has already accomplished something
(?). The likelihood of such errors
practically zero.

When recording:

 bit 7 - the same reading.
 bit 6 = 1 in the floppy disk glued
slot 'defense record. "
 bit 5 = 1 write error. Not
know what these things mean.
 bit 4 and 0 - the same reading.

 When the correct address to
controller, the probability of error bit 2 and 1 is also equal 
to zero.


Well, for today.
Expect to continue ...






Other articles:

Authors Journal - ZX-Format No.5

From the authors - the fifth issue of the journal.

Toys - 48 Iron (Part 4).

Toys - on popolochkam: Castle Master # 1

Toys - short story by playing Robin Of Sherlock.

Programmers - Basic for Dummies - Part 5.

Programmers - artificial intelligence in computer games.

Programmers - TR-DOS programmers.

Programmers - a description and history of the creation MEM.

Programmers - exchange of experience: On the effects on the curb, and about something else.

Programmers - the exchange of experience: "Counting the Brain" - AUTOconfig v5.03.

Programmers - adventure: a sensible approach to passing.

IS-DOS - users: a guide to basic commands and utilities, basic kit IS-DOS.

IS-DOS - the programmer: a short course in programming in the IS-DOS.

IS-DOS - IS-NEWS - "News of the World IS-DOS".

IS-DOS - software and hardware support for IDE HDD for the ZX Spectrum.

Iron - KAY: ZX Spectrum Ttransformer.

Iron - Technology is a war.

Iron - General Sound.

Iron - XTR Modem.

Iron - Shema KEMPSTON MOUSE.

Iron - What if the Bat is not the correct type.

Iron - LPT COVOX and not only ...

Premiere - a program description Catalogue Master.

Premiere - description of the program Micro-editor. (MED)

Premiere - Text designer.

Interview - an interview with the developer of the clone HOBBIT (Part 2).

a rest - dictionary of advertising (with humor, but not without common sense!).

a rest - Memories of the future.

Mail - Letters from readers.

Mail - advertising and announcements.

Mail - Corner lamer (children under 16 years of reading strictly forbidden).

Miscellaneous - Outlook: a new game from Mednonogova "Black Crow".

Miscellaneous - Prospects: Pink Floyd - the new operating system for the Spectrum.

Miscellaneous - Prospects: the game's expansion.

Miscellaneous - It was you.

Miscellaneous - A review of the game Kings bounty II.

Miscellaneous - Competition for the best level of the game Laser Squad continues. New competition at the micro-demo.

Miscellaneous - Questionnaire for the readers.

Amiga - cri de coeur: Windows 95, and another about something.

Amiga - Amiga-Club, questions and answers.

Amiga - Project PowerUp - the next generation Amig.


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

Similar articles:
Report - Photo exhibition in Krasnodar.
Topic - disassembly: a way cool if Unbeliever? Eternity Industry themselves spoiled DiHalt'99? Gravediggers at the Spectrum.

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