Item duplication glitch

The item duplication glitch is a glitch that allows the duplication of items in Generation I.

Pokédex 000 item duplication glitch
The Pokédex 000 item duplication glitch (also referred to as the Rare Candy cheat due to the preferred item chosen to duplicate) is a glitch in the Generation I games. It allows the player to duplicate items in their Bag.

Through the development of, which occurred in the two years following the release of in Japan, the old man glitch was disabled by blanking the data for wild Pokémon before overwriting it, and reprogramming shore tiles to not have any Pokémon. However, it is still possible to encounter MissingNo. and exploit the item duplication glitch using the or the Cable Club escape glitch, although MissingNo. other than its Ghost and Fossil forms on will commonly freeze the game. The glitch Pokémon g g and $ are also possible alternatives through a combination of the Time Capsule exploit and the Cable Club escape glitch, but both may also freeze the game after being sent out from the opponent's side.

Results
The sixth item in the Bag is duplicated upon encountering the glitch Pokémon. The quantity of this item will be increased by 128, provided that the quantity is less than 128 before performing the glitch. This means that the player is free to perform the glitch again by swapping the item, or using/tossing the duplicated item to reduce its quantity back under 128.

If the player catches the 000-variant in battle, then it becomes possible to duplicate the sixth item again, given that the quantity of the item in the sixth slot is less that 128 (this can be achieved by using the item in the battle or switching another into its place).

Key Items can be duplicated, but the only Key Items which are practical to duplicate are the Dome Fossil, Helix Fossil, and Old Amber. Key Items will stack, but the number next to the associated Key Item will not be visible. Under normal circumstances, it becomes impossible to remove duplicate Key Items without storing them one at a time in the PC; however, Fossils are an exception to this, because the game allows the player to revive the same Fossil Pokémon more than once.

Cause
Every Pokémon has two separate bit lists that tells the game whether it has been seen or caught. If the bit is off, that means it hasn't been caught or seen.

MissingNo.'s Pokédex seen bit is in the same location as the bit that stores how many of the 6th item is in the Bag, as well as 'M (00)'s. This is why, when MissingNo. or 'M (00) is encountered, the sixth item slot is increased by 128 if the quantity of the item is less than 128. The glitchy box symbol is a result of the game attempting to display a number greater than 99, which causes it to grab sprites from beyond the number sprites. Sometimes it can appear to be a blank tile, but if one goes somewhere else or out of battle it will revert to an unusual tile.

A way to tell whether " 9" is in fact 9 or [blank tile]9 is to select Toss. The quantity is displayed with a leading zero if the amount is actually 9, and as simply " 9" if not.

Performing the glitch
The player must perform the old man glitch to encounter MissingNo. or 'M (00), then defeat, run from, or catch the MissingNo. or 'M (00).

After the battle, the player should open the menu and view the items currently in the Bag. If done correctly, the game should show a glitch character followed by a standard number. This glitch character represents a place value of 10 or above.

If the amount of the item in question is already 128 or more, this glitch will not work.

255 stack duplication glitch
The 255 stack item duplication glitch is a glitch in Generation I that is caused by obtaining 255 of an item, and then tossing an item above it. This creates another stack of 255 items. The only way to obtain a stack of 255 items is via the Pokédex 000 item duplication glitch, making this glitch a subglitch of it.

Performing the glitch
The player must obtain 255 of an item. The only way to do this is via the Pokédex 000 item duplication glitch to obtain over 128 of an item, then using or tossing items until the player has 127, followed by performing the glitch again to increase the total number to 255. As long as there is exactly 255 of an item, tossing an item above it will cause this glitch. It means that the stack of 255 items is copied to the slot above it, as well as its original slot. Tossing an item below the 255 stack causes no glitch. Swapping the places of two items causes no glitch. When there are two or more non-adjacent item piles of quantity ×255, only the ×255 pile closest after the tossed item duplicates.

Using the glitch once will make the last item in the inventory act as the Cancel button, twice will make the second to last item in the inventory act as the Cancel button, and so on. One cannot scroll beyond the Cancel button, even though the scroll arrow is there. Items below the acting Cancel button will be unreachable. The acting Cancel button can be swapped with another item, which will then restore the old item's function and cause the new item to act as the Cancel button.

The above Cancel behavior occurs because the glitch causes the game to think that there are fewer items in the Bag than there actually are, causing it to prevent the player from scrolling past what it thinks is the last item (even though more items below it are visible). This disparity between how many items the game thinks is in the player's Bag and the number of items actually in the Bag can be extended into the item underflow subglitch.

Adding an item to the Bag will erase the item acting as the Cancel button as well as those underneath it (which wouldn't be reachable in any case). A normally functioning Cancel button will be directly below the bought item.

Aside from the Cancel button issue, all items will function normally.

How it works
When an item is tossed, each item below it is copied upward one space, starting with the item directly below the tossed item and going down. However, when the game encounters a pile of quantity ×255 while going down the list, it is copied up, but the items after it are not, leaving two adjacent piles of ×255 of the same item. The game still decreases its count of the total number of inventory items by one (which accounts for the messed up Cancel button).

When the game goes down the list on this copying spree, encountering an FF byte signals to cancel the action for the button and stop copying, even though in this case the FF byte is for item quantity, not item type. Under normal cases, nobody would have ×255 of an item anyway. Under normal cases, since the Cancel button masks anything after it, the game doesn't have to delete the extra Cancel button left behind after copying the cancel button up one space.