[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 6502 illegal opcodes questions



In article <446f7e4c$0$4512$9b4e6d93@newsread2.arcor-online.net>,
 Linards Ticmanis <ticmanis@gmx.de> wrote:

> Paul Schlyter wrote:
> 
> >> IIRC the S-JiffyDOS patch uses illegal opcodes to speed up GCR decoding.
> >> (Jochen, are you reading here and can comment?)
> > 
> > That can also be done without illegal opcodes.  The Apple Pascal RWTS
> > did it, and was able to read all sectors of a floppy on one revolution
> > of the disk -- oncluding GCR decoding on-the-fly.
> 
> But isn't Apple GCR a bit simpler than commodore GCR? Apple's 16-sector 
> format stores three data bytes per four disk bytes (3:4), Commodore gets 
> in four data bytes per five disk bytes (4:5) IIRC.

I've tinkered with code to decode both using a catweasel board.  The 
Apple GCR is more robust, but more complicated.  It has extra codes used 
for data marks (so there is no question where the data begins), it 
encodes 5 or 6 bits in 8 for more redundancy (you are more likely to get 
a bad nibble and know the sector is bad with no need for a checksum), 
and more important, the encoding relies on every nibble starting with a 
'1' bit, so after an error it has a good chance of getting back in 
nibble sync (and you might get some useful data from a bad sector).

However, the bits are stored in a crazy order.  After reading an Apple 
GCR sector, you have to run the 5-bit or 6-bit decoded nibble data 
through an unscrambler, which is different between 13 sector and 16 
sector encodings.  The 13 sector decoder is a total mess in C.

Commodore's GCR relies on long strings of 1s to synchronize, so if there 
is a glitch in the gap, you will think you see data, and by the time you 
figure it out, you could have gone too far and missed the real sector 
header.  I had lots of problems keeping sync with the sector headers.  I 
can't remember exactly, but I know I had to do a lot of tweaking to 
avoid false syncs.  And nibbles can start with either a 0 or a 1, so if 
you get lost, you will remain hopelessly out of sync with your data.