Studies - Address to the drive mode IM 2. Working with non-standard disc format.

ZX Review #7-8-9-10
(C) Labutin D., Nizhny Novgorod
region, Dzerzhinsk


   You have already written to the ZX-95 REVIEW N5
on page 53 that you can work with the regime interrupt IM 2
and at the same address to the disk.
This way I have not approached,
since, working in the mode of 128 kb,
interrupt handler with
addresses of 65,129 or 65,524 have not, because pages there
constantly changing, and the other
appropriate register values ​​I
I have not picked it up. Then I thought
another way. All appeals to the
disk (CALL # 3D13, or similar)
is replaced by CALL DOS. Sub-DOS is as follows:
140.
DOS PUSH AF

        LD A, 1

        LD (FLAG), A

        POP AF

        CALL # 3D13

        PUSH AF

        XOR A

        LD (FLAG), A

        POP AF

        RET
FLAG DEFB 0


   A routine interrupts looks like this:

IM2 PUSH AF

        LD A, (FLAG)

        OR A

        JR Z, IM21

        POP AF

        PUSH HL

        LD HL, # 3D2F

        EX (SP), HL

        PUSH AF

        PUSH BC
IM21 ............... ; Preservation registers

        CALL PROG; treatment interruption

     ............... ; Restore registers

        POP BC

        POP AF

        RET
2

   Ed.: Good idea, only you do not
take into account the fact that the TR-DOS ROM is ROM
BASIC even when performing such simple
operations, such as reading groups of sectors. For
This routine is used at
# 5CC2, consisting of only one team
RET. Placed on the stack address of the subroutine, the 
registers are loaded options, and done JP # 5CC2. Return of the 
subroutine is at # 3D2F. To have your method to work, should be 
at # 5CC2 put JP on the following subroutine: 140.


        POP HL; take the address of the called subroutine

        PUSH AF; keep AF

        SUB A; working ROM BASIC

        LD (FLAG), A

        POP AF; recovery AF

        PUSH HL; store address of the calling subroutine

        LD HL, L1; put on a stack of new return address

                       ; From subroutine

        EX (SP), HL; and restore the address of the subroutine

        PUSH HL; pushed onto the stack address of subroutine

        LD HL, (23810); restore HL

        RET; move on to the subroutine
L1 PUSH AF; keep AF

        LD A, # 01; working ROM TR-DOS

        LD (FLAG), A

        POP AF; recovery AF

        RET; return to the TR-DOS ROM
2

   A few words about the restoration of HL.
Subroutine call ROM BASIC uses
variables 23810 and 23812 to save
HL and DE, respectively, therefore, for
call # 5CC2 in these variables will be copies of these 
registers. This fact and used the above routine. 


   Corr.: I'm writing a graphic adventyuru (certainly not me
one, but I program), and
one point realized that the floppy disk in
640 KB enough for graphics.
Then I decided to switch to non-standard format. In one lane 5 
sectors of 1024 bytes. Obtained disk size of 800 KB. I do not 
remember what program I've formatted floppy disk giving the 
sector number 1, 2, 3, 4, 5.


   It seemed that the deed is done,
but there it was - the fifth sector
unreadable. You can do the following:
140.

        LD E, 0, or 1,2,3

        LD C, 5

        LD B, 1

        LD D, 5, or any

                      ; Track

        LD HL, 40000

        CALL # 3D13

But if you try:


        LD BC, # 0105

        LD HL, 40000

        LD DE, # 0504

        CALL # 3D13
2
that sector is unreadable. Here I
remembered that in the IS DOS 5 sectors per track for the 
kilobyte. After analyzing the contents of a track floppy disk, 
formatted IS DOS, I was very surprised. There

sector have the numbers 1, 2, 3, 4,
9. Why 9, not 5? Reformatting the disk in this way,
I was no more similar
problems. I wrote the following
uploader:
140.
DOSLOAD PUSH BC

        PUSH DE

        PUSH HL

        LD A, E

        CP 4

        JR NZ, DOSLD1

        LD E, 8
DOSLD1 LD B, 1

        CALL # 3D13

        POP HL

        INC H

        INC H

        INC H

        INC H

        POP DE

        INC E

        LD A, E

        CP 5

        JR NZ, DOSLD2

        INC D

        LD E, 0
DOSLD2 POP BC

        DJNZ DOSLOAD

        LD (# 5CF4), DE

        RET
2

   Before the call: HL = address
loading, B = number of sectors
(1024 bytes), C = 5 - reading,
6 - entry, D = path, E =
sector (from 0 to 4). But downloading
walking very slowly, and I've placed the sector on the track in 
the following order: 1, 4, 2, 9, 3, and rate increased by 2 
times. Maybe this information will prove useful to somebody, 
and someone can explain why need to use nine sectors, rather 
than five. 


   Prim Ed.: Strange story. Ninth
sector, or the fifth, but at least the 130th, all
should work. Perhaps the lack of Dmitri in the format program. 
Dmitry, try to format the drive so how do you like the same 
program, and then look at it with the function Analyse

Track ADS programs or RDS. Likely
You'll find the answer to your question. Now on
why in the IS-DOS used in the ninth
sector. It is necessary for the implementation of
Startup of the system. The principle is. Before any operation 
with TR-DOS disk loads nine sectors zero track in a specially 
allocated for this buffer at # 5D25. The buffer has a length of 
257 bytes. Why not 256 - can only say the creators of TR-DOS. 
During this buffer area will be based on descriptors channels. 
TR-DOS does not can read part of the sector, it loads

the whole thing, no matter how long it was. In
result of sector length of more than 256
byte overwrites a descriptor channels.
But the TR-DOS does not know and tries to
identify the disc. The first thing she
checks in the sector of bytes at offset
231, and if it does not equal 16, it is
immediate interruption of operation with the issuance of
Posts Disc Error. Issue Post
goes through the channel K. Here's the startup mechanism is 
triggered. Enough to cell offset # 0101 and # 0102 to record

address of your boot, which is located in the same sector. The 
loader will start, and there really do whatever you want. 


           *