Skip to content

Commit

Permalink
Fix verifychk for gen1
Browse files Browse the repository at this point in the history
Thanks bokepall !
  • Loading branch information
kwsch committed Sep 22, 2016
1 parent 0c818ed commit c8f14fb
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions PKHeX/Saves/SAV1.cs
Expand Up @@ -202,17 +202,11 @@ public override bool ChecksumsValid
get
{
int CHECKSUM_OFS = Japanese ? 0x3594 : 0x3523;
Data[CHECKSUM_OFS] = 0;
uint chksum = 0;
for (int i = 0x2598; i < CHECKSUM_OFS; i++)
{
chksum += Data[i];
}

chksum = ~chksum;
chksum &= 0xFF;

return Data[CHECKSUM_OFS] == (byte)chksum;
byte temp = Data[CHECKSUM_OFS]; // cache current chk
setChecksums(); // chksum is recalculated (after being set to 0 to perform check)
byte chk = Data[CHECKSUM_OFS]; // correct checksum
Data[CHECKSUM_OFS] = temp; // restore old chk
return temp == chk;
}
}
public override string ChecksumInfo => ChecksumsValid ? "Checksum valid." : "Checksum invalid";
Expand Down

0 comments on commit c8f14fb

Please sign in to comment.