static void vc1541_sector_to_gcr(int track, int sector) { int i=0, j, offset, chksum=0; if (vc1541->d64.data==NULL) return; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541_sector_start(); vc1541_sector_data(8, &i); chksum= sector^track ^vc1541->d64.data[D64_TRACK_ID1]^vc1541->d64.data[D64_TRACK_ID2]; vc1541_sector_data(chksum, &i); vc1541_sector_data(sector, &i); vc1541_sector_data(track, &i); vc1541_sector_data(vc1541->d64.data[D64_TRACK_ID1], &i); vc1541_sector_data(vc1541->d64.data[D64_TRACK_ID2], &i); vc1541_sector_data(0xf, &i); vc1541_sector_data(0xf, &i); vc1541_sector_end(&i); /* 5 - 10 gcr bytes cap */ gcr_double_2_gcr(0, 0, 0, 0, vc1541->head.data+i);i+=5; gcr_double_2_gcr(0, 0, 0, 0, vc1541->head.data+i);i+=5; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541->head.data[i++]=0xff; vc1541_sector_data(0x7, &i); chksum=0; for (offset=d64_tracksector2offset(track,sector), j=0; j<256; j++) { chksum^=vc1541->d64.data[offset]; vc1541_sector_data(vc1541->d64.data[offset++], &i); } vc1541_sector_data(chksum, &i); vc1541_sector_data(0, &i); /* padding up */ vc1541_sector_data(0, &i); vc1541_sector_end(&i); gcr_double_2_gcr(0, 0, 0, 0, vc1541->head.data+i);i+=5; gcr_double_2_gcr(0, 0, 0, 0, vc1541->head.data+i);i+=5; }
int d64_getcrc(d64_image *image, int track, int sector) { int pos=d64_tracksector2offset(track, sector)>>8; if (!image->crc) return 0; return image->data[d64_tracksector2offset(image->tracks+1,0)+pos]; }