Make `CRC32.Calculate` return a uint
This commit is contained in:
parent
484a1d8fa4
commit
f95e03bff3
|
@ -32,7 +32,7 @@ namespace BizHawk.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static int Calculate(ReadOnlySpan<byte> data)
|
||||
public static uint Calculate(ReadOnlySpan<byte> data)
|
||||
{
|
||||
uint result = 0xFFFFFFFF;
|
||||
foreach (var b in data)
|
||||
|
@ -40,7 +40,7 @@ namespace BizHawk.Common
|
|||
result = (result >> 8) ^ Crc32Table[b ^ (result & 0xFF)];
|
||||
}
|
||||
|
||||
return (int)~result;
|
||||
return ~result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using BizHawk.Common;
|
||||
|
||||
using ISOParser;
|
||||
|
||||
//disc type identification logic
|
||||
|
@ -301,7 +303,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
return false;
|
||||
|
||||
byte[] sector20 = ReadDataSectorCached(20);
|
||||
uint zecrc = (uint)BizHawk.Common.CRC32.Calculate(sector20);
|
||||
var zecrc = CRC32.Calculate(sector20);
|
||||
|
||||
//known_crcs
|
||||
if (zecrc == 0xd7b47c06) return true; // AV Tanjou
|
||||
|
|
|
@ -565,7 +565,7 @@ namespace BizHawk.Tests.Client.Common.Movie
|
|||
throw new Exception("Length field corrupted");
|
||||
var bytes = buff.AsSpan(0, length - 8);
|
||||
br.Read(bytes);
|
||||
if (br.ReadInt32() != CRC32.Calculate(bytes))
|
||||
if (br.ReadUInt32() != CRC32.Calculate(bytes))
|
||||
throw new Exception("Data or CRC field corrupted");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Tests.Common.checksums
|
|||
}
|
||||
|
||||
var data = InitialiseArray();
|
||||
Assert.AreEqual(EXPECTED, (uint) CRC32.Calculate(data));
|
||||
Assert.AreEqual(EXPECTED, CRC32.Calculate(data));
|
||||
|
||||
data = InitialiseArray();
|
||||
DiscHasher.SpecialCRC32 crc32 = new();
|
||||
|
|
Loading…
Reference in New Issue