-
Notifications
You must be signed in to change notification settings - Fork 811
Custom order for the Old Pokédex mode
This tutorial allows you to give the Old Pokédex mode a different order than the index order of the Pokémon themselves.
- Define the Old Mode order
- Edit how Old Mode is implemented
- Update the index numbers to reflect the Pokédex order
We're going to define the order in which Pokémon will appear in the Old Mode Pokédex, in the same way as data/pokemon/dex_order_new.asm does for the New Mode.
Create data/pokemon/dex_order_old.asm:
+OldPokedexOrder:
+ db BULBASAUR
+ db IVYSAUR
+ db VENUSAUR
+ ...
+ db LUGIA
+ db HO_OH
+ db CELEBI
You can leave the order as is, or change it up to your liking.
We also need to include this new file in the ROM.
Edit engine/pokedex/pokedex.asm
INCLUDE "data/pokemon/dex_order_alpha.asm"
INCLUDE "data/pokemon/dex_order_new.asm"
+
+INCLUDE "data/pokemon/dex_order_old.asm"
We're going to reuse the same code that's used for the New Mode Pokédex, but instead of using NewPokedexOrder
, we're going to tell it to use OldPokedexOrder
. This ensures that the Pokémon are displayed in the order we want them to in the Old Mode Pokédex.
Edit engine/pokedex/pokedex.asm:
Pokedex_OrderMonsByMode:
...
.NewMode:
ld de, NewPokedexOrder
+.do_dex
ld hl, wPokedexOrder
ld c, NUM_POKEMON
.loopnew
ld a, [de]
inc de
ld [hli], a
dec c
jr nz, .loopnew
call .FindLastSeen
ret
.OldMode:
- ld hl, wPokedexOrder
- ld a, $1
- ld c, NUM_POKEMON
-.loopold
- ld [hli], a
- inc a
- dec c
- jr nz, .loopold
- call .FindLastSeen
- ret
+ ld de, OldPokedexOrder
+ jr .do_dex
That's it! Now we have two Pokédex modes, Old and New, each with their own custom order that doesn't depend on the internal index order.
Now you have the old mode Pokédex showing a custom order. However, when you look at the Pokémon's index number both on the dex list, and in their actual dex entry, it still shows the old number. We're going to change that now.
Edit main.asm:
SECTION "bank10", ROMX
-INCLUDE "engine/pokedex/pokedex.asm"
INCLUDE "data/moves/moves.asm"
INCLUDE "engine/pokemon/evolve.asm"
SECTION "bank11", ROMX
INCLUDE "engine/events/fruit_trees.asm"
INCLUDE "engine/battle/ai/move.asm"
INCLUDE "engine/pokemon/mail.asm"
+INCLUDE "engine/pokedex/pokedex.asm"
INCLUDE "engine/pokedex/pokedex_2.asm"
There should be plenty of space in that bank for both Pokedex ASMs. With this code, as I have it, you'll need to have them in the same bank, so with that done, move on to engine/pokedex/pokedex.asm:
Pokedex_PrintNumberIfOldMode:
ld a, [wCurDexMode]
cp DEXMODE_OLD
jr z, .printnum
ret
.printnum
push hl
ld de, -SCREEN_WIDTH
add hl, de
call Pokedex_GetDexNumber
ld de, wUnusedBCDNumber
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
call PrintNum
pop hl
ret
And add this code to any safe place in the file. I put it right before OldPokedexOrder:
Pokedex_GetDexNumber:
; Get the intended number of the selected Pokémon.
push bc
push hl
ld a, [wTempSpecies] ;a = current mon (internal number)
ld b, a ;b = Needed mon (a and b must be matched)
ld c, 0 ;c = index
ld hl,OldPokedexOrder
.loop
inc c
ld a, [hli]
cp b
jr nz, .loop
ld a, c
ld [wUnusedBCDNumber], a
pop hl
pop bc
ret
Before we move on, please note "wUnusedBCDNumber". This is a point in wRAM where the correct Pokedex number is stored. This variable is read from in some unused code, but never written too or read from otherwise, so it is safe to use in Crystal vanilla.
Edit pokedex_2.asm:
; Print dex number
hlcoord 2, 8
ld a, $5c ; No
ld [hli], a
ld a, $5d ; .
ld [hli], a
;ld de, wTempSpecies
call Pokedex_GetDexNumber
ld de, wUnusedBCDNumber
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
call PrintNum
Build and test! All Pokemon will now show a correct Pokedex number corresponding to dex_order_old.asm!
If you want the number to also be reflected on the Pokémon's stats page, make the following changes to engine/pokemon/stats_screen.asm:
…
StatsScreen_InitUpperHalf:
call .PlaceHPBar
xor a
ldh [hBGMapMode], a
ld a, [wBaseDexNo]
ld [wTextDecimalByte], a
ld [wCurSpecies], a
hlcoord 8, 0
ld [hl], "№"
inc hl
ld [hl], "."
inc hl
- hlcoord 10, 0
+ farcall Pokedex_GetDexNumber
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
- ld de, wTextDecimalByte
+ ld de, wUnusedBCDNumber
+ hlcoord 10, 0
call PrintNum
…