forked from gameboyadvancesp/understanding-pokemon-red
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlearn_move.asm
224 lines (212 loc) · 3.52 KB
/
learn_move.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
LearnMove:
call SaveScreenTilesToBuffer1
ld a, [wWhichPokemon]
ld hl, wPartyMonNicks
call GetPartyMonName
ld hl, wcd6d
ld de, wLearnMoveMonName
ld bc, NAME_LENGTH
call CopyData
DontAbandonLearning:
ld hl, wPartyMon1Moves
ld bc, wPartyMon2Moves - wPartyMon1Moves
ld a, [wWhichPokemon]
call AddNTimes
ld d, h
ld e, l
ld b, NUM_MOVES
.findEmptyMoveSlotLoop
ld a, [hl]
and a
jr z, .next
inc hl
dec b
jr nz, .findEmptyMoveSlotLoop
push de
call TryingToLearn
pop de
jp c, AbandonLearning
push hl
push de
ld [wd11e], a
call GetMoveName
ld hl, OneTwoAndText
call PrintText
pop de
pop hl
.next
ld a, [wMoveNum]
ld [hl], a
ld bc, wPartyMon1PP - wPartyMon1Moves
add hl, bc
push hl
push de
dec a
ld hl, Moves
ld bc, MoveEnd - Moves
call AddNTimes
ld de, wBuffer
ld a, BANK(Moves)
call FarCopyData
ld a, [wBuffer + 5] ; a = move's max PP
pop de
pop hl
ld [hl], a
jpIfInField PrintLearnedMove
ld a, [wWhichPokemon]
ld b, a
ld a, [wPlayerMonNumber]
cp b
jp nz, PrintLearnedMove
ld h, d
ld l, e
ld de, wBattleMonMoves
ld bc, NUM_MOVES
call CopyData
ld bc, wPartyMon1PP - wPartyMon1OTID
add hl, bc
ld de, wBattleMonPP
ld bc, NUM_MOVES
call CopyData
jp PrintLearnedMove
AbandonLearning:
ld hl, AbandonLearningText
call PrintText
coord hl, 14, 7
lb bc, 8, 15
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu
ld a, [wCurrentMenuItem]
and a
jp nz, DontAbandonLearning
ld hl, DidNotLearnText
call PrintText
ld b, 0
ret
PrintLearnedMove:
ld hl, LearnedMove1Text
call PrintText
ld b, 1
ret
TryingToLearn:
push hl
ld hl, TryingToLearnText
call PrintText
coord hl, 14, 7
lb bc, 8, 15
ld a, TWO_OPTION_MENU
ld [wTextBoxID], a
call DisplayTextBoxID ; yes/no menu
pop hl
ld a, [wCurrentMenuItem]
rra
ret c
ld bc, -NUM_MOVES
add hl, bc
push hl
ld de, wMoves
ld bc, NUM_MOVES
call CopyData
callab FormatMovesString
pop hl
.loop
push hl
ld hl, WhichMoveToForgetText
call PrintText
coord hl, 4, 7
ld b, 4
ld c, 14
call TextBoxBorder
coord hl, 6, 8
ld de, wMovesString
ld a, [hFlags_0xFFF6]
set 2, a
ld [hFlags_0xFFF6], a
call PlaceString
ld a, [hFlags_0xFFF6]
res 2, a
ld [hFlags_0xFFF6], a
ld hl, wTopMenuItemY
ld a, 8
ld [hli], a ; wTopMenuItemY
ld a, 5
ld [hli], a ; wTopMenuItemX
xor a
ld [hli], a ; wCurrentMenuItem
inc hl
ld a, [wNumMovesMinusOne]
ld [hli], a ; wMaxMenuItem
ld a, A_BUTTON | B_BUTTON
ld [hli], a ; wMenuWatchedKeys
ld [hl], 0 ; wLastMenuItem
ld hl, hFlags_0xFFF6
set 1, [hl]
call HandleMenuInput
ld hl, hFlags_0xFFF6
res 1, [hl]
push af
call LoadScreenTilesFromBuffer1
pop af
pop hl
bit 1, a ; pressed b
jr nz, .cancel
push hl
ld a, [wCurrentMenuItem]
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
push af
push bc
call IsMoveHM
pop bc
pop de
ld a, d
jr c, .hm
pop hl
add hl, bc
and a
ret
.hm
ld hl, HMCantDeleteText
call PrintText
pop hl
jr .loop
.cancel
scf
ret
LearnedMove1Text:
TX_FAR _LearnedMove1Text
TX_SFX_ITEM_1 ; plays SFX_GET_ITEM_1 in the party menu (rare candy) and plays SFX_LEVEL_UP in battle
TX_BLINK
db "@"
WhichMoveToForgetText:
TX_FAR _WhichMoveToForgetText
db "@"
AbandonLearningText:
TX_FAR _AbandonLearningText
db "@"
DidNotLearnText:
TX_FAR _DidNotLearnText
db "@"
TryingToLearnText:
TX_FAR _TryingToLearnText
db "@"
OneTwoAndText:
TX_FAR _OneTwoAndText
TX_DELAY
TX_ASM
ld a, SFX_SWAP
call PlaySoundWaitForCurrent
ld hl, PoofText
ret
PoofText:
TX_FAR _PoofText
TX_DELAY
ForgotAndText:
TX_FAR _ForgotAndText
db "@"
HMCantDeleteText:
TX_FAR _HMCantDeleteText
db "@"