This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

47
DataPRO/TiltMIF/CRC16.cs Normal file
View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace TiltMIF
{
public static class CRC16
{
private const ushort _polynomial = 0xA001;
private static readonly ushort[] _table = new ushort[256];
public static ushort ComputeChecksum(byte[] bytes)
{
ushort crc = 0;
for (int i = 0; i < bytes.Length; ++i)
{
byte index = (byte)(crc ^ bytes[i]);
crc = (ushort)((crc >> 8) ^ _table[index]);
}
return crc;
}
static CRC16()
{
ushort value;
ushort temp;
for (ushort i = 0; i < _table.Length; ++i)
{
value = 0;
temp = i;
for (byte j = 0; j < 8; ++j)
{
if (((value ^ temp) & 0x0001) != 0)
{
value = (ushort)((value >> 1) ^ _polynomial);
}
else
{
value >>= 1;
}
temp >>= 1;
}
_table[i] = value;
}
}
}
}