mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-25 22:09:35 +00:00
Use Adler32 instead of QT qChecksum for checksum of Japanese rom name.
This commit is contained in:
parent
208fea0442
commit
5f8d720916
|
@ -176,6 +176,33 @@ void writeSettings(const QString & _strFileName)
|
|||
settings.endGroup();
|
||||
}
|
||||
|
||||
static
|
||||
u32 Adler32(u32 crc, const void *buffer, u32 count)
|
||||
{
|
||||
register u32 s1 = crc & 0xFFFF;
|
||||
register u32 s2 = (crc >> 16) & 0xFFFF;
|
||||
int k;
|
||||
const u8 *Buffer = (const u8*)buffer;
|
||||
|
||||
if (Buffer == NULL)
|
||||
return 0;
|
||||
|
||||
while (count > 0) {
|
||||
/* 5552 is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
k = (count < 5552 ? count : 5552);
|
||||
count -= k;
|
||||
while (k--) {
|
||||
s1 += *Buffer++;
|
||||
s2 += s1;
|
||||
}
|
||||
/* 65521 is the largest prime smaller than 65536 */
|
||||
s1 %= 65521;
|
||||
s2 %= 65521;
|
||||
}
|
||||
|
||||
return (s2 << 16) | s1;
|
||||
}
|
||||
|
||||
void loadCustomRomSettings(const QString & _strFileName, const char * _strRomName)
|
||||
{
|
||||
QSettings settings(_strFileName, QSettings::IniFormat);
|
||||
|
@ -188,7 +215,7 @@ void loadCustomRomSettings(const QString & _strFileName, const char * _strRomNam
|
|||
for (int i = 0; i < bytes.length() && bASCII; ++i)
|
||||
bASCII = bytes.at(i) >= 0;
|
||||
|
||||
const QString romName = bASCII ? QString::fromLatin1(_strRomName) : QString::number(qChecksum(bytes.data(), bytes.length()), 16);
|
||||
const QString romName = bASCII ? QString::fromLatin1(_strRomName) : QString::number(Adler32(0xFFFFFFFF, bytes.data(), bytes.length()), 16);
|
||||
if (settings.childGroups().indexOf(romName) < 0)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user