Delta Blast Burn Posted June 27, 2013 Posted June 27, 2013 (edited) Does anyone know specifically how the checksum for gba pokemon file is calculated? Im trying to create a pokemon I can trade from Emerald into : Gale of Darkness for sweeping Mt. Battle. My problem is that I have to hex edit the 3gpkm file. Where my problem comes in is that I'm using a move several indexes past Shadow Rush which itself is 356. The move I'm trying to teach is index 362, and no editor has support for moves past 354, Psycho Boost, the move with the highest legally obtainable index, and the upper limit for all editors I've seen. EDIT: According to http://www.ppnstudio.com/maker/PokemonMakerHelp.txt it's calculated by summing all the unencrypted words, but the problem lies in the fact that the definition of a word changes between system dependent on the processor. Edited June 27, 2013 by Delta Blast Burn Got some new information.
evandixon Posted June 27, 2013 Posted June 27, 2013 I don't know, but it's probably the same as 4th Gen pkm files. If that doesn't work, try big endian words. If that doesn't work, I have no idea.
Delta Blast Burn Posted June 27, 2013 Author Posted June 27, 2013 (edited) What I know is that the cksm itself is 16-bit but the data it references is four blocks of 12 bytes each, encrypted 32-bits at a time, via the PID Xor'ed with the OTID AND the SID. But my problem is not the cryptography, it's the math. It seems that whenever change more than one byte ... You know what i'll just attach my work so far. If i had any programming knowledge, I would probably write a command line tool. May post more info later. Here are my notes from various sources. 3gpkm File structure.txt Edited October 3, 2013 by Delta Blast Burn clarified my thoughts
Zaz Posted February 18, 2014 Posted February 18, 2014 Is it a problem with endianness? I do the calculation on lines 453-470 here https://github.com/Zazcallabah/PokeSave/blob/master/PokeSave/MonsterEntry.cs Maybe no help if you cant read code, so basically this happens: * Group the entire array of data into 12 sections with 4 bytes in each section. (Not 4 sections with 12 each.) * The key you want to xor each section with is, as you say, the PID xor:ed with the original trainer id. * In every section, after xor:ing with the key, take the high 16 bits and the low 16 bits and add them together. (You now have a number that is the sum of 24 other numbers) * The low 16 bits of that number is what you want I can give you an example, if you want, I just need to look through my notes for a good sample
Zaz Posted February 18, 2014 Posted February 18, 2014 Example: lets use the pokemon provided in section 11 in this document http://www.ppnstudio.com/maker/PokemonMakerHelp.txt 9de847ff e1dd6e3b bdbbcdbd c9c9c8ff 80430202 c5d9e2ff ffffff00 a4f10000 7c3529c4 7c3529c4 7c3529c4 593429c4 013529c4 7c7329c4 7c0eace4 5875f8c9 7c3529c4 163529c4 7c3529c4 623529c4 Remember the endianness. Its little-endian, so when you do maths, the pid isn't 9de847ff. You have to reverse it one byte at a time. The pid is ff47e89d. Same with the next line, the original trainer id. (The SID and TID) is 3b6edde1. Xor these two to get the key: C429357C Now we take the subsection data: 7c3529c4 7c3529c4 7c3529c4 593429c4 013529c4 7c7329c4 7c0eace4 5875f8c9 7c3529c4 163529c4 7c3529c4 623529c4 Each line is one part. Remember it is little-endian, so each line has to be reversed before we do maths: c429357c c429357c c429357c c4293459 c4293501 c429737c e4ac0e7c c9f87558 c429357c c4293516 c429357c c4293562 Now xor each line separately with the key c429357c 00000000 00000000 00000000 00000125 0000007D 00004600 20853B00 0DD14024 00000000 0000006A 00000000 0000001E Until now the endianness actually didnt really matter since we did it both to the data and the key. But now we start adding, so now it gets confusing if you didnt do it at the start. Split each line in two. 0000 0000 0000 0000 0000 0000 0000 0125 0000 007D 0000 4600 2085 3B00 0DD1 4024 0000 0000 0000 006A 0000 0000 0000 001E And add them together and take the lowest 16 bits, the result in this case is F1A4 Remember that you have done the little-endian conversion, and you have to convert this number back before you write it to the file. 9de847ff e1dd6e3b bdbbcdbd c9c9c8ff 80430202 c5d9e2ff ffffff00 a4f10000 <-- Here it is 7c3529c4 7c3529c4 7c3529c4 593429c4 013529c4 7c7329c4 7c0eace4 5875f8c9 7c3529c4 163529c4 7c3529c4 623529c4
ABZB Posted July 10, 2019 Posted July 10, 2019 (edited) So, to confirm I'm reading this right: for each line that in the original data was ordered: wwxxyyzz, I reverse it to: zzyyxxww decrypt it to : ZZYYXXWW split it into: ZZYY XXWW Take the sum: ZZYY + XXWW = S Repeat that each of the three lines in each of the 4 blocks, then sum the 12 S's to: ABCDEFGH Then take the last four hex characters: EFGH as the checksum? Edited July 10, 2019 by ABZB
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now