| 142 | } |
| 143 | |
| 144 | nanoseconds_t advanceToNextRecord() override |
| 145 | { |
| 146 | nanoseconds_t now = tell().ns(); |
| 147 | |
| 148 | /* For all but the first sector, seek to the next sector pulse. |
| 149 | * The first sector does not contain the sector pulse in the fluxmap. |
| 150 | */ |
| 151 | if (now != 0) |
| 152 | { |
| 153 | seekToIndexMark(); |
| 154 | now = tell().ns(); |
| 155 | } |
| 156 | |
| 157 | /* Discard a possible partial sector at the end of the track. |
| 158 | * This partial sector could be mistaken for a conflicted sector, if |
| 159 | * whatever data read happens to match the checksum of 0, which is |
| 160 | * rare, but has been observed on some disks. There's 570uS of slack in |
| 161 | * each sector, after accounting for preamble, data, and postamble. |
| 162 | */ |
| 163 | if (now > (getFluxmapDuration() - 12.0e6)) |
| 164 | { |
| 165 | seekToIndexMark(); |
| 166 | return 0; |
| 167 | } |
| 168 | |
| 169 | nanoseconds_t clock = seekToPattern(SECTOR_SYNC_PATTERN); |
| 170 | |
| 171 | auto syncDelta = tell().ns() - now; |
| 172 | /* Due to the weak nature of the Micropolis SYNC patern, |
| 173 | * it's possible to detect a false SYNC during the gap |
| 174 | * between the sector pulse and the write gate. If the SYNC |
| 175 | * is detected less than 100uS after the sector pulse, search |
| 176 | * for another valid SYNC. |
| 177 | * |
| 178 | * Reference: Vector Micropolis Disk Controller Board Technical |
| 179 | * Information Manual, pp. 1-16. |
| 180 | */ |
| 181 | if ((syncDelta > 0) && (syncDelta < 100e3)) |
| 182 | { |
| 183 | seekToPattern(SECTOR_ADVANCE_PATTERN); |
| 184 | clock = seekToPattern(SECTOR_SYNC_PATTERN); |
| 185 | } |
| 186 | |
| 187 | _sector->headerStartTime = tell().ns(); |
| 188 | |
| 189 | /* seekToPattern() can skip past the index hole, if this happens |
| 190 | * too close to the end of the Fluxmap, discard the sector. The |
| 191 | * preamble was expected to be 640uS long. |
| 192 | */ |
| 193 | if (_sector->headerStartTime > (getFluxmapDuration() - 11.3e6)) |
| 194 | { |
| 195 | return 0; |
| 196 | } |
| 197 | |
| 198 | return clock; |
| 199 | } |
| 200 | |
| 201 | void decodeSectorRecord() override |