Rework the ibm encoder to allow per-track configurations. Rename everything for

consistency.
This commit is contained in:
David Given
2021-05-19 23:01:32 +02:00
parent 8a136ac4f6
commit a1f4014738
24 changed files with 266 additions and 212 deletions

View File

@@ -3,7 +3,7 @@ syntax = "proto2";
import "lib/common.proto";
message ImgInputOutputProto {
message FormatProto {
message TrackdataProto {
optional int32 track = 1 [(help) = "if present, this format only applies to this track"];
optional int32 side = 2 [(help) = "if present, this format only applies to this side"];
@@ -11,7 +11,7 @@ message ImgInputOutputProto {
optional int32 sectors = 4 [(help) = "number of sectors in this track"];
}
repeated FormatProto format = 4 [(help) = "per-track format information (repeatable)"];
repeated TrackdataProto trackdata = 4 [(help) = "per-track format information (repeatable)"];
optional int32 tracks = 5 [default=80, (help) = "number of tracks in image"];
optional int32 sides = 6 [default=2, (help) = "number of sides in image"];
}

View File

@@ -27,12 +27,12 @@ public:
{
for (int side = 0; side < _config.img().sides(); side++)
{
ImgInputOutputProto::FormatProto format;
getTrackFormat(format, track, side);
ImgInputOutputProto::TrackdataProto trackdata;
getTrackFormat(trackdata, track, side);
for (int sectorId = 0; sectorId < format.sectors(); sectorId++)
for (int sectorId = 0; sectorId < trackdata.sectors(); sectorId++)
{
Bytes data(format.sector_size());
Bytes data(trackdata.sector_size());
inputFile.read((char*) data.begin(), data.size());
std::unique_ptr<Sector>& sector = sectors.get(track, side, sectorId);
@@ -57,17 +57,17 @@ public:
}
private:
void getTrackFormat(ImgInputOutputProto::FormatProto& format, unsigned track, unsigned side)
void getTrackFormat(ImgInputOutputProto::TrackdataProto& trackdata, unsigned track, unsigned side)
{
format.Clear();
for (const ImgInputOutputProto::FormatProto& f : _config.img().format())
trackdata.Clear();
for (const ImgInputOutputProto::TrackdataProto& f : _config.img().trackdata())
{
if (f.has_track() && (f.track() != track))
continue;
if (f.has_side() && (f.side() != side))
continue;
format.MergeFrom(f);
trackdata.MergeFrom(f);
}
}
};