Jump to content

Extracting Pokemon from Generation 5 RAM


Recommended Posts

For the fifth generation of Pokémon games the RAM is actually very easy to read when compared to the fourth generation.  This is largely due to the fact that when the RAM is opened in a simple text editor the headers in the RAM are in plain text.  However, ripping Pokémon from RAM is both easier, but harder than generation four.  In my pervious topic when I broke down the structure of Pokémon in generation four’s RAM I was able to locate all of the important information of the Pokémon, but with generation five important information that one would expect to find does not appear to be present at a first glance.  Fortunately that is not where this topic ends; it turns out all Pokémon that are on the field as well as the entire party of all trainers are stored in the RAM in an encrypted format.  It appears that the entire party block from the save is copied into the RAM and when a battle starts the other trainer’s Pokémon in loaded into the RAM using the exact same structure as the player’s party Pokémon.  This allows for easy ripping of Pokémon at the cost of this topic appearing extremely underwhelming due to this outcome (sorry no table this time).

How to Extract Pokémon from RAM Dumps During a Non Vs. Recorder Battle

As stated earlier the RAM for generation 5 is very easy to read and this easiness to read makes it easy to rip Pokémon.  In order to rip a Pokémon you will need to find it in the RAM and that is where the header N.pokeparty.c comes into play or its hex equivalent 4E 19 70 6F 6B 65 70 61 72 74 79 2E 63.  In most cases there will be four instances of this header with the first one being the player’s party, the second one being the NPC’s party, the third one being the player’s party again, and the last one being the NPC’s party again (upon writing this I have realized that I did not test this with a multi-battle so the results my change for that).  In some cases there may be an extra header before the first normal instance of it where different functionality such as Wi-Fi is mentioned.  In order to start extracting a Pokémon you will need to start 20 bytes after the c in N.pokeparty.c, therefore the 21st byte onwards will be the start of the Pokémon data.  Since it follows the same structure as party Pokémon in the save each Pokémon occupies 220 bytes so with some simple multiplication you can find the end of relevant data in the block.

At this point I have covered general information and how to find the Pokémon, but now you probably want to know how to get a Pokémon from the RAM to the save even though the data is encrypted.
1.    Locate the correct party block that has the Pokémon you want.
2.    Copy the entire block or until the end of relevant data (if there is less than six Pokémon only copy up to the end of the last Pokémon).
3.    Get a save file where the party Pokémon can be over written.
4.    Copy the RAM block into the party block.
5.    Open the save in PKHeX
6.    Use PKHeX to update the checksum or remove the Pokémon from the same to your main save.
For now this is the best method until an application is developed that can do this.

How to Extract Pokémon from RAM Dumps During a Vs. Recorder Playback

For these kind of RAM dumps the method above does not work as intended and the Pokémon will appear to have incorrect data if opened in PKHeX.  The corruption occurs primarily with Pokémon obtained in a fifth generation game and is caused by the 0x5F byte which indicates which game the Pokémon was caught in being set to 00.  In order to prevent this the Pokémon needs to be extracted from the RAM, decrypted without the use of PKHeX, opened in a hex editor, and manually change the 0x59 byte to either 14 for Pokémon White or 15 for Pokémon Black.  This only needs to be done if the 0x59 byte is set to 00.

Now just general remarks and interesting information from looking into this:
In Pokémon Black2 and Pokémon White 2 there are NPCs that you can trade with and then have them challenge you to a battle with the traded Pokémon, but is it the same Pokémon?  No, it is not the same Pokémon.  In the end the Pokémon does maintain its PID, gender, nickname, ID, and SID, but its level is raised to the nearest 5th level, nature is changed, held item removed, met data wiped, IVs are changed to a predetermined set of IVs, EVs are set to 0, moves will reflect the four most recent moves that that species of Pokémon would know at the new level, and OT is wiped.  As well, despite not usually being found in the RAM decrypted the Pokémon will have its name, ID, and SID decrypted in the RAM.

Going back to generation four, Pokémon are also stored in the RAM encrypted, but it does not appear NPC Pokémon are always stored this way since 1 out of 5 attempts resulted in a good rip and not a glitch Pokémon.  Therefore, keep using the information outlined in my earlier topic.
For further reading please read my mapping of Pokémon in generation four RAM and generation five Pokémon structure in the technical documents.

Spoiler

Generation three Pokemon mapping in RAM:

Generation four Pokémon mapping in RAM:

Generation five Pokémon structure:

RAM to PKX Rip (Pokémon from RAM extractor):
https://projectpokemon.org/home/files/file/4187-ram-to-pkx-rip/

 

Special thanks to @BlackSharkfor providing some Pokémon White RAM dumps.

Also here is an updated folder of some Pokémon that I dumped from popular NPC’s from Pokémon Black and Pokémon White (this time properly ripped and not using an AR code):

Black White Special Trainers Updated.zip

  • Like 1
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...