Instant encounter infinite chain glitch
Instant encounter infinite chain glitch is a glitch in Pokémon Red and Blue.
It was found by luckytyphlosion and is based on the effect of the glitch item "8 8" (hex:7C), which is used indirectly thanks to the item effect address becoming corrupted as part of unterminated name glitch item corruption.
In this technique the address CFC4 is also modified to an even number to avoid a freeze that may occur after using 8 8.
This glitch is one of the base glitches for LGFly, a mass Pokémon farming glitch used to capture a greater variety of Pokémon.
The glitch allows you to get a presumably unlimited chain of Pokémon by first doing a Trainer escape glitch (either via a "Rival's effect" item or a black out warp on the Youngster near the exit) in Viridian Forest, and using (not just selecting) an unterminated name glitch item at the south entrance after the start menu pops up.
1) Go to Viridian Forest and either get a wild encounter and black out before a Trainer battles you on the tile in the image, or use a "Rival's effect" glitch item, such as 't' (hex:94) to get in the Trainer's range, open the Pokémon menu, close it, and Escape Rope away before they battle you.
2) Battle any Trainer and get the start menu working.
3) Return to Viridian Forest through Route 2 (important) and the menu should pop up.
4) Select a unterminated name glitch item (e.g. hex:80 or hex:93 and more) and use it.
A battle will start with a Pokémon based on the Special stat of the last Trainer (or the Viridian Forest Trainer if you did the black out method and don't encounter another Trainer/a Pokémon) and it appears that the start menu and items menu doesn't close.
5) The menu will be pop up again. Repeat step 4 as many times you want. The Pokémon that appears will be based on the Special stat of the Pokémon that appeared previously.
You can get any glitch item with the Celadon looping map trick.
Unterminated name glitch items are items which have a name with no 50h (terminator) in the first 20 characters. When you select a unterminated name glitch item or try to sell it, the first 20 characters of its name are stored at $CD6D. The game also copies this name data elsewhere to $CF4B and beyond. If there is no 50h in the first 20 characters, the game copies more than it should from $CD6D.
After the name data from $CD6D is screen data beginning from $CD81. Hence, the screen data will corrupt unrelated data from $CF4B+dec:20 ($CF5F) until the game finds a 50h, after which it stops copying.
In Viridian Forest there is a 50h screen tile (which looks like an 'up' arrow), meaning the game won't freeze here after selecting the unterminated name glitch item. If the 50 was too late (off the screen) you would probably get a freeze, meaning you normally can't view unterminated name glitch items everywhere.
The tile at BGB coordinate y=0A, x=02 will change the memory address CF91. For this glitch, we want a 50h after it and not before it. This memory address controls the function of an item. Its value is always the border tile just before "POKéDEX" on the menu; which is hex:7C. In this glitch, we trick the game into thinking we're using hex:7C instead of the unterminated name glitch item, so the original effect of the unterminated name glitch item doesn't matter.
The hex:7C glitch item has an interesting property. Using it when you have an instant encounter for the current map in memory can (for specific locations) cause the battle to happen while you still have the menu up. Then, if you run, the menu will be up again and you can use the item again and again to encounter more Pokémon, with the species being based on the Special stat of the last Pokémon.
There is a catch to hex:7C though, when it is used on its own without a unterminated name glitch item in the right spot. When the menu opens CFC4 is set to 01, and it's supposed to be reset to 00 when you close the menu. Hex:7C doesn't reset this value to 00, and unfortunately in Red/Blue running from a battle when CFC4 is odd causes a freeze in most places, Viridian Forest included.
With a unterminated name glitch item, you can work around the CFC4 problem because the tile which affects CFC4 at the Viridian Forest (BGB coordinate x=01 y=05) is hex:30; an even number (non freezing value), which is unchanged after the item is used.
Unfortunately, the item hex:7C effect is different in Yellow, so you can't do this trick there. Furthermore, you seemingly can't even do this with a CFC3 freeze in Yellow due to there being no known items with constant effects with an effect like Red's hex:7C item.
If you do this trick by first entering Route 13 from the west and doing a Trainer escape there instead of using Viridian Forest, you can still force an 'open-menu' encounter, however the menus will be shifted down and you have to scroll through some glitch text (which will be invisible if you used hex:7C via a unterminated name glitch item's item effect change effect). Furthermore, since CFC4 becomes an odd number (even when you use a unterminated name glitch item for this particular location; an unterminated name glitch item sets it to hex:39 which is dec:57), you can't exit the battle here without a freeze.