AtlasPreview
Mechanics

The Pomeg Berry glitch (Emerald)

A berry that drops max HP below the HP left: a Pokémon at 0 HP, or at 65,535.

A subtraction with no guard

The Pomeg Berry removes 10 HP EVs. Max HP is then recalculated, and the game applies the same difference to current HP: current HP + (new max HP − old max HP). Nothing checks that the result stays above zero.

A Pokémon with 1 or 2 HP left whose max HP drops by as much or more ends up at 0 HP without having fainted, or at a negative number. HP being stored as 16 unsigned bits, −1 becomes 65,535. The fixed build of the code simply adds: if the result is zero or negative, set 1.

Max HP only drops when the 10 EVs removed cross a multiple of 4 (EVs count in quarters) and the level is high enough: at level 100 the drop is 2 or 3 HP.

Sources : pokeemerald src/pokemon.c : CalculateMonStats (« BUG: currentHP is unintentionally able to become <= 0 […] This causes the pomeg berry glitch »), PokemonUseItemEffects ; include/constants/item_effects.h : ITEM6_SUBTRACT_EV -10 ; src/data/pokemon/item_effects.h : gItemEffect_PomegBerry