Make cross-track sector collation optional (as it usually just makes things

confusing).
This commit is contained in:
David Given
2024-02-03 01:08:23 +01:00
parent df83b558bf
commit bb82dc864a
6 changed files with 33 additions and 12 deletions

View File

@@ -137,8 +137,10 @@ std::shared_ptr<TrackDataFlux> Decoder::decodeToSectors(
if (_sector->status != Sector::MISSING) if (_sector->status != Sector::MISSING)
{ {
auto trackLayout = Layout::getLayoutOfTrack( if ((_sector->status == Sector::OK) &&
_sector->logicalTrack, _sector->logicalSide); ((_sector->logicalTrack != trackInfo->logicalTrack) ||
(_sector->logicalSide != trackInfo->logicalSide)))
_sector->status == Sector::WRONG_PLACE;
_trackdata->sectors.push_back(_sector); _trackdata->sectors.push_back(_sector);
} }
} }

View File

@@ -21,7 +21,7 @@ import "arch/zilogmcz/zilogmcz.proto";
import "lib/fluxsink/fluxsink.proto"; import "lib/fluxsink/fluxsink.proto";
import "lib/common.proto"; import "lib/common.proto";
//NEXT: 32 //NEXT: 33
message DecoderProto { message DecoderProto {
optional double pulse_debounce_threshold = 1 [default = 0.30, optional double pulse_debounce_threshold = 1 [default = 0.30,
(help) = "ignore pulses with intervals shorter than this, in fractions of a clock"]; (help) = "ignore pulses with intervals shorter than this, in fractions of a clock"];
@@ -66,6 +66,7 @@ message DecoderProto {
optional string write_csv_to = 23 optional string write_csv_to = 23
[(help) = "if set, write a CSV report of the disk state"]; [(help) = "if set, write a CSV report of the disk state"];
optional bool skip_unnecessary_tracks = 29 [default = true, optional bool skip_unnecessary_tracks = 29 [default = true,
(help) = "don't read tracks if we already have all necessary sectors"]; (help) = "don't read physical tracks if we already have all necessary sectors"];
optional bool collate_sectors_from_all_tracks = 32 [default = false,
(help) = "when creating the image, consider all valid sectors even if they're on the wrong track"];
} }

View File

@@ -97,9 +97,16 @@ void measureDiskRotation()
log(EndSpeedOperationLogMessage{oneRevolution}); log(EndSpeedOperationLogMessage{oneRevolution});
} }
static int getEffectiveStatus(int status)
{
if ((status == Sector::WRONG_PLACE) &&
globalConfig()->decoder().collate_sectors_from_all_tracks())
return Sector::OK;
return status;
}
/* Given a set of sectors, deduplicates them sensibly (e.g. if there is a good /* Given a set of sectors, deduplicates them sensibly (e.g. if there is a good
* and bad version of the same sector, the bad version is dropped). */ * and bad version of the same sector, the bad version is dropped). */
static std::set<std::shared_ptr<const Sector>> collectSectors( static std::set<std::shared_ptr<const Sector>> collectSectors(
std::set<std::shared_ptr<const Sector>>& track_sectors, std::set<std::shared_ptr<const Sector>>& track_sectors,
bool collapse_conflicts = true) bool collapse_conflicts = true)
@@ -124,9 +131,11 @@ static std::set<std::shared_ptr<const Sector>> collectSectors(
it->second, it->second,
[&](auto left, auto& rightit) -> std::shared_ptr<const Sector> [&](auto left, auto& rightit) -> std::shared_ptr<const Sector>
{ {
int leftStatus = left->status;
auto& right = rightit.second; auto& right = rightit.second;
if ((left->status == Sector::OK) && int rightStatus = right->status;
(right->status == Sector::OK) && if ((leftStatus == Sector::OK) &&
(rightStatus == Sector::OK) &&
(left->data != right->data)) (left->data != right->data))
{ {
if (!collapse_conflicts) if (!collapse_conflicts)
@@ -139,13 +148,13 @@ static std::set<std::shared_ptr<const Sector>> collectSectors(
s->status = Sector::CONFLICT; s->status = Sector::CONFLICT;
return s; return s;
} }
if (left->status == Sector::CONFLICT) if (leftStatus == Sector::CONFLICT)
return left; return left;
if (right->status == Sector::CONFLICT) if (rightStatus == Sector::CONFLICT)
return right; return right;
if (left->status == Sector::OK) if (leftStatus == Sector::OK)
return left; return left;
if (right->status == Sector::OK) if (rightStatus == Sector::OK)
return right; return right;
return left; return left;
}); });

View File

@@ -31,6 +31,8 @@ std::string Sector::statusToString(Status status)
return "present but no data found"; return "present but no data found";
case Status::CONFLICT: case Status::CONFLICT:
return "conflicting data"; return "conflicting data";
case Status::WRONG_PLACE:
return "incorrectly placed";
default: default:
return fmt::format("unknown error {}", status); return fmt::format("unknown error {}", status);
} }
@@ -50,6 +52,8 @@ std::string Sector::statusToChar(Status status)
return "!"; return "!";
case Status::CONFLICT: case Status::CONFLICT:
return "*"; return "*";
case Status::WRONG_PLACE:
return "/";
default: default:
return "?"; return "?";
} }

View File

@@ -44,6 +44,7 @@ struct Sector : public LogicalLocation
DATA_MISSING, DATA_MISSING,
CONFLICT, CONFLICT,
INTERNAL_ERROR, INTERNAL_ERROR,
WRONG_PLACE,
}; };
static std::string statusToString(Status status); static std::string statusToString(Status status);

View File

@@ -109,6 +109,10 @@ option_group {
set_by_default: true set_by_default: true
config { config {
decoder {
collate_sectors_from_all_tracks: true
}
layout { layout {
format_type: FORMATTYPE_80TRACK format_type: FORMATTYPE_80TRACK
} }