Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/menus/party_menu.asm
1271 views
1
DrawPartyMenu_::
2
xor a
3
ldh [hAutoBGTransferEnabled], a
4
call ClearScreen
5
call UpdateSprites
6
farcall LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
7
8
RedrawPartyMenu_::
9
ld a, [wPartyMenuTypeOrMessageID]
10
cp SWAP_MONS_PARTY_MENU
11
jp z, .printMessage
12
call ErasePartyMenuCursors
13
farcall InitPartyMenuBlkPacket
14
hlcoord 3, 0
15
ld de, wPartySpecies
16
xor a
17
ld c, a
18
ldh [hPartyMonIndex], a
19
ld [wWhichPartyMenuHPBar], a
20
.loop
21
ld a, [de]
22
cp $FF ; reached the terminator?
23
jp z, .afterDrawingMonEntries
24
push bc
25
push de
26
push hl
27
ld a, c
28
push hl
29
ld hl, wPartyMonNicks
30
call GetPartyMonName
31
pop hl
32
call PlaceString ; print the pokemon's name
33
farcall WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
34
ldh a, [hPartyMonIndex]
35
ld [wWhichPokemon], a
36
inc a
37
ldh [hPartyMonIndex], a
38
call LoadMonData
39
pop hl
40
push hl
41
ld a, [wMenuItemToSwap]
42
and a ; is the player swapping pokemon positions?
43
jr z, .skipUnfilledRightArrow
44
; if the player is swapping pokemon positions
45
dec a
46
ld b, a
47
ld a, [wWhichPokemon]
48
cp b ; is the player swapping the current pokemon in the list?
49
jr nz, .skipUnfilledRightArrow
50
; the player is swapping the current pokemon in the list
51
dec hl
52
dec hl
53
dec hl
54
ld a, "▷" ; unfilled right arrow menu cursor
55
ld [hli], a ; place the cursor
56
inc hl
57
inc hl
58
.skipUnfilledRightArrow
59
ld a, [wPartyMenuTypeOrMessageID] ; menu type
60
cp TMHM_PARTY_MENU
61
jr z, .teachMoveMenu
62
cp EVO_STONE_PARTY_MENU
63
jr z, .evolutionStoneMenu
64
push hl
65
ld bc, 14 ; 14 columns to the right
66
add hl, bc
67
ld de, wLoadedMonStatus
68
call PrintStatusCondition
69
pop hl
70
push hl
71
ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column
72
ldh a, [hUILayoutFlags]
73
set BIT_PARTY_MENU_HP_BAR, a
74
ldh [hUILayoutFlags], a
75
add hl, bc
76
predef DrawHP2 ; draw HP bar and prints current / max HP
77
ldh a, [hUILayoutFlags]
78
res BIT_PARTY_MENU_HP_BAR, a
79
ldh [hUILayoutFlags], a
80
call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
81
pop hl
82
jr .printLevel
83
.teachMoveMenu
84
push hl
85
predef CanLearnTM ; check if the pokemon can learn the move
86
pop hl
87
ld de, .ableToLearnMoveText
88
ld a, c
89
and a
90
jr nz, .placeMoveLearnabilityString
91
ld de, .notAbleToLearnMoveText
92
.placeMoveLearnabilityString
93
ld bc, 20 + 9 ; down 1 row and right 9 columns
94
push hl
95
add hl, bc
96
call PlaceString
97
pop hl
98
.printLevel
99
ld bc, 10 ; move 10 columns to the right
100
add hl, bc
101
call PrintLevel
102
pop hl
103
pop de
104
inc de
105
ld bc, 2 * 20
106
add hl, bc
107
pop bc
108
inc c
109
jp .loop
110
.ableToLearnMoveText
111
db "ABLE@"
112
.notAbleToLearnMoveText
113
db "NOT ABLE@"
114
.evolutionStoneMenu
115
push hl
116
ld hl, EvosMovesPointerTable
117
ld b, 0
118
ld a, [wLoadedMonSpecies]
119
dec a
120
add a
121
rl b
122
ld c, a
123
add hl, bc
124
ld de, wEvoDataBuffer
125
ld a, BANK(EvosMovesPointerTable)
126
ld bc, 2
127
call FarCopyData
128
ld hl, wEvoDataBuffer
129
ld a, [hli]
130
ld h, [hl]
131
ld l, a
132
ld de, wEvoDataBuffer
133
ld a, BANK(EvosMovesPointerTable)
134
ld bc, wEvoDataBufferEnd - wEvoDataBuffer
135
call FarCopyData
136
ld hl, wEvoDataBuffer
137
ld de, .notAbleToEvolveText
138
; loop through the pokemon's evolution entries
139
.checkEvolutionsLoop
140
ld a, [hli]
141
and a ; reached terminator?
142
jr z, .placeEvolutionStoneString ; if so, place the "NOT ABLE" string
143
inc hl
144
inc hl
145
cp EVOLVE_ITEM
146
jr nz, .checkEvolutionsLoop
147
; if it's a stone evolution entry
148
dec hl
149
dec hl
150
ld b, [hl]
151
ld a, [wEvoStoneItemID] ; the stone the player used
152
inc hl
153
inc hl
154
inc hl
155
cp b ; does the player's stone match this evolution entry's stone?
156
jr nz, .checkEvolutionsLoop
157
; if it does match
158
ld de, .ableToEvolveText
159
.placeEvolutionStoneString
160
ld bc, 20 + 9 ; down 1 row and right 9 columns
161
pop hl
162
push hl
163
add hl, bc
164
call PlaceString
165
pop hl
166
jr .printLevel
167
.ableToEvolveText
168
db "ABLE@"
169
.notAbleToEvolveText
170
db "NOT ABLE@"
171
.afterDrawingMonEntries
172
ld b, SET_PAL_PARTY_MENU
173
call RunPaletteCommand
174
.printMessage
175
ld hl, wStatusFlags5
176
ld a, [hl]
177
push af
178
push hl
179
set BIT_NO_TEXT_DELAY, [hl]
180
ld a, [wPartyMenuTypeOrMessageID] ; message ID
181
cp FIRST_PARTY_MENU_TEXT_ID
182
jr nc, .printItemUseMessage
183
add a
184
ld hl, PartyMenuMessagePointers
185
ld b, 0
186
ld c, a
187
add hl, bc
188
ld a, [hli]
189
ld h, [hl]
190
ld l, a
191
call PrintText
192
.done
193
pop hl
194
pop af
195
ld [hl], a
196
ld a, 1
197
ldh [hAutoBGTransferEnabled], a
198
call Delay3
199
jp GBPalNormal
200
.printItemUseMessage
201
and $0F
202
ld hl, PartyMenuItemUseMessagePointers
203
add a
204
ld c, a
205
ld b, 0
206
add hl, bc
207
ld a, [hli]
208
ld h, [hl]
209
ld l, a
210
push hl
211
ld a, [wUsedItemOnWhichPokemon]
212
ld hl, wPartyMonNicks
213
call GetPartyMonName
214
pop hl
215
call PrintText
216
jr .done
217
218
PartyMenuItemUseMessagePointers:
219
dw AntidoteText
220
dw BurnHealText
221
dw IceHealText
222
dw AwakeningText
223
dw ParlyzHealText
224
dw PotionText
225
dw FullHealText
226
dw ReviveText
227
dw RareCandyText
228
229
PartyMenuMessagePointers:
230
dw PartyMenuNormalText
231
dw PartyMenuItemUseText
232
dw PartyMenuBattleText
233
dw PartyMenuUseTMText
234
dw PartyMenuSwapMonText
235
dw PartyMenuItemUseText
236
237
PartyMenuNormalText:
238
text_far _PartyMenuNormalText
239
text_end
240
241
PartyMenuItemUseText:
242
text_far _PartyMenuItemUseText
243
text_end
244
245
PartyMenuBattleText:
246
text_far _PartyMenuBattleText
247
text_end
248
249
PartyMenuUseTMText:
250
text_far _PartyMenuUseTMText
251
text_end
252
253
PartyMenuSwapMonText:
254
text_far _PartyMenuSwapMonText
255
text_end
256
257
PotionText:
258
text_far _PotionText
259
text_end
260
261
AntidoteText:
262
text_far _AntidoteText
263
text_end
264
265
ParlyzHealText:
266
text_far _ParlyzHealText
267
text_end
268
269
BurnHealText:
270
text_far _BurnHealText
271
text_end
272
273
IceHealText:
274
text_far _IceHealText
275
text_end
276
277
AwakeningText:
278
text_far _AwakeningText
279
text_end
280
281
FullHealText:
282
text_far _FullHealText
283
text_end
284
285
ReviveText:
286
text_far _ReviveText
287
text_end
288
289
RareCandyText:
290
text_far _RareCandyText
291
sound_get_item_1 ; probably supposed to play SFX_LEVEL_UP but the wrong music bank is loaded
292
text_promptbutton
293
text_end
294
295
SetPartyMenuHPBarColor:
296
ld hl, wPartyMenuHPBarColors
297
ld a, [wWhichPartyMenuHPBar]
298
ld c, a
299
ld b, 0
300
add hl, bc
301
call GetHealthBarColor
302
ld b, SET_PAL_PARTY_MENU_HP_BARS
303
call RunPaletteCommand
304
ld hl, wWhichPartyMenuHPBar
305
inc [hl]
306
ret
307
308