ref: bd45cfd5fdad3d019e752836ec88ac930bb6572b
parent: be7a5e09b5e54676a9c239682707331be1229828
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Wed Oct 6 13:44:34 EDT 2021
Add `assert PokemonPicPointers == UnownPicPointers` in `GetFrontpicPointer`
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -49,29 +49,8 @@
.PicsBanks:
db BANK("Pics 1") ; BANK("Pics 1") + 0
- db BANK("Pics 2") ; BANK("Pics 1") + 1
- db BANK("Pics 3") ; BANK("Pics 1") + 2
- db BANK("Pics 4") ; BANK("Pics 1") + 3
- db BANK("Pics 5") ; BANK("Pics 1") + 4
- db BANK("Pics 6") ; BANK("Pics 1") + 5
- db BANK("Pics 7") ; BANK("Pics 1") + 6
- db BANK("Pics 8") ; BANK("Pics 1") + 7
- db BANK("Pics 9") ; BANK("Pics 1") + 8
- db BANK("Pics 10") ; BANK("Pics 1") + 9
- db BANK("Pics 11") ; BANK("Pics 1") + 10
- db BANK("Pics 12") ; BANK("Pics 1") + 11
- db BANK("Pics 13") ; BANK("Pics 1") + 12
- db BANK("Pics 14") ; BANK("Pics 1") + 13
- db BANK("Pics 15") ; BANK("Pics 1") + 14
- db BANK("Pics 16") ; BANK("Pics 1") + 15
- db BANK("Pics 17") ; BANK("Pics 1") + 16
- db BANK("Pics 18") ; BANK("Pics 1") + 17
- db BANK("Pics 19") ; BANK("Pics 1") + 18
- db BANK("Pics 20") ; BANK("Pics 1") + 19
- db BANK("Pics 21") ; BANK("Pics 1") + 20
- db BANK("Pics 22") ; BANK("Pics 1") + 21
- db BANK("Pics 23") ; BANK("Pics 1") + 22
- db BANK("Pics 24") ; BANK("Pics 1") + 23
+ ...
+ db BANK("Pics 24") ; BANK("Pics 1") + 23
```
**Fix:** Delete `FixPicBank` and remove all four calls to `FixPicBank` in [engine/gfx/load_pics.asm](https://github.com/pret/pokecrystal/blob/master/engine/gfx/load_pics.asm). Then use `dba` instead of `dba_pic` everywhere.
@@ -121,18 +100,18 @@
ld a, [wCurPartySpecies]
cp UNOWN
jr z, .unown
- ld a, [wCurPartySpecies]
+ ld hl, PokemonPicPointers
+ ld a, [wCurPartySpecies]
ld d, BANK(PokemonPicPointers)
jr .ok
-
.unown
- ld a, [wUnownLetter]
+ ld hl, UnownPicPointers
+ ld a, [wUnownLetter]
ld d, BANK(UnownPicPointers)
-
.ok
-- ld hl, PokemonPicPointers ; UnownPicPointers
+- ; These are assumed to be at the same address in their respective banks.
+- assert PokemonPicPointers == UnownPicPointers
+- ld hl, PokemonPicPointers
dec a
ld bc, 6
call AddNTimes
@@ -142,14 +121,14 @@
```diff
- ; These are assumed to be at the same address in their respective banks.
-- ld hl, PokemonPicPointers ; UnownPicPointers
+- assert PokemonPicPointers == UnownPicPointers
+ ld hl, PokemonPicPointers
ld a, b
-+ ld hl, PokemonPicPointers
ld d, BANK(PokemonPicPointers)
cp UNOWN
jr nz, .ok
- ld a, c
+ ld hl, UnownPicPointers
+ ld a, c
ld d, BANK(UnownPicPointers)
.ok
dec a
--- a/engine/gfx/load_pics.asm
+++ b/engine/gfx/load_pics.asm
@@ -109,13 +109,13 @@
ld a, [wCurPartySpecies]
ld d, BANK(PokemonPicPointers)
jr .ok
-
.unown
ld a, [wUnownLetter]
ld d, BANK(UnownPicPointers)
-
.ok
- ld hl, PokemonPicPointers ; UnownPicPointers
+ ; These are assumed to be at the same address in their respective banks.
+ assert PokemonPicPointers == UnownPicPointers
+ ld hl, PokemonPicPointers
dec a
ld bc, 6
call AddNTimes