MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / rnc_crc

Function rnc_crc

Source/Amiga/dernc.cpp:348–373  ·  view source on GitHub ↗

* Calculate a CRC, the RNC way. It re-computes its CRC table every * time it's run, but who cares? ;-) */

Source from the content-addressed store, hash-verified

346 * time it's run, but who cares? ;-)
347 */
348long rnc_crc (void *data, long len) {
349 unsigned short crctab[256];
350 unsigned short val;
351 int i, j;
352 unsigned char *p = (unsigned char*) data;
353
354 for (i=0; i<256; i++) {
355 val = i;
356
357 for (j=0; j<8; j++) {
358 if (val & 1)
359 val = (val >> 1) ^ 0xA001;
360 else
361 val = (val >> 1);
362 }
363 crctab[i] = val;
364 }
365
366 val = 0;
367 while (len--) {
368 val ^= *p++;
369 val = (val >> 8) ^ crctab[val & 0xFF];
370 }
371
372 return val;
373}

Callers 1

rnc_unpackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected