Quote:
Originally Posted by BlueAchenar
I saw somewhere that the blitter could be used to encode/decode MFM disk tracks. Is this really possible?
|
Certainly. The logical operation that you perform to decode a sector is, in C:
Code:
char rawSectorData[512*2];
char decodedSectorData[512];
// fill rawSectorData with contents first
for (int i = 0; i < 512; i++)
decodedSectorData[i] = ((rawSectorData[i] & 0x55) << 1)
| (rawSectorData[i + 512] & 0x55);
In order to perform that operation using the blitter:
- rewrite it using word operations
- the blitter can only shift left when in descending mode, so make loop go backwards
- the blitter shifts before masking together channels, so move shift before masking
Code:
short rawSectorData[256*2];
short decodedSectorData[256];
// fill rawSectorData with contents first
for (int i = 0; i < 256; i++)
decodedSectorData[255 - i] = ((rawSectorData[255 - i] << 1) & ~0x5555)
| (rawSectorData[511 - i] & 0x5555);
So in order to decode with a blit operation, you do something like:
BLTAPT = rawSectorData + 255 words;
BLTBPT = rawSectorData + 511 words;
BLTDPT = decodedSectorData + 255 words;
BPLAMOD..BPLDMOD = 0
BLTCDAT = $5555
minterm = Ac + BC = ABc + Abc + ABC + aBC = $40 + $10 + $80 + $08 = $D8
Channel A-shift = 1
Channel B-shift = 0
Enabled DMA channels = ABD
Descending = 1
=> BLTCON0 = $1DD8
=> BLTCON1 = $0002
BLTAFWM,BLTALWM = $FFFF
BLTSIZE = 256 * 64 + 1