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

Function vectorGraphicEccFix

arch/micropolis/decoder.cc:107–132  ·  view source on GitHub ↗

Fixes bytes when possible, returning true if changed. */

Source from the content-addressed store, hash-verified

105
106/* Fixes bytes when possible, returning true if changed. */
107static bool vectorGraphicEccFix(Bytes& bytes, uint32_t syndrome)
108{
109 uint32_t ecc = syndrome;
110 int pos = (MICROPOLIS_ENCODED_SECTOR_SIZE - 5) * 8 + 7;
111 bool aligned = false;
112 while ((ecc & 0xff000000) == 0)
113 {
114 pos += 8;
115 ecc <<= 8;
116 }
117 for (; pos >= 0; pos--)
118 {
119 bool bit = ecc & 1;
120 ecc >>= 1;
121 if (bit)
122 ecc ^= 0x808264c0;
123 if ((ecc & 0xff07ffff) == 0)
124 aligned = true;
125 if (aligned && pos % 8 == 0)
126 break;
127 }
128 if (pos < 0)
129 return false;
130 bytes[pos / 8] ^= ecc >> 16;
131 return true;
132}
133
134class MicropolisDecoder : public Decoder
135{

Callers 1

decodeSectorRecordMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected