BadgeStatBoosts runs where the original calls it: when a Pokémon is sent out, after an in-battle level-up, and in CalcPlayerStats. It keeps the PlainBadge/MineralBadge swap and the Glacier Badge's Special Defense register bug. A transformed Pokémon that levels up now keeps its copied stats.
The reference emulator compares all 256 badge bytes over 28 stat sets per browser against the unmodified routine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>