If everyone who used this site donated just $3/month, it could be a full time job for multiple people!
Gist: What are Vblanks and their impact on Pokémon generation.
What are Vblanks?
A vblank interrupt is the mechanism used by the GBA to refresh the screen. It is triggered every 1/60th of a second independently from regular game logic execution.When a vblank interrupt occurs, the regular game program execution is paused, vblank associated code is executed, then the regular game program resumes.In GBA Pokémon games, the vblank associated code updates the RNG to advance by 1. This means that every 1/60th of a second, the RNG advances by 1.
Impact of vblanks
Here's the simplified logic for Pokémon generation:
Step
Advance At Step Start
Generate PID
1
Generate IVs
2
In most cases, this is exactly what happens, and the Pokémon is generating with RNG advance 1 and 2.However, in some rare cases, a vblank occurs seemingly out of nowhere and alters the generation:
Step
Advance At Step Start
Generate PID
1
VBLANK: Advance RNG
2
Generate IVs
3
Even though the Pokémon generation started on the same RNG advance, the resulting IVs are different because they were generated with advance 3 instead of advance 2.
Vblanks Frequency
As stated before, a vblank occurs every 1/60th of a second, more specifically every 280'896 CPU instruction cycles. Every operation performed by the GBA (ex: addition, loading data) takes a certain number of CPU instruction cycles.The more instruction cycles a Pokémon generation step takes, the more likely a vblank will occur during it.
Ex: A step that takes 28'000 cycles will have ~10% chance to have a vblank.
Ex: A step that takes 300'000 cycles is guaranteed to have at least 1 vblank, possibly 2.
The generation of a stationary Pokémon takes few instructions, which makes vblank rare.In the other hand, wild Pokémon generation with a Synchronize lead can take a lot of instructions, which makes vblanks a lot more common.Fortunately, in most cases, vblanks occuring during the Pokémon generation don't actually impact the resulting Pokémon. But sometimes, they do impact and cause what we call Methods 2-4.