66 KiB
Bugs and Glitches
These are known bugs and glitches in the original Pokémon Crystal game: code that clearly does not work as intended, or that only works in limited circumstances but has the possibility to fail or crash.
Fixes are written in the diff
format. If you've used Git before, this should look familiar:
this is some code
-delete red - lines
+add green + lines
Fixes in the multi-player battle engine category will break compatibility with standard Pokémon Gold/Silver/Crystal for link battles, unless otherwise noted. This can be avoided by writing more complicated fixes that only apply if the value at [wLinkMode]
is not LINK_COLOSSEUM
. That's how Crystal itself fixed two bugs in Gold and Silver regarding the moves Reflect and Light Screen and Present.
Contents
- Multi-player battle engine
- Perish Song and Spikes can leave a Pokémon with 0 HP and not faint
- Thick Club and Light Ball can make (Special) Attack wrap around above 1024
- Metal Powder can increase damage taken with boosted (Special) Defense
- Reflect and Light Screen can make (Special) Defense wrap around above 1024
- Moves with a 100% secondary effect chance will not trigger it in 1/256 uses
- Belly Drum sharply boosts Attack even with under 50% HP
- Berserk Gene's confusion lasts for 256 turns or the previous Pokémon's confusion count
- Confusion damage is affected by type-boosting items and Explosion/Self-Destruct doubling
- Moves that lower Defense can do so after breaking a Substitute
- Counter and Mirror Coat still work if the opponent uses an item
- A Disabled but PP Up–enhanced move may not trigger Struggle
- A Pokémon that fainted from Pursuit will have its old status condition when revived
- Lock-On and Mind Reader don't always bypass Fly and Dig
- Beat Up can desynchronize link battles
- Beat Up works incorrectly with only one Pokémon in the party
- Beat Up may fail to raise Substitute
- Beat Up may trigger King's Rock even if it failed
- Present damage is incorrect in link battles
- Dragon Scale, not Dragon Fang, boosts Dragon-type moves
- HP bar animation is slow for high HP
- HP bar animation off-by-one error for low HP
- Moves that do damage and increase your stats do not increase stats after a KO
- Single-player battle engine
- A Transformed Pokémon can use Sketch and learn otherwise unobtainable moves
- Catching a Transformed Pokémon always catches a Ditto
- Experience underflow for level 1 Pokémon with Medium-Slow growth rate
- The Dude's catching tutorial may crash if his Poké Ball can't be used
- BRN/PSN/PAR do not affect catch rate
- Moon Ball does not boost catch rate
- Love Ball boosts catch rate for the wrong gender
- Fast Ball only boosts catch rate for three Pokémon
- Heavy Ball uses wrong weight value for three Pokémon
- Glacier Badge may not boost Special Defense depending on the value of Special Attack
- "Smart" AI encourages Mean Look if its own Pokémon is badly poisoned
- "Smart" AI discourages Conversion2 after the first turn
- AI does not discourage Future Sight when it's already been used
- AI makes a false assumption about
CheckTypeMatchup
- AI use of Full Heal or Full Restore does not cure Nightmare status
- AI use of Full Heal does not cure confusion status
- Wild Pokémon can always Teleport regardless of level difference
HELD_CATCH_CHANCE
has no effect- Credits sequence changes move selection menu behavior
- Overworld engine
- Graphics
- Audio
- Text
- Scripted events
- Clair can give TM24 Dragonbreath twice
- Daisy's grooming doesn't always increase happiness
- Magikarp in Lake of Rage are shorter, not longer
- Magikarp length limits have a unit conversion error
- Magikarp lengths can be miscalculated
CheckOwnMon
only checks the first five letters of OT namesCheckOwnMonAnywhere
does not check the Day-Care- The unused
phonecall
script command may crash
- Internal engine routines
- Saves corrupted by mid-save shutoff are not handled
ScriptCall
can overflowwScriptStack
and crashLoadSpriteGFX
does not limit the capacity ofUsedSprites
ChooseWildEncounter
doesn't really validate the wild Pokémon speciesTryObjectEvent
arbitrary code executionReadObjectEvents
overflows intowObjectMasks
ClearWRAM
only clears WRAM bank 1BattleAnimCmd_ClearObjs
only clears the first 6⅔ objects
Multi-player battle engine
Perish Song and Spikes can leave a Pokémon with 0 HP and not faint
(Video)
Fix: Edit CheckFaint_PlayerThenEnemy
and CheckFaint_EnemyThenPlayer
in engine/battle/core.asm:
jp HandleEncore
+HasAnyoneFainted:
+ call HasPlayerFainted
+ jp nz, HasEnemyFainted
+ ret
+
CheckFaint_PlayerThenEnemy:
+.faint_loop
+ call .Function
+ ret c
+ call HasAnyoneFainted
+ ret nz
+ jr .faint_loop
+
+.Function:
call HasPlayerFainted
jr nz, .PlayerNotFainted
call HandlePlayerMonFaint
...
CheckFaint_EnemyThenPlayer:
+.faint_loop
+ call .Function
+ ret c
+ call HasAnyoneFainted
+ ret nz
+ jr .faint_loop
+
+.Function:
call HasEnemyFainted
jr nz, .EnemyNotFainted
call HandleEnemyMonFaint
...
Thick Club and Light Ball can make (Special) Attack wrap around above 1024
(Video)
Fix: Edit SpeciesItemBoost
in engine/battle/effect_commands.asm
; Double the stat
sla l
rl h
+
+ ld a, HIGH(MAX_STAT_VALUE)
+ cp h
+ jr c, .cap
+ ret nz
+ ld a, LOW(MAX_STAT_VALUE)
+ cp l
+ ret nc
+
+.cap
+ ld hl, MAX_STAT_VALUE
ret
Metal Powder can increase damage taken with boosted (Special) Defense
(Video)
Fix: Edit DittoMetalPowder
in engine/battle/effect_commands.asm:
ld a, c
srl a
add c
ld c, a
ret nc
srl b
ld a, b
and a
jr nz, .done
inc b
.done
scf
rr c
+
+ ld a, HIGH(MAX_STAT_VALUE)
+ cp b
+ jr c, .cap
+ ret nz
+ ld a, LOW(MAX_STAT_VALUE)
+ cp c
+ ret nc
+
+.cap
+ ld bc, MAX_STAT_VALUE
ret
Reflect and Light Screen can make (Special) Defense wrap around above 1024
This bug existed for all battles in Gold and Silver, and was only fixed for single-player battles in Crystal to preserve link compatibility.
Fix: Edit TruncateHL_BC
in engine/battle/effect_commands.asm
.finish
- ld a, [wLinkMode]
- cp LINK_COLOSSEUM
- jr z, .done
; If we go back to the loop point,
; it's the same as doing this exact
; same check twice.
ld a, h
or b
jr nz, .loop
-.done
ld b, l
ret
(This fix also affects Thick Club, Light Ball, and Metal Powder, as described above, but their specific fixes in the above bugs allow more accurate damage calculations.)
Moves with a 100% secondary effect chance will not trigger it in 1/256 uses
(Video)
Fix: Edit BattleCommand_EffectChance
in engine/battle/effect_commands.asm:
- ; BUG: 1/256 chance to fail even for a 100% effect chance,
- ; since carry is not set if BattleRandom == [hl] == 255
- call BattleRandom
+ ld a, [hl]
+ sub 100 percent
+ ; If chance was 100%, RNG won't be called (carry not set)
+ ; Thus chance will be subtracted from 0, guaranteeing a carry
+ call c, BattleRandom
cp [hl]
pop hl
ret c
.failed
ld a, 1
ld [wEffectFailed], a
and a
ret
Compatibility preservation: If you wish to keep compatibility with standard Pokémon Crystal, you can disable the fix during link battles by also applying the following edit in the same place:
+ ld a, [wLinkMode]
+ cp LINK_COLOSSEUM
+ scf ; Force RNG to be called
+ jr z, .nofix ; Don't apply fix in link battles, for compatibility
ld a, [hl]
sub 100 percent
; If chance was 100%, RNG won't be called (carry not set)
; Thus chance will be subtracted from 0, guaranteeing a carry
+.nofix
call c, BattleRandom
Belly Drum sharply boosts Attack even with under 50% HP
(Video)
Fix: Edit BattleCommand_BellyDrum
in engine/battle/move_effects/belly_drum.asm:
BattleCommand_BellyDrum:
; bellydrum
-; This command is buggy because it raises the user's attack
-; before checking that it has enough HP to use the move.
-; Swap the order of these two blocks to fix.
- call BattleCommand_AttackUp2
- ld a, [wAttackMissed]
- and a
- jr nz, .failed
-
callfar GetHalfMaxHP
callfar CheckUserHasEnoughHP
jr nc, .failed
+
+ push bc
+ call BattleCommand_AttackUp2
+ pop bc
+ ld a, [wAttackMissed]
+ and a
+ jr nz, .failed
Berserk Gene's confusion lasts for 256 turns or the previous Pokémon's confusion count
(Video)
Fix: Edit HandleBerserkGene
in engine/battle/core.asm:
HandleBerserkGene:
...
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr
push af
set SUBSTATUS_CONFUSED, [hl]
+ ldh a, [hBattleTurn]
+ and a
+ ld hl, wEnemyConfuseCount
+ jr z, .set_confuse_count
+ ld hl, wPlayerConfuseCount
+.set_confuse_count
+ call BattleRandom
+ and %11
+ add 2
+ ld [hl], a
ld a, BATTLE_VARS_MOVE_ANIM
call GetBattleVarAddr
...
This makes the Berserk Gene use the regular confusion duration (2–5 turns).
Confusion damage is affected by type-boosting items and Explosion/Self-Destruct doubling
(Video)
Fix:
First, edit wram.asm:
wTurnEnded:: db
- ds 1
+wIsConfusionDamage:: db
wPlayerStats::
Then edit four routines in engine/battle/effect_commands.asm:
HitSelfInConfusion:
...
call TruncateHL_BC
ld d, 40
pop af
ld e, a
+ ld a, TRUE
+ ld [wIsConfusionDamage], a
ret
BattleCommand_DamageCalc:
; damagecalc
...
.skip_zero_damage_check
+ xor a ; Not confusion damage
+ ld [wIsConfusionDamage], a
+ ; fallthrough
+
+ConfusionDamageCalc:
; Minimum defense value is 1.
ld a, c
and a
jr nz, .not_dividing_by_zero
ld c, 1
.not_dividing_by_zero
...
; Item boosts
+
+; Item boosts don't apply to confusion damage
+ ld a, [wIsConfusionDamage]
+ and a
+ jr nz, .DoneItem
+
call GetUserItem
...
CheckEnemyTurn:
...
ld hl, HurtItselfText
call StdBattleTextbox
call HitSelfInConfusion
- call BattleCommand_DamageCalc
+ call ConfusionDamageCalc
call BattleCommand_LowerSub
...
HitConfusion:
ld hl, HurtItselfText
call StdBattleTextbox
xor a
ld [wCriticalHit], a
call HitSelfInConfusion
- call BattleCommand_DamageCalc
+ call ConfusionDamageCalc
call BattleCommand_LowerSub
Moves that lower Defense can do so after breaking a Substitute
(Video)
This bug affects Acid, Iron Tail, and Rock Smash.
Fix: Edit DefenseDownHit
in data/moves/effects.asm:
DefenseDownHit:
checkobedience
usedmovetext
doturn
critical
damagestats
damagecalc
stab
damagevariation
checkhit
effectchance
hittarget
failuretext
checkfaint
criticaltext
supereffectivetext
checkfaint
buildopponentrage
- effectchance ; bug: duplicate effectchance shouldn't be here
defensedown
statdownmessage
endmove
Counter and Mirror Coat still work if the opponent uses an item
(Video)
Fix: Edit BattleCommand_Counter
in engine/battle/move_effects/counter.asm and BattleCommand_MirrorCoat
in engine/battle/move_effects/mirror_coat.asm:
- ; BUG: Move should fail with all non-damaging battle actions
ld hl, wCurDamage
ld a, [hli]
or [hl]
- ret z
+ jr z, .failed
Add this to the end of each file:
+.failed
+ ld a, 1
+ ld [wEffectFailed], a
+ and a
+ ret
A Disabled but PP Up–enhanced move may not trigger Struggle
(Video)
Fix: Edit CheckPlayerHasUsableMoves
in engine/battle/core.asm:
.done
- ; Bug: this will result in a move with PP Up confusing the game.
- and a ; should be "and PP_MASK"
+ and PP_MASK
ret nz
.force_struggle
ld hl, BattleText_MonHasNoMovesLeft
call StdBattleTextbox
ld c, 60
call DelayFrames
xor a
ret
A Pokémon that fainted from Pursuit will have its old status condition when revived
(Video)
Fix: Edit PursuitSwitch
in engine/battle/core.asm
ld a, $f0
ld [wCryTracks], a
ld a, [wBattleMonSpecies]
call PlayStereoCry
+ ld a, [wCurBattleMon]
+ push af
ld a, [wLastPlayerMon]
+ ld [wCurBattleMon], a
+ call UpdateFaintedPlayerMon
+ pop af
+ ld [wCurBattleMon], a
- ld c, a
- ld hl, wBattleParticipantsNotFainted
- ld b, RESET_FLAG
- predef SmallFarFlagAction
call PlayerMonFaintedAnimation
ld hl, BattleText_MonFainted
jr .done_fainted
Lock-On and Mind Reader don't always bypass Fly and Dig
This bug affects Attract, Curse, Foresight, Mean Look, Mimic, Nightmare, Spider Web, Transform, and stat-lowering effects of moves like String Shot or Bubble during the semi-invulnerable turn of Fly or Dig.
Fix: Edit CheckHiddenOpponent
in engine/battle/effect_commands.asm:
CheckHiddenOpponent:
-; BUG: This routine is completely redundant and introduces a bug, since BattleCommand_CheckHit does these checks properly.
- ld a, BATTLE_VARS_SUBSTATUS3_OPP
- call GetBattleVar
- and 1 << SUBSTATUS_FLYING | 1 << SUBSTATUS_UNDERGROUND
+ xor a
ret
Beat Up can desynchronize link battles
(Video)
Fix: Edit BattleCommand_BeatUp
in engine/battle/move_effects/beat_up.asm:
.got_mon
ld a, [wCurBeatUpPartyMon]
ld hl, wPartyMonNicknames
call GetNickname
ld a, MON_HP
call GetBeatupMonLocation
ld a, [hli]
or [hl]
jp z, .beatup_fail ; fainted
ld a, [wCurBeatUpPartyMon]
ld c, a
ld a, [wCurBattleMon]
- ; BUG: this can desynchronize link battles
- ; Change "cp [hl]" to "cp c" to fix
- cp [hl]
+ cp c
ld hl, wBattleMonStatus
jr z, .active_mon
ld a, MON_STATUS
call GetBeatupMonLocation
.active_mon
ld a, [hl]
and a
jp nz, .beatup_fail
Beat Up works incorrectly with only one Pokémon in the party
This bug prevents the rest of Beat Up's effect from being executed if the player or enemy only has one Pokémon in their party while using it. It prevents Substitute from being raised and King's Rock from working.
Fix: Edit BattleCommand_EndLoop
in engine/battle/effect_commands.asm:
.only_one_beatup
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr
res SUBSTATUS_IN_LOOP, [hl]
- call BattleCommand_BeatUpFailText
- jp EndMoveEffect
+ ret
Cosmetic fix: This fix does not break compatibility, but it only affects what's shown on the screen for the patched game.
.only_one_beatup
ld a, BATTLE_VARS_SUBSTATUS3
call GetBattleVarAddr
res SUBSTATUS_IN_LOOP, [hl]
call BattleCommand_BeatUpFailText
+ call BattleCommand_RaiseSub
jp EndMoveEffect
Beat Up may fail to raise Substitute
Fixing this cosmetic bug will not break link battle compatibility.
This bug prevents Substitute from being raised if Beat Up was blocked by Protect or Detect.
Fix: Edit BattleCommand_FailureText
in engine/battle/effect_commands.asm.
cp EFFECT_MULTI_HIT
jr z, .multihit
cp EFFECT_DOUBLE_HIT
jr z, .multihit
cp EFFECT_POISON_MULTI_HIT
jr z, .multihit
+ cp EFFECT_BEAT_UP
+ jr z, .multihit
jp EndMoveEffect
.multihit
call BattleCommand_RaiseSub
jp EndMoveEffect
Beat Up may trigger King's Rock even if it failed
This bug is caused because Beat Up never sets wAttackMissed
, even when no Pokémon was able to attack (due to being fainted or having a status condition).
Fix: Edit BattleCommand_BeatUpFailText
in engine/battle/move_effects/beat_up.asm:
BattleCommand_BeatUpFailText:
; beatupfailtext
ld a, [wBeatUpHitAtLeastOnce]
and a
ret nz
+
+ inc a
+ ld [wAttackMissed], a
jp PrintButItFailed
Present damage is incorrect in link battles
(Video)
This bug existed for all battles in Gold and Silver, and was only fixed for single-player battles in Crystal to preserve link compatibility.
Fix: Edit BattleCommand_Present
in engine/battle/move_effects/present.asm:
BattleCommand_Present:
; present
- ld a, [wLinkMode]
- cp LINK_COLOSSEUM
- jr z, .colosseum_skippush
push bc
push de
-.colosseum_skippush
-
call BattleCommand_Stab
-
- ld a, [wLinkMode]
- cp LINK_COLOSSEUM
- jr z, .colosseum_skippop
pop de
pop bc
-.colosseum_skippop
Dragon Scale, not Dragon Fang, boosts Dragon-type moves
Fix: Edit ItemAttributes
in data/items/attributes.asm:
; DRAGON_FANG
- item_attribute 100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
+ item_attribute 100, HELD_DRAGON_BOOST, 10, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
...
; DRAGON_SCALE
- item_attribute 2100, HELD_DRAGON_BOOST, 10, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
+ item_attribute 2100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE
HP bar animation is slow for high HP
Fixing this cosmetic bug will not break link battle compatibility.
(Video)
Fix: Edit LongAnim_UpdateVariables
in engine/battle/anim_hp_bar.asm:
- ; This routine is buggy. The result from ComputeHPBarPixels is stored
- ; in e. However, the pop de opcode deletes this result before it is even
- ; used. The game then proceeds as though it never deleted that output.
- ; To fix, uncomment the line below.
call ComputeHPBarPixels
- ; ld a, e
+ ld a, e
pop bc
pop de
pop hl
- ld a, e ; Comment or delete this line to fix the above bug.
ld hl, wCurHPBarPixels
cp [hl]
jr z, .loop
ld [hl], a
and a
ret
HP bar animation off-by-one error for low HP
Fixing this cosmetic bug will not break link battle compatibility.
(Video)
Fix: Edit ShortHPBar_CalcPixelFrame
in engine/battle/anim_hp_bar.asm:
ld b, 0
-; This routine is buggy. If [wCurHPAnimMaxHP] * [wCurHPBarPixels] is
-; divisible by HP_BAR_LENGTH_PX, the loop runs one extra time.
-; To fix, uncomment the line below.
.loop
ld a, l
sub HP_BAR_LENGTH_PX
ld l, a
ld a, h
sbc $0
ld h, a
- ; jr z, .done
+ jr z, .done
jr c, .done
inc b
jr .loop
Moves that do damage and increase your stats do not increase stats after a KO
BattleCommand_CheckFaint
"ends the move effect if the opponent faints", and these moves attempt to raise the user's stats after checkfaint
. Note that fixing this can lead to stats being increased at the end of battle, but will not have any negative effects.
Fix: Edit data/moves/effects.asm:
DefenseUpHit:
...
criticaltext
supereffectivetext
+ defenseup
+ statupmessage
checkfaint
buildopponentrage
- defenseup
- statupmessage
endmove
AttackUpHit:
...
criticaltext
supereffectivetext
+ attackup
+ statupmessage
checkfaint
buildopponentrage
- attackup
- statupmessage
endmove
AllUpHit:
...
criticaltext
supereffectivetext
+ allstatsup
checkfaint
buildopponentrage
- allstatsup
endmove
Single-player battle engine
A Transformed Pokémon can use Sketch and learn otherwise unobtainable moves
(Video)
Fix: Edit BattleCommand_Sketch
in engine/battle/move_effects/sketch.asm:
-; If the opponent is transformed, fail.
+; If the user is transformed, fail.
- ld a, BATTLE_VARS_SUBSTATUS5_OPP
+ ld a, BATTLE_VARS_SUBSTATUS5
call GetBattleVarAddr
bit SUBSTATUS_TRANSFORMED, [hl]
jp nz, .fail
Catching a Transformed Pokémon always catches a Ditto
This bug can affect Mew or Pokémon other than Ditto that used Transform via Mirror Move or Sketch.
Fix: Edit PokeBallEffect
in engine/items/item_effects.asm:
ld hl, wEnemySubStatus5
ld a, [hl]
push af
set SUBSTATUS_TRANSFORMED, [hl]
-; This code is buggy. Any wild Pokémon that has Transformed will be
-; caught as a Ditto, even if it was something else like Mew.
-; To fix, do not set [wTempEnemyMonSpecies] to DITTO.
bit SUBSTATUS_TRANSFORMED, a
- jr nz, .ditto
- jr .not_ditto
+ jr nz, .load_data
-.ditto
- ld a, DITTO
- ld [wTempEnemyMonSpecies], a
- jr .load_data
-
-.not_ditto
- set SUBSTATUS_TRANSFORMED, [hl]
ld hl, wEnemyBackupDVs
ld a, [wEnemyMonDVs]
ld [hli], a
ld a, [wEnemyMonDVs + 1]
ld [hl], a
.load_data
ld a, [wTempEnemyMonSpecies]
ld [wCurPartySpecies], a
ld a, [wEnemyMonLevel]
ld [wCurPartyLevel], a
farcall LoadEnemyMon
pop af
ld [wEnemySubStatus5], a
Experience underflow for level 1 Pokémon with Medium-Slow growth rate
(Video)
This can bring Pokémon straight from level 1 to 100 by gaining just a few experience points.
Fix: Edit CalcExpAtLevel
in engine/pokemon/experience.asm:
CalcExpAtLevel:
; (a/b)*n**3 + c*n**2 + d*n - e
+ ld a, d
+ dec a
+ jr nz, .UseExpFormula
+; Pokémon have 0 experience at level 1
+ ld hl, hProduct
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ret
+
+.UseExpFormula
ld a, [wBaseGrowthRate]
add a
add a
ld c, a
ld b, 0
ld hl, GrowthRates
add hl, bc
The Dude's catching tutorial may crash if his Poké Ball can't be used
(Video)
This can occur if your party and current PC box are both full when you start the tutorial.
Fix: Edit PokeBallEffect
in engine/items/item_effects.asm:
ld a, [wBattleMode]
dec a
jp nz, UseBallInTrainerBattle
+ ld a, [wBattleType]
+ cp BATTLETYPE_TUTORIAL
+ jr z, .room_in_party
+
ld a, [wPartyCount]
cp PARTY_LENGTH
jr nz, .room_in_party
ld a, BANK(sBoxCount)
call OpenSRAM
ld a, [sBoxCount]
cp MONS_PER_BOX
call CloseSRAM
jp z, Ball_BoxIsFullMessage
BRN/PSN/PAR do not affect catch rate
Fix: Edit PokeBallEffect
in engine/items/item_effects.asm:
-; This routine is buggy. It was intended that SLP and FRZ provide a higher
-; catch rate than BRN/PSN/PAR, which in turn provide a higher catch rate than
-; no status effect at all. But instead, it makes BRN/PSN/PAR provide no
-; benefit.
-; Uncomment the line below to fix this.
ld b, a
ld a, [wEnemyMonStatus]
and 1 << FRZ | SLP
ld c, 10
jr nz, .addstatus
- ; ld a, [wEnemyMonStatus]
+ ld a, [wEnemyMonStatus]
and a
ld c, 5
jr nz, .addstatus
ld c, 0
.addstatus
ld a, b
add c
jr nc, .max_1
ld a, $ff
.max_1
Moon Ball does not boost catch rate
Fix: Edit MoonBallMultiplier
in engine/items/item_effects.asm:
-; Moon Stone's constant from Pokémon Red is used.
-; No Pokémon evolve with Burn Heal,
-; so Moon Balls always have a catch rate of 1×.
push bc
ld a, BANK("Evolutions and Attacks")
call GetFarByte
- cp MOON_STONE_RED ; BURN_HEAL
+ cp MOON_STONE
pop bc
ret nz
Love Ball boosts catch rate for the wrong gender
Fix: Edit LoveBallMultiplier
in engine/items/item_effects.asm:
.wildmale
ld a, d
pop de
cp d
pop bc
- ret nz ; for the intended effect, this should be "ret z"
+ ret z
Fast Ball only boosts catch rate for three Pokémon
Fix: Edit FastBallMultiplier
in engine/items/item_effects.asm:
.loop
ld a, BANK(FleeMons)
call GetFarByte
inc hl
cp -1
jr z, .next
cp c
- jr nz, .next ; for the intended effect, this should be "jr nz, .loop"
+ jr nz, .loop
sla b
jr c, .max
Heavy Ball uses wrong weight value for three Pokémon
Fix: Edit GetPokedexEntryBank
in engine/items/item_effects.asm:
GetPokedexEntryBank:
-; This function is buggy.
-; It gets the wrong bank for Kadabra (64), Tauros (128), and Sunflora (192).
-; Uncomment the line below to fix this.
push hl
push de
ld a, [wEnemyMonSpecies]
- ; dec a
+ dec a
rlca
rlca
maskbits NUM_DEX_ENTRY_BANKS
ld hl, .PokedexEntryBanks
ld d, 0
ld e, a
add hl, de
ld a, [hl]
pop de
pop hl
ret
.PokedexEntryBanks:
db BANK("Pokedex Entries 001-064")
db BANK("Pokedex Entries 065-128")
db BANK("Pokedex Entries 129-192")
db BANK("Pokedex Entries 193-251")
Glacier Badge may not boost Special Defense depending on the value of Special Attack
As Pryce's dialog ("That BADGE will raise the SPECIAL stats of POKéMON.") implies, Glacier Badge is intended to boost both Special Attack and Special Defense. However, due to BoostStat overwriting a
when boosting Special Attack, the Special Defense boost will not happen if the unboosted Special Attack stat is either 0–205 or 433–660.
Fix: Edit BadgeStatBoosts.CheckBadge
in engine/battle/core.asm:
.CheckBadge:
ld a, b
srl b
+ push af
call c, BoostStat
+ pop af
inc hl
inc hl
; Check every other badge.
srl b
dec c
jr nz, .CheckBadge
; Check GlacierBadge again for Special Defense.
-; This check is buggy because it assumes that a is set by the "ld a, b" in the above loop,
-; but it can actually be overwritten by the call to BoostStat.
srl a
call c, BoostStat
ret
"Smart" AI encourages Mean Look if its own Pokémon is badly poisoned
(Video)
Fix: Edit AI_Smart_MeanLook
in engine/battle/ai/scoring.asm:
-; 80% chance to greatly encourage this move if the enemy is badly poisoned (buggy).
-; Should check wPlayerSubStatus5 instead.
- ld a, [wEnemySubStatus5]
+; 80% chance to greatly encourage this move if the player is badly poisoned
+ ld a, [wPlayerSubStatus5]
bit SUBSTATUS_TOXIC, a
jr nz, .asm_38e26
"Smart" AI discourages Conversion2 after the first turn
Fix: Edit AI_Smart_Conversion2
in engine/battle/ai/scoring.asm:
AI_Smart_Conversion2:
ld a, [wLastPlayerMove]
and a
- jr nz, .discourage ; should be jr z
+ jr z, .discourage
AI does not discourage Future Sight when it's already been used
Fix: Edit AI_Redundant
in engine/battle/ai/redundant.asm:
.FutureSight:
- ld a, [wEnemyScreens]
- bit 5, a
+ ld a, [wEnemyFutureSightCount]
+ and a
ret
AI makes a false assumption about CheckTypeMatchup
Fix: Edit BattleCheckTypeMatchup
in engine/battle/effect_commands.asm:
BattleCheckTypeMatchup:
ld hl, wEnemyMonType1
ldh a, [hBattleTurn]
and a
- jr z, CheckTypeMatchup
+ jr z, .get_type
ld hl, wBattleMonType1
+.get_type
+ ld a, BATTLE_VARS_MOVE_TYPE
+ call GetBattleVar ; preserves hl, de, and bc
CheckTypeMatchup:
-; There is an incorrect assumption about this function made in the AI related code: when
-; the AI calls CheckTypeMatchup (not BattleCheckTypeMatchup), it assumes that placing the
-; offensive type in a will make this function do the right thing. Since a is overwritten,
-; this assumption is incorrect. A simple fix would be to load the move type for the
-; current move into a in BattleCheckTypeMatchup, before falling through, which is
-; consistent with how the rest of the code assumes this code works like.
push hl
push de
push bc
- ld a, BATTLE_VARS_MOVE_TYPE
- call GetBattleVar
ld d, a
...
AI use of Full Heal or Full Restore does not cure Nightmare status
(Video)
Fix: Edit AI_HealStatus
in engine/battle/ai/items.asm:
AI_HealStatus:
ld a, [wCurOTMon]
ld hl, wOTPartyMon1Status
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
xor a
ld [hl], a
ld [wEnemyMonStatus], a
- ; Bug: this should reset SUBSTATUS_NIGHTMARE
- ; Uncomment the 2 lines below to fix
- ; ld hl, wEnemySubStatus1
- ; res SUBSTATUS_NIGHTMARE, [hl]
+ ld hl, wEnemySubStatus1
+ res SUBSTATUS_NIGHTMARE, [hl]
; Bug: this should reset SUBSTATUS_CONFUSED
; Uncomment the 2 lines below to fix
; ld hl, wEnemySubStatus3
; res SUBSTATUS_CONFUSED, [hl]
ld hl, wEnemySubStatus5
res SUBSTATUS_TOXIC, [hl]
ret
AI use of Full Heal does not cure confusion status
Fix: Edit EnemyUsedFullRestore
, EnemyUsedFullHeal
, and AI_HealStatus
in engine/battle/ai/items.asm:
EnemyUsedFullRestore:
call AI_HealStatus
ld a, FULL_RESTORE
ld [wCurEnemyItem], a
- ld hl, wEnemySubStatus3
- res SUBSTATUS_CONFUSED, [hl]
xor a
ld [wEnemyConfuseCount], a
EnemyUsedFullHeal:
call AIUsedItemSound
call AI_HealStatus
ld a, FULL_HEAL
+ ld [wCurEnemyItem], a
+ xor a
+ ld [wEnemyConfuseCount], a
jp PrintText_UsedItemOn_AND_AIUpdateHUD
AI_HealStatus:
ld a, [wCurOTMon]
ld hl, wOTPartyMon1Status
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
xor a
ld [hl], a
ld [wEnemyMonStatus], a
; Bug: this should reset SUBSTATUS_NIGHTMARE
; Uncomment the 2 lines below to fix
; ld hl, wEnemySubStatus1
; res SUBSTATUS_NIGHTMARE, [hl]
- ; Bug: this should reset SUBSTATUS_CONFUSED
- ; Uncomment the 2 lines below to fix
- ; ld hl, wEnemySubStatus3
- ; res SUBSTATUS_CONFUSED, [hl]
+ ld hl, wEnemySubStatus3
+ res SUBSTATUS_CONFUSED, [hl]
ld hl, wEnemySubStatus5
res SUBSTATUS_TOXIC, [hl]
ret
Wild Pokémon can always Teleport regardless of level difference
Fix: Edit BattleCommand_Teleport
in engine/battle/move_effects/teleport.asm:
.loop_enemy
call BattleRandom
cp c
jr nc, .loop_enemy
srl b
srl b
cp b
- ; This should be jr c, .failed
- ; As written, it makes enemy use of Teleport always succeed if able
- jr nc, .run_away
+ jr c, .failed
HELD_CATCH_CHANCE
has no effect
Fix: Edit PokeBallEffect
in engine/items/item_effects.asm:
- ; BUG: farcall overwrites a, and GetItemHeldEffect takes b anyway.
- ; This is probably the reason the HELD_CATCH_CHANCE effect is never used.
- ; Uncomment the line below to fix.
ld d, a
push de
ld a, [wBattleMonItem]
- ; ld b, a
+ ld b, a
farcall GetItemHeldEffect
ld a, b
cp HELD_CATCH_CHANCE
pop de
ld a, d
jr nz, .max_2
add c
jr nc, .max_2
ld a, $ff
.max_2
Credits sequence changes move selection menu behavior
(Video)
To select a move in battle, you have to press and release the Up or Down buttons. However, after playing the credits sequence, holding down either button will continuously scroll through the moves.
Fix: Edit Credits
in engine/movie/credits.asm:
ldh a, [hVBlank]
push af
ld a, $5
ldh [hVBlank], a
+ ldh a, [hInMenu]
+ push af
ld a, $1
ldh [hInMenu], a
...
ldh [hLCDCPointer], a
ldh [hBGMapAddress], a
+ pop af
+ ldh [hInMenu], a
pop af
ldh [hVBlank], a
pop af
ldh [rSVBK], a
The [hInMenu]
value determines this button behavior. However, the battle moves menu doesn't actually set [hInMenu]
to anything, so either behavior may have been intentional. The default 0 prevents continuous scrolling; a value of 1 allows it. (The Japanese release sets it to 0.)
Optional fix: To explicitly set a [hInMenu]
for the moves menu, edit BattleTurn
in engine/battle/core.asm:
BattleTurn:
+ ldh a, [hInMenu]
+ push af
+ ld a, 1 ; or "xor a" for the value 0
+ ldh [hInMenu], a
+
.loop
...
jp .loop
.quit
+ pop af
+ ldh [hInMenu], a
ret
Overworld engine
LoadMetatiles
wraps around past 128 blocks
This bug prevents you from using blocksets with more than 128 blocks.
Fix: Edit LoadMetatiles
in home/map.asm:
; Set hl to the address of the current metatile data ([wTilesetBlocksAddress] + (a) tiles).
- ; This is buggy; it wraps around past 128 blocks.
- ; To fix, uncomment the line below.
- add a ; Comment or delete this line to fix the above bug.
ld l, a
ld h, 0
- ; add hl, hl
+ add hl, hl
add hl, hl
add hl, hl
add hl, hl
ld a, [wTilesetBlocksAddress]
add l
ld l, a
ld a, [wTilesetBlocksAddress + 1]
adc h
ld h, a
Surfing directly across a map connection does not load the new map
(Video)
Fix:
First, edit UsedSurfScript
in engine/events/overworld.asm:
UsedSurfScript:
writetext UsedSurfText ; "used SURF!"
waitbutton
closetext
callasm .empty_fn ; empty function
readmem wSurfingPlayerState
writevar VAR_MOVEMENT
special UpdatePlayerSprite
special PlayMapMusic
-; step into the water (slow_step DIR, step_end)
special SurfStartStep
- applymovement PLAYER, wMovementBuffer
end
Then edit SurfStartStep
in engine/overworld/player_object.asm:
SurfStartStep:
- call InitMovementBuffer
- call .GetMovementData
- call AppendToMovementBuffer
- ld a, movement_step_end
- call AppendToMovementBuffer
- ret
-
-.GetMovementData:
ld a, [wPlayerDirection]
srl a
srl a
maskbits NUM_DIRECTIONS
ld e, a
ld d, 0
ld hl, .movement_data
add hl, de
- ld a, [hl]
- ret
+ add hl, de
+ add hl, de
+ ld a, BANK(.movement_data)
+ jp StartAutoInput
.movement_data
- slow_step DOWN
- slow_step UP
- slow_step LEFT
- slow_step RIGHT
+ db D_DOWN, 0, -1
+ db D_UP, 0, -1
+ db D_LEFT, 0, -1
+ db D_RIGHT, 0, -1
This fix will make the player enter the water at a normal walking speed, not with a slow step.
Swimming NPCs aren't limited by their movement radius
This bug is why the Lapras in maps/UnionCaveB2F.asm, which uses SPRITEMOVEDATA_SWIM_WANDER
, is not restricted by its 1, 1
movement radius.
Fix: Edit CanObjectMoveInDirection
in engine/overworld/npc_movement.asm:
ld hl, OBJECT_FLAGS1
add hl, bc
bit NOCLIP_TILES_F, [hl] ; lost, uncomment next line to fix
- ; jr nz, .noclip_tiles
+ jr nz, .noclip_tiles
Graphics
In-battle “…
” ellipsis is too high
This is a mistake with the “…
” tile in gfx/battle/hp_exp_bar_border.png:
Fix: Lower the ellipsis by two pixels:
Two tiles in the port
tileset are drawn incorrectly
This is a mistake with the left-hand warp carpet corner tiles in gfx/tilesets/port.png:
Fix: Adjust them to match the right-hand corner tiles:
Using a Park Ball in non-Contest battles has a corrupt animation
(Video)
Fix: Edit PokeBallEffect
in engine/items/item_effects.asm:
.room_in_party
xor a
ld [wWildMon], a
- ld a, [wCurItem]
- cp PARK_BALL
+ ld a, [wBattleType]
+ cp BATTLETYPE_CONTEST
call nz, ReturnToBattle_UseBall
Battle transitions fail to account for the enemy's level
(Video)
There are three things wrong here:
wEnemyMonLevel
isn't initialized yetwBattleMonLevel
gets overwritten after it's initialized byFindFirstAliveMonAndStartBattle
wBattleMonLevel
isn't initialized until much later when the battle is with a trainer
Fix:
First, edit engine/battle/battle_transition.asm:
StartTrainerBattle_DetermineWhichAnimation:
; The screen flashes a different number of times depending on the level of
; your lead Pokemon relative to the opponent's.
-; BUG: wBattleMonLevel and wEnemyMonLevel are not set at this point, so whatever
-; values happen to be there will determine the animation.
+ ld a, [wOtherTrainerClass]
+ and a
+ jr z, .wild
+ farcall SetTrainerBattleLevel
+
+.wild
+ ld b, PARTY_LENGTH
+ ld hl, wPartyMon1HP
+ ld de, PARTYMON_STRUCT_LENGTH - 1
+
+.loop
+ ld a, [hli]
+ or [hl]
+ jr nz, .okay
+ add hl, de
+ dec b
+ jr nz, .loop
+
+.okay
+ ld de, MON_LEVEL - MON_HP - 1
+ add hl, de
ld de, 0
- ld a, [wBattleMonLevel]
+ ld a, [hl]
add 3
- ld hl, wEnemyMonLevel
+ ld hl, wCurPartyLevel
cp [hl]
jr nc, .not_stronger
set TRANS_STRONGER_F, e
.not_stronger
ld a, [wEnvironment]
cp CAVE
jr z, .cave
cp ENVIRONMENT_5
jr z, .cave
cp DUNGEON
jr z, .cave
set TRANS_NO_CAVE_F, e
.cave
ld hl, .StartingPoints
add hl, de
ld a, [hl]
ld [wJumptableIndex], a
ret
.StartingPoints:
; entries correspond to TRANS_* constants
db BATTLETRANSITION_CAVE
db BATTLETRANSITION_CAVE_STRONGER
db BATTLETRANSITION_NO_CAVE
db BATTLETRANSITION_NO_CAVE_STRONGER
Then edit engine/battle/start_battle.asm:
FindFirstAliveMonAndStartBattle:
xor a
ldh [hMapAnims], a
call DelayFrame
- ld b, PARTY_LENGTH
- ld hl, wPartyMon1HP
- ld de, PARTYMON_STRUCT_LENGTH - 1
-
-.loop
- ld a, [hli]
- or [hl]
- jr nz, .okay
- add hl, de
- dec b
- jr nz, .loop
-
-.okay
- ld de, MON_LEVEL - MON_HP
- add hl, de
- ld a, [hl]
- ld [wBattleMonLevel], a
predef DoBattleTransition
Finally, edit engine/battle/read_trainer_party.asm:
INCLUDE "data/trainers/parties.asm"
+
+SetTrainerBattleLevel:
+ ld a, 255
+ ld [wCurPartyLevel], a
+
+ ld a, [wInBattleTowerBattle]
+ bit 0, a
+ ret nz
+
+ ld a, [wLinkMode]
+ and a
+ ret nz
+
+ ld a, [wOtherTrainerClass]
+ dec a
+ ld c, a
+ ld b, 0
+ ld hl, TrainerGroups
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ld a, [wOtherTrainerID]
+ ld b, a
+.skip_trainer
+ dec b
+ jr z, .got_trainer
+.skip_party
+ ld a, [hli]
+ cp $ff
+ jr nz, .skip_party
+ jr .skip_trainer
+.got_trainer
+
+.skip_name
+ ld a, [hli]
+ cp "@"
+ jr nz, .skip_name
+
+ inc hl
+ ld a, [hl]
+ ld [wCurPartyLevel], a
+ ret
Some trainer NPCs have inconsistent overworld sprites
Some of these may have been intentional behavior; use your own judgment for whether to fix them.
Most trainer classes always use the same sprite and color for their overworld NPCs. There are some exceptions:
- maps/FastShipCabins_SE_SSE_CaptainsCabin.asm:
TrainerPsychicRodney
should useSPRITE_YOUNGSTER
, notSPRITE_SUPER_NERD
- maps/LakeOfRage.asm:
TrainerFisherAndre
andTrainerFisherRaymond
should usePAL_NPC_GREEN
, notPAL_NPC_BLUE
- maps/Route13.asm:
TrainerHikerKenny
should usePAL_NPC_BROWN
, notPAL_NPC_RED
- maps/Route44.asm:
TrainerBirdKeeperVance1
should usePAL_NPC_BLUE
, notPAL_NPC_GREEN
- maps/Route44.asm:
TrainerPokemaniacZach
should usePAL_NPC_BLUE
, notPAL_NPC_GREEN
- maps/UnionCaveB2F.asm:
TrainerCooltrainermNick
should useSPRITE_COOLTRAINER_M
, notSPRITE_ROCKER
- maps/FuchsiaPokecenter1F.asm:
FuchsiaPokecenter1FNurseScript
should usePAL_NPC_RED
, notPAL_NPC_GREEN
Most of the NPCs in maps/NationalParkBugContest.asm and maps/Route36NationalParkGate.asm are also inconsistent with their trainers from other maps:
BugCatchingContestant1AScript
andBugCatchingContestant1BScript
:BUG_CATCHER DON
from maps/Route30.asm should useSPRITE_BUG_CATCHER
andPAL_NPC_BROWN
, notSPRITE_YOUNGSTER
andPAL_NPC_RED
BugCatchingContestant2AScript
andBugCatchingContestant2BScript
:BUG_CATCHER ED
from maps/Route2.asm should useSPRITE_BUG_CATCHER
andPAL_NPC_BROWN
, notSPRITE_YOUNGSTER
andPAL_NPC_GREEN
BugCatchingContestant3AScript
andBugCatchingContestant3BScript
:COOLTRAINERM NICK
from maps/UnionCaveB2F.asm should useSPRITE_COOLTRAINER_M
andPAL_NPC_RED
, notSPRITE_ROCKER
andPAL_NPC_BLUE
BugCatchingContestant4AScript
andBugCatchingContestant4BScript
:POKEFANM WILLIAM
from maps/NationalPark.asm should usePAL_NPC_RED
, notPAL_NPC_BROWN
BugCatchingContestant5AScript
andBugCatchingContestant5BScript
:BUG_CATCHER BENNY
from maps/AzaleaGym.asm should useSPRITE_BUG_CATCHER
andPAL_NPC_BROWN
, notSPRITE_YOUNGSTER
andPAL_NPC_RED
BugCatchingContestant7AScript
andBugCatchingContestant7BScript
:PICNICKER CINDY
from maps/FuchsiaGym.asm should usePAL_NPC_GREEN
, notPAL_NPC_BLUE
BugCatchingContestant8AScript
andBugCatchingContestant8BScript
:BUG_CATCHER JOSH
from maps/AzaleaGym.asm should useSPRITE_BUG_CATCHER
andPAL_NPC_BROWN
, notSPRITE_YOUNGSTER
andPAL_NPC_RED
BugCatchingContestant9AScript
andBugCatchingContestant9BScript
:YOUNGSTER SAMUEL
from maps/Route34.asm should usePAL_NPC_BLUE
, notPAL_NPC_GREEN
(Note that maps/Route8.asm has three BIKER
s, DWAYNE
, HARRIS
, and ZEKE
, that use PAL_NPC_RED
, PAL_NPC_GREEN
, and PAL_NPC_BLUE
instead of PAL_NPC_BROWN
; this is intentional since they're the "Kanto Pokémon Federation".)
(The use of SPRITE_ROCKER
instead of SPRITE_COOLTRAINER_M
for COOLTRAINERM NICK
may also be an intentional reference to the player's brother from the Space World '97 beta.)
Audio
Slot machine payout sound effects cut each other off
(Video)
Fix: Edit SlotsAction_PayoutAnim
in engine/games/slot_machine.asm:
.okay
ld [hl], e
dec hl
ld [hl], d
ld a, [wSlotsDelay]
and $7
- ret z ; ret nz would be more appropriate
+ ret nz
ld de, SFX_GET_COIN_FROM_SLOTS
call PlaySFX
ret
Team Rocket battle music is not used for Executives or Scientists
Fix: Edit PlayBattleMusic
in engine/battle/start_battle.asm:
ld de, MUSIC_ROCKET_BATTLE
cp GRUNTM
jr z, .done
cp GRUNTF
jr z, .done
+ cp EXECUTIVEM
+ jr z, .done
+ cp EXECUTIVEF
+ jr z, .done
+ cp SCIENTIST
+ jr z, .done
No bump noise if standing on tile $3E
Fix: Edit DoPlayerMovement.CheckWarp
in engine/overworld/player_movement.asm:
.CheckWarp:
-; Bug: Since no case is made for STANDING here, it will check
-; [.EdgeWarps + $ff]. This resolves to $3e.
-; This causes wWalkingIntoEdgeWarp to be nonzero when standing on tile $3e,
-; making bumps silent.
-
ld a, [wWalkingDirection]
- ; cp STANDING
- ; jr z, .not_warp
+ cp STANDING
+ jr z, .not_warp
ld e, a
ld d, 0
ld hl, .EdgeWarps
add hl, de
ld a, [wPlayerStandingTile]
cp [hl]
jr nz, .not_warp
ld a, TRUE
ld [wWalkingIntoEdgeWarp], a
ld a, [wWalkingDirection]
- ; This is in the wrong place.
- cp STANDING
- jr z, .not_warp
Playing Entei's Pokédex cry can distort Raikou's and Suicune's
(Video)
The exact cause of this bug is unknown.
Workaround: Edit DexEntryScreen_MenuActionJumptable.Cry
in engine/pokedex/pokedex.asm:
.Cry:
- call Pokedex_GetSelectedMon
- ld a, [wTempSpecies]
- call GetCryIndex
- ld e, c
- ld d, b
- call PlayCry
+ ld a, [wCurPartySpecies]
+ call PlayMonCry
ret
Text
Five-digit experience gain is printed incorrectly
(Video)
Fix: Edit _BoostedExpPointsText
and _ExpPointsText
in data/text/common_2.asm:
_BoostedExpPointsText::
text_start
line "a boosted"
cont "@"
- text_decimal wStringBuffer2, 2, 4
+ text_decimal wStringBuffer2, 2, 5
text " EXP. Points!"
prompt
_ExpPointsText::
text_start
line "@"
- text_decimal wStringBuffer2, 2, 4
+ text_decimal wStringBuffer2, 2, 5
text " EXP. Points!"
prompt
Only the first three evolution entries can have Stone compatibility reported correctly
Workaround: Edit PlacePartyMonEvoStoneCompatibility.DetermineCompatibility
in engine/pokemon/party_menu.asm:
.DetermineCompatibility:
ld de, wStringBuffer1
ld a, BANK(EvosAttacksPointers)
ld bc, 2
call FarCopyBytes
ld hl, wStringBuffer1
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wStringBuffer1
ld a, BANK("Evolutions and Attacks")
- ld bc, 10
+ ld bc, STRING_BUFFER_LENGTH
call FarCopyBytes
This supports up to six entries.
EVOLVE_STAT
can break Stone compatibility reporting
Fix: Edit PlacePartyMonEvoStoneCompatibility.DetermineCompatibility
in engine/pokemon/party_menu.asm:
.loop2
ld a, [hli]
and a
jr z, .nope
+ cp EVOLVE_STAT
+ jr nz, .not_four_bytes
+ inc hl
+.not_four_bytes
inc hl
inc hl
cp EVOLVE_ITEM
jr nz, .loop2
A "HOF Master!" title for 200-Time Famers is defined but inaccessible
(Video)
Fix: Edit _HallOfFamePC.DisplayMonAndStrings
in engine/events/halloffame.asm:
ld a, [wHallOfFameTempWinCount]
- cp HOF_MASTER_COUNT + 1 ; should be HOF_MASTER_COUNT
+ cp HOF_MASTER_COUNT
jr c, .print_num_hof
ld de, .HOFMaster
hlcoord 1, 2
call PlaceString
hlcoord 13, 2
jr .finish
Scripted events
Clair can give TM24 Dragonbreath twice
(Video)
Fix: Edit DragonsDen1F_MapScripts
in maps/DragonsDen1F.asm:
- db 0 ; callbacks
+ db 1 ; callbacks
+ callback MAPCALLBACK_NEWMAP, .UnsetClairScene
+
+.UnsetClairScene:
+ setmapscene DRAGONS_DEN_B1F, SCENE_DRAGONSDENB1F_NOTHING
+ return
Daisy's grooming doesn't always increase happiness
This is a bug with HaircutOrGrooming
in engine/events/haircut.asm:
; Bug: Subtracting $ff from $ff fails to set c.
; This can result in overflow into the next data array.
; In the case of getting a grooming from Daisy, we bleed
; into CopyPokemonName_Buffer1_Buffer3, which passes
; $d0 to ChangeHappiness and returns $73 to the script.
; The end result is that there is a 0.4% chance your
; Pokemon's happiness will not change at all.
.loop
sub [hl]
jr c, .ok
inc hl
inc hl
inc hl
jr .loop
.ok
inc hl
ld a, [hli]
ld [wScriptVar], a
ld c, [hl]
call ChangeHappiness
ret
...
INCLUDE "data/events/happiness_probabilities.asm"
CopyPokemonName_Buffer1_Buffer3:
ld hl, wStringBuffer1
ld de, wStringBuffer3
ld bc, MON_NAME_LENGTH
jp CopyBytes
Fix: Edit data/events/happiness_probabilities.asm:
HappinessData_DaisysGrooming:
- db 100 percent, 2, HAPPINESS_GROOMING ; 99.6% chance
+ db 50 percent + 1, 2, HAPPINESS_GROOMING ; 50% chance
+ db 100 percent, 2, HAPPINESS_GROOMING ; 50% chance
Magikarp in Lake of Rage are shorter, not longer
Fix: Edit LoadEnemyMon.CheckMagikarpArea
in engine/battle/core.asm:
.CheckMagikarpArea:
-; The "jr z" checks are supposed to be "jr nz".
-
-; Instead, all maps in GROUP_LAKE_OF_RAGE (Mahogany area)
-; and Routes 20 and 44 are treated as Lake of Rage.
-
-; This also means Lake of Rage Magikarp can be smaller than ones
-; caught elsewhere rather than the other way around.
-
-; Intended behavior enforces a minimum size at Lake of Rage.
-; The real behavior prevents a minimum size in the Lake of Rage area.
-
-; Moreover, due to the check not being translated to feet+inches, all Magikarp
-; smaller than 4'0" may be caught by the filter, a lot more than intended.
ld a, [wMapGroup]
cp GROUP_LAKE_OF_RAGE
- jr z, .Happiness
+ jr nz, .Happiness
ld a, [wMapNumber]
cp MAP_LAKE_OF_RAGE
- jr z, .Happiness
+ jr nz, .Happiness
Magikarp length limits have a unit conversion error
Fix: Edit LoadEnemyMon.CheckMagikarpArea
in engine/battle/core.asm:
; Get Magikarp's length
ld de, wEnemyMonDVs
ld bc, wPlayerID
callfar CalcMagikarpLength
; No reason to keep going if length > 1536 mm (i.e. if HIGH(length) > 6 feet)
ld a, [wMagikarpLength]
- cp HIGH(1536) ; should be "cp 5", since 1536 mm = 5'0", but HIGH(1536) = 6
+ cp 5
jr nz, .CheckMagikarpArea
; 5% chance of skipping both size checks
call Random
cp 5 percent
jr c, .CheckMagikarpArea
; Try again if length >= 1616 mm (i.e. if LOW(length) >= 4 inches)
ld a, [wMagikarpLength + 1]
- cp LOW(1616) ; should be "cp 4", since 1616 mm = 5'4", but LOW(1616) = 80
+ cp 4
jr nc, .GenerateDVs
; 20% chance of skipping this check
call Random
cp 20 percent - 1
jr c, .CheckMagikarpArea
; Try again if length >= 1600 mm (i.e. if LOW(length) >= 3 inches)
ld a, [wMagikarpLength + 1]
- cp LOW(1600) ; should be "cp 3", since 1600 mm = 5'3", but LOW(1600) = 64
+ cp 3
jr nc, .GenerateDVs
Better fix: Rewrite the whole system to use millimeters instead of feet and inches, since they have better precision (1 in = 25.4 mm); and only convert from metric to imperial units for display purposes (or don't, of course).
Magikarp lengths can be miscalculated
Fix: Edit CalcMagikarpLength.BCLessThanDE
in engine/events/magikarp.asm:
.BCLessThanDE:
-; Intention: Return bc < de.
-; Reality: Return b < d.
ld a, b
cp d
ret c
- ret nc ; whoops
ld a, c
cp e
ret
CheckOwnMon
only checks the first five letters of OT names
(Video)
This bug can allow you to talk to Eusine in Celadon City and encounter Ho-Oh with only traded legendary beasts.
Fix: Edit CheckOwnMon
in engine/pokemon/search.asm:
; check OT
-; This only checks five characters, which is fine for the Japanese version,
-; but in the English version the player name is 7 characters, so this is wrong.
ld hl, wPlayerName
-rept NAME_LENGTH_JAPANESE - 2 ; should be PLAYER_NAME_LENGTH - 2
+rept PLAYER_NAME_LENGTH - 2
ld a, [de]
cp [hl]
jr nz, .notfound
cp "@"
jr z, .found ; reached end of string
inc hl
inc de
endr
ld a, [de]
cp [hl]
jr z, .found
CheckOwnMonAnywhere
does not check the Day-Care
This may have been intentional behavior; use your own judgment for whether to fix it.
This bug can prevent you from talking to Eusine in Celadon City or encountering Ho-Oh when a caught legendary beast is in the Day-Care.
Fix: Edit CheckOwnMonAnywhere
in engine/pokemon/search.asm:
; If there are no monsters in the party,
; the player must not own any yet.
ld a, [wPartyCount]
and a
ret z
+
+ ld hl, wBreedMon1Species
+ ld bc, wBreedMon1OT
+ call CheckOwnMon
+ ret c ; found!
+
+ ld hl, wBreedMon2Species
+ ld bc, wBreedMon2OT
+ call CheckOwnMon
+ ret c ; found!
The unused phonecall
script command may crash
The phonecall
script command calls the PhoneCall
routine, which calls the BrokenPlaceFarString
routine; this switches banks without being in bank 0, so it would start running arbitrary data as code.
Fix: Edit PhoneCall.CallerTextboxWithName
in engine/phone/phone.asm:
- ld a, [wPhoneScriptBank]
- ld b, a
ld a, [wPhoneCaller]
ld e, a
ld a, [wPhoneCaller + 1]
ld d, a
- call BrokenPlaceFarString
+ ld a, [wPhoneScriptBank]
+ call PlaceFarString
ret
You can also delete the now-unused BrokenPlaceFarString
routine.
Internal engine routines
Saves corrupted by mid-save shutoff are not handled
This does not have a simple and accurate fix. It would involve redesigning parts of the save system for Pokémon boxes.
ScriptCall
can overflow wScriptStack
and crash
Fix: Edit ScriptCall
in engine/overworld/scripting.asm:
ScriptCall:
-; Bug: The script stack has a capacity of 5 scripts, yet there is
-; nothing to stop you from pushing a sixth script. The high part
-; of the script address can then be overwritten by modifications
-; to wScriptDelay, causing the script to return to the rst/interrupt
-; space.
-
+ ld hl, wScriptStackSize
+ ld a, [hl]
+ cp 5
+ ret nc
push de
- ld hl, wScriptStackSize
- ld e, [hl]
inc [hl]
+ ld e, a
ld d, 0
ld hl, wScriptStack
add hl, de
add hl, de
add hl, de
pop de
ld a, [wScriptBank]
ld [hli], a
ld a, [wScriptPos]
ld [hli], a
ld a, [wScriptPos + 1]
ld [hl], a
ld a, b
ld [wScriptBank], a
ld a, e
ld [wScriptPos], a
ld a, d
ld [wScriptPos + 1], a
ret
LoadSpriteGFX
does not limit the capacity of UsedSprites
Fix: Edit LoadSpriteGFX
in engine/overworld/overworld.asm:
LoadSpriteGFX:
-; Bug: b is not preserved, so it's useless as a next count.
-; Uncomment the lines below to fix.
-
ld hl, wUsedSprites
ld b, SPRITE_GFX_LIST_CAPACITY
.loop
ld a, [hli]
and a
jr z, .done
push hl
call .LoadSprite
pop hl
ld [hli], a
dec b
jr nz, .loop
.done
ret
.LoadSprite:
- ; push bc
+ push bc
call GetSprite
- ; pop bc
+ pop bc
ld a, l
ret
ChooseWildEncounter
doesn't really validate the wild Pokémon species
Fix: Edit ChooseWildEncounter
in engine/overworld/wildmons.asm:
.ok
ld a, b
ld [wCurPartyLevel], a
ld b, [hl]
- ; ld a, b
+ ld a, b
call ValidateTempWildMonSpecies
jr c, .nowildbattle
- ld a, b ; This is in the wrong place.
cp UNOWN
jr nz, .done
TryObjectEvent
arbitrary code execution
Fix: Edit TryObjectEvent
in engine/overworld/events.asm:
-; Bug: If IsInArray returns nc, data at bc will be executed as code.
push bc
ld de, 3
ld hl, .pointers
call IsInArray
- jr nc, .nope
pop bc
+ jr nc, .nope
inc hl
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
.nope
- ; pop bc
xor a
ret
ReadObjectEvents
overflows into wObjectMasks
Fix: Edit ReadObjectEvents
in home/map.asm:
-; get NUM_OBJECTS - [wCurMapObjectEventCount]
+; get NUM_OBJECTS - [wCurMapObjectEventCount] - 1
ld a, [wCurMapObjectEventCount]
ld c, a
- ld a, NUM_OBJECTS ; - 1
+ ld a, NUM_OBJECTS - 1
sub c
jr z, .skip
- ; jr c, .skip
+ jr c, .skip
; could have done "inc hl" instead
ld bc, 1
add hl, bc
-; Fill the remaining sprite IDs and y coords with 0 and -1, respectively.
-; Bleeds into wObjectMasks due to a bug. Uncomment the above code to fix.
ld bc, MAPOBJECT_LENGTH
.loop
ld [hl], 0
inc hl
ld [hl], -1
dec hl
add hl, bc
dec a
jr nz, .loop
ClearWRAM
only clears WRAM bank 1
Fix: Edit ClearWRAM
in home/init.asm:
ClearWRAM::
; Wipe swappable WRAM banks (1-7)
; Assumes CGB or AGB
ld a, 1
.bank_loop
push af
ldh [rSVBK], a
xor a
ld hl, WRAM1_Begin
ld bc, WRAM1_End - WRAM1_Begin
call ByteFill
pop af
inc a
cp 8
- jr nc, .bank_loop ; Should be jr c
+ jr c, .bank_loop
ret
BattleAnimCmd_ClearObjs
only clears the first 6⅔ objects
Fix: Edit BattleAnimCmd_ClearObjs
in engine/battle_anims/anim_commands.asm:
BattleAnimCmd_ClearObjs:
-; BUG: This function only clears the first 6⅔ objects
ld hl, wActiveAnimObjects
- ld a, $a0 ; should be NUM_ANIM_OBJECTS * BATTLEANIMSTRUCT_LENGTH
+ ld a, NUM_ANIM_OBJECTS * BATTLEANIMSTRUCT_LENGTH
.loop
ld [hl], 0
inc hl
dec a
jr nz, .loop
ret