diff options
Diffstat (limited to 'docs/design_flaws.md')
-rw-r--r-- | docs/design_flaws.md | 116 |
1 files changed, 56 insertions, 60 deletions
diff --git a/docs/design_flaws.md b/docs/design_flaws.md index e4a81123b..4b24a0cc3 100644 --- a/docs/design_flaws.md +++ b/docs/design_flaws.md @@ -28,7 +28,7 @@ ENDM The offset is translated into a correct bank by `FixPicBank` in [engine/gfx/load_pics.asm](/engine/gfx/load_pics.asm): ```asm -FixPicBank: ; 511c5 +FixPicBank: ; This is a thing for some reason. PICS_FIX EQU $36 @@ -36,7 +36,7 @@ GLOBAL PICS_FIX push hl push bc - sub BANK(Pics_1) - PICS_FIX + sub BANK("Pics 1") - PICS_FIX ld c, a ld b, 0 ld hl, .PicsBanks @@ -46,34 +46,34 @@ GLOBAL PICS_FIX pop hl ret -.PicsBanks: ; 511d4 - db BANK(Pics_1) + 0 - db BANK(Pics_1) + 1 - db BANK(Pics_1) + 2 - db BANK(Pics_1) + 3 - db BANK(Pics_1) + 4 - db BANK(Pics_1) + 5 - db BANK(Pics_1) + 6 - db BANK(Pics_1) + 7 - db BANK(Pics_1) + 8 - db BANK(Pics_1) + 9 - db BANK(Pics_1) + 10 - db BANK(Pics_1) + 11 - db BANK(Pics_1) + 12 - db BANK(Pics_1) + 13 - db BANK(Pics_1) + 14 - db BANK(Pics_1) + 15 - db BANK(Pics_1) + 16 - db BANK(Pics_1) + 17 - db BANK(Pics_1) + 18 - db BANK(Pics_1) + 19 - db BANK(Pics_1) + 20 - db BANK(Pics_1) + 21 - db BANK(Pics_1) + 22 - db BANK(Pics_1) + 23 +.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 ``` -**Fix:** Use `dba` instead of `dba_pic`, and don't call `FixPicBank` to modify `a`. +**Fix:** Use `dba` instead of `dba_pic`, delete `FixPicBank`, and remove all four calls to `FixPicBank`. ## `PokemonPicPointers` and `UnownPicPointers` are assumed to start at the same address @@ -84,6 +84,7 @@ In [gfx/pics.asm](/gfx/pics.asm): ; PokemonPicPointers and UnownPicPointers are assumed to start at the same ; address, but in different banks. This is enforced in pokecrystal.link. + SECTION "Pic Pointers", ROMX INCLUDE "data/pokemon/pic_pointers.asm" @@ -298,7 +299,7 @@ NUM_TMS = const_value - TM01 - 2 ; discount ITEM_C3 and ITEM_DC `GetTMHMNumber` and `GetNumberedTMHM` in [engine/items/items.asm](/engine/items/items.asm) have to compensate for this: ```asm -GetTMHMNumber:: ; d407 +GetTMHMNumber:: ; Return the number of a TM/HM by item id c. ld a, c ; Skip any dummy items. @@ -315,7 +316,7 @@ GetTMHMNumber:: ; d407 ld c, a ret -GetNumberedTMHM: ; d417 +GetNumberedTMHM: ; Return the item id of a TM/HM by number c. ld a, c ; Skip any gaps. @@ -341,7 +342,7 @@ Move `ITEM_C3` and `ITEM_DC` above all the TMs in every table of item data. Modify engine/items/items.asm: ```asm -GetTMHMNumber:: ; d407 +GetTMHMNumber:: ; Return the number of a TM/HM by item id c. ld a, c sub TM01 @@ -349,7 +350,7 @@ GetTMHMNumber:: ; d407 ld c, a ret -GetNumberedTMHM: ; d417 +GetNumberedTMHM: ; Return the item id of a TM/HM by number c. ld a, c add TM01 @@ -366,7 +367,7 @@ GetNumberedTMHM: ; d417 Three separate routines do the same derivation; `GetDexEntryPointer` in [engine/pokedex/pokedex_2.asm](/engine/pokedex/pokedex_2.asm): ```asm -GetDexEntryPointer: ; 44333 +GetDexEntryPointer: ; return dex entry pointer b:de push hl ld hl, PokedexDataPointerTable @@ -393,10 +394,10 @@ GetDexEntryPointer: ; 44333 ret .PokedexEntryBanks: - db BANK(PokedexEntries1) - db BANK(PokedexEntries2) - db BANK(PokedexEntries3) - db BANK(PokedexEntries4) + db BANK("Pokedex Entries 001-064") + db BANK("Pokedex Entries 065-128") + db BANK("Pokedex Entries 129-192") + db BANK("Pokedex Entries 193-251") ``` `GetPokedexEntryBank` in [engine/items/item_effects.asm](/engine/items/item_effects.asm): @@ -419,10 +420,10 @@ GetPokedexEntryBank: ret .PokedexEntryBanks: - db BANK(PokedexEntries1) - db BANK(PokedexEntries2) - db BANK(PokedexEntries3) - db BANK(PokedexEntries4) + db BANK("Pokedex Entries 001-064") + db BANK("Pokedex Entries 065-128") + db BANK("Pokedex Entries 129-192") + db BANK("Pokedex Entries 193-251") ``` And `PokedexShow_GetDexEntryBank` in [engine/pokegear/radio.asm](/engine/pokegear/radio.asm): @@ -446,10 +447,10 @@ PokedexShow_GetDexEntryBank: ret .PokedexEntryBanks: - db BANK(PokedexEntries1) - db BANK(PokedexEntries2) - db BANK(PokedexEntries3) - db BANK(PokedexEntries4) + db BANK("Pokedex Entries 001-064") + db BANK("Pokedex Entries 065-128") + db BANK("Pokedex Entries 129-192") + db BANK("Pokedex Entries 193-251") ``` **Fix:** Use `dba` instead of `dw` in `PokedexDataPointerTable`, and modify the code that accesses it to match. @@ -460,7 +461,7 @@ PokedexShow_GetDexEntryBank: `_Sine` in [engine/math/sine.asm](/engine/math/sine.asm): ```asm -_Sine:: ; 84d9 +_Sine:: ; a = d * sin(e * pi/32) ld a, e calc_sine_wave @@ -469,11 +470,11 @@ _Sine:: ; 84d9 `Sprites_Cosine` and `Sprites_Sine` in [engine/gfx/sprites.asm](/engine/gfx/sprites.asm): ```asm -Sprites_Cosine: ; 8e72a +Sprites_Cosine: ; a = d * cos(a * pi/32) add %010000 ; cos(x) = sin(x + pi/2) ; fallthrough -Sprites_Sine: ; 8e72c +Sprites_Sine: ; a = d * sin(a * pi/32) calc_sine_wave ``` @@ -481,37 +482,34 @@ Sprites_Sine: ; 8e72c `BattleAnim_Cosine` and `BattleAnim_Sine` in [engine/battle_anims/functions.asm](/engine/battle_anims/functions.asm): ```asm -BattleAnim_Cosine: ; ce732 (33:6732) +BattleAnim_Cosine: ; a = d * cos(a * pi/32) add %010000 ; cos(x) = sin(x + pi/2) ; fallthrough -BattleAnim_Sine: ; ce734 (33:6734) +BattleAnim_Sine: ; a = d * sin(a * pi/32) calc_sine_wave BattleAnimSineWave ... -BattleAnimSineWave: ; ce77f +BattleAnimSineWave: sine_table 32 -; ce7bf ``` `StartTrainerBattle_DrawSineWave` in [engine/battle/battle_transition.asm](/engine/battle/battle_transition.asm): ```asm -StartTrainerBattle_DrawSineWave: ; 8c6f7 (23:46f7) +StartTrainerBattle_DrawSineWave: calc_sine_wave -; 8c768 ``` And `CelebiEvent_Cosine` in [engine/events/celebi.asm](/engine/events/celebi.asm): ```asm -CelebiEvent_Cosine: ; 49b3b (12:5b3b) +CelebiEvent_Cosine: ; a = d * cos(a * pi/32) add %010000 ; cos(x) = sin(x + pi/2) calc_sine_wave -; 49bae ``` They all rely on `calc_sine_wave` in [macros/code.asm](/macros/code.asm): @@ -586,7 +584,7 @@ ENDM In [engine/tilesets/tileset_anims.asm](/engine/tilesets/tileset_anims.asm): ```asm -GetForestTreeFrame: ; fc54c +GetForestTreeFrame: ; Return 0 if a is even, or 2 if odd. and a jr z, .even @@ -609,16 +607,14 @@ GetForestTreeFrame: ; fc54c .even xor a ret -; fc56d ``` **Fix:** ```asm -GetForestTreeFrame: ; fc54c +GetForestTreeFrame: ; Return 0 if a is even, or 2 if odd. and 1 add a ret -; fc56d ``` |