| Previous | 15994 Revisions | Next |
| r15036 Thursday 26th April, 2012 at 02:46:00 UTC by Jonathan Gevaryahu |
|---|
| ap2_dsk: added some missing defines and comments and a way to select whether to use lenient (if the address mark contents are sane regardless of whether the checksum byte was good or not) or normal (only if checksum was valid) usage of the address marks. Also switched the default output sector order from prodos order to dos3.3 order, which is slightly more useful. Added a define to switch between the three possible sector orderings: prodos, dos3.3, and logical. [Lord Nightmare] |
| [src/lib/formats] | ap2_dsk.c |
| r15035 | r15036 | |
|---|---|---|
| 664 | 664 | { |
| 665 | 665 | int g_tracks, g_heads; |
| 666 | 666 | int visualgrid[16][35]; // visualizer grid, cleared/initialized below |
| 667 | // lenient addr check: if unset, only accept an addr mark if the checksum was good | |
| 668 | // if set, accept an addr mark if the track and sector values are both sane | |
| 669 | #undef LENIENT_ADDR_CHECK | |
| 670 | // if set, use the old, not as robust logic for choosing which copy of a decoded sector to write | |
| 671 | // to the resulting image if the sector has a bad checksum and/or postamble | |
| 672 | #undef USE_OLD_BEST_SECTOR_PRIORITY | |
| 673 | // select a sector order for resulting file: 0 = logical, 1 = dos3.3, 2 = prodos | |
| 674 | #define SECTOR_ORDER 1 | |
| 675 | // nothing found | |
| 667 | 676 | #define NOTFOUND 0 |
| 668 | 677 | // address mark was found |
| 669 | 678 | #define ADDRFOUND 1 |
| r15035 | r15036 | |
| 726 | 735 | UINT8 chk = gcr4_decode(h[6],h[7]); |
| 727 | 736 | UINT32 post = (h[8]<<16)|(h[9]<<8)|h[10]; |
| 728 | 737 | printf("Address Mark:\tVolume %d, Track %d, Sector %2d, Checksum %02X: %s, Postamble %03X: %s\n", vl, tr, se, chk, (chk ^ vl ^ tr ^ se)==0?"OK":"BAD", post, (post&0xFFFF00)==0xDEAA00?"OK":"BAD"); |
| 738 | // sanity check | |
| 729 | 739 | if (tr == track/2 && se < nsect) { |
| 730 | visualgrid[se][track/2] |= ADDRFOUND; | |
| 731 | visualgrid[se][track/2] |= (chk ^ vl ^ tr ^ se)==0?ADDRGOOD:0; | |
| 740 | visualgrid[se][track/2] |= ADDRFOUND; | |
| 741 | visualgrid[se][track/2] |= (chk ^ vl ^ tr ^ se)==0?ADDRGOOD:0; | |
| 742 | } | |
| 743 | #ifdef LENIENT_ADDR_CHECK | |
| 744 | if ((visualgrid[se][track/2] & ADDRFOUND) == ADDRFOUND) { | |
| 745 | #else | |
| 746 | if ((visualgrid[se][track/2] & ADDRGOOD) == ADDRGOOD) { | |
| 747 | #endif | |
| 732 | 748 | int opos = pos; |
| 733 | 749 | int owrap = wrap; |
| 734 | 750 | hb = 0; |
| r15035 | r15036 | |
| 747 | 763 | } |
| 748 | 764 | if((hb == 4)&&(dosver == 0)) { |
| 749 | 765 | visualgrid[se][track/2] |= DATAFOUND; |
| 750 | int prodos_translate[16] = { | |
| 766 | int sector_translate[16] = { | |
| 767 | #if SECTOR_ORDER == 0 | |
| 768 | // logical order (0-15) | |
| 769 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | |
| 770 | 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F | |
| 771 | #elif SECTOR_ORDER == 1 | |
| 772 | // DOS order (*.do) | |
| 773 | 0x00, 0x07, 0x0E, 0x06, 0x0D, 0x05, 0x0C, 0x04, | |
| 774 | 0x0B, 0x03, 0x0A, 0x02, 0x09, 0x01, 0x08, 0x0F | |
| 775 | #elif SECTOR_ORDER == 2 | |
| 776 | // prodos order (*.po) | |
| 751 | 777 | 0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B, |
| 752 | 778 | 0x04, 0x0C, 0x05, 0x0D, 0x06, 0x0E, 0x07, 0x0F |
| 779 | #endif | |
| 753 | 780 | }; |
| 754 | UINT8 *dest = sectdata+(256)* | |
| 781 | UINT8 *dest = sectdata+(256)* | |
| 755 | 782 | UINT8 data[0x157]; |
| 756 | 783 | UINT32 dpost = 0; |
| 757 | 784 | UINT8 c = 0; |
| Previous | 15994 Revisions | Next |