ref: fe605b2fa756b7ea18d3f92b95523fa0eb7a2a9e
parent: 97dd40284b885da2dd27099d97d03c221a1cb879
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Thu Dec 28 09:08:29 EST 2017
Document the Magikarp bug fix from PR #443
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -30,7 +30,7 @@
- [Dragon Scale, not Dragon Fang, boosts Dragon-type moves](#dragon-scale-not-dragon-fang-boosts-dragon-type-moves)
- [Daisy's grooming doesn't always increase happiness](#daisys-grooming-doesnt-always-increase-happiness)
- [Magikarp in Lake of Rage are shorter, not longer](#magikarp-in-lake-of-rage-are-shorter-not-longer)
-- [Magikarp lengths in Lake of Rage have a unit conversion error](#magikarp-lengths-in-lake-of-rage-have-a-unit-conversion-error)
+- [Magikarp length limits have a unit conversion error](#magikarp-length-limits-have-a-unit-conversion-error)
- [Magikarp lengths can be miscalculated](#magikarp-lengths-can-be-miscalculated)
- [Battle transitions fail to account for the enemy's level](#battle-transitions-fail-to-account-for-the-enemys-level)
- [Slot machine payout sound effects cut each other off](#slot-machine-payout-sound-effects-cut-each-other-off)
@@ -785,7 +785,7 @@
**Fix:** Change both `jr z, .Happiness` to `jr nz, .Happiness`.
-## Magikarp lengths in Lake of Rage have a unit conversion error
+## Magikarp length limits have a unit conversion error
This is a bug with `LoadEnemyMon.CheckMagikarpArea` in [engine/battle/core.asm](/engine/battle/core.asm):
@@ -795,9 +795,9 @@
ld bc, PlayerID
callfar CalcMagikarpLength
-; We're clear if the length is < 1536
+; No reason to keep going if length > 1536 (i.e. if length / 256 != 6)
ld a, [wMagikarpLength]
- cp HIGH(1536)
+ cp HIGH(1536) ; this compares to 6'0'', should be cp 5
jr nz, .CheckMagikarpArea
; 5% chance of skipping both size checks
@@ -804,9 +804,9 @@
call Random
cp 5 percent
jr c, .CheckMagikarpArea
-; Try again if > 1614
+; Try again if length > 1615
ld a, [wMagikarpLength + 1]
- cp LOW(1616)
+ cp LOW(1616) ; this compares to 6'80'', should be cp 3
jr nc, .GenerateDVs
; 20% chance of skipping this check
@@ -813,13 +813,13 @@
call Random
cp 20 percent - 1
jr c, .CheckMagikarpArea
-; Try again if > 1598
+; Try again if length > 1599
ld a, [wMagikarpLength + 1]
- cp LOW(1600)
+ cp LOW(1600) ; this compares to 6'64'', should be cp 2
jr nc, .GenerateDVs
```
-*To do:* Fix this bug.
+**Fix:** Change the three `cp` instructions to use their commented values.
## Magikarp lengths can be miscalculated
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -157,14 +157,14 @@
cp UNOWN
jr z, .unown
ld a, [CurPartySpecies]
- ld d, BANK(PokemonPicPointers)
ld hl, PokemonPicPointers
+ ld d, BANK(PokemonPicPointers)
jr .ok
.unown
ld a, [UnownLetter]
- ld d, BANK(UnownPicPointers)
ld hl, UnownPicPointers
+ ld d, BANK(UnownPicPointers)
.ok
dec a
@@ -264,6 +264,7 @@
INCBIN "gfx/footprints/charizard.1bpp"
INCBIN "gfx/footprints/squirtle.1bpp"
INCBIN "gfx/footprints/wartortle.1bpp"
+...
```
Modify `Pokedex_LoadAnyFootprint`: