vg

ZXNet echo conference «code.zx»

From Oleg Grigoriev To All 19 June 2003

Let your enemies, All, die without sons! I dug out here a deep alpha version of my article for SpectrumExpert3, which never came out. however, the article was not written either. :) suddenly someone will be interested in it, like an antique. :) 2LD: eh, damn... it was time. :~( p.s. By the way, I can dig up something else from the sources. flop driver type and Windows drivers for isdos. if anyone else is interested. :) == { Begin } ======================================================== { tr_dosv0.cod } == ;(c) Ruiner. ; 15-11-98 - 24-11-98 ; 21-12-98 - 23-12-98 ; In this article I will try to give the best more complete information about the operation of TR-DOS at a low level, disassemble in detail capabilities of BIS KR1818VG93, lead examples of frequently used routines, and give answers to the most frequently encountered questions questions. Preludium. Before you start, you must immediately talk about the advantages and disadvantages of bots with a disk drive at such a low level - no, and also understand the terminology. First of all you need to understand that you are working with the disk and only with disk. All kinds of hard drives, ramdisks disappear instantly. It should also be note that different versions of trdos do not match the addresses of subroutines inside ROM However, firmware 5.03 (5.04T) is lately has become a kind of standard vol. Further in the text the addresses will be yes- to be used specifically for 5.03.The advantages include that you are not limited in their capabilities in any way than in addition to the actual possibilities of control disk drive roller. Further in the text will be used such concepts: Disk - instead of a flexible magnetic disk. Disk drive (drive) - storage device floppy magnetic disks. Controller - drive controller on floppy magnetic disks based on LSI KR1818VG93. Track (cylinder) - physical track as a storage device. Logical track (track) - physical Which track multiplied by 2 plus number sides. Head - a block of magnetic heads. A little educational program. Just in case. The controller is programmed is achieved using 5 ports located married in the trdos address space. Since these ports are only accessible from under trdos, then to work with the controller It is advisable to use pieces of trdos ROM. This is done, for example, like this way: ld ix,addr ;address in trdos. call dos ... dos push ix jp #3d2f When the processor enters the address space #3d00-#3dff when installed- nom ROM 48 BASIC, the se- window lecturer and in place of the standard ROM ROM TRDOS is connected. When the processor for some reason leaves the address #0000-#3fff the ROM returns to its place BASIC-48. At address #3d2f in the ROM the trdos contains - the following: #3d2f nopret You shouldn't use #3d30 instead #3d2f - on some computers con- the roller may not have time to connect the ROM trdos with all the consequences for the program we are the consequences. . == { End } ========================================================= { tr_dosv0.cod } == == { Begin } ======================================================== { tr_dosv1.cod } == Volume 1 The controller provides storage communication body with a computer: installing the head on specified track, reading and writing sec- pa or tracks with control calculation sums (CRC16), transfer speed control head displacement and recording precompensation si. Provides disk drive control data exchange between the processor and the disk water, programming track numbers, sector, sector length, etc. etc. Communication between the processor and controller occurs at 8 digits - no data bus. On the same bus there is controller programming goes on various modes and control commands roller. The controller has 4 internal registers ditches through which work management takes place that controller, and another external re- hyster, performed, as a rule, on a micro- circuit 555TM9 (latch trigger), for drive control and readiness polling tee. From the point of view of a control programmer The ler is presented in the form of 5 ports stupid in the trdos address space.Control register. Port #FF. Used to control the disk drive and reading the controller readiness - when work or when exchanging data. This re- the hyster is made on a TM9 microcircuit - trig- here latch. When a byte is supplied to the port, it is saved - latched. Reading. ; Below are 7 lines with a picture. ┌──┬──┬──┬──┬──┬──┬──┬──┐ │D7│D6│D5│D4│D3│D2│D1│D0│ └──┴──┴──┴──┴──┴──┴──┴──┘ │ │ │ │ │ │ │ │ │ │ └──┴──┴──┴──┴──┴─── Not used. │ └───────────────────── DRQ output. Output INTRQ. D0-D5 - Not used when reading are equal to 0. D6 - DRQ output - data strobe. If equal to 1; When reading, indicates that The data register contains information for transfers. When recording, it signals readiness controller receive information from the bus data. If equal to 0; When reading, indicates that information from the controller data register ra is read by the processor. When recording, indicates that the re- The controller data register received the information tion from the data bus. D7 - INTRQ output - control readiness Lera. If equal to 1, the controller is ready accept the command. If 0 is equal - contact the roller is executing a command or has been read status register. Record. ; Below are 9 lines with a picture. ┌──┬──┬──┬──┬──┬──┬──┬──┐ │D7│D6│D5│D4│D3│D2│D1│D0│└──┴──┴──┴──┴──┴──┴──┴──┘ │ │ │ │ │ │ │ │ │ │ └──┴─── Drive number for operation. │ │ │ └───────── (0) - Reset the controller. │ │ └──────────── (1) - HRDY, (0) - IP emulation. │ └─────────────── Disc side. (1) - Top. └───────────────────── Recording density. (0) - double. D0, D1 - these bits are directly from the TM9 output connected to DISK drive inputs A,B,C,D. Used to set disco water for work. In some variants controller, for example in controller Scorpion computer, D1 bit is not used Yes. D2 - This is the CLR controller input. When us- When set to 0, the controller is reset ra. In particular, there is an immediate drive stop, register value sector becomes equal to 1, sets - Signal INTRQ = 0 and the controller freezes until the CLR appears at the input 1. After exiting the reset, the controller is dusty is set at the minimum speed set screw the drive head onto the zero track ku by issuing pulses "step on- butt." If after giving 256 pulses there is no TR00 signal appears, the controller is pre- increases the execution of the command. At clock frequency 1 MHz step at minimum speed executes in 30 ms, which gives us 30*256=7680 ms or 7.68 seconds. Exactly this is how long it will take to exit the reset on a regular controller. On turbochargedthe controller is half as fast - 3.84 sec. An alternative way to exit the reset may be an immediate command interrupts after installing D2. Control- The lehr will be ready for use approximately in ~173 µs or ~608 clock cycles based on that the processor clock speed equal to 3.5 MHz. D3 - Controls simultaneous inputs controller HRDY (head readiness) and IP (index pulse). When set to 1 at the HRDY input, the roller is fed log. 1, that the alarm indicates that the heads are in working order. sideways position, i.e. pressed to the surface disk capacity. Unit at this input ensures that the drive motor stops upon arrival of 15-16 index pulses after the controller sets INTRQ=1. The IP input is not affected. When reset to 0 at the HRDY control input log is submitted. 0, which signals that the heads are raised. At the same time, installation of the drive will not produce - even if the heads are in working order position until bit D3 is again set to 1. It’s interesting that the introduction of auxiliary controller commands this does not affect, since they can perform work even with your head raised. Simultaneously with the HRDY input log. 0 is also supplied to the input of the IP controller, which signals that the index the pulse is read and the disk begins the next turnover D4 - Directly connected to the drive inputSIDE. When set to 1, selects top zero side corresponding even tracks, 0 - bottom. D6 - DDEN controller input. Selected disk density. If 1 is equal, one normal density (FM), when equal to 0 - double (MFM). Most controllers on ZX-Spectrum-compatible computers are unable to work with a single seal ness. This lack of control is deprived lers in Scorpion, Profi, ATM computers Turbo. D5, D7 - not used. Some descriptions indicate different density bit value, sometimes in D5 is indicated as such. Data register. Port #7F. Serves for data exchange between dis- com and computer. Sector register. Port #5F. Used to record the sector number when operations or to read the vehicle number Tabernacle sector. Track register. Port #3F. Serves to store the current number paths. Command-status register. Port #1F. The controller provides reception and completion of 11 teams of 4 types submitted to the command register. Each of the 11 teams has its own modifier code, which, due to changes some conditions for fulfilling the co- mand. TYPE BIN HEX 1 0000 hvrr 00...0F recovery 1 0001 hvrr 10...1F search 1 001t hvrr 20...3F head pitch 1 010t hvrr 40...5F step forward 1 011t hvrr 60...7F step back2 100m sec0 80...9E read sector 2 101m sec A0...BF sector write 3 1100 0e00 C0, C4 read address 3 1110 0e00 E0, E4 read track 3 1111 0e00 F0, F4 write track 4 1101 iiii D0...DF forced interrupt Meaning of flag bits: rr - head positioning speed: 00 - 6 ms 01 - 12 ms 10 - 20 ms 11 - 30 ms For a turbocharged controller these the numbers are two times smaller. v - checking the track number after position tioning. h - head loading. t - change the track number in the register paths after each step. a - address label type (0 - FB, 1 - F8). c - checking the party number when identifying fixation of the index area. e - delay after loading the head on 30 ms (15 ms for 2 Mhz). s - side of the disk. m - multi-sector operation. i - interrupt condition: i0 - upon transition of the drive to the state "ready" i1 - upon transition of the drive to the state saying "not ready". i2 - by index pulse. i3 - immediate interrupt. When i3=i2=i1=i0=0 the command stops is present, but INTRQ is not set. It should be noted that in ZX-Spect- rum the heads are ready for work (clamping to the surface) is provided automatically manually by turning the knob accumulating body after inserting the disc. It is also necessarysay that any actions with modification torus h=0 will only lead to instantaneous storage tank installation. Teams of the first type. These commands provide promotion drive motor. RESTORATION command. This command provides translation of the drive of the drive to the zero cylinder. You- The command execution is terminated either when appearance at the TR00 input of the log controller. 0 or after 256 pulses. CYLINDER SEARCH command. Before the command, the track register must contain the number of the current cylinder, and re- data register number required. The search is performed with the modifier v=1. The controller determines the direction of transfer moves and walks until the register of the track is not equal to the register data. After which, depending on the mo- difier v or ends execution commands, or checks the location of the dexterous and in case of an error puts up the 4th status register bit. STEP command. The command ensures the movement of the drive of the drive by one step (cylinder). The direction of movement remains the same him. Team STEP FORWARD. Provides head movement one step forward (one cylinder to the center) ru disk). Command STEP BACK. The command ensures the movement of the movements one cylinder back (towards the edge of the dis- ka). Teams of the second type. SECTOR READ command. Results of completion or failurecommands are displayed in the status register languor, each bit of which carries information information about the progress of the command. . == { End } ========================================================= { tr_dosv1.cod } == == { Begin } ======================================================== { tr_dosv2.cod } == Volume 2 In this part I will give the addresses of the most more frequently used routines trdos, and also here low-level level procedures that will be used use in the following parts. Required dimo discuss that all procedures give - based on work on an 80-track 2-sided drive with similar floppy disk. Also stored at drive address current drive number. 1. Trdos. 1.1 Writing a number to a port located in address space trdos. #2a53 out (c),a ret 1.2 Read until the end of the operation. Before call must set c=#7f, hl - download address, de - waiting time readiness. #3fd5 ld b,#04 #3fd7 in a,(#ff) and #c0 jr nz,#3fec inc de ld a,d or e jr nz,#3fd7 djnz #3fd7 ret #3fe5 in a,(#ff) and #c0 jr z,#3fe5 ret m #3fec ini jr #3fe5 You can also use #3fe5, though in this case, the procedure can wait for readiness controller ad infinitum. 1.3 Recording until the end of the operation. Allsimilar to reading. #3fba ld b,#04 #3fbc in a,(#ff) and #c0 jr nz,#3fd1 inc de ld a,e or d jr nz,#3fbc djnz #3fbc ret #3fca in a,(#ff) and #c0 jr z,#3fca ret m #3fd1 outi jr #3fca 1.4 Waiting for readiness. Spinning loop until the controller masters butts. Attention! So you can lose one byte when reading. #3ef5 in a,(#ff) and #c0 jr z,#3ef5 ei ret m di in a,(#7f) jr #3ef5 1.5 Waiting for readiness fixed time. At input b - number of attempts, с=#7f, de - time, hl - address for ini. You can lose a byte. Used in case, if readiness may not appear curl in general. #3fd7 in a,(#ff) see clause 1.2 1.6 Reading any port located in the trdos address space. Control- The ler must be ready, i.e. intrq=1. #3ef3 in h,(c) see clause 1.4 When reading #1f intrq will be reset to 0. Therefore it cannot be used in a loop. 2. Procedures. 2.1 Standard minimum. ; wait intrq fixed time. intrqw ld de,#0000 ld h,d ld l,e ld bc,#017f ld ix,#3fd7 jr to_dos ; wait intrq. intrq ld ix,#3ef5 jr to_dos ; writing to controller ports.toprff ld c,#ff:jr topr topr7f ld c,#7f:jr topr topr5f ld c,#5f:jr topr topr3f ld c,#3f:jr topr topr1f ld c,#1f topr ld ix,#2a53 to_dos push ix di jp #3d2f 2.2 Reading controller ports. 2.2.1 Read any port when intrq=1. ; the output h is the contents of c. frpr ld ix,#3ef3 jr to_dos 2.2.2 Reading port #5f. Goes to trdos ROM to address #3f72 and after several transitions flies away #5cc2. At address #5cb6 there should be #f4! ; the output is c, a is the contents of #5f. frpr5f ld (frp05f+#01),sp ld a,#c3 ld hl,frp05f ld (#5cc2),a ld (#5cc3),hl ld ix,#3f72 jr to_dos frp05f ld sp,#0000 ret 2.2.3 Reading port #3f. Everything is similar to #5f. frpr3f ld (frp03f+#01),sp ld a,#c3 ld hl,frp03f ld (#5cc2),a ld (#5cc3),hl ld ix,#3f69 jr to_dos frp03f ld sp,#0000 ret 2.2.4 Reading port #1f. There are quite a few ways to read this port. They all have some shortcomings. This one too. But he is the best my opinion. In reg. d - current cylinder. During of its work, the procedure reads the value #1f and stores it at #5ccd, after which it tries to position the catch on the cylinder from d. Then it goes at #5cc2. There, if necessary, you can applyimmediate interrupt command, stop twist the disk drive that has begun to spin up or anything else... frpr1f ;call frpr3f ;ld d,a ld (frp01f+#01),sp ld a,#c3 ld hl,frp01f ld (#5cc2),a ld (#5cc3),hl ld ix,#2740 jr to_dos frp01f ld sp,#0000 ld a,(#5ccd) ret 3. Some auxiliary procedures ry. 3.1 Side installation. At the input d - track number! setside push af,bc,de ld a,(drive) srl d ld b,#3c ;top jr nc,$+#04 ld b,#2c ;bottom or b call toprff ;installation pop de,bc,af ret 3.2 Step forward. stepfw push af,bc ld a,#58 call topr1f ;write command call intrq ;wait for execution pop bc,af ret 3.3 Move to next logical track. At input d - current track, at input course d=d+1. nxttrk push af inc d call setside ;set side ld a,d srl a jr c,$+#05 ;if necessary, then call stepfw ;step forward pop af ret 3.4 Positioning on a given track in d. ptrk push af,bc call setside ld a,d ;write to srl a ;data register call topr7f ;number of the required ;cylinderld a,#18 ;positioning call topr1f call intrq ;wait for execution pop bc,af ret . == { End } ========================================================= { tr_dosv2.cod } == == { Begin } ======================================================== { tr_dosv3.cod } == Volume 3 Here we will consider such general known things like reading and writing secto- ra, sector block, read address, read track and track recording (more known as formatting). 1. Read or write one sector. To read, use the procedure address #2090 in trdos ROM, for recording it the same, but starting from #2099. In case of error contents of memory cell at address #5cd6 will increase by 1. At the entrance hl - address, de - track and sec- torus, c - type of operation, depends on 0 bits (0-read, 1-write). Initially, the drive should already be promoted, the required track is set and side. This procedure attempts to write/write the sector four times, after what does recovery do and 4 more attempts. In case of failure there will be an exhibition flax flag carry. Recovery is done to eliminate erroneous positioning nia. wo_sec push hl,de,bc ld a,(#5cd6) push af ;save. ld a,e ;sectors on the disk inc a ;numbered from 1. ld e,c ;save the type;operations in e. call topr5f ld bc,wo_se1 ;return address. push bc ld bc,$ ;address indicates push bc ;to byte #01. bit 0,e jr nz,sa_sec ;for recording. ld bc,#2090 push bc jr sa_se1 ;---------------------; sa_sec ld b,#01 push bc ld bc,#2099 push bc ld bc,#3fca ;write to end ;operations. push bc ld a,#a0 ;sector entry. call topr1f sa_se1 ld bc,#017f di jp #3d2f ;---------------------; wo_se1 di ;#2090 on exit ;allows interruptions- ;vania. ld a,(#5cd6) ;restore pop bc ;and compare. cp b ld a,b ld (#5cd6),a pop bc,de,hl ret z ;exit if ;everything is correct. ;---------------------; ;on the 4th attempt it makes a recovery, and ;on the eighth it comes out with carry=1 wo_ser push af wo_sr0 ld a,#00 inc a and #07 ld(wo_sr0+#01),a jr z,wo_sr3 cp #04 jr z,wo_sr2 wo_sr1 pop af jr wo_sec ;---------------------; wo_sr2 push bc ld a,#08 ;recovery call topr1f call intrqcall ptrk ;positioning pop bc jr wo_sr1 ;---------------------; ;sets carry. wo_sr3 pop af scf ret 2. Read or write a block of sectors. Actually, based on the procedures very little data can be collected earlier lazy program. Here you only need note that the sector is being read separately, and increasing the address separately, because the controller always reads the entire sec- torus, and the sector can have a size of 128, 256, 512 and 1024 bytes. Usage example: ld hl,#4000 ;address ld de,#0000 ;track/sector ld bc,#1000 ;quantity/type call driver ... driver call ptrk ;positioning call wo_sec ;read/write. jr c,error ;do something ;smart. inc h ;sector length ;equals 256. inc e bit 4,e ;16 sectors per jr z,$+#05 ;track. ld e,#00 inc d dec b jr nz,driver ret 3. Reading the address label. It is assumed that the drive is already promoted. ld a,#c0 ;read address. call topr1f ld hl,buffer ;buffer 6 bytes. ld c,#7f ;data register. ld ix,#3fe5 ;reading. jp to_dos 4. Reading the track.ld a,#e0 ;reading track. call topr1f ld hl,buffer ;about 6300 bytes. ld c,#7f ld ix,#3fe5 jp to_dos 5. Record a track. It must be created in the computer memory a complete image of the track. Necessary remember that the controller when formatted NI cannot write bytes #f5 to disk, #f6, #f7. ld a,#f0 ;record track. call topr1f ld hl,buffer ;image address. ld c,#7f ld ix,#3fca ;record. jp to_dos . == { End } ========================================================= { tr_dosv3.cod } == == { Begin } ======================================================== { tr_dosv4.cod } == Volume 4 This is where we actually come to... Why was this all started? I want it late to kill those who had the courage to then to get to this part of me a tale of woe about no one the necessary secrets of VG. Okay, lyrics aside. There will be describes how to find a drive, search disk in this drive, instantaneous new disk drive, control over availability disk in the drive, music downloaders ki and disk autorun when accessing him using standard TRDOS means; a Some tips will also be given. I hope that the reader has already had enough understood the functioning of the controller ra, because I should comment on the code pretty tired.1. Search for a drive. Performed by issuing commands dy recovery and movement verification heads on the zero cylinder. Because it has been restored formation is a team of the first tier pa, then it will be executed regardless of the presence of a disk in the drive. At the entrance reg. a - drive number, the carry signal flag set at the output lyses about the absence of a disk drive. seadrv or #3c call toprff ld a,#08 call topr1f call intrq call frpr1f bit 2,a ret nz scf ret 2. Search for a disk in the drive. Unwinds in some way drive and then an interrupt command is issued movement according to the index pulse. Because It is quite possible that the disk is in the drive no and the index pulse will not appear at all in general, a wait procedure is used readiness fixed time. Carry flag on output - no disk. seadsk ld a,#08 call topr1f call intrq ld a,#d2 call topr1f call intrqw ld a,d or e ret nz scf ret 3. Instant drive stop. The need for this action may arise for various reasons, for example from the previous paragraph it is clear that when If there is no disc in the drive, it may rotate for a very long time. There are several ways to stop I'll list 3.3.1. Resetting the controller. Not the best way. Pretty this was discussed in detail in the description port #ff. stpdrv xor a call toprff ld a,#3c call toprff ld a,#d8 call topr1f ei halt halt ret 3.2. Execution of auxiliary co- mands with modifier h=0. In my opinion this is the best way. Not- no income. In this particular case sometimes the step command is used, although this not critical. stpdrv ld a,#20 jp topr1f 3.3. Supply to the controller input is required required number of index pulses. Cool way. Practical in my opinion, has no change, due to zi with the perfection of the 2nd method. stpdrv ld b,#10 stpdr0 ld a,#34 call toprff ld a,#3c call toprff djnz stpdr0 ret 4. Disk availability control. May be required if you are lazy make any option in the program for re-reading the disc or for other purposes any goals. And in general, add- Close control over the user is not superfluous there will be. Carried out by monitoring changes Signal reduction write protection. Do it not necessary very often, once every interruption will be quite enough. Can be done this is much less common, but then the disk drive It will be disgusting to blink. Moreover, if not a very frequent survey, the user can keep uppull out the disk. It is also necessary before the beginning of control to find out the current state- record protection, and then compare read with previously remembered. In the port reading procedure #1f is uncomment the lines reading the port #3f. Or feed the current cylinder procedure in any other way. The algorithm is extremely transparent: positional We look at the current cylinder, read the re- state hyster and stop the disco water It is worth saying that at wrstat the initial protection state is stored records. tstdsk call frpr3f call topr7f ld a,#18 call topr1f call intrq call frpr1f push af call intrq ld a,#20 call topr1f pop af and #40 cp #00 wrstat equ $-#01 ret z scf ret . == { End } ========================================================= { tr_dosv4.cod } == WBR, Oleg.

From Aleksey Senilov To Oleg Grigoriev 7 July 2003

||*()*|| Hello, _/Oleg/_! June 19, 2003 22:12, Oleg Grigoriev wrote to All: OG> suddenly someone will be interested in it, like an antique. :) Not an antique at all! OG> p.s. By the way, I can dig up something else from the sources. driver type OG> flop and winch driver under isdos. if anyone else is interested. :) Me please :) Flop driver. All the best! /*Gandalf*/ *Grey* was with you. ||*()*||

From Oleg Grigoriev To Aleksey Senilov 24 July 2003

Let your enemies, Aleksey, die without sons! 07 Jul 2003 at 21:24, Aleksey Senilov => Oleg Grigoriev: OG>> suddenly someone will be interested in it, like an antique. :) AS> Not an antique at all! Is there anything else relevant there? no, I'm serious. OG>> p.s. By the way, I can dig up something else from the sources. type OG>> flop driver and winch driver for isdos. if this is for anyone else OG>> interesting. :) AS> Me please :) Flop driver. I did dig it up. sorry for the brakes. yes, with comments there is tension and code such that the devil will break his leg. :) == { Begin } ======================================================== { compiler.bat } == as2 #0R_driv.as /.key%000 link #0R_driv.obj /res /out #0R_driv.blk as2 #0R_driv.as /.key%001 link #0R_driv.obj /res /out #0R+MOA.blk as2 #0R_driv.as /.key%010 link #0R_driv.obj /res /out #0R_drvh.blk as2 #0R_driv.as /.key%011 link #0R_driv.obj /res /out #0R+MOAh.blk . == { End } ========================================================== { compiler.bat } == == { Begin } ======================================================== { #0R_driv.as } == ;********************************************************************** ; //LICENSE ; ; Copyright - 1998-2000, Oleg Grigoriev. ; ; 1. Source text and set of drivers (hereinafter referred to as the 'program'); distributed according to the principle 'as is