Add config option to ignore BPS/UPS checksums for soft patching

This commit is contained in:
qwertymodo 2017-09-28 10:45:32 -07:00
parent 75d3ac2a1b
commit 992157ec84
3 changed files with 7 additions and 4 deletions

View File

@ -3950,7 +3950,7 @@ static bool8 ReadUPSPatch (Stream *r, long, int32 &rom_size)
uint32 py_crc32 = (data[size - 8] << 0) + (data[size - 7] << 8) + (data[size - 6] << 16) + (data[size - 5] << 24);
uint32 pp_crc32 = (data[size - 4] << 0) + (data[size - 3] << 8) + (data[size - 2] << 16) + (data[size - 1] << 24);
if(patch_crc32 != pp_crc32) { delete[] data; return false; } //patch is corrupted
if((rom_crc32 != px_crc32) && (rom_crc32 != py_crc32)) { delete[] data; return false; } //patch is for a different ROM
if(!Settings.IgnorePatchChecksum && (rom_crc32 != px_crc32) && (rom_crc32 != py_crc32)) { delete[] data; return false; } //patch is for a different ROM
uint32 px_size = XPSdecode(data, addr, size);
uint32 py_size = XPSdecode(data, addr, size);
@ -3977,7 +3977,8 @@ static bool8 ReadUPSPatch (Stream *r, long, int32 &rom_size)
delete[] data;
uint32 out_crc32 = caCRC32(Memory.ROM, rom_size);
if(((rom_crc32 == px_crc32) && (out_crc32 == py_crc32))
if(Settings.IgnorePatchChecksum
|| ((rom_crc32 == px_crc32) && (out_crc32 == py_crc32))
|| ((rom_crc32 == py_crc32) && (out_crc32 == px_crc32))
) {
return true;
@ -4032,7 +4033,7 @@ static bool8 ReadBPSPatch (Stream *r, long, int32 &rom_size)
uint32 target_crc32 = (data[size - 8] << 0) + (data[size - 7] << 8) + (data[size - 6] << 16) + (data[size - 5] << 24);
uint32 pp_crc32 = (data[size - 4] << 0) + (data[size - 3] << 8) + (data[size - 2] << 16) + (data[size - 1] << 24);
if(patch_crc32 != pp_crc32) { delete[] data; return false; } //patch is corrupted
if(rom_crc32 != source_crc32) { delete[] data; return false; } //patch is for a different ROM
if(!Settings.IgnorePatchChecksum && rom_crc32 != source_crc32) { delete[] data; return false; } //patch is for a different ROM
uint32 source_size = XPSdecode(data, addr, size);
uint32 target_size = XPSdecode(data, addr, size);
@ -4083,7 +4084,7 @@ static bool8 ReadBPSPatch (Stream *r, long, int32 &rom_size)
delete[] data;
uint32 out_crc32 = caCRC32(patched_rom, target_size);
if(out_crc32 == target_crc32) {
if(Settings.IgnorePatchChecksum || out_crc32 == target_crc32) {
memcpy(Memory.ROM, patched_rom, target_size);
rom_size = target_size;
delete[] patched_rom;

View File

@ -456,6 +456,7 @@ struct SSettings
bool8 ApplyCheats;
bool8 NoPatch;
bool8 IgnorePatchChecksum;
int32 AutoSaveDelay;
bool8 DontSaveOopsSnapshot;
bool8 UpAndDown;

View File

@ -986,6 +986,7 @@ void WinRegisterConfigItems()
#define CATEGORY "ROM"
AddBoolC("Cheat", Settings.ApplyCheats, true, "true to allow enabled cheats to be applied");
AddInvBoolC("Patch", Settings.NoPatch, true, "true to allow IPS/UPS patches to be applied (\"soft patching\")");
AddBoolC("IgnorePatchChecksum", Settings.IgnorePatchChecksum, false, "true to allow BPS patches to be applied even if the checksum fails");
AddBoolC("BS", Settings.BS, false, "Broadcast Satellaview emulation");
#undef CATEGORY
#ifdef NETPLAY_SUPPORT