MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / encode

Method encode

arch/ibm/encoder.cc:110–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109public:
110 std::unique_ptr<Fluxmap> encode(const LogicalTrackLayout& ltl,
111 const std::vector<std::shared_ptr<const Sector>>& sectors,
112 const Image& image) override
113 {
114 IbmEncoderProto::TrackdataProto trackdata;
115 getEncoderTrackData(trackdata, ltl.logicalCylinder, ltl.logicalHead);
116
117 auto writeBytes = [&](const Bytes& bytes)
118 {
119 if (trackdata.use_fm())
120 encodeFm(_bits, _cursor, bytes);
121 else
122 encodeMfm(_bits, _cursor, bytes, _lastBit);
123 };
124
125 auto writeFillerRawBytes = [&](int count, uint16_t byte)
126 {
127 for (int i = 0; i < count; i++)
128 writeRawBits(byte, 16);
129 };
130
131 auto writeFillerBytes = [&](int count, uint8_t byte)
132 {
133 Bytes b{byte};
134 for (int i = 0; i < count; i++)
135 writeBytes(b);
136 };
137
138 double clockRateUs = trackdata.target_clock_period_us();
139 if (!trackdata.use_fm())
140 clockRateUs /= 2.0;
141 int bitsPerRevolution =
142 (trackdata.target_rotational_period_ms() * 1000.0) / clockRateUs;
143 _bits.resize(bitsPerRevolution);
144 _cursor = 0;
145
146 uint8_t idamUnencoded = decodeUint16(trackdata.idam_byte());
147 uint8_t damUnencoded = decodeUint16(trackdata.dam_byte());
148
149 uint8_t sectorSize = 0;
150 {
151 int s = ltl.sectorSize >> 7;
152 while (s > 1)
153 {
154 s >>= 1;
155 sectorSize += 1;
156 }
157 }
158
159 uint16_t gapFill = trackdata.gap_fill_byte();
160
161 writeFillerRawBytes(trackdata.gap0(), gapFill);
162 if (trackdata.emit_iam())
163 {
164 writeFillerBytes(trackdata.use_fm() ? 6 : 12, 0x00);
165 if (!trackdata.use_fm())
166 {
167 for (int i = 0; i < 3; i++)

Callers 2

writeTracksFunction · 0.45
writeTracksAndVerifyFunction · 0.45

Calls 8

encodeFmFunction · 0.85
encodeMfmFunction · 0.85
errorFunction · 0.85
sliceMethod · 0.80
decodeUint16Function · 0.70
crc16Function · 0.50
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected