|
ZX Time #08
30 апреля 2002 |
|
Coder - private moments in the work of TR-DOS (TR-DOS port level).

Encoders
Nuts
Private moments to work with TR-DOS
So today we'll talk about work
with TR-DOS port level. This question
repeatedly obmusolivalsya in various media, I just want to note
a few things that were mentioned
malorasprotrannenyh only in newspapers and
Journals: someone has long been
their programs, while others continue to not
know.
First of all we are talking about reading
notorious port # 1F TR-DOS. Briefly
remember its purpose.
Bit 0 - busy is the command.
Bit 1 - Index pulse (small
hole in the floppy disk is located between the optocoupler
photosensor) - "the beginning of the track."
Bit 2 - magnetic head is in
original position.
Bit 3 - CRC error in the sector.
Bit 4 - positioning error.
Bit 5 - magnetic head is in
position.
Bit 6 - on disk is the label for write protection.
As is known, the standard TR-DOS ROM
can not directly read the port.
Therefore, even Larchenko and Rodionov still in
early 90-ies porylis in this same ROM and invented a method of
indirect reading of the port: if by cunning utanovit some
registers and variables, then one of the procedures ROM
match transitions akkurat to normal
RET.
This method was published in a book
the aforementioned: "ZX SPECTRUM 'TR-DOS
for users and organisms "... ie
ugh ... PROGRAMMERS ... "here. This book
received a well-known distribution, and
on these things and the way too. Of him dancing and
izestny and respected by all, Ivan Roshchin.
He has published in various sources
a large number of corrections and comments to this method.
Therefore, there was a certain concentration of thought on this
method.
But this is not the only method!
For example, we solve the problem
forehead: pick up and flash the ROM in a couple of
byte read ports. Developing such
method produced, in my opinion, the company MICRO
ART with its ATM Turbo, in ROM which
these bytes are. Known HONEY
COMMANDER, who uncompromisingly demanded precisely these bytes
in ROM, not wanting to work without them. In addition, I want to
mention ELS COMMANDER, (c) 1995
Electronic services, Gomel - he did not
desired. Leave this question because
there are a lot of versions of the ROM, with all
changes - all I do not remember!
Other methods are also often used,
but since the boom in the pages of Esme
does not cease - have about them to say again.
Below are a couple of methods, more
or less used by programmers:
1) Method, torn from MultiColor
Studio v2.0, (c) OHG. It applies to
every other program, and even somewhere
published.
It is based on the same method as above, but in another
procedure ROM: formatting the hard drive, or rather, the
verification procedure sector after formatting. For this sector
is read and verified the contents of our favorite port. Thus,
this procedure can be used to verify errors when reading from
disk.
Here is a used piece of
Procedure:
# 2099 IN A, (# 1F); READ PORT
AND A, # 7F; PROVIDES Bits 0-6
POP BC; SOMETHING recovered
; Vai from the stack
JR Z, # 20A6; no errors - transitions
, Dim
LD HL, # 5CD6; address of the variable -
; Number of bad sectors
The pit
INC (HL); increase its
# 20A6 POP HL; SOMETHING recovered
; Vai from the stack
LD A, (HL); do
INC HL; check
CP 1, should be 1
JR NZ, # 20A8; otherwise somewhere Pra
, Guy
EI; and if 1 ->
RET; vertaemsya
Thus, to read port # 1F and test are equal to zero
his bits 0-6 must:
1) write a zero in an intrinsic # 5CD6;
2) Th Nito put on stack;
3) put on the stack address at which
accurately place number 1;
4) put on a stack of mail continue
program after it left the
ROM;
5) put on a stack address routines
# 2099;
6) to jump into the ROM # 3D2F
7) in the continuation of the program (after it comes out
from the ROM) to check the variable # 5CD6: Yezhel there is
zero, then to work on, otherwise - to handle the error.
The following protsedurka implements
this algorithm.
READ1F LD B, 1
XOR A
LD (# 5CD6), A; zero out
LD HL, TEMP; address where 1
LD (HL), a
LD DE, # 2099
LD IX, CONTIN
PUSH IX
PUSH HL; all put
PUSH BC; on stack
JP DOS_DE; and jump into the ROM
CONTIN LD A, (# 5CD6); continued
DI
OR A; check
JR NZ, DERR; mistake!
; Work beyond
TEMP DB 0; Temporary variables
DOS_DE PUSH DE; jump in ROM DOS
JP # 3D2F; through the point
That's it.
2) The process for reading the port with
procedures for TR-DOS, located at
# 3FE5. Applies to quadrupeds Program
RDS v3.1 (c) RokSoftware. This procedure
usually designed for reading array
data from port (C), with the synchronization
by bits 6 and 7 (strobe and data availability) port # FF.
Here we used is not quite the standard treatment, because if,
immediately make the transition to this procedure, it fixated
on a survey of these bits. Therefore, we first define the drive
controller relatively long command polls the port and just in
time for the execution of this team and arrive at the polling
bit. Happens is your address # 3FEC:
# 3FEC INI; read port (C)
, And place it
; Soderschimoe in (HL)
JR # 3FE5; prehodim
# 3FE5 IN A, (# FF); Examine
AND # C0; bits
JR Z, # 3FE5; preparedness
RET M; vertaemsya
And if all reads
Thus read port and write its contents to the specified address
should:
1) Run to execute the command
drive. For this purpose, commonly used command position. The
point is that the drive will be positioned on the current path,
ie just start. This limits
Application method: it can be used in the procedure to check
for a floppy disk in the drive;
2) Record in the register C port number:
# 1F;
3) Record of HL will be written to address the port;
4) It would be nice and stop the drive
According to this algorithm works following procedure to
check for disk in the drive.
Despite the fact that the procedure reads
all the bits of the port, the procedure checks only the second
bit - the presence of anti- write to disk. This is explained by
the fact that not all drives work procedures that make such a
check on the presence of an index pulse (hole in the
floppy disk) - it seems the hardware implementation
and temporal characteristics of different
drives differ greatly
from each other.
This procedure only reads this
bits, and the procedure must check
wait for 1 in this bit (when the disk is pulled out), then 0.
If the disc is protected write, then while it is inserted, this
bit always be installed.
DREADY LD A, # 3C; entry # FF
CALL TOFF
LD A, # 1F; pozitsianirovanie on
CALL TO1F; current track
LD A, # D8; interrupt opreatsii
CALL TO1F
LD HL, TEMP; read here
LD C, # 1F; from port # 1F
LD DE, # 3FEC
CALL DOS_DE; read
XOR A; reset controller
CALL TO1F
LD A, # D8; interrupt opreatsii
CALL TO1F
LD A, (TEMP); check bit 6
AND # 40
RET Z; reset
LD A, 1
RET; set
TOFF LD C, # FF; entry # FF
JR TOWG
TO1F LD C, # 1F; entry # 1F
TOWG LD IX, # 2A53; OUT (C), A
DOS_IX PUSH IX; passage in Rom
JP 15663
TEMP DB 0; temporary variable
Ultra-fast positioning
drive
This technique is used very rarely,
while providing a quiet and fast moving drive heads. Almost -
is the replacement of hardware turbirovanie drive. The downside
of this produdury is its incompatibility with some type of
"slow drive" with worm ("Screw") by moving the heads. Strictly
speaking, this procedure used MultiColor Studio v2.0,
(C) OHG. So if this program is a
You do not go, then the blame should drive and
The author, not predusmotrevshih
setup procedure.
In general, it is desirable to consider turning off this
sverbystrogo positioning, in addition, this method You can
"hedge" more team positioning controller
drive. The program itself uses
command a forward step "and" step back ". Speed premescheniya
defined delay between two such teams (preferably
provide for its regulation!).
You must first write
desired values in registers # 7F (track)
and # FF (the status of the controller). In addition,
need to store the value of the current track (in the variable
TRACK), as from it counted the number of steps needed to move
on a given track. Its contents - LUN track (0-166).
At the entrance to the procedures in the register A should be
given a track number, where by premeschenie.
POSIT PUSH AF; remember
SRL A; get physical
LD C, A; track number
LD A, (TRACK); current
SRL A; physical path
CP C
JR Z, POSI_OK; already here
JR C, POSI_UP; forward
SUB C; ago
LD B, A; in tracks
LD A, # 78, "Step Back"
JR POSITI
POSI_UP LD D, A
LD A, C
SUB D; ago
LD B, A; in tracks
LD A, # 58; "Undo"
POSITI LD (POS_COM), A; command code
CALL PAUSE; pause
POSITIC PUSH BC
LD DE, # 2FC1
CALL DOS_DE
POS_COM EQU $ +1
LD A, # 58; code
LD DE, # 2FC3; team
CALL DOS_DE
CALL PAUSE; wait a bit
POP BC
DJNZ POSITIC; repeat
POSI_OK POP AF
LD (TRACK), A; new value
RET
TRACK DB 0; current track
PAUSE PUSH BC
PUSH HL
LD BC, 400; delay
POS1 DEC BC
LD A, B
OR C
JR NZ, POS1
POP HL
POP BC
RET
DOS_DE PUSH DE; jump in ROM DOS
JP # 3D2F; through the point
Ultrafast stop the drive
This protsedurka also ripped out
MultiColor Studio v2.0, (c) OHG. She
also based on muhlevanii with the team
positioning and the original reading
Port # 1F. To read this procedure is used at # 3EF3:
# 3EF3 IN H, (C); reading port
# 3EF5 IN A, (255), waiting
AND 192; any signal
JR Z, # 3EF5
EI; in case of return
RET M; if entered INTRQ
, Then return
DI; ban interrupt
IN A, (127) Read byte
JR # 3EF5; repeat
As you can see, the contents of the port remains in the
register H, and carried out by
execution team.
Now, the procedure itself, which provides
otsanovku quick drive. I must say
it conflicts with some emulators: there is movement on the track
forward.
STOPDSK PUSH AF
PUSH HL
LD A, # 40, a step forward without
; Increment register tracks
LD DE, # 2FC3
CALL DOS_DE
LD A, # D8; interrupt
LD DE, # 2FC3
CALL DOS_DE
LD C, # 1F
LD DE, # 3EF3
CALL DOS_DE
POP HL
POP AF
EI
RET
*
Other articles:
Similar articles:
В этот день... 15 November