Anonymous user
Focus Energy glitch: Difference between revisions
Stadium fact check, code formatting
>Krys3000 No edit summary |
>Bbbbbbbbba (Stadium fact check, code formatting) |
||
Line 7:
In Generation I, due to a bug, Focus Energy will always effectively quarter the player's chances of getting a critical hit.
This glitch was fixed in [[bp:Pokémon Stadium|Pokémon Stadium]], where [[bp:Critical hit#In Pokémon Stadium|a different critical hit rate formula]] is used instead, and Focus Energy
==Analysis==
The relevant block of code for Focus Energy's effect is this, beginning at offset 3E055 in Pokémon Red and Blue (view 0F:6055 in a debugger). Thanks Wack0 for walking through this.
bit 2, a ; test for focus energy
jr nz, .focusEnergyUsed
sla b ; b=b*2
jr nc, .noFocusEnergyUsed ; if b was below 128, skip...
ld b, $ff ; a cap at 255/256
jr .noFocusEnergyUsed
.focusEnergyUsed
srl b ; whoops! b=b/2, and if you look, the jump to here is before the b=b*2, so b is effectively 1/4 of what it should be
.noFocusEnergyUsed ; no cap at 255/256 for focus energy. I wonder if, if done properly, this would have caused bugs related to integer wraparound..
; ... (check for high critical hit move here)
The relative jump to '.focusEnergyUsed' that happens when Focus Energy is used makes the game skip a 'sla b' (double b), and then a 'srl b' (half b) at '.focusEnergyUsed' halves the value in register 'b'.
|