Jump to content

The syntax of the .pkm files (documentation?)


Vlad

Recommended Posts

I've been looking on the save files in a hex editor but I can't quite seem to figure out the purpose of most positions.

What I have figured out so far is basically the ground rules:

  1-4 = unknown
 5-6 = zero
 7-8 = unknown
 9 = pokemon id
 10 = zero
 11 = unknown
 12 = zero
 13-19 = unknown
 20 = zero
 21 = unknown
 22 = unknown
 23 = zero
 24 = "2"
 25 = EV; HP
 26 = EV; Attack
 27 = EV; Defense
 28 = EV; Speed
 29 = EV; Sp. Atk
 30 = EV; Sp. Def
 31 = Cool
 32 = Beauty
 33 = Cute
 34 = Smart
 35 = Though
 36 = Sheen
 37 = "1"
 38-40 = zero
 41-60 = unknown
 61-72 = zero
 73-94 = pokemon (custom) name, separated by "01", name ends when "FFFF" occurs, rest is zero bytes
 95 = zero
 96 = unknown
 97-104 = zero
 105-120 = trainer name, same method as pokemon name
 121-140 = unknown
 141-156 = unknown, syntax is 2 bit, a suffix, and repeated -assuming this is the stats values when the save is from a party pokemon
 157-161 = unknown, zeros
 162-163 = unknown
 164-186 = "ff"
 187-188 = zero
 189-190 = "ff"
 191-192 = unknown
 193-198 = "ff"
 199-200 = unknown
 201-206 = "ff"
 207-208 = unknown
 209-212 = "ff"
 213-EoF = zero

I am amazed that I could not find documentation on this on the old forum too... the wiki is new so there is nothing in there to help me on this matter.

I am trying to make a site where you can upload your .pkm file and let the site calculate a random average stats for your Pokemon. For example if you create one you usually put the IV to 31 since it is max, you put some numbers here and there on the EV but you don't really know what you have used, how much you have left, e.g. so I wanted to make this tool to automatically correct and balance the stats -of course depending on the user if he wants a Pokemon specialized in attack, defense, speed, sp.atk, e.g. Same goes for IV if he wants to have a super inhuman farmed Pokemon or if he wants a average one, and so on.

There is much that can be done, I just need help on mapping the .pkm file structure so I can have my PHP parse it correctly.

I am sure a developer of Pokesav can help me here, unless you want to keep the documentation on the .pkm files a secret of course. ;)

*Edit*

Noticed there is a "SAV Research" forum but a bit too late.

Link to comment
Share on other sites

Thanks, I didn't look for that keyword when searching. That will definitely help me out! ;)

*Edit*

I have made a core now, but there are some things I can't quite manage to do.

Checksum - generating it and where to store it, a C++ sample would be nice. any kind of example would be really.

Block shuffling - what I need to use the formula on, a C++ example would something or some sample code that I can read and use in my PHP script.

Encryption - again, what do I need to decrypt/encrypt.

So other stuff I can't manage is:

- Pokemon nickname decrypting so I can read the text

- Trainer name decrypting

- Encrypting a new pokemon nick or trainer name

- Decrypting the IV properly, I see "ffffff" that equals 31 in all fields (reading from 0x38-0x3B), but it seems to go up and down random when I change the values in the save file and re-save it. Also encrypting new values.

I also didn't find the PID stuff that decides gender, shiny, e.g. that you can generate in the editor and pick from a list the gender, nature, e.g. I wonder where and how that is made.

Otherwise I can read the rest of the data with no problem, so the tool can at least make a report and check if a pokemon looks legit by comparing data with what the pokedex database says the pokemon can learn, max stats obtainable, e.g. so it's on it's way.

Edited by Vlad
Added a question or two
Link to comment
Share on other sites

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...