1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
This tutorial allows you to give the Old Pokédex mode a different order than the index order of the Pokémon themselves.
## Contents
1. [Define the Old Mode order](#1-define-old-pokédex-order)
2. [Edit how Old Mode is implemented](#2-edit-how-old-mode-is-implemented)
3. [Update the index numbers to reflect the Pokédex order](#3-update-the-index-numbers-to-reflect-the-pokédex-order)
## 1. Define the Old Mode 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](../blob/master/data/pokemon/dex_order_new.asm) does for the New Mode.
Create **data/pokemon/dex_order_old.asm**:
```diff
+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](../blob/master/engine/pokedex/pokedex.asm)
```diff
INCLUDE "data/pokemon/dex_order_alpha.asm"
INCLUDE "data/pokemon/dex_order_new.asm"
+
+INCLUDE "data/pokemon/dex_order_old.asm"
```
## 2. Edit how Old Mode is implemented
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](../blob/master/engine/pokedex/pokedex.asm):
```diff
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.
## 3. Update the index numbers to reflect the Pokédex 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](../blob/master/main.asm):
```diff
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](../blob/master/engine/pokedex/pokedex.asm):
```diff
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, wc296
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 [wc296], a
pop hl
pop bc
ret
```
Before we move on, please note "wc296". 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](../blob/master/engine/pokedex/pokedex_2.asm):
```diff
; 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, wc296
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!
|