Table of Contents
12/20/11 Update: RNG Reporter now supports Method H, the method of Wild Pokémon generation supported in FireRed and LeafGreen.
09/14/11 Update: The technically inclined may see Bond697's latest posts on Method Determination and GBA Video Functions.
[A]#preliminary_information[/A]
Preliminary Information
Abusing the Random Number Generator of FireRed and LeafGreen is very difficult in comparison to games such as Emerald or Diamond and Pearl. Many users have found success thanks to save states from emulators, though the goal of this topic is to facilitate this process for those using actual game paks.
One of the most important pieces of knowledge in the puzzle of RNG abuse is the "seed". A "seed" is a number that is initially plugged into the formula used to generate strings of pseudo-random numbers. If we know the seed, it is possible to determine the sequence of pseudo-random numbers it creates. In Emerald, we always know the seed, as it is 0 each time the game starts up. In Diamond and Pearl, we can manipulate the seed by starting the game at a certain time, and hitting a certain delay.
FireRed and LeafGreen operate in a different fashion than the abovementioned games, but they share certain similarities with all of them. They still make use of a seed, which generates a set of frames—simply put, a frame is the spot when the RNG generates a certain PID (a nature and IVs for Pokémon). User flovv has looked into the game's code and discovered the specifics of seeding for FireRed and LeafGreen:
Researcher Kaphotics has also noted that the current seed information is stored in memory location 0x03005000.
Frequent contributor mattj has summarized much information concerning seeding and the advancement of frames as follows:
It is important to note that "button mashing" is undesirable due to its effects on seed groupings. It is much better to be deliberate with button presses whenever you are booting up the game.
User NeoSyrex also has information concerning the FireRed/LeafGreen RNG, which he famously applied to capture a Zapdos for use in the Video Game Championsips. The information provided by NeoSyrex is as follows:
This seed may be found manually by program FR/LG Seed Finder, which is attached to this post. NeoSyrex, the author of this program, says the following:
As mentioned earlier, it is possible to generate a list of upcoming spreads using mingot's RNG Reporter program. This is more reactive RNG manipulation than proactive, but this is the best we have at the moment.
From here, it is possible to aim for a spread that you want by hitting its frame. Frames advance in realtime in a similar vein to Emerald, albeit with a catch. In a "quiet" area, such as outside Mt. Moon, the RNG advances at approximately 60 frames per second. However, this does not apply to all locations in the game. In certain locations, the RNG advances somewhat differently.
The RNG runs in an altered state in certain areas (many of which seem to be interior), cycling through either odd frames, or even frames. For example, if the game chooses odd frames, it will only cycle through frames 1, 3, 7, 9, 11, and so on. This creates the illusion that the RNG is advancing at 120 frames per second, when it is actually skipping over one type of frame. However, you can change whether the RNG will cycle through even or odd frames. This is achieved through opening up the menu, saving your game, and possibly other actions that have yet to be documented. This will cause the frames to switch to the opposite types; if the game was cycling through odd frames, it will now cycle through even frames, and vice versa. The specifics of quiet and noisy frame advancement are not yet known.
It would also seem that noisy and quiet areas are not necessarily consistent; noisy areas can be silenced through a technique described by flovv:
At the moment, you would look through the list of spreads generated by your recurring seeds until you found one you wanted.
[A]#method_1[/A]
Method 1 Pokémon
Much like Emerald, FireRed and LeafGreen
Bulbasaur, Charmander, Squirtle, Clefairy¹, Abra¹, Hypno², Voltorb³, Electrode³, Hitmonlee, Hitmonchan, Scyther¹, Pinsir¹, Magikarp⁴, Lapras, Eevee, Porygon, Omanyte, Kabuto, Aerodactyl, Snorlax, Articuno, Zapdos, Moltres, Dratini¹, Mewtwo, Togepi, Lugia, Ho-Oh, and Deoxys
¹Only Clefairy, Abra, Scyther, Pinsir, and Dratini bought at the Game Corner are consistently generated by method 1. Scyther is exclusive to FireRed, whereas Pinsir can only be found in LeafGreen.
²Only the Hypno encountered by Lostelle in the Berry Forest is consistently generated by method 1.
³Only Voltorb and Electrode disguised as Poké Balls are consistently generated by method 1.
⁴Only Magikarp bought from the salesman in the Pokémon Center on Route 3 are consistently generated by method 1.
Note that as in Emerald, a Pokémon's spread is not necessarily selected at the precise moment you press A next to its overworld sprite. Rather, the RNG keeps cycling right up until the battle starts (or in the case of gift Pokémon, it is received), unless "spread selected" is indicated in the place of "last input". A list of where to save and the last inputs for each Pokémon is as follows:
Bulbasaur/Charmander/Squirtle: Save in front of the Poké Ball containing the starter of your choice. Spread selected upon pressing the A button after the message "This POKéMON is really quite energetic!" appears.
Abra/Clefairy/Dratini/Scyther/Pinsir/Porygon: Save in front of the Game Corner Prize Corner desk. Spread selected after pressing A when the message "So, you want the [ABRA/CLEFAIRY/DRATINI/SCYTHER/PINSIR/PORYGON]?" appears.
Hypno: Save in front of Lostelle in the Berry Forest. Last input is a press of the A button after Lostelle wails "Waaaaaaah! I want my daddy!"
Hitmonlee/Hitmonchan: Save in front of the Poké Ball which contains the Pokémon of your choice. Spread selected after pressing A when the message "You want the hard-kicking HITMONLEE?" or "You want the piston-punching HITMONCHAN?" appears.
Magikarp: Save in front of the salesman in the Route 3 Pokémon Center. Last input is a press of the A button after he asks "So you’ll buy it, am I right?"
Lapras: Save in front of the Silph employee nearest to your rival. Spread selected with a press of the A button after he says "I want you to have this POKéMON for saving us."
Omanyte/Kabuto/Aerodactyl: Save in front of the important doctor who revives Pokémon fossils. Spread selected after pressing A when he says "Your fossil is back to life! It was [OMANYTE/KABUTO/AERODACTYL] like I think!"
Snorlax: Save in front of the sleeping Snorlax. Last input is a press of the A button when the message "It attacked in a grumpy rage!" is displayed.
Articuno/Zapdos/Moltres: Save in front of the legendary bird. Last input is a press of the A button after it cries "Gyaoo!"
Mewtwo: Save in front of the Genetic Pokémon. Last input is a press of the A button when it says "Mew!"
Togepi: Save in front of the man in Five Island's Water Labyrinth. Spread selected upon pressing A when he says "Please, I'd like you to have this."
Ho-Oh: Save on the first space of the peak of the cliff. Last input is pressing up on the directional pad to place yourself on the second space of the cliff.
Other: Save directly in front of the Pokémon’s overworld sprite. Last input is a press of the A button to "activate" the battle. In the case of Deoxys, the red-hot rock serves as the overworld sprite. In the case of Eevee, the Poké Ball that houses it counts as its overworld sprite, and no battle is required.
Note that freezing or changing certain values in an emulator can alter a Pokémon's generation and lead to an illegal result. Due to a phenomenon known as vBlank (detailed in Bond697's posts on GBA Video Functions), "Method 1" Pokémon can also be generated through methods 2 and 4, but this is not the default behaviour; know if you get an abnormal spread for a method 1 Pokémon, this is the factor at work.
[A]#method_h[/A]
Wild Pokémon: Method H
FireRed and LeafGreen use a method known as Method H (which comes before the "Method J" and "Method K" with which you may be familiar if you have done RNG manipulation in the fourth generation) to generate their wild and Pokémon. This is the same method used in Ruby and Sapphire, and is now supported in the latest version of RNG Reporter (9.93). More technical information is available below in HIDE tags. What you need to know is that all wild Pokémon are generated using Method H, but with a bias towards the Method 2 variant.
[A]#practical[/A]
Practical Applications
As for the practical side of RNG manipulation, in light of recent (12/20/11) Method H information, OmegaDonut has proposed a method of manipulating gift and wild Pokémon that is simpler than ever. Read his post here for a quick breakdown:
In the event that you wish to have the luxury of recalibration, NixHex's original method can be found below:
User Zari has taken the information we have right now and created a method of RNG manipulation that makes RNG manipulation in FireRed/LeafGreen more accessible to the average user, even if it is not entirely possible to manipulate the seed at will. As NixHex has put it, try thinking of this method as a variant of Emerald, albeit one with more options from which to choose. Zari's post below describes his method:
Note that triggering the advance to the start screen at the right instant will yield better results than mashing buttons either to a beat or as quickly as possible. Zari notes that three button presses are needed to execute the skipping method.
Zari has also kindly compiled a list of the different seeds found:
Here is Zari's success story in which he details how he caught his Mewtwo in Kanto:
[A]#tid_sid[/A]
Trainer ID and Secret ID Generation
The RNG is constantly running during Professor Oak's introduction to the player, and the point at which the player's ID, or visible Trainer ID is created has been found, as well as the moment when the invisible Secret ID is generated. Our knowledge of the TID/SID generation process will hopefully allow manipulators to obtain custom ID combinations for use in the capture of shiny Pokémon, or general aesthetic purposes.
"Frequently Asked" Questions
As implied by the quotation marks in the header, not all of these questions are frequently asked. However, I do anticipate them coming up, so I'll try to provide some help here:
Q: How are Eggs/shiny Eggs generated?
A: Information on the generation of Eggs can be found in this post of the RNG Research thread. Similarly, Egg availability and generation is elaborated upon in a subsequent post in the thread. In both cases, the information has been provided by Kaphotics.
Q: There were two runs of FireRed/LeafGreen cartridges. Does the RNG work the same on both?
A: As far as we are aware, there are no differences between the runs of the games as far as the RNG is concerned.
Q: Do these findings apply to other games, such as Ruby/Sapphire, or just FireRed/LeafGreen?
A: As mentioned above, all Pokémon handheld games share some similarities as far as RNG mechanics go, but they also have their own nuances. This thread is made specifically dealing with FireRed/LeafGreen mechanics. Ruby and Sapphire share wild Pokémon generation Method H, so that research may be applied there.
[A]#research_questions[/A]
Research Questions
As you have likely gathered, we do not have enough information to create a streamlined RNG manipulation experience in FireRed/LeafGreen at this time. This is why your help is needed. Here is a list of all the things that need researching at the moment (that I can think of):
Helpful Links
[A]#general_resources[/A]
General Resources
Applications
[A]#credits[/A]
Credits
I would be remiss to not give credit to the various users that have made this information available. Of course, where the RNG is concerned, loadingNOW and X-Act did the pioneering research that has made all RNG manipulation possible. =Jonny=, Syberia, Equinox, and Negator contributed to early tests and research concerning the FireRed/LeafGreen random number generator, and the program used to find FireRed and LeafGreen seeds was crafted by NeoSyrex. Additionally, user NixHex has made several significant contributions, including a series of updates. Similarly, Kaphotics and Bond 697's work in the RNG Research thread has proven useful in illuminating some of the outstanding technical aspects of the RNG, and they have posted many new developments in this thread. Many other users such as chrish, mattj, flovv, andZari made consistent or large contributions. Many other users have contributed to this cause.
- [JUMP=#preliminary_information]Preliminary Information[/JUMP]
- [JUMP=#method_1]Method 1 Pokémon[/JUMP]
- [JUMP=#method_h]Wild Pokémon: Method H[/JUMP]
- [JUMP=#practical]Practical Applications[/JUMP]
- [JUMP=#tid_sid]Trainer ID and Secret ID Generation[/JUMP]
- [JUMP=#faq]"Frequently Asked" Questions[/JUMP]
- [JUMP=#research_questions]Research Questions[/JUMP]
- [JUMP=#helpful_links]Helpful Links[/JUMP]
- [JUMP=#general_resources]General Resources[/JUMP]
- [JUMP=#applications]Applications[/JUMP]
- [JUMP=#credits]Credits[/JUMP]
12/20/11 Update: RNG Reporter now supports Method H, the method of Wild Pokémon generation supported in FireRed and LeafGreen.
09/14/11 Update: The technically inclined may see Bond697's latest posts on Method Determination and GBA Video Functions.
[A]#preliminary_information[/A]
Preliminary Information
Abusing the Random Number Generator of FireRed and LeafGreen is very difficult in comparison to games such as Emerald or Diamond and Pearl. Many users have found success thanks to save states from emulators, though the goal of this topic is to facilitate this process for those using actual game paks.
One of the most important pieces of knowledge in the puzzle of RNG abuse is the "seed". A "seed" is a number that is initially plugged into the formula used to generate strings of pseudo-random numbers. If we know the seed, it is possible to determine the sequence of pseudo-random numbers it creates. In Emerald, we always know the seed, as it is 0 each time the game starts up. In Diamond and Pearl, we can manipulate the seed by starting the game at a certain time, and hitting a certain delay.
FireRed and LeafGreen operate in a different fashion than the abovementioned games, but they share certain similarities with all of them. They still make use of a seed, which generates a set of frames—simply put, a frame is the spot when the RNG generates a certain PID (a nature and IVs for Pokémon). User flovv has looked into the game's code and discovered the specifics of seeding for FireRed and LeafGreen:
Creation of the initial seed is not complex, it's not even a formula needed.
How does it work? After some more debugging I found out that the
initial seed gets copied from 0x04000104 to its final position in memory (0x02020000).
That address is the counter of the GBA timer 2/4, which is running @ 256Hz; 65536clks.
More about those Timers can be found here.
The timer starts counting when the screen changes to the "Press Start"-Screen.
This is initiated by the first button press or waiting till intro is finished.
Once it started counting, it will do so until the initial seed has been determinated.
A soft reset will have the same effect as if you switch off the GBA.
Also this explains my captured initial seeds. The low ones from frame 1 to 48 had no
other instructions at the moment the first button was pressed.
The ones after that have a routine running which takes some cycles and therefore increase the counter.
Researcher Kaphotics has also noted that the current seed information is stored in memory location 0x03005000.
Frequent contributor mattj has summarized much information concerning seeding and the advancement of frames as follows:
1) It really is possible to hit reasonably consistent starting seeds in FR/LG: Been There Done That.
1) The moment the game "begins seeding": When you press A to make the "Venu/zard Scene" begin.
2) The moment the starting seed is chosen/calculated: [A few moments after Venusaur/Charizard's cry sounds, upon pressing A again to advance.]
3) The moment frames STOP rolling: When you press A the SECOND time on your pokemon and the battle actually begins.
It is important to note that "button mashing" is undesirable due to its effects on seed groupings. It is much better to be deliberate with button presses whenever you are booting up the game.
User NeoSyrex also has information concerning the FireRed/LeafGreen RNG, which he famously applied to capture a Zapdos for use in the Video Game Championsips. The information provided by NeoSyrex is as follows:
Basically the way to abuse FR/LG's RNG is to catch a Pokémon (for example Zapdos), check its IVs, and get the seed. Then go backwards through the RNG (using the reverse RNG formula on the seed) until you find your starting seed. I never figured out how the game creates it, but the starting seed is always going to be a 2 byte number so it doesn't really matter since the RNG rarely comes up with numbers that small (and when it does the offset is usually a giveaway as to whether its the starting seed or not). I made a program that can do this, its a simple DOS program I quickly made that I haven't had a chance to make look nice. (...)
Continue doing this until you find a seed you land on often. Once you find a particular seed that seems to work for you, use RNG Reporter to check if there are any spreads for the seed that you want. Finally, you need to correctly time the frame you enter the battle to match the corresponding spread.
This seed may be found manually by program FR/LG Seed Finder, which is attached to this post. NeoSyrex, the author of this program, says the following:
(...)it's pretty simple, just enter the seed you calculated and it will return possible starting seeds, and how many frames earlier they occurred. Usually the first one (the lowest number of frames backwards) will be the correct starting seed, although there are exceptions, especially if you waited a while to calculate your seed.
As mentioned earlier, it is possible to generate a list of upcoming spreads using mingot's RNG Reporter program. This is more reactive RNG manipulation than proactive, but this is the best we have at the moment.
From here, it is possible to aim for a spread that you want by hitting its frame. Frames advance in realtime in a similar vein to Emerald, albeit with a catch. In a "quiet" area, such as outside Mt. Moon, the RNG advances at approximately 60 frames per second. However, this does not apply to all locations in the game. In certain locations, the RNG advances somewhat differently.
The RNG runs in an altered state in certain areas (many of which seem to be interior), cycling through either odd frames, or even frames. For example, if the game chooses odd frames, it will only cycle through frames 1, 3, 7, 9, 11, and so on. This creates the illusion that the RNG is advancing at 120 frames per second, when it is actually skipping over one type of frame. However, you can change whether the RNG will cycle through even or odd frames. This is achieved through opening up the menu, saving your game, and possibly other actions that have yet to be documented. This will cause the frames to switch to the opposite types; if the game was cycling through odd frames, it will now cycle through even frames, and vice versa. The specifics of quiet and noisy frame advancement are not yet known.
It would also seem that noisy and quiet areas are not necessarily consistent; noisy areas can be silenced through a technique described by flovv:
About the noisy areas:
Most of them can be turned to normal ones by saving there and reloading the game.
It also seems that sometime if you visit a noisy area and go to a normal the frames will remain noisy.
At the moment, you would look through the list of spreads generated by your recurring seeds until you found one you wanted.
[A]#method_1[/A]
Method 1 Pokémon
Much like Emerald, FireRed and LeafGreen
Bulbasaur, Charmander, Squirtle, Clefairy¹, Abra¹, Hypno², Voltorb³, Electrode³, Hitmonlee, Hitmonchan, Scyther¹, Pinsir¹, Magikarp⁴, Lapras, Eevee, Porygon, Omanyte, Kabuto, Aerodactyl, Snorlax, Articuno, Zapdos, Moltres, Dratini¹, Mewtwo, Togepi, Lugia, Ho-Oh, and Deoxys
¹Only Clefairy, Abra, Scyther, Pinsir, and Dratini bought at the Game Corner are consistently generated by method 1. Scyther is exclusive to FireRed, whereas Pinsir can only be found in LeafGreen.
²Only the Hypno encountered by Lostelle in the Berry Forest is consistently generated by method 1.
³Only Voltorb and Electrode disguised as Poké Balls are consistently generated by method 1.
⁴Only Magikarp bought from the salesman in the Pokémon Center on Route 3 are consistently generated by method 1.
Note that as in Emerald, a Pokémon's spread is not necessarily selected at the precise moment you press A next to its overworld sprite. Rather, the RNG keeps cycling right up until the battle starts (or in the case of gift Pokémon, it is received), unless "spread selected" is indicated in the place of "last input". A list of where to save and the last inputs for each Pokémon is as follows:
Bulbasaur/Charmander/Squirtle: Save in front of the Poké Ball containing the starter of your choice. Spread selected upon pressing the A button after the message "This POKéMON is really quite energetic!" appears.
Abra/Clefairy/Dratini/Scyther/Pinsir/Porygon: Save in front of the Game Corner Prize Corner desk. Spread selected after pressing A when the message "So, you want the [ABRA/CLEFAIRY/DRATINI/SCYTHER/PINSIR/PORYGON]?" appears.
Hypno: Save in front of Lostelle in the Berry Forest. Last input is a press of the A button after Lostelle wails "Waaaaaaah! I want my daddy!"
Hitmonlee/Hitmonchan: Save in front of the Poké Ball which contains the Pokémon of your choice. Spread selected after pressing A when the message "You want the hard-kicking HITMONLEE?" or "You want the piston-punching HITMONCHAN?" appears.
Magikarp: Save in front of the salesman in the Route 3 Pokémon Center. Last input is a press of the A button after he asks "So you’ll buy it, am I right?"
Lapras: Save in front of the Silph employee nearest to your rival. Spread selected with a press of the A button after he says "I want you to have this POKéMON for saving us."
Omanyte/Kabuto/Aerodactyl: Save in front of the important doctor who revives Pokémon fossils. Spread selected after pressing A when he says "Your fossil is back to life! It was [OMANYTE/KABUTO/AERODACTYL] like I think!"
Snorlax: Save in front of the sleeping Snorlax. Last input is a press of the A button when the message "It attacked in a grumpy rage!" is displayed.
Articuno/Zapdos/Moltres: Save in front of the legendary bird. Last input is a press of the A button after it cries "Gyaoo!"
Mewtwo: Save in front of the Genetic Pokémon. Last input is a press of the A button when it says "Mew!"
Togepi: Save in front of the man in Five Island's Water Labyrinth. Spread selected upon pressing A when he says "Please, I'd like you to have this."
Ho-Oh: Save on the first space of the peak of the cliff. Last input is pressing up on the directional pad to place yourself on the second space of the cliff.
Other: Save directly in front of the Pokémon’s overworld sprite. Last input is a press of the A button to "activate" the battle. In the case of Deoxys, the red-hot rock serves as the overworld sprite. In the case of Eevee, the Poké Ball that houses it counts as its overworld sprite, and no battle is required.
Note that freezing or changing certain values in an emulator can alter a Pokémon's generation and lead to an illegal result. Due to a phenomenon known as vBlank (detailed in Bond697's posts on GBA Video Functions), "Method 1" Pokémon can also be generated through methods 2 and 4, but this is not the default behaviour; know if you get an abnormal spread for a method 1 Pokémon, this is the factor at work.
[A]#method_h[/A]
Wild Pokémon: Method H
FireRed and LeafGreen use a method known as Method H (which comes before the "Method J" and "Method K" with which you may be familiar if you have done RNG manipulation in the fourth generation) to generate their wild and Pokémon. This is the same method used in Ruby and Sapphire, and is now supported in the latest version of RNG Reporter (9.93). More technical information is available below in HIDE tags. What you need to know is that all wild Pokémon are generated using Method H, but with a bias towards the Method 2 variant.
As for the encounter slots of FireRed and LeafGreen, Zari states that they appear to (for the most part) conform to the same twelve-slot format as the fourth generation games. In other words, for all areas with twelve Pokémon listed, the slots should correspond to the following:
20% / 20% / 10% / 10% / 10% / 10% / 5% / 5% / 4% / 4% / 1% / 1%
This information has been corroborated by a separate study conducted by Kaphotics in the RNG Research thread, as seen below (post edited to remove R/S/E information):
The encounter slots seem to differ when using each Fishing Rod, which Kaphotics has also addressed below:
For a comprehensive list of encounter slots for each game, please refer to this post.
For those interested in the technical side of PID generation, Kaphotics has laid out a simplified version of the process as follows:
Setup of everything before PID:
Now to generate a PID.
Then comes the IVs, which depend on the Method of Generation.
Not sure if this is that calc at frame 1, the rejection of IV bits, or something else.
20% / 20% / 10% / 10% / 10% / 10% / 5% / 5% / 4% / 4% / 1% / 1%
This information has been corroborated by a separate study conducted by Kaphotics in the RNG Research thread, as seen below (post edited to remove R/S/E information):
FRLG Encounter Slots
RNG Seed is 32 bits, only uses u16 as we know already.
Backwards Method:
- Find the frame the IVs occur on for the initial seed (000005A0).
- Take the PID of that frame and %25 (0x19) to get Nature.
- Subtract One from the frame, determine if it is odd or even.
- Set up researcher, as described in the example (until a method is available).
- I call it Method H, it's VERY similar to Method J / K in gen 4 due to how it works. It exists before gen 4, thus H is before J.
- Work backwards from the PID frame, only looking for your Nature in custom 2 in the even/odd frames (You determined even or odd in step 3).
- Once you have found it, two frames back on Custom 3 is the ESV.
Instead if you predict it forwards, you can possibly have a few different encounter slots for the PIDIV, just like Gen 4.
Code:Slot 0 1 2 3 4 5 6 7 8 9 10 11 Rate 20% 20% 10% 10% 10% 10% 5% 5% 4% 4% 1% 1% Value 0-19 20-39 40-49 50-59 60-69 70-79 80-84 85-89 90-93 94-97 98 99
Example
Code:LOCATION: [URL="http://bulbapedia.bulbagarden.net/wiki/Cerulean_Cave#B1F_2"]Cerulean Cave B1F[/URL] Initial Seed: 00005542 Version: Fire Red Sweet Scenting Sceptile (lulz)
Do note that this does make some spreads unobtainable for this encounter type just like in J/K.
Method 1 based generation will have the same excluded spreads as Method K, but for Method 2 and 4 based generation, nobody knows yet!
The encounter slots seem to differ when using each Fishing Rod, which Kaphotics has also addressed below:
Code:
Old Rod
Slot 0: 0-69
Slot 1: 70-99
Good Rod
Slot 0: 0-59
Slot 1: 60-79
Slot 2: 80-99
Super Rod
Slot 0: 0-39
Slot 1: 40-79
Slot 2: 80-94
Slot 3: 95-98
Slot 4: 99
For a comprehensive list of encounter slots for each game, please refer to this post.
For those interested in the technical side of PID generation, Kaphotics has laid out a simplified version of the process as follows:
Setup of everything before PID:
Code:
0 - Initial
1 - Battle Decision, pretty long thing = Battle
2 - Encounter Slot Value (0-99), via Upper16 %100 = Slot
3 - Encounter Level (from Slot), via Upper16 %(High-Low+1) + Low = Level
4 - Encounter Nature, via Upper16 %25 = Nature
Now to generate a PID.
Code:
set n = 0
loop until break to get a PID%25 = Nature
5+n - Temp Low16PID
6+n - Temp High16PID
if High16PID_Low16PID % 25 = Nature
set as the PID, break
else n=n+2
repeat loop
end
end
Not sure if this is that calc at frame 1, the rejection of IV bits, or something else.
Code:
if Method 1
a = 0
b = 0
elseif Method 2
a = 1
b = 0
elseif Method 4
a = 0
b = 1
end
7+n + a - IVSet1
8+n + a+b - IVSet2
[A]#practical[/A]
Practical Applications
As for the practical side of RNG manipulation, in light of recent (12/20/11) Method H information, OmegaDonut has proposed a method of manipulating gift and wild Pokémon that is simpler than ever. Read his post here for a quick breakdown:
uy a cheap Method 1 Abra at the Game Corner, note the IVs and calculate the "seed" for that Abra.
You could then plug that seed into RNG Reporter, generate a list of upcoming spreads, and look for spreads of interest. If you have a timer synchronized with the button press of the moment you obtained Abra, it shouldn't be too difficult to hit your target. Much easier than dealing with a 16 MHz Timer1.
[...]
My method gives you one chance to hit a spread, and no opportunity to re-calibrate if Method H messed you up and you didn't know it. But it's still easier than dealing with a 16 MHz timer AND the 60 frames\sec advancements.
In the event that you wish to have the luxury of recalibration, NixHex's original method can be found below:
Requirements:
This will only work if you are shooting for a very large frame, because you need to allow yourself a great deal of time to check IV's and to verify what seed you are on.
- A Pokemon who knows Sweet Scent
- (2) Master Balls
- 2 empty team slots
- 10 or so Rare Candies
- Metalkid's IV Calculator (www.metalkid.info)
Calibration:
For the lack of creativity, I'll call this time TCheck. You only really need to do this a few times if you're shooting for high enough of a frame.
- Start the game normally. Start a stopwatch the moment the game seeds.
- At the first chance you get, use Sweet Scent, catch whatever insanely high-leveled Cerulean Cave Pokemon appears.
- Check its IVs and verify seed. [Note that wild spreads are [usually] generated using method 2, so [...] use method 2 to verify the seed.]
- Stop the stop watch
Now, make sure that your target frame satisfies:
Code:Eq. 1 TF >> TCheck (in seconds) * 60
Now, let's say, completely hypothetically, I start the stop watch as the game seeds, use Sweet Scent, catch, say, a Wobbuffet, and check its IVs. As soon as I find my seed from FRLGSeedFinder, I hit STOP. Let's say this time is 5:45. Converting to seconds, I get 5*60 + 45 = 345 seconds. Now, I go back to Equation 1.
TF >> 345 * 60, or TF >> 20700
In other words, this method can only be used for HIGH frames. In fact, it wouldn't even be worth it to use this method for lower frames, as you would probably overshoot your target frame just by doing the calibration.
Now that we're done with that, we can get to the cool part. Let's say you can consistently hit the seed 9AA0. So, you decide to search the [method 1] frames on this seed and you find this admittedly lame spread:
Frame 44586 Brave 30/30/14/30/25/30
Is this frame high enough to warrant using this method? Plugging 44586 into equation 1 yields 44586 >> 20700, which is obviously true. Now we're set.
- Now, create an emloop/pikatimer for a frame of 44586, and Soft-reset.
- The moment the game seeds, start the timer
- Quickly Sweet Scent, catch, and check seed of the wild pokemon.
- If your seed is, in fact, 9AA0, let the timer run its course, then encounter Mewtwo
- If the seed is incorrect, you can restart now and save yourself the trouble of waiting another 7 minutes just to get a bad seed
User Zari has taken the information we have right now and created a method of RNG manipulation that makes RNG manipulation in FireRed/LeafGreen more accessible to the average user, even if it is not entirely possible to manipulate the seed at will. As NixHex has put it, try thinking of this method as a variant of Emerald, albeit one with more options from which to choose. Zari's post below describes his method:
Important Info
This is a reactive-proactive method; you find groupings of seeds that you can hit, then search for spreads within those ranges that are of interest. NixHex and I have hit similar groupings of seeds independently, leading me to the conclusion that it *should* be possible for any user to hit those seeds/the spreads within them as well.
The [combined] data we have collected is as follows:
Seed [Hex] groupings (an "X" indicates a variable value)
54XX (XX usually ranges from the values c0 to d4/d5)
30XX (XX: 82 to a0)
0bXX/0cXX (XX: ef to 07 [latter value has 0c at the forefront])
9eXX (XX: 0c to 17)
There are other groupings, but these are the most common. Now onto the method itself!
The "Skipping" Method
Basically, what we need to do is skip the intro and charizard/venusaur "flash" sequence entirely. We do this by button mashing, but it requires some timing as well.
I don't have the exact/close approx. time length nailed (working on this as I find the time), but you need to begin button mashing the "A" button after the credits/nintendo junk, but directly before the screen opens up from the center with a deep blue (this is the background screen which the Game Freak star passes over).
Directly after the introduction finishes (or would finish, if you let it run its entire course) there is the zard/venu "flash" as I like to call it, where the pokemon's sprite appears white, then forms a grey version of itself, and then becomes full color after that subsequence finishes. What we want to do is press "A" fast enough so that we skip this "flash" entirely.
The final part of this method is to press "A" fast a third time, after skipping both of those sequences. If done correctly, the cry of venusaur/charizard should sound within 1 to 2 notes of the pokemon theme's beginning.
Warning: this may take a lot of tries to get correct; the desired time length between button presses is ideally zero, but, since that's physically impossible, you want to aim for as small as you can make it. The smaller the time length between button presses, the more consistent results you will get.
That's basically it for the method. After all of that is complete, do the usual by catching mewtwo (or another high level legend/mon), finding the PID via RNG reporter, then inputting that seed into NeoSyrex's FRLG Seed Finder.
Notable spreads within the given groupings:
For Mewtwo:
Seed: 54cc, F:1838, Naive 27 / 28 / 30 / 30 / 27 / 31
Seed: 54de, F:42197, Timid 28 / 31 / 30 / 31 / 30 / 31
Seed: 3081, F: 22538, Hasty 30 / 30 / 26 / 30 / 30 / 31 -- note, I have not been able to hit this seed yet, though I have hit ones around it many times.
Seed: 9e0c, F: 25054, Naive 28 / 31 / 31 / 27 / 23 / 31
Seed: 0bf0, F: 30980, Hasty 31 / 30 / 25 / 31 / 25 / 31
Seed: 0bff, F: 20091, Hasty 28 / 31 / 30 / 27 / 30 / 31
Seed: 0c00, F: 6208, Naive 29 / 31 / 24 / 29 / 31 / 31
For those who might like to play ADV sometime again:
Seed: 54c6, F: 8631, Calm 31 / 31 / 30 / 31 / 28 / 31
Seed: 3082, F: 6403, Naughty 31 / 30 / 30 / 30 / 22 / 31
Seed: 9e14, F: 35262, Naughty 30 / 29 / 27 / 30 / 27 / 31
Seed: 0c02, F: 11279, Rash 30 / 30 / 31 / 27 / 31 / 31
Seed: 9e10, F: 63361, Jolly 28 / 31 / 29 / 1 / 31 / 31
---
There's most likely more, but that's just an example of what you can find with a few groupings of seeds. All but the last jolly one are under 10 minutes; most are under 4.
Note that triggering the advance to the start screen at the right instant will yield better results than mashing buttons either to a beat or as quickly as possible. Zari notes that three button presses are needed to execute the skipping method.
Zari has also kindly compiled a list of the different seeds found:
Code:
By groupings:
9eXX [02 - 2d]
9e02 * 2
9e03
9e0a * 2
9e0b * 4
9e0c * 2
9e0d
9e0f * 4
9e13 * 8
9e14 * 10
9e18
9e1c
9e1d * 2
9e29 * 2
9e2d
54XX [c2 - f3]
54c2 * 2
54c3
54ca * 2
54cb * 6
54cf * 2
54d2 * 2
54d3 * 3
54d4 * 10
54d7
54d8
54db
54de * 2
54e0
54ed * 2
54f3
30XXv1 [82 - a8]
3082
3083
308a
308b * 5
308e
3093
3098
309c
30a0
30a8
30XXv2 [3d - 5a]
303d
3045 * 2
3046 * 2
3047
3048
304b
304c * 5
304d * 2
304f * 2
3050
3056 * 2
305a
e7XX [42 - 72]
e742
e749
e747
e74b * 9
e74f * 5
e753
e758 * 3
e75c * 2
e75d * 3
e769
e771
e772 * 3
Here is Zari's success story in which he details how he caught his Mewtwo in Kanto:
For as fast as FRLG seeds, a 33.3% ratio of hitting a target seed is quite good. Now, I've hit this seed before, but what made this different from previous tests was that I only hit the A button 3 times per attempt. As such, I got even more consistent results when I used the skipping method (3 presses is the minimum needed to do the skipping method).
As for how I got my new mewtwo....well, it took a lot of attempts, a lot of luck, and the right kind of target frame. What I mean by that is, well, choose a low target frame; you'll be hitting quite a few groupings of seeds, so select a frame from one of them that's somewhere under a minute (I used frame 2051 for my mewtwo).
Basically, to RNG in frlg you first need to find what you can hit; in my case on my lg, it was the groupings 4cXX, 7aX, 9a9X, and f4dX. Notice that, as opposed to those I hit earlier on my fr in the first post, there's mostly only 1 X variable (4cXX is right on the split point). This is due to the groupings being smaller, like Kaphotics has mentioned. Anyways, once I found what I could hit, I looked through the groupings for low frames with good spreads. I chose one out of the 7aX grouping because it was the smallest grouping that I could easily hit (7a4 - 7a7), thus increasing my chances of hitting my target seed when timer0 selected that grouping. After that, it just took using eontimer to find my lag for that particular frame (-517), and then a few more resets and....
![]()
/ Hasty / Pressure / Genderless
28 / 31 / 7 / 29 / 24 / 31
....became mine. :)
If you guys have any more questions I'll try my best to answer them, but that was the main process for which I used to get my mewtwo. Obviously there was a lot of luck involved in the capture, but when it comes to frlg, you don't really have any other choice since timer0 moves so fast.
[A]#tid_sid[/A]
Trainer ID and Secret ID Generation
The RNG is constantly running during Professor Oak's introduction to the player, and the point at which the player's ID, or visible Trainer ID is created has been found, as well as the moment when the invisible Secret ID is generated. Our knowledge of the TID/SID generation process will hopefully allow manipulators to obtain custom ID combinations for use in the capture of shiny Pokémon, or general aesthetic purposes.
[A]#faq[/A]FireRed/LeafGreen TID/SID Generation
Code:The moment you press OK and the screen fades out completely, the 0x04000104 timer value gets set as the new seed. The game then takes that seed and considers it the initial, and that initial seed is your TID.
Code:The SID is set later in the process, but is still related to the seed. It is taken from the frame you are on when you end the miniaturization, taking the seed on that frame (and using the upper16).
"Frequently Asked" Questions
As implied by the quotation marks in the header, not all of these questions are frequently asked. However, I do anticipate them coming up, so I'll try to provide some help here:
Q: How are Eggs/shiny Eggs generated?
A: Information on the generation of Eggs can be found in this post of the RNG Research thread. Similarly, Egg availability and generation is elaborated upon in a subsequent post in the thread. In both cases, the information has been provided by Kaphotics.
Q: There were two runs of FireRed/LeafGreen cartridges. Does the RNG work the same on both?
A: As far as we are aware, there are no differences between the runs of the games as far as the RNG is concerned.
Q: Do these findings apply to other games, such as Ruby/Sapphire, or just FireRed/LeafGreen?
A: As mentioned above, all Pokémon handheld games share some similarities as far as RNG mechanics go, but they also have their own nuances. This thread is made specifically dealing with FireRed/LeafGreen mechanics. Ruby and Sapphire share wild Pokémon generation Method H, so that research may be applied there.
[A]#research_questions[/A]
Research Questions
As you have likely gathered, we do not have enough information to create a streamlined RNG manipulation experience in FireRed/LeafGreen at this time. This is why your help is needed. Here is a list of all the things that need researching at the moment (that I can think of):
- What areas have a "quiet" RNG, and what areas are "noisy"?
- It is unclear at the moment just where (and when) the RNG goes into the "noisy" pseudo-120 FPS mode. We need users to test in different areas to see where the RNG is "noisy" and where it is not. Bear in mind that the RNG can be silenced, as described by flovv earlier in the post.
That "fast mode" as we call it showed up also on a Sevii Island, it would really be helpful if some real cartridge owner can figure out if it appears even there:
The how to should be very easy, since the tester should just get their seed, aim for a 10/15 minutes far spread, and at the supposed time, check if their outcome is close at the aimed target, or if it's far away (double the time far).
This should be done after changing location, for example, starting the game outside Cerulean Cave, going inside, and only then do the scenting.
- It is unclear at the moment just where (and when) the RNG goes into the "noisy" pseudo-120 FPS mode. We need users to test in different areas to see where the RNG is "noisy" and where it is not. Bear in mind that the RNG can be silenced, as described by flovv earlier in the post.
- What actions cause the RNG to switch from even to odd?
- It is known that opening the menu and saving both cause the RNG to switch to the opposite type of frame. However, the full range of actions which cause this switch are not known as of yet.
Helpful Links
[A]#general_resources[/A]
General Resources
- How to turn off unnecessary RNG calls for research, thanks to Bond 697.
- The Process of PID and IV Creation of Non-Bred Pokémon, thanks to X-Act.
- RNG Manipulation in Pokémon Emerald Introduction (contains a quick explanation of Emerald's RNG; many concepts carry over to FireRed and LeafGreen).
- SRing on VBA Part 1 and SRing on VBA Part 2, thanks to Syberia.
- Emulator LUA Scripts, thanks to Kaphotics.
- Capturing FR/LG Legendaries (general tips not specific to RNG manipulation).
- [ポケモン-その他] - アーマーの雑記 (Japanese FireRed and LeafGreen RNG information—exact content is unknown, but it does not appear to cover much ground that this thread does not)
Applications
- RNG Reporter, thanks to mingot and OmegaDonut.
- PokéRNG, thanks to Wichu.*
- IVs to PID Applet, thanks to X-Act.
[A]#credits[/A]
Credits
I would be remiss to not give credit to the various users that have made this information available. Of course, where the RNG is concerned, loadingNOW and X-Act did the pioneering research that has made all RNG manipulation possible. =Jonny=, Syberia, Equinox, and Negator contributed to early tests and research concerning the FireRed/LeafGreen random number generator, and the program used to find FireRed and LeafGreen seeds was crafted by NeoSyrex. Additionally, user NixHex has made several significant contributions, including a series of updates. Similarly, Kaphotics and Bond 697's work in the RNG Research thread has proven useful in illuminating some of the outstanding technical aspects of the RNG, and they have posted many new developments in this thread. Many other users such as chrish, mattj, flovv, andZari made consistent or large contributions. Many other users have contributed to this cause.