RNG oddities (Generation III)

From Glitch City Wiki
Jump to navigationJump to search
Miscellaneous glitches of Pokémon Ruby and Sapphire, Pokémon FireRed and LeafGreen and Pokémon Emerald

While luck manipulation can be considered a class of non-glitch exploits, there are aspects of RNG implementation in the Generation III handheld games that are almost certainly unintentional.

Emerald initial seeding

In Pokémon Emerald, no matter what, the RNG seed is 0 upon bootup, despite the existence of substantial initial seeding algorithms in Pokémon Ruby and Sapphire and Pokémon FireRed and LeafGreen. (When the internal battery has run dry or is disconnected in Ruby and Sapphire, the algorithm always returns 5A0, resulting in the same predictability as in Emerald. It takes the internal clock roughly two days to stop functioning after the battery is disconnected.)

VBlank RNG interrupt glitch ("Methods")

In all five games, there exist multiple sets of PIDs and IVs for a given Egg or encounter on any given frame. Even though the effects of this are mostly innocuous and potentially beneficial to the player, these are due to a programming oversight.

The GBA's VBlank routine runs roughly once every 16.743 milliseconds. Stat generation is generally much faster than this, making four calls to the RNG returning a halfword each time, two each for the PID and IV spread. These can be predicted for any given current seed by running the LCG on each result manually, noting the upper 16 bits of each value. However, VBlank is an interrupt and the LCG advances by one sequential state every time it's run, so to generate the needed four values, an additional call sometimes needs to be made.

These unintended orders have been referred to as "methods" by various sources. Three have been confirmed to occur on official hardware. Each has a counterpart that includes the random encounter nature hunt routine ("Methods H-1, H-2, and H-4"). Method H-1 almost never occurs, as the slowness of the nature hunt almost always causes VBlank to interrupt the four main RNG calls. Method 4 has frequently occurred in Pokémon Box Ruby & Sapphire, and H-1 has been occasionally witnessed in Pokémon Ruby and Sapphire.

Sequential RNG calls
Method PID1 PID2 IV1 IV2
1 1 2 3 4
2 1 2 4 5
4 1 2 3 5