what does ' length 12656/4' mean in output?
how long is the header, what is its format?
thanks.
edit: is it like this:
OFFSET Count TYPE Description
0000h 8 byte 'UAE-1ADF'
0008h 4 byte trackcount
000Ch 4 byte 0=amigados 1=raw mfm
0010h 4 byte tracklength
0014h 4 byte tracklength in bits
0018h 4 byte 0=amigados 1=raw mfm
...
Shrug... this does not look like anything I would expect to find on a standard Amiga formatted floppy disk. Are you sure you are looking for MFM data? If this is the data structure layout, I would expect it to be a container format, not the contents.
I just cant find '0xAAAA AAAA 4489 4489'
( http://lclevy.free.fr/adflib/adf_info.html#p23 )
You may not be able to see this pattern in the encoded MFM data at all. The thing is, this is a bit pattern, not a byte pattern. It can start in the MFM bit stream at virtually any position in the track buffer, but usually it's somewhere near the beginning of the buffer.
So, how do you find the bit position where it starts? The key is the 0xAAAA pattern, which either shows up as 0xAAAA in the MFM bit stream (if the header starts at an even bit position), or as 0x5555 (if it starts at an odd bit position).
The first step to decoding is to find out where the 0xAAAA bit pattern shows up. Because it covers 32 bits, you should be able to find it by looking for any two consecutive bytes which either read as 0xAA or as 0x55.
UWORD * mfm_buffer;
int mfm_buffer_size, i;
int num_words = mfm_buffer_size / sizeof(*mfm_buffer);
UWORD pattern;
int word_position = -1;
for(i = 0 ; i < num_words ; i++)
{
if (mfm_buffer[i] == 0xAAAA)
{
pattern = 0xAAAA;
word_position = i;
break;
}
else if (mfm_buffer[i] == 0x5555)
{
pattern = 0x5555;
word_position = i;
break;
}
}
/* Skip the pattern if it shows up again, which happens
* if it started at the very first bit of the byte.
*/
if(word_position != -1 && word_position + 1 < num_words && mfm_buffer[word_position+1] == pattern)
word_position++;
If these two bytes are part of a sector header, then they should be followed by two 0x4489 bit patterns in the next 0..14 bits. You need to figure out which bit position they show up at.
if(word_position != -1 && word_position + 1 < num_words)
{
int bit_position = -1;
ULONG match;
match = (((ULONG)mfm_buffer[word_position]) << 16) | mfm_buffer[word_position+1];
for(i = 0 ; i < 15 ; i++)
{
if(((match << i) & 0xFFFF0000) == 0x44890000)
{
bit_position = i;
break;
}
}
}
At this point you should be able to tell if you found the byte and bit positions of the first 0x4489 sync bit pattern. The next step would be to check if the first 0x4489 pattern you found is followed by another one. If that's the case, you can begin to read the individual words, shift them as needed and reconstruct both the sector header and sector data in their MFM-encoded forms.
Please note that in production code the task of finding the sync words is usually table-driven and does not run in a loop which shifts bits around