1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Improved logic for detecting when all sense has been derived from a track to spot any repeated track, not necessarily the first one. That avoids sectors that run over the index hold and obscure the first throwing things.

This commit is contained in:
Thomas Harte 2017-08-17 15:31:53 -04:00
parent 733ee5a5c3
commit 4f8b89772e

View File

@ -11,6 +11,8 @@
#include "../PCMTrack.hpp"
#include "../../../NumberTheory/CRC.hpp"
#include <set>
using namespace Storage::Encodings::MFM;
class MFMEncoder: public Encoder {
@ -274,13 +276,20 @@ std::shared_ptr<Sector> Parser::get_sector(uint8_t head, uint8_t track, uint8_t
seek_to_track(track);
int track_index = get_index(head, track, 0);
// Populate the sector cache if it's not already populated.
// Populate the sector cache if it's not already populated by asking for sectors unless and until
// one is returned that has already been seen.
if(decoded_tracks_.find(track_index) == decoded_tracks_.end()) {
std::shared_ptr<Sector> first_sector = get_next_sector();
std::set<uint8_t> visited_sectors;
if(first_sector) {
while(1) {
std::shared_ptr<Sector> next_sector = get_next_sector();
if(!next_sector || next_sector->sector == first_sector->sector) break;
if(next_sector) {
if(visited_sectors.find(next_sector->sector) != visited_sectors.end()) {
break;
}
visited_sectors.insert(next_sector->sector);
}
}
}
decoded_tracks_.insert(track_index);