On 2013-05-30, at 22:48, Greg King wrote: >>> Yes, each track can be considered a closed loop of data, just like a >>> real disk. It is usually good practice to have the track splice occur at >>> this loop as it was written on the floppy; but, that is not always possible >>> to determine. >> >> Now, that makes it even more complicated (just when you thought it was safe). >> So, I have always to wrap around when I potentially miss some data at the end of the track. > > "Mirror" the track buffer. (Think about Commodore's I/O chips and their "shadow" registers.) Double the length of the buffer; and, store each byte twice (starting at the beginning of the buffer, and at the halfway spot). > > Then, your program won't need to care where the track seam happens > to be -- there is no wrap-around! That's a quick shot indeed. Just - one shouldn't use "shadow" registers as we all know ;-) I mean in the modern machine a few KiBs here or there doesn't make any real difference but for a CBM almost 16KiB for the buffer alone is a high price. So far I did this for the SYNC byte0 = gcrBytes + offset; switch (trackDataLength - offset) // we always need two 2 or 3 bytes to get 10 consecutive bits so checking the last single byte doesn't make sense unless we "wrap around" the buffer { case 1: byte1 = gcrBytes; byte2 = gcrBytes + 1; break; case 2: byte1 = gcrBytes + offset + 1; byte2 = gcrBytes; break; default: byte1 = gcrBytes + offset + 1; byte2 = gcrBytes + offset + 2; break; } which I believe takes care of the wrapping in a relatively effective way. -- SD! Message was sent through the cbm-hackers mailing listReceived on 2013-05-30 22:00:03
Archive generated by hypermail 2.2.0.