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

Function micropolisChecksum

arch/micropolis/decoder.cc:25–39  ·  view source on GitHub ↗

Standard Micropolis checksum. Adds all bytes, with carry. */

Source from the content-addressed store, hash-verified

23
24/* Standard Micropolis checksum. Adds all bytes, with carry. */
25uint8_t micropolisChecksum(const Bytes& bytes)
26{
27 ByteReader br(bytes);
28 uint16_t sum = 0;
29 while (!br.eof())
30 {
31 if (sum > 0xFF)
32 {
33 sum -= 0x100 - 1;
34 }
35 sum += br.read_8();
36 }
37 /* The last carry is ignored */
38 return sum & 0xFF;
39}
40
41/* Vector MZOS does not use the standard Micropolis checksum.
42 * The checksum is initially 0.

Callers 2

write_sectorFunction · 0.85
decodeSectorRecordMethod · 0.85

Calls 2

read_8Method · 0.80
eofMethod · 0.45

Tested by

no test coverage detected