NdsForge.NET 1.0.1
Read, validate, edit, compare, and build Nintendo DS and DSi images from .NET
Loading...
Searching...
No Matches
NdsChecksums.cs
1namespace NdsForge;
2
4public static class NdsChecksums
5{
10 public static ushort ComputeCrc16(ReadOnlySpan<byte> data, ushort seed = ushort.MaxValue)
11 {
12 ushort crc = seed;
13 foreach (byte value in data)
14 {
15 crc ^= value;
16 for (int bit = 0; bit < 8; bit++)
17 {
18 crc = (ushort)(((crc & 1) == 0) ? crc >> 1 : (crc >> 1) ^ 0xA001);
19 }
20 }
21
22 return crc;
23 }
24}
25
Calculates checksums used by Nintendo DS image structures.
static ushort ComputeCrc16(ReadOnlySpan< byte > data, ushort seed=ushort.MaxValue)
Calculates the CRC-16 used by Nintendo DS headers and banners.