Consistent RNG manipulation in Gen 1 RTA runs

Pokémon Trainer
Posts: 141
Joined: Wed Feb 04, 2015 11:22 pm

Consistent RNG manipulation in Gen 1 RTA runs

Post by entrpntr » Thu Aug 18, 2016 10:19 pm

There have been a few theoretical discussions about RNG manipulation potential in Gen 1 since the RTA discussions began, and gifvex and I were able to find something consistent last night that will likely have massive implications on Red/Blue/Yellow speedruns.

To cut to the chase, for Red/Blue, there are likely 3 points in runs where manipulation is worth performing (Yellow manips are similar, but not quite the same):
  • S&Q before Nido bush for a specific Nidoran (w/fixed level & DVs; manips for L12 Clefairy and L33 Nidorino have also been considered)
  • S&Q at some point during Mt. Moon for an encounterless section up to Rocket (or, alternatively, make the only encounter be a Paras right before the fight)
  • S&Q a few tiles outside of Surge's gym to manip trash cans in pairs
Our co-conspirator in performing the basic initial research was noted German speedrunning enthusiast mumpfel77, who prepared a video explaining the basic manipulation.

To summarize, the RNG always gets set to the same initial values on hard reset, and it is trivial to get to the overworld with the same RNG every time (it's very similar in concept to that for TID manip in Gold Any%). Each sequence of saving and resetting costs roughly 19 seconds from my timing of it (on emulator); note that to save a few frames, you can hard reset as soon as you see the "Now saving..." text, as your save has completed by this point (those playing on Game Boy Player should be able to reset as soon as they select "YES" to save):


For reference, below are input sequences for the intro (note that all of these have ENORMOUS frame windows—hitting them to get the manip is basically free).

[NEW METHOD] - saves ~2.2s, a video of the new method can be found here
  • Hold Up+Select+B during the copyright text and fight scene
  • Hold Start when the screen fades white after fight scene
  • Hold A when the screen fades white again
(Alternatively, hold A in step 2, and hold Start+A in step 3)

[OLD METHOD] - as in mumpfel's video
  • Hold A during the copyright text
  • Hold Start while Nidorino/Jiggly is hopping around
  • Hold A when the screen fades white
  • Hold Start+A when the screen fades white again
(Alternatively, hold Start in steps 1 & 3, and hold A in steps 2 & 4)

Since RNG will always roll the same values for the respective methods, S&Q manipulation is consistent between both resets AND runs, and the ultimate matter is one of finding setups for the crucial manipulations. As long as there is no complex menuing and no textboxes to mash through, you will be able to buffer all inputs and these manipulations will be very trivial to perform.

Some crucial details that will help in finding pathing for godly RNG:
  • If you save on a different tile, RNG will be offset from what it otherwise was, and will usually result in things playing out much differently
  • When you vary your movement paths, RNG will change and be different from there on out
  • You can buffer A before a random tile (+2 frames), take extra steps (+17 frames per extra tile walked), or frame perfectly menu flash/pokedex flash (adds a variable amount of frames, depending on the map)
  • On the floor you enter Mt. Moon (from Route 3), each step you take when there is a trainer that you haven't fought on screen creates 1 extra frame of lag, which adds even more to number of variations
  • Red/Blue RNG will differ because of the different intro, so if the right setup is found, Blue could possibly be better to run on than Red
  • D-Sum still exists and will start from the same point on hard reset; goal encounters will only appear in specific windows after the reset (which is why the old input method still might be relevant, despite being slower).
The bullet points above are simply ways to increase the number of trivially executable variations to test for finding paths. Luckily, RNG emulates with console accuracy on BGB 1.5.3 and Gambatte-speedrun with the GBC bootrom installed, so routing on emulator should translate to console and greatly improve the efficiency of the routing/pathing process. I put a page on the wiki for setting up BGB with the GBC bootrom, so others can help finding potential console setups. See Keizaron's video for how to set up Gambatte-speedrun here.

One more note: Trash can manip can also be performed in pairs and is evidently worth going for in Red/Blue. You do this by S&Q'ing after the Vermillion cut tree before entering the gym. Reloading the Vermillion City map resets the cans, so doing it after an S&Q manip will set them to predictable values.

Feel free to post if you need clarifications on anything with this manip. Otherwise, happy pathing and routing to all!
Last edited by entrpntr on Sat Mar 25, 2017 9:58 pm, edited 10 times in total.

Pokémon Trainer
Posts: 141
Joined: Wed Feb 04, 2015 11:22 pm

Re: Consistent RNG manipulation in Gen 1 RTA runs

Post by entrpntr » Sun Aug 21, 2016 1:01 am

Technicalities/Sources of Inconsistency

(Last updated 5 Feb 2018) - Since the original post, there has been a lot of research performed to determine and root out sources of inconsistency. I'll keep this post updated with various findings from ongoing RNG research.

(1) Palettes / Bootrom inputs

In Red/Blue, there are five different input methods during the bootrom (i.e. when the Game Boy logo flashes) that will produce unique (but consistent) RNG:
  • Not pressing any buttons
  • Pressing or holding one of A/B/Start/Select at any point during the bootrom (this won't select a palette)
  • Pressing and releasing inputs to select a palette (86 frame window for d-pad only; 12 frame window for d-pad + A/B)
  • Selecting the inputs for a palette and holding them through the end of the bootrom (same 86/12 frame windows)
  • Buffering a d-pad input during the hard reset, adding A or B between when the 'E' and 'B' in 'GAME BOY' appear, and holding both inputs through the end of the bootrom (12 frame window for the d-pad, 16 frame window for A/B)
Note that inputs can be buffered during the hard reset on Game Boy Player, so the initial window is much larger than 12 frames there.

For clarity, you can see a video here for what the inputs look like for each of these methods.

(2) A vs Start+A on Continue screen

Input methods during the intro can end either with A or Start+A on the Continue/File Select screens. Holding A will produce a jingle, whereas Start+A will not. So far, this has not seemed to matter in most cases, but there are certain setups where the choice of inputs in the intro has produced RNG differences.

(3) NPCs / Overworld Sprites

All NPCs and other overworld sprites (e.g. Poké Ball items) have internal timers that are included in save data. These timers are initialized to random values (unless, of course, it is during a manip segment), so saving with them on-screen should be avoided.

You need to be wary not only of saving with these sprites off-screen, but also of whether they appear on-screen at any point prior to saving (with the exception of any Poké Balls that you picked up). You will find inconsistency between saves if the path you take after the S&Q reloads any of these sprites onto the screen. That said, once you account for these mechanics, the issue can be avoided through smart pathing.

NOTE: Sprites have their timers reset when you reload the map (exit/re-enter cave, go up/down stairs, etc). So if you are routing and notice that you had taken a bad path up to some point, you can recover to a workable state relatively easily.

NOTE: Additionally, there will be different RNG between saves if different trainers are fought or different items are picked up on any maps that get loaded during a manipulation segment. Be sure that setups account for the strats that you'll be using on the run (e.g. S&Q setups for post-Bug Catcher vs post-Lass on Mt. Moon entry floor are sensitive to which trainer you actually fought), and be aware that you may not produce the same results from any arbitrary save file.

(4) IGT0 (also "IGTimer0" or "IGT fuckery")

The in-game timer's frame count (at the point of S&Q) has a chance to create inconsistencies in RNG between saves, and these inconsistencies are not likely to be eliminated entirely. To illustrate things, the IGT is stored as hh/mm/ss/ff (hours/minutes/seconds/frames), where mm/ss/ff will be values between 0-59. Whenever loading a new map, there are two [consecutive] values for ff that will cause the in-game timer to overflow at a sensitive time, and consequently disrupt the normal cycle for RNG. The two undesirable frames impact the RNG in different ways, so there are multiple failure cases that can surface.

This only applies to map loading routines that disable the LCD, so overworld route transitions (e.g. Viridian -> Route 22) are not affected. However, each map loaded after an S&Q or after ladder/building/cave transitions has a chance to induce the issue. This essentially means that each applicable map load has a 1/30 chance of getting screwed by IGT overflowing.

Additionally, when an on-screen NPC's timer hits 0 (or when an NPC first comes on-screen) the same frame IGT overflows, there is a decent chance that cycle differences will creep in and affect RNG. As a result, the more sprites you pass during a manipulation segment, the greater the likelihood will be for inconsistencies to surface.

There are a couple other places where "IGT0" (as dubbed by Dabomstew/ExtraTricky) can occur, such as manips that use pokedex buffering or yoloballing. There are also many more subtle ways for IGT0 issues to surface, and at this point, botting has taken over as the main way to empirically tell what the success rate is for any given manip.

(5) Clearing text boxes ("PrintLetterDelay")

Another subtle, but preventable, source of inconsistency lies in how you clear text boxes during item ball pickups. Inputs here can cause differences in RNG, so care must be taken when picking up items during a manipulation segment (e.g. picking up Moon Stone in Mt. Moon). The recommended approach (and the approach used in current manips) is to hold A and wait to release the input during the item jingle, as there is a much larger window for consistency.

Other manips that involve textboxes (yoloball manips and advanced/extended manips) also need to account for the possible impacts of PrintLetterDelay. For more information, read Dabomstew's writeup here.

(6) Buffered vs unbuffered saves

Whether or not you "buffer" your save (i.e. buffering START on the save tile before your character stops moving) can affect manips that happen to load sprites during the path (the more sprites you pass, the more likely there is a divergence). Theoretically, this affects both Red/Blue and Yellow equally, though in the manips found to date, the issue more directly impacts Yellow.


  • The top 4 items in your inventory matter on manips where you are yoloballing, as extra lag can be produced depending on which items appear.
  • In Red/Blue, yoloball manips will likely have different success rates if your lead Pokemon is in red bar (as the cry will be cancelled, so the ball will be thrown a different frame). Though cries still play in Yellow for red bar, extra lag is produced when in yellow bar or red bar, so there is a difference for yoloball manips in those instances vs being in green bar.
  • The timing of A inputs can affect RNG on naming screens, though this is currently limited to a couple advanced manips (starter manips and extended manips after catching NidoranM).

A couple of edge cases that can also affect manips (in most cases, they won't):
  • The number of Pokemon in your party has a small chance to affect manip results (on one or more IGT frames)
  • Manips where you pick up items (such as in Mt. Moon) can have different success rates depending on how many items are in your inventory at the start of the manip
  • A vs Start+A and PrintLetterDelay-related techniques (which are mentioned above), as well as general game events that involve waitloops/lag, have a chance to shift things by enough to cause offsets in RNG


Advanced reading:
Last edited by entrpntr on Mon Feb 05, 2018 8:04 am, edited 9 times in total.

Posts: 2
Joined: Sun Jul 24, 2016 6:47 pm

Re: Consistent RNG manipulation in Gen 1 RTA runs

Post by Sherkel » Sun Sep 04, 2016 10:30 pm

These are amazing contributions! Thanks to everyone for all their work in discovering these!

Posts: 6
Joined: Sat Feb 28, 2015 12:52 am

Re: Consistent RNG manipulation in Gen 1 RTA runs

Post by beware » Wed Mar 08, 2017 7:01 pm

bgb 1.5.3 is released with correct pokemon TID. so anyone who speedruns pokemon with bgb should get 1.5.3.


- correct TID for rby/gsc, for GBC and GBA (tested)

- with and without bootroms should both give correct TIDs (tested)

- regardless of using bootroms or not, "detect GBA" in settings will give GBA TID, unchecking it gives GBC TID
to achieve this, the bootrom is patched "live" in memory to give the correct initial state for GBC or GBA. and for DMG or MGB.
so you're supposed to use the original (dumped) GBC bootrom.
however, if you use a GBA bootrom (hard-patched) it will still work, and it should even soft-patch it back to GBC.
the soft-patching is made to be safe and to not produce a corrupt final result.

- if a bootrom is not used, the faked initial state is affected/modified for GBA (including one clock timing difference)
likewise fake initial state is affected for DMG vs MGB.
fake initial state for gbc bootrom and pressing a button to give a custom color palette is *not* simulated.

- running a GBC/GBA bootrom and pressing keys to give custom color palette isn't tested (but it should be correct)

- when emulating the classic gameboy/DMG it should be correct as real DMG (not tested)

- emulating super gameboy should give correct TID for SGB (not tested). SGB initial state has generally been made more like a SGB.


Return to “Generation 1”

Who is online

Users browsing this forum: No registered users and 3 guests