public static void TestFamicheckTool() { var result = SuperFamiCheckTool.Run(RomFileName); result.Complement.Should().Be(0x8773); result.Checksum.Should().Be(0x788c); // it's stored in the ROM file like this: // 73 87 8C 78 }
public static void TestInternalChecksumVsExternal() { var result = SuperFamiCheckTool.Run(RomFileName); result.Complement.Should().Be(0x8773); result.Checksum.Should().Be(0x788c); (result.Complement + result.Checksum).Should().Be(0xFFFF); const uint expected4ByteChecksums = 0x788C8773; result.AllCheckBytes.Should().Be(expected4ByteChecksums); var project = ImportUtils.ImportRomAndCreateNewProject(RomFileName); project.Should().NotBeNull("project should have loaded successfully"); project.Data.GetRomByte(0xFFDC).Should().Be(0x73); // complement 1 project.Data.GetRomByte(0xFFDD).Should().Be(0x87); // complement 2 project.Data.GetRomByte(0xFFDE).Should().Be(0x8C); // checksum 1 project.Data.GetRomByte(0xFFDF).Should().Be(0x78); // checksum 2 var complement = project.Data.GetRomWord(0xFFDC); complement.Should().Be(0x8773); // complement 16bit var checksum = project.Data.GetRomWord(0xFFDE); checksum.Should().Be(0x788c); // checksum 16bit (complement + checksum).Should().Be(0xFFFF); project.Data.GetRomDoubleWord(0xFFDC).Should().Be((int)expected4ByteChecksums); // complement 16bit project.Data.RomCheckSumsFromRomBytes.Should().Be(expected4ByteChecksums); project.InternalCheckSum.Should().Be(expected4ByteChecksums); result.Complement.Should().Be((uint)complement); result.Checksum.Should().Be((uint)checksum); project.Data.ComputeChecksum().Should().Be((ushort)checksum); project.Data.ComputeIsChecksumValid().Should().Be(true); var firstByte = project.Data[0x00]; firstByte.Should().NotBe(0); project.Data[0x00] = 0; project.Data.ComputeIsChecksumValid().Should().Be(false); project.Data.FixChecksum(); project.Data.ComputeIsChecksumValid().Should().Be(true); project.Data[0x00] = firstByte; project.Data.ComputeIsChecksumValid().Should().Be(false); project.Data.FixChecksum(); project.Data.ComputeIsChecksumValid().Should().Be(true); // SNES docs dictate: // 15. Complement Check (0xFFDC, 0xFFDD) // 16. Check Sum (0xFFDE, 0xFFDF) // in the actual ROM file, it appears like this (remember: little endian for SNES) // complement checksum // 73 87 8C 78 }
public void TestInternalChecksumVsExternal() { var result = SuperFamiCheckTool.Run(CartNameData.ExampleHiRomFile); result.Complement.Should().Be(0x8773); result.Checksum.Should().Be(0x788c); (result.Complement + result.Checksum).Should().Be(0xFFFF); const uint expected4ByteChecksums = 0x788C8773; result.AllCheckBytes.Should().Be(expected4ByteChecksums); var project = projectImporter.CreateProjectFromDefaultSettings(CartNameData.ExampleHiRomFile); project.Should().NotBeNull("project should have loaded successfully"); project.Data.GetRomByte(0xFFDC).Should().Be(0x73); // complement 1 project.Data.GetRomByte(0xFFDD).Should().Be(0x87); // complement 2 project.Data.GetRomByte(0xFFDE).Should().Be(0x8C); // checksum 1 project.Data.GetRomByte(0xFFDF).Should().Be(0x78); // checksum 2 var complement = project.Data.GetRomWord(0xFFDC); complement.Should().Be(0x8773); // complement 16bit var checksum = project.Data.GetRomWord(0xFFDE); checksum.Should().Be(0x788c); // checksum 16bit (complement + checksum).Should().Be(0xFFFF); var snesApi = project.Data.GetSnesApi(); Debug.Assert(snesApi != null); project.Data.GetRomDoubleWord(0xFFDC).Should().Be((int)expected4ByteChecksums); // complement 16bit snesApi.RomCheckSumsFromRomBytes.Should().Be(expected4ByteChecksums); project.InternalCheckSum.Should().Be(expected4ByteChecksums); result.Complement.Should().Be((uint)complement); result.Checksum.Should().Be((uint)checksum); snesApi.ComputeChecksum().Should().Be((ushort)checksum); snesApi.ComputeIsChecksumValid().Should().Be(true); var firstByte = project.Data.RomBytes[0x00].Rom; firstByte.Should().NotBe(0); project.Data.RomBytes[0x00].Rom = 0; snesApi.ComputeIsChecksumValid().Should().Be(false); snesApi.FixChecksum(); snesApi.ComputeIsChecksumValid().Should().Be(true); project.Data.RomBytes[0x00].Rom = firstByte; snesApi.ComputeIsChecksumValid().Should().Be(false); snesApi.FixChecksum(); snesApi.ComputeIsChecksumValid().Should().Be(true); // SNES docs dictate: // 15. Complement Check (0xFFDC, 0xFFDD) // 16. Check Sum (0xFFDE, 0xFFDF) // in the actual ROM file, it appears like this (remember: little endian for SNES) // complement checksum // 73 87 8C 78 }