diff options
Diffstat (limited to 'docs/design_flaws.md')
-rw-r--r-- | docs/design_flaws.md | 119 |
1 files changed, 118 insertions, 1 deletions
diff --git a/docs/design_flaws.md b/docs/design_flaws.md index 26560b58f..945c2ff75 100644 --- a/docs/design_flaws.md +++ b/docs/design_flaws.md @@ -513,7 +513,124 @@ PokedexShow_GetDexEntryBank: db BANK("Pokedex Entries 193-251") ``` -**Fix:** Use `dba` instead of `dw` in `PokedexDataPointerTable`. Then edit [home.asm](https://github.com/pret/pokecrystal/blob/master/home.asm) to contain a single copy of the `PokedexDataPointerTable` lookup code, updated to work with 3-byte `dba` entries and get the bank from the first entry byte. Delete the three separate lookup routines and use the new one (placed in [home.asm](https://github.com/pret/pokecrystal/blob/master/home.asm) so it can be called from any bank.) +**Fix:** + +Use `dba` instead of `dw` in `PokedexDataPointerTable`. + +Delete `GetPokedexEntryBank` and `PokedexShow_GetDexEntryBank`. You can also delete `NUM_DEX_ENTRY_BANKS` from [constants/pokemon_data_constants.asm](https://github.com/pret/pokecrystal/blob/master/constants/pokemon_data_constants.asm). + +Edit [engine/pokedex/pokedex_2.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokedex/pokedex_2.asm): + +```diff + GetDexEntryPointer: + ; return dex entry pointer b:de + push hl + ld hl, PokedexDataPointerTable + ld a, b + dec a + ld d, 0 + ld e, a + add hl, de + add hl, de +- ld e, [hl] +- inc hl +- ld d, [hl] +- push de +- rlca +- rlca +- maskbits NUM_DEX_ENTRY_BANKS +- ld hl, .PokedexEntryBanks +- ld d, 0 +- ld e, a +- add hl, de +- ld b, [hl] +- pop de ++ add hl, de ++ ; b = bank ++ ld a, [hli] ++ ld b, a ++ ; de = address ++ ld a, [hli] ++ ld e, a ++ ld d, [hl] + 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") +``` + +Edit [engine/items/item_effects.asm](https://github.com/pret/pokecrystal/blob/master/engine/items/item_effects.asm): + +```diff + HeavyBallMultiplier: + ; subtract 20 from catch rate if weight < 102.4 kg + ; else add 0 to catch rate if weight < 204.8 kg + ; else add 20 to catch rate if weight < 307.2 kg + ; else add 30 to catch rate if weight < 409.6 kg + ; else add 40 to catch rate (never happens) + ld a, [wEnemyMonSpecies] + ld hl, PokedexDataPointerTable + dec a + ld e, a + ld d, 0 + add hl, de + add hl, de ++ add hl, de ++ ; d = bank, hl = address ++ ld a, BANK(PokedexDataPointerTable) ++ call GetFarByte ++ push af ++ inc hl + ld a, BANK(PokedexDataPointerTable) + call GetFarHalfword ++ pop de + + .SkipText: +- call GetPokedexEntryBank ++ ld a, d + call GetFarByte + inc hl + cp "@" + jr nz, .SkipText + +- call GetPokedexEntryBank ++ ld a, d + push bc + inc hl + inc hl + call GetFarHalfword +``` + +And edit [engine/pokegear/radio.asm](https://github.com/pret/pokecrystal/blob/master/engine/pokegear/radio.asm): + +```diff + PokedexShow2: + ld a, [wCurPartySpecies] + dec a + ld hl, PokedexDataPointerTable + ld c, a + ld b, 0 + add hl, bc + add hl, bc ++ add hl, bc ++ b = bank ++ ld a, BANK(PokedexDataPointerTable) ++ call GetFarByte ++ ld b, a ++ inc hl ++ ; hl = address + ld a, BANK(PokedexDataPointerTable) + call GetFarHalfword +- call PokedexShow_GetDexEntryBank ++ ld a, b + push af + push hl + call CopyDexEntryPart1 +``` ## Identical sine wave code and data is repeated five times |