Jules Richardson wrote:
I did want to
get a primitive MFM data-separator working tonight, but
I've spent all afternoon scratching my head over this and come up with
nothing.
I was going to do all that in software - seemed like a lot easier way of
doing it than having two different data streams from the hardware to
deal with (MFM versus "something else").
Oh, I'm going to do most of that in software too. I just want to get MFM
sync-word detection and maybe pre-decoding working. SWD would be handy for
reading Amiga format discs, on the grounds that the data can start anywhere on
the track, not just at an index pulse.
AIUI, with uPD765-written discs, you'd start reading when the index pulse goes
active, read a whole track, then stop reading when it goes active then
inactive, i.e.:
__ __
INDEX ___| |_____________________| |___
: :
: :
Start point Stop point
This gives you enough overlap (assuming the index sensor is fairly accurate)
to be reasonably sure you've got the whole track. Then you look for the sync
markers and decode it in software.
With Amiga discs, because the data is stored with no index-pulse sync, you
look for the MFM codeword 0x4489 which decodes as 0xA1, but isn't a valid MFM
encoding (there's a missing clock pulse -- see last paragraph and bottom
diagram of <http://en.wikipedia.org/wiki/Modified_Frequency_Modulation>).
The whole reason the datasep is needed is to figure out where the data bits
lie. To detect the sync word, you shift data bits into a 16-bit shift register
according to the transitions (positive *and* negative) of the Data Window
line. If there was a pulse on DATA during a Data Window cycle, you clock in a
one, else you clock in a zero. Then you add a comparator (basically an AND
gate and a bunch of inverters) to signal when the shift register contains
0x4489. You use that signal to trigger the start of an acquisition cycle, then
stop shortly after the sync word is detected again.
The beauty of the sync word is that because it's not valid MFM (but it's close
enough to be picked up by a data separator), it can never appear in normal
data, so you don't have to worry about what to do if the track contains a 0xA1
byte somewhere in a sector (or sector header).
If you want to be ultra-pedantic, you could search for the whole Amiga sync
sequence -- 0xAAAA 0xAAAA 0x4489 0x4489 -- but then you need a 64-bit shift
register instead of a 16-bit shift register.
I'd love to try my idea out, but I don't have any Amiga floppies to play with,
nor do I have an Amiga to create them...
--
Phil. | (\_/) This is Bunny. Copy and paste Bunny
classiccmp at philpem.me.uk | (='.'=) into your signature to help him gain
http://www.philpem.me.uk/ | (")_(") world domination.