I'm working in a save editor for gen3 games and i'm having trouble with the pkm checksums.
I'm using MILOTIC.bin as example/test, it's saved checksum is 0x3408 and the one i calculate is 0x3A02
This is the function I'm using to calculate the checksum:
public function calcDataChecksum():UInt
{
var sum:UInt = 0x00;
for (i in 0...24)
{
var pos = i * 2;
sum += [this.data[pos], this.data[pos+1]].toUInt16();
}
// truncate to 16-bit
sum = sum & 0xFFFF;
return sum;
}
And this is how i'm unencrypting the data:
public function decryptData(key:UInt):Array<UInt>
{
var newData:Array<UInt> = [];
// data offset at 32
var offset = 32;
var ar = key.fromUInt32();
for (i in 0...48)
{
newData.push(this.pkm[offset+i] ^ ar[i%4]);
}
return newData;
}
Gen3 pkm Checksum Help
in PKM
Posted
I'm working in a save editor for gen3 games and i'm having trouble with the pkm checksums.
I'm using MILOTIC.bin as example/test, it's saved checksum is 0x3408 and the one i calculate is 0x3A02
This is the function I'm using to calculate the checksum:
public function calcDataChecksum():UInt { var sum:UInt = 0x00; for (i in 0...24) { var pos = i * 2; sum += [this.data[pos], this.data[pos+1]].toUInt16(); } // truncate to 16-bit sum = sum & 0xFFFF; return sum; }
And this is how i'm unencrypting the data:
Can someone help me find what i'm doing wrong?
Thanks