diff --git a/src/BizHawk.Common/CRC32.cs b/src/BizHawk.Common/CRC32.cs index 1be0360aa0..7d7516a2b1 100644 --- a/src/BizHawk.Common/CRC32.cs +++ b/src/BizHawk.Common/CRC32.cs @@ -32,7 +32,7 @@ namespace BizHawk.Common } } - public static int Calculate(ReadOnlySpan data) + public static uint Calculate(ReadOnlySpan 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; } } } diff --git a/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs index f62ccd0737..9badad99ca 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs @@ -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 diff --git a/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs b/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs index 70ff3db33a..5783e6e4b3 100644 --- a/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs +++ b/src/BizHawk.Tests/Client.Common/Movie/ZwinderStateManagerTests.cs @@ -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"); } } diff --git a/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs b/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs index f90c01f2ca..70b29cb12b 100644 --- a/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs +++ b/src/BizHawk.Tests/Common/checksums/CRC32Tests.cs @@ -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();