shithub: pokecrystal

Download patch

ref: 1357e0d674efaae639c930b02477c316d1c7b6ca
parent: e9767dcfa8e91559787d1a97d5c831d12b346fe0
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Sun Sep 27 08:39:27 EDT 2020

Fix #769: document the Heavy Ball weight bank bug

--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -46,6 +46,7 @@
   - [Moon Ball does not boost catch rate](#moon-ball-does-not-boost-catch-rate)
   - [Love Ball boosts catch rate for the wrong gender](#love-ball-boosts-catch-rate-for-the-wrong-gender)
   - [Fast Ball only boosts catch rate for three Pokémon](#fast-ball-only-boosts-catch-rate-for-three-pokémon)
+  - [Heavy Ball uses wrong weight value 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](#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-encourages-mean-look-if-its-own-pokémon-is-badly-poisoned)
   - [AI makes a false assumption about `CheckTypeMatchup`](#ai-makes-a-false-assumption-about-checktypematchup)
@@ -974,6 +975,40 @@
 ```
 
 
+### Heavy Ball uses wrong weight value for three Pokémon
+
+**Fix:** Edit `GetPokedexEntryBank` in [engine/items/item_effects.asm](https://github.com/pret/pokecrystal/blob/master/engine/items/item_effects.asm):
+
+```diff
+ 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.
@@ -2222,7 +2257,7 @@
  	jr z, .skip
 -	; jr c, .skip
 +	jr c, .skip
- 
+
  	; could have done "inc hl" instead
  	ld bc, 1
  	add hl, bc
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -745,9 +745,13 @@
 	ret
 
 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
 	rlca
 	rlca
 	maskbits NUM_DEX_ENTRY_BANKS