Jump to content

Recommended Posts

Posted

So I just finished a project called CC4Wifi (Challenge Cup for Wi-Fi), which generates pkm files for random pokemon with random movesets, as per "Challenge Cup" rules.

Here's the weird thing, though--while the files import fine into Pokesav, when I try importing one into Pokegen, it's complete nonsense.

I've done some additional testing. My template file imports fine. But when I load the template, change just *one* byte (see below)--even something as innocuous as an EV value--and write it back, Pokegen refuses to read it any more. Does Pokegen have some sort of weird checksum thing that Pokesav does not? Or is something else going on?

Test code (in python):

from array import *
p=array('B'); p.fromstring(open("template.pkm",'rb').read()) #template.pkm imports fine into Pokegen
p[0x18]=120
p.tofile(open("test.pkm",'wb')) #test.pkm imports as garbage

And I've tried looking at the files in a hex editor--the only difference between the files is indeed the value at 0x18.

Edit: Looked back over this handy reference. So there is indeed a checksum. Now I just gotta figure out how to calculate it...

Posted

You can go ahead and close this. I figured it out from here:

checksum=0
for i in range(8,137,2):
checksum = (checksum+p[i]+p[i+1]*256)%65536
p[0x06]=checksum%256
p[0x07]=checksum/256

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...