forked from waicalibre/pokered-eo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
party_menu.asm
executable file
·306 lines (288 loc) · 5.75 KB
/
party_menu.asm
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
DrawPartyMenu_::
xor a
ldh [hAutoBGTransferEnabled], a
call ClearScreen
call UpdateSprites
farcall LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
RedrawPartyMenu_::
ld a, [wPartyMenuTypeOrMessageID]
cp SWAP_MONS_PARTY_MENU
jp z, .printMessage
call ErasePartyMenuCursors
farcall InitPartyMenuBlkPacket
hlcoord 3, 0
ld de, wPartySpecies
xor a
ld c, a
ldh [hPartyMonIndex], a
ld [wWhichPartyMenuHPBar], a
.loop
ld a, [de]
cp $FF ; reached the terminator?
jp z, .afterDrawingMonEntries
push bc
push de
push hl
ld a, c
push hl
ld hl, wPartyMonNicks
call GetPartyMonName
pop hl
call PlaceString ; print the pokemon's name
farcall WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
ldh a, [hPartyMonIndex]
ld [wWhichPokemon], a
inc a
ldh [hPartyMonIndex], a
call LoadMonData
pop hl
push hl
ld a, [wMenuItemToSwap]
and a ; is the player swapping pokemon positions?
jr z, .skipUnfilledRightArrow
; if the player is swapping pokemon positions
dec a
ld b, a
ld a, [wWhichPokemon]
cp b ; is the player swapping the current pokemon in the list?
jr nz, .skipUnfilledRightArrow
; the player is swapping the current pokemon in the list
dec hl
dec hl
dec hl
ld a, "▷" ; unfilled right arrow menu cursor
ld [hli], a ; place the cursor
inc hl
inc hl
.skipUnfilledRightArrow
ld a, [wPartyMenuTypeOrMessageID] ; menu type
cp TMHM_PARTY_MENU
jr z, .teachMoveMenu
cp EVO_STONE_PARTY_MENU
jr z, .evolutionStoneMenu
push hl
ld bc, 14 ; 14 columns to the right
add hl, bc
ld de, wLoadedMonStatus
call PrintStatusCondition
pop hl
push hl
ld bc, SCREEN_WIDTH + 1 ; down 1 row and right 1 column
ldh a, [hFlagsFFF6]
set 0, a
ldh [hFlagsFFF6], a
add hl, bc
predef DrawHP2 ; draw HP bar and prints current / max HP
ldh a, [hFlagsFFF6]
res 0, a
ldh [hFlagsFFF6], a
call SetPartyMenuHPBarColor ; color the HP bar (on SGB)
pop hl
jr .printLevel
.teachMoveMenu
push hl
predef CanLearnTM ; check if the pokemon can learn the move
pop hl
ld de, .ableToLearnMoveText
ld a, c
and a
jr nz, .placeMoveLearnabilityString
ld de, .notAbleToLearnMoveText
.placeMoveLearnabilityString
ld bc, 20 + 9 ; down 1 row and right 9 columns
push hl
add hl, bc
call PlaceString
pop hl
.printLevel
ld bc, 10 ; move 10 columns to the right
add hl, bc
call PrintLevel
pop hl
pop de
inc de
ld bc, 2 * 20
add hl, bc
pop bc
inc c
jp .loop
.ableToLearnMoveText
db "ABLE@"
.notAbleToLearnMoveText
db "NOT ABLE@"
.evolutionStoneMenu
push hl
ld hl, EvosMovesPointerTable
ld b, 0
ld a, [wLoadedMonSpecies]
dec a
add a
rl b
ld c, a
add hl, bc
ld de, wEvosMoves
ld a, BANK(EvosMovesPointerTable)
ld bc, 2
call FarCopyData
ld hl, wEvosMoves
ld a, [hli]
ld h, [hl]
ld l, a
ld de, wEvosMoves
ld a, BANK(EvosMovesPointerTable)
ld bc, wEvosMoves.end - wEvosMoves
call FarCopyData
ld hl, wEvosMoves
ld de, .notAbleToEvolveText
; loop through the pokemon's evolution entries
.checkEvolutionsLoop
ld a, [hli]
and a ; reached terminator?
jr z, .placeEvolutionStoneString ; if so, place the "NOT ABLE" string
inc hl
inc hl
cp EV_ITEM
jr nz, .checkEvolutionsLoop
; if it's a stone evolution entry
dec hl
dec hl
ld b, [hl]
ld a, [wEvoStoneItemID] ; the stone the player used
inc hl
inc hl
inc hl
cp b ; does the player's stone match this evolution entry's stone?
jr nz, .checkEvolutionsLoop
; if it does match
ld de, .ableToEvolveText
.placeEvolutionStoneString
ld bc, 20 + 9 ; down 1 row and right 9 columns
pop hl
push hl
add hl, bc
call PlaceString
pop hl
jr .printLevel
.ableToEvolveText
db "ABLE@"
.notAbleToEvolveText
db "NOT ABLE@"
.afterDrawingMonEntries
ld b, SET_PAL_PARTY_MENU
call RunPaletteCommand
.printMessage
ld hl, wd730
ld a, [hl]
push af
push hl
set 6, [hl] ; turn off letter printing delay
ld a, [wPartyMenuTypeOrMessageID] ; message ID
cp FIRST_PARTY_MENU_TEXT_ID
jr nc, .printItemUseMessage
add a
ld hl, PartyMenuMessagePointers
ld b, 0
ld c, a
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
.done
pop hl
pop af
ld [hl], a
ld a, 1
ldh [hAutoBGTransferEnabled], a
call Delay3
jp GBPalNormal
.printItemUseMessage
and $0F
ld hl, PartyMenuItemUseMessagePointers
add a
ld c, a
ld b, 0
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
push hl
ld a, [wUsedItemOnWhichPokemon]
ld hl, wPartyMonNicks
call GetPartyMonName
pop hl
call PrintText
jr .done
PartyMenuItemUseMessagePointers:
dw AntidoteText
dw BurnHealText
dw IceHealText
dw AwakeningText
dw ParlyzHealText
dw PotionText
dw FullHealText
dw ReviveText
dw RareCandyText
PartyMenuMessagePointers:
dw PartyMenuNormalText
dw PartyMenuItemUseText
dw PartyMenuBattleText
dw PartyMenuUseTMText
dw PartyMenuSwapMonText
dw PartyMenuItemUseText
PartyMenuNormalText:
text_far _PartyMenuNormalText
text_end
PartyMenuItemUseText:
text_far _PartyMenuItemUseText
text_end
PartyMenuBattleText:
text_far _PartyMenuBattleText
text_end
PartyMenuUseTMText:
text_far _PartyMenuUseTMText
text_end
PartyMenuSwapMonText:
text_far _PartyMenuSwapMonText
text_end
PotionText:
text_far _PotionText
text_end
AntidoteText:
text_far _AntidoteText
text_end
ParlyzHealText:
text_far _ParlyzHealText
text_end
BurnHealText:
text_far _BurnHealText
text_end
IceHealText:
text_far _IceHealText
text_end
AwakeningText:
text_far _AwakeningText
text_end
FullHealText:
text_far _FullHealText
text_end
ReviveText:
text_far _ReviveText
text_end
RareCandyText:
text_far _RareCandyText
sound_get_item_1 ; probably supposed to play SFX_LEVEL_UP but the wrong music bank is loaded
text_promptbutton
text_end
SetPartyMenuHPBarColor:
ld hl, wPartyMenuHPBarColors
ld a, [wWhichPartyMenuHPBar]
ld c, a
ld b, 0
add hl, bc
call GetHealthBarColor
ld b, SET_PAL_PARTY_MENU_HP_BARS
call RunPaletteCommand
ld hl, wWhichPartyMenuHPBar
inc [hl]
ret