fix crc calculation method for cheats DB

This commit is contained in:
zeromus 2019-09-25 22:04:58 -04:00
parent 9e6b4f128f
commit 46980d7732
3 changed files with 6 additions and 1 deletions

View File

@ -698,10 +698,14 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi
//run crc over the whole buffer (chunk at a time, to avoid coding a streaming crc //run crc over the whole buffer (chunk at a time, to avoid coding a streaming crc
gameInfo.reader->Seek(gameInfo.fROM, 0, SEEK_SET); gameInfo.reader->Seek(gameInfo.fROM, 0, SEEK_SET);
gameInfo.crc = 0; gameInfo.crc = 0;
bool first = true;
for(;;) { for(;;) {
u8 buf[4096]; u8 buf[4096];
int read = gameInfo.reader->Read(gameInfo.fROM,buf,4096); int read = gameInfo.reader->Read(gameInfo.fROM,buf,4096);
if(read == 0) break; if(read == 0) break;
if(first && read >= 512)
gameInfo.crcForCheatsDb = ~crc32(0, buf, 512);
first = false;
gameInfo.crc = crc32(gameInfo.crc, buf, read); gameInfo.crc = crc32(gameInfo.crc, buf, read);
} }

View File

@ -339,6 +339,7 @@ struct GameInfo
u32 cardSize; u32 cardSize;
u32 mask; u32 mask;
u32 crc; u32 crc;
u32 crcForCheatsDb;
u32 chipID; u32 chipID;
u32 romType; u32 romType;
u32 headerOffset; u32 headerOffset;

View File

@ -1564,7 +1564,7 @@ INT_PTR CALLBACK CheatsExportProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpa
lvi.pszText= tmp[i].description; lvi.pszText= tmp[i].description;
SendMessage(exportListView, LVM_INSERTITEM, 0, (LPARAM)&lvi); SendMessage(exportListView, LVM_INSERTITEM, 0, (LPARAM)&lvi);
} }
if (gameInfo.crc && (gameInfo.crc != cheatsExport->CRC)) if (gameInfo.crc && (gameInfo.crcForCheatsDb != cheatsExport->CRC))
msgbox->warn("Checksums not matching"); msgbox->warn("Checksums not matching");
SendMessage(exportListView, WM_SETREDRAW, (WPARAM)TRUE,0); SendMessage(exportListView, WM_SETREDRAW, (WPARAM)TRUE,0);