Posted September 21, 2016
Here's an interesting one:
In the Game Boy Pokemon games, the division routine could handle only 8-bit divisions, but the damage formula has an Attack/Defense term in it, which could be a problem if either value would exceed 255.
Well, they did have a solution; if either value is > 255, the game divides both values by 4 (a simple bit shift operation) before actually doing the division. This allowed the game to function, though it did cause loss of precision. This, in turn, resulted in strange results if the defender has less than 4 defense:
In Gold/Silver/Crystal, 1 is used in place of defense. This has the strange behavior that the Pokemon will take *less* damage from an attacker with 256 Attack than from one with 255 Attack. (It would normally round down, but there is a reason the developers made a special case here.)
In Red/Green/Blue/Yellow, defense gets rounded down to 0. This is, of course, a very bad thing, as the game now tries to divide by 0. The result is a softlock, as the division never completes.
In the Game Boy Pokemon games, the division routine could handle only 8-bit divisions, but the damage formula has an Attack/Defense term in it, which could be a problem if either value would exceed 255.
Well, they did have a solution; if either value is > 255, the game divides both values by 4 (a simple bit shift operation) before actually doing the division. This allowed the game to function, though it did cause loss of precision. This, in turn, resulted in strange results if the defender has less than 4 defense:
In Gold/Silver/Crystal, 1 is used in place of defense. This has the strange behavior that the Pokemon will take *less* damage from an attacker with 256 Attack than from one with 255 Attack. (It would normally round down, but there is a reason the developers made a special case here.)
In Red/Green/Blue/Yellow, defense gets rounded down to 0. This is, of course, a very bad thing, as the game now tries to divide by 0. The result is a softlock, as the division never completes.