diff --git a/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs b/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs index e799501b84..4f2869aec7 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscHasher.cs @@ -35,15 +35,17 @@ namespace BizHawk.Emulation.DiscSystem }; //hash the TOC - crc.Add((int)disc.TOC.Session1Format); - crc.Add(disc.TOC.FirstRecordedTrackNumber); - crc.Add(disc.TOC.LastRecordedTrackNumber); + static void AddAsBytesTo(SpecialCRC32 crc32, int i) + => crc32.Add(BitConverter.GetBytes(i), 0, 4); + AddAsBytesTo(crc, (int)disc.TOC.Session1Format); + AddAsBytesTo(crc, disc.TOC.FirstRecordedTrackNumber); + AddAsBytesTo(crc, disc.TOC.LastRecordedTrackNumber); for (int i = 1; i <= 100; i++) { //if (disc.TOC.TOCItems[i].Exists) Console.WriteLine("{0:X8} {1:X2} {2:X2} {3:X8}", crc.Current, (int)disc.TOC.TOCItems[i].Control, disc.TOC.TOCItems[i].Exists ? 1 : 0, disc.TOC.TOCItems[i].LBATimestamp.Sector); //a little debugging - crc.Add((int)disc.TOC.TOCItems[i].Control); - crc.Add(disc.TOC.TOCItems[i].Exists ? 1 : 0); - crc.Add((int)disc.TOC.TOCItems[i].LBA); + AddAsBytesTo(crc, (int)disc.TOC.TOCItems[i].Control); + AddAsBytesTo(crc, disc.TOC.TOCItems[i].Exists ? 1 : 0); + AddAsBytesTo(crc, (int)disc.TOC.TOCItems[i].LBA); } //hash first 26 sectors @@ -147,16 +149,6 @@ namespace BizHawk.Emulation.DiscSystem } } - private readonly byte[] smallbuf = new byte[8]; - public void Add(int data) - { - smallbuf[0] = (byte)((data) & 0xFF); - smallbuf[1] = (byte)((data >> 8) & 0xFF); - smallbuf[2] = (byte)((data >> 16) & 0xFF); - smallbuf[3] = (byte)((data >> 24) & 0xFF); - Add(smallbuf, 0, 4); - } - /// /// The negated output (the typical result of the CRC calculation) ///