gasman / goldfinch

An open-ended C/Z80 software stack for mass-storage access on the ZX Spectrum
6 stars 0 forks source link

Bounce detection when reading/writing IDE sectors #19

Closed gasman closed 14 years ago

gasman commented 14 years ago

From Velesoft on http://www.worldofspectrum.org/forums/showthread.php?t=26213&page=5:

It's original read sector(512bytes) code from GASWARE:

ld bc,0x00a3 ; C = data register, 0x00 = loop x256 inir ; inir twice to read 512 bytes inir

And it's new better code with bouncing detection:

ld bc,0x00a3 ; C = data register, 0x00 = loop x256 inir ; read first 256 bytes dec b dec b inir ; read only 254 bytes in a,(191) ; test read error before read last word form IDE ini ini ;read complette sector bit 3,a ;if DRQ=0 then sector is read with errors (bouncing - early read sector data) jr z,rdrepeat ;program must reread same IDE sector if error is detected

After detect bouncing is good increment software bouncing counter with limited range up to 20x. If sector is read 20x with bouncing then is sector reading very unstable and routine must return error. Mimilar code is good use also in write sector code:

It's original write sector(512bytes) code from GASWARE:

ld bc,0x00a3 ; C = data register, 0x00 = loop x256 otir ; otir twice to write 512 bytes otir

And it's new better code with bouncing detection:

ld bc,0x00a3 ; C = data register, 0x00 = loop x256 otir ; write first 256 bytes dec b dec b otir ; write only 254 bytes in a,(191) ; test write error before write last word to IDE outi outi ;write complette sector bit 3,a ;if DRQ=0 then sector is writed with errors (bouncing - early write sector data) jr z,wrrepeat ;program must rewrite same IDE sector if error is detected

This routines with "software debouncer" work also on unstable hardware. Same routines is used in my DivIDE bios.

Idea of bouncing detection by MTS: http://translate.google.com/translate?u=http%3A%2F%2Fmts.speccy.cz%2F_divide.htm&sl=cs&tl=en&hl=cs&ie=UTF-8

gasman commented 14 years ago

applied in aedc5cc57439d3b6be154deafc89eae0bbdf14e9 and 7302a8eb843ea504c285620f4692f0ffb54fc4dc