#include <stdint.h>
-extern uint32_t crc32(unsigned char *buf, int len);
+extern uint32_t crc32(unsigned char *buf, int len, uint32_t crc0);
extern void crc32_init();
#endif
uint32_t crc32_table[256];
-uint32_t crc32(uint8_t *buf, int len)
+uint32_t crc32(uint8_t *buf, int len, uint32_t crc0)
{
uint8_t *p;
uint32_t crc;
- crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
+ crc = crc0;
for (p = buf; len > 0; ++p, --len)
crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p];
- return ~crc; /* transmit complement, per CRC-32 spec */
+ return crc;
}
/*
for (i = 0; i < height; i++) {
lineaddr = fb->fbaddr + (i + y) * scanline + (4 * x);
- sum ^= crc32(lineaddr, width * 4);
+ sum = crc32(lineaddr, width * 4, sum);
}
return sum;
cx = x;
texty = cy / 14;
textx = cx / 9;
- cksm ^= crc32(video + texty * 160 + textx * 2, (w / 9 + 1) * 2); /* Err on the side of 'too many'. */
+ cksm = crc32(video + texty * 160 + textx * 2, (w / 9) * 2 + 2, cksm); /* Err on the side of 'too many'. */
}
smram_restore_state(old_state);