Neurophage Posted April 20, 2011 Share Posted April 20, 2011 So, I've finally wrapped my head around the Generation IV decryption algorithm. I knew that the best way to find the start of the party block was to just figure out my first party Pokémon's PID and then search for it in a hex editor; after a bit of frustration, I read that it was in little-endian. Having found it, I then needed to implement the PRNG to decrpyt the data, but I got snared pretty much near the start of my adventure by numbers that just seemed wrong. Here's my arithmetic and some pseudocode (with ints in place of hexadecimal numbers to better clarify my point): seed = 15665 // my checksum, of course prng: next = 1103515245 * seed + 24691; seed = next; return next; So, this is where I'm stuck. The first time I run prng(), it's going to return 17286566337616; it's big, but definitely feasible. Now, I'm supposed to return the first 16 bits of that, unless I completely misinterpreted. 17286566337616 = 0b111110111000110101111010010100000000000000000101110001010000 So, the first 16 bits are 1111101110001101; does this mean that the first time I run prng(), it should return 64397 and that I should use that value as seed when filling the next variable when I run it again? I completely understand recursively using the PRNG to decrypt each hex word; I just wanted to make sure I had my prng() function returning the proper values before confusing myself any further. Any helpful pointers, suggestions, or advice would be greatly appreciated. Link to comment Share on other sites More sharing options...
Prof. Kakashi151 Posted July 31, 2011 Share Posted July 31, 2011 Eh..I think so. I think that the first 16 bits (in your case; 1111101110001101) should convert to the 64397. I may be wrong...but it sounds like that should happen. And yes, you should list that as the 'seed' when you list the next variable. Hope I helped! Link to comment Share on other sites More sharing options...
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