If the player performs a task that increments the number of items in a list (purchasing an item from a Poké Mart, depositing it via the PC or withdrawing it via the PC) while they have an existing stack of 99 of that item in the last slot of their inventory (e.g. Ultra Ball x99), the game will try to add to an item quantity of the same item from beyond that slot in an attempt to contain the items in an existing stack without creating a new one.
The end terminator is ignored if it directly follows the 99-quantity stack. This means the game reads past the item list, and start to interpret unrelated memory addresses as item index number and item quantity. If the game finds the same interpreted item index before it finds a 0xFF terminator, it may change the respective quantity byte.
This works even if the existing item stack has less than 99 items, as long as the total quantity of the existing stack and the new stack is greater than 99. In this case, the game will add enough items to make the existing stack x99 and then proceed to trigger the glitch.
Note that any memory address in an "item type" slot (even address for bag, odd address for PC) with value 0xFF will end the search. The new item is put in the correct slot because it's calculated from the number of items, not decided by the 0xFF terminator. As a result, the glitch will not occur if the player has less item slots occupied than previously (e.g., if the player has had 15 item slots filled in his inventory, having less than 15 item slots occupied will prevent the glitch), because in this case the item list will have multiple terminators. Having all 8 badges in the English versions will also prevent most corruptions.
The glitch also doesn't happen if the item list is already full (20 in the case of the bag and 50 for the PC), because in these cases, the game wouldn't even try to move past the first existing stack.
In English versions, when buying Ultra Balls with Ultra Ball x99 in the last slot of the inventory, it is possible to corrupt $D35D (item 32 quantity; controlling the screen palette) if $D35C (item 32; current sound bank value) is 2 (Ultra Ball).
In English versions, one can exploit the Yami Shop glitch to buy Master Balls. If $D364 (Block-X ID) is 1 and there are no Master Ball stacks which aren't ×99 before it, then one can add to $D365 (map exit warp) to access locations up to 0x63 (S.S. Anne Deck). It may be necessary to change the quantity in address $D358 to 99 first.
In Japanese versions, when buying Great Balls with Great Ball x99 in the last slot of the inventory, it is possible to corrupt number of badges ($D2D5) if the options byte ($D2D4) is equal to 3 (Battle Animation On, Battle Style On, medium text speed).
The last example is not possible in the English version of Yellow because there the options byte ($D355) is an odd address, and the array of badges obtained ($D356) is an even address.