Standard Micropolis checksum. Adds all bytes, with carry. */
| 23 | |
| 24 | /* Standard Micropolis checksum. Adds all bytes, with carry. */ |
| 25 | uint8_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. |
no test coverage detected