diff --git a/Core/iNesLoader.cpp b/Core/iNesLoader.cpp index 8ebbed19..3c536441 100644 --- a/Core/iNesLoader.cpp +++ b/Core/iNesLoader.cpp @@ -80,7 +80,13 @@ void iNesLoader::LoadRom(RomData& romData, vector& romFile, NESHeader * MessageManager::Log("[iNes] Warning: File is larger than excepted (based on the file header)."); } + romData.Info.Hash.PrgCrc32 = CRC32::GetCRC(buffer, prgSize); + romData.PrgRom.insert(romData.PrgRom.end(), buffer, buffer + prgSize); + while(romData.PrgRom.size() < 256) { + //Ensure the PRG is at least 256 bytes in size by mirroring as needed (mapper code requires it to be 256 bytes at least) + romData.PrgRom.insert(romData.PrgRom.end(), buffer, buffer + std::min(prgSize, 256 - romData.PrgRom.size())); + } buffer += prgSize; romData.ChrRom.insert(romData.ChrRom.end(), buffer, buffer + chrSize); buffer += chrSize; @@ -90,8 +96,6 @@ void iNesLoader::LoadRom(RomData& romData, vector& romFile, NESHeader * romData.MiscRomsData.insert(romData.MiscRomsData.end(), buffer, buffer + (dataSize - (prgSize + chrSize))); } - romData.Info.Hash.PrgCrc32 = CRC32::GetCRC(romData.PrgRom.data(), romData.PrgRom.size()); - Log("PRG CRC32: 0x" + HexUtilities::ToHex(romData.Info.Hash.PrgCrc32, true)); Log("PRG+CHR CRC32: 0x" + HexUtilities::ToHex(romData.Info.Hash.PrgChrCrc32, true));