+ else if (TagType == 0xfe) {\r
+ PrintToScrollback("Info: Rewriteable TI tag detected.");\r
+\r
+ // put 64 bit data into shift1 and shift0\r
+ shift0 = (shift0>>24) | (shift1 << 8);\r
+ shift1 = (shift1>>24) | (shift2 << 8);\r
+\r
+ // align 16 bit crc into lower half of shift2\r
+ shift2 = ((shift2>>24) | (shift3 << 8)) & 0x0ffff;\r
+\r
+ // align 16 bit "end bits" or "ident" into lower half of shift3\r
+ shift3 >>= 16;\r
+\r
+ // only 15 bits compare, last bit of ident is not valid\r
+ if ( (shift3^shift0)&0x7fff ) {\r
+ PrintToScrollback("Error: Ident mismatch!");\r
+ }\r
+ // WARNING the order of the bytes in which we calc crc below needs checking\r
+ // i'm 99% sure the crc algorithm is correct, but it may need to eat the\r
+ // bytes in reverse or something\r
+ // calculate CRC\r
+ crc=0;\r
+ crc = update_crc16(crc, (shift0)&0xff);\r
+ crc = update_crc16(crc, (shift0>>8)&0xff);\r
+ crc = update_crc16(crc, (shift0>>16)&0xff);\r
+ crc = update_crc16(crc, (shift0>>24)&0xff);\r
+ crc = update_crc16(crc, (shift1)&0xff);\r
+ crc = update_crc16(crc, (shift1>>8)&0xff);\r
+ crc = update_crc16(crc, (shift1>>16)&0xff);\r
+ crc = update_crc16(crc, (shift1>>24)&0xff);\r
+ PrintToScrollback("Info: Tag data = %08X%08X", shift1, shift0);\r
+ if (crc != (shift2&0xffff)) {\r
+ PrintToScrollback("Error: CRC mismatch, calculated %04X, got ^04X", crc, shift2&0xffff);\r
+ } else {\r
+ PrintToScrollback("Info: CRC %04X is good", crc);\r