Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/pokemon/learn_move.asm
1271 views
1
LearnMove:
2
call SaveScreenTilesToBuffer1
3
ld a, [wWhichPokemon]
4
ld hl, wPartyMonNicks
5
call GetPartyMonName
6
ld hl, wNameBuffer
7
ld de, wLearnMoveMonName
8
ld bc, NAME_LENGTH
9
call CopyData
10
11
DontAbandonLearning:
12
ld hl, wPartyMon1Moves
13
ld bc, wPartyMon2Moves - wPartyMon1Moves
14
ld a, [wWhichPokemon]
15
call AddNTimes
16
ld d, h
17
ld e, l
18
ld b, NUM_MOVES
19
.findEmptyMoveSlotLoop
20
ld a, [hl]
21
and a
22
jr z, .next
23
inc hl
24
dec b
25
jr nz, .findEmptyMoveSlotLoop
26
push de
27
call TryingToLearn
28
pop de
29
jp c, AbandonLearning
30
push hl
31
push de
32
ld [wNamedObjectIndex], a
33
call GetMoveName
34
ld hl, OneTwoAndText
35
call PrintText
36
pop de
37
pop hl
38
.next
39
ld a, [wMoveNum]
40
ld [hl], a
41
ld bc, wPartyMon1PP - wPartyMon1Moves
42
add hl, bc
43
push hl
44
push de
45
dec a
46
ld hl, Moves
47
ld bc, MOVE_LENGTH
48
call AddNTimes
49
ld de, wBuffer
50
ld a, BANK(Moves)
51
call FarCopyData
52
ld a, [wBuffer + 5] ; a = move's max PP
53
pop de
54
pop hl
55
ld [hl], a
56
ld a, [wIsInBattle]
57
and a
58
jp z, PrintLearnedMove
59
ld a, [wWhichPokemon]
60
ld b, a
61
ld a, [wPlayerMonNumber]
62
cp b
63
jp nz, PrintLearnedMove
64
ld h, d
65
ld l, e
66
ld de, wBattleMonMoves
67
ld bc, NUM_MOVES
68
call CopyData
69
ld bc, wPartyMon1PP - wPartyMon1OTID
70
add hl, bc
71
ld de, wBattleMonPP
72
ld bc, NUM_MOVES
73
call CopyData
74
jp PrintLearnedMove
75
76
AbandonLearning:
77
ld hl, AbandonLearningText
78
call PrintText
79
hlcoord 14, 7
80
lb bc, 8, 15
81
ld a, TWO_OPTION_MENU
82
ld [wTextBoxID], a
83
call DisplayTextBoxID ; yes/no menu
84
ld a, [wCurrentMenuItem]
85
and a
86
jp nz, DontAbandonLearning
87
ld hl, DidNotLearnText
88
call PrintText
89
ld b, 0
90
ret
91
92
PrintLearnedMove:
93
ld hl, LearnedMove1Text
94
call PrintText
95
ld b, 1
96
ret
97
98
TryingToLearn:
99
push hl
100
ld hl, TryingToLearnText
101
call PrintText
102
hlcoord 14, 7
103
lb bc, 8, 15
104
ld a, TWO_OPTION_MENU
105
ld [wTextBoxID], a
106
call DisplayTextBoxID ; yes/no menu
107
pop hl
108
ld a, [wCurrentMenuItem]
109
rra
110
ret c
111
ld bc, -NUM_MOVES
112
add hl, bc
113
push hl
114
ld de, wMoves
115
ld bc, NUM_MOVES
116
call CopyData
117
callfar FormatMovesString
118
pop hl
119
.loop
120
push hl
121
ld hl, WhichMoveToForgetText
122
call PrintText
123
hlcoord 4, 7
124
ld b, 4
125
ld c, 14
126
call TextBoxBorder
127
hlcoord 6, 8
128
ld de, wMovesString
129
ldh a, [hUILayoutFlags]
130
set BIT_SINGLE_SPACED_LINES, a
131
ldh [hUILayoutFlags], a
132
call PlaceString
133
ldh a, [hUILayoutFlags]
134
res BIT_SINGLE_SPACED_LINES, a
135
ldh [hUILayoutFlags], a
136
ld hl, wTopMenuItemY
137
ld a, 8
138
ld [hli], a ; wTopMenuItemY
139
ld a, 5
140
ld [hli], a ; wTopMenuItemX
141
xor a
142
ld [hli], a ; wCurrentMenuItem
143
inc hl
144
ld a, [wNumMovesMinusOne]
145
ld [hli], a ; wMaxMenuItem
146
ld a, PAD_A | PAD_B
147
ld [hli], a ; wMenuWatchedKeys
148
ld [hl], 0 ; wLastMenuItem
149
ld hl, hUILayoutFlags
150
set BIT_DOUBLE_SPACED_MENU, [hl]
151
call HandleMenuInput
152
ld hl, hUILayoutFlags
153
res BIT_DOUBLE_SPACED_MENU, [hl]
154
push af
155
call LoadScreenTilesFromBuffer1
156
pop af
157
pop hl
158
bit B_PAD_B, a
159
jr nz, .cancel
160
push hl
161
ld a, [wCurrentMenuItem]
162
ld c, a
163
ld b, 0
164
add hl, bc
165
ld a, [hl]
166
push af
167
push bc
168
call IsMoveHM
169
pop bc
170
pop de
171
ld a, d
172
jr c, .hm
173
pop hl
174
add hl, bc
175
and a
176
ret
177
.hm
178
ld hl, HMCantDeleteText
179
call PrintText
180
pop hl
181
jr .loop
182
.cancel
183
scf
184
ret
185
186
LearnedMove1Text:
187
text_far _LearnedMove1Text
188
sound_get_item_1 ; plays SFX_GET_ITEM_1 in the party menu (rare candy) and plays SFX_LEVEL_UP in battle
189
text_promptbutton
190
text_end
191
192
WhichMoveToForgetText:
193
text_far _WhichMoveToForgetText
194
text_end
195
196
AbandonLearningText:
197
text_far _AbandonLearningText
198
text_end
199
200
DidNotLearnText:
201
text_far _DidNotLearnText
202
text_end
203
204
TryingToLearnText:
205
text_far _TryingToLearnText
206
text_end
207
208
OneTwoAndText:
209
text_far _OneTwoAndText
210
text_pause
211
text_asm
212
ld a, SFX_SWAP
213
call PlaySoundWaitForCurrent
214
ld hl, PoofText
215
ret
216
217
PoofText:
218
text_far _PoofText
219
text_pause
220
ForgotAndText:
221
text_far _ForgotAndText
222
text_end
223
224
HMCantDeleteText:
225
text_far _HMCantDeleteText
226
text_end
227
228