Merge pull request #374 from davidgiven/ibm

Make the gap fill byte configurable.
This commit is contained in:
David Given
2021-12-05 22:27:45 +00:00
committed by GitHub
2 changed files with 16 additions and 9 deletions

View File

@@ -133,11 +133,17 @@ public:
encodeMfm(_bits, _cursor, bytes, _lastBit);
};
auto writeFillerRawBytes = [&](int count, uint16_t byte)
{
for (int i=0; i<count; i++)
writeRawBits(byte, 16);
};
auto writeFillerBytes = [&](int count, uint8_t byte)
{
Bytes bytes = { byte };
Bytes b { byte };
for (int i=0; i<count; i++)
writeBytes(bytes);
writeBytes(b);
};
double clockRateUs = 1e3 / trackdata.clock_rate_khz();
@@ -160,9 +166,9 @@ public:
}
}
uint8_t gapFill = trackdata.use_fm() ? 0x00 : 0x4e;
uint16_t gapFill = trackdata.gap_fill_byte();
writeFillerBytes(trackdata.gap0(), gapFill);
writeFillerRawBytes(trackdata.gap0(), gapFill);
if (trackdata.emit_iam())
{
writeFillerBytes(trackdata.use_fm() ? 6 : 12, 0x00);
@@ -172,7 +178,7 @@ public:
writeRawBits(MFM_IAM_SEPARATOR, 16);
}
writeRawBits(trackdata.use_fm() ? FM_IAM_RECORD : MFM_IAM_RECORD, 16);
writeFillerBytes(trackdata.gap1(), gapFill);
writeFillerRawBytes(trackdata.gap1(), gapFill);
}
int logicalSide = physicalSide ^ trackdata.swap_sides();
@@ -180,7 +186,7 @@ public:
for (int sectorId : trackdata.sectors().sector())
{
if (!first)
writeFillerBytes(trackdata.gap3(), gapFill);
writeFillerRawBytes(trackdata.gap3(), gapFill);
first = false;
const auto& sectorData = image.get(physicalTrack, logicalSide, sectorId);
@@ -227,7 +233,7 @@ public:
writeBytes(header.slice(conventionalHeaderStart));
}
writeFillerBytes(trackdata.gap2(), gapFill);
writeFillerRawBytes(trackdata.gap2(), gapFill);
{
Bytes data;
@@ -264,7 +270,7 @@ public:
if (_cursor >= _bits.size())
Error() << "track data overrun";
while (_cursor < _bits.size())
writeFillerBytes(1, gapFill);
writeFillerRawBytes(1, gapFill);
std::unique_ptr<Fluxmap> fluxmap(new Fluxmap);
fluxmap->appendBits(_bits, clockRateUs*1e3);

View File

@@ -15,7 +15,7 @@ message IbmDecoderProto {
}
message IbmEncoderProto {
// Next: 18
// Next: 19
message TrackdataProto {
message SectorsProto {
repeated int32 sector = 1 [(help) = "write these sectors (in order) on each track"];
@@ -37,6 +37,7 @@ message IbmEncoderProto {
optional int32 gap3 = 12 [default=80, (help) = "size of gap 4 (the post-data or format gap)"];
optional bool swap_sides = 14 [default=false, (help) = "swap side bytes when writing"];
optional SectorsProto sectors = 17 [(help) = "write these sectors (in order) on each track"];
optional int32 gap_fill_byte = 18 [default=0x9254, (help) = "16-bit raw bit pattern of gap fill byte"];
}
repeated TrackdataProto trackdata = 1;