summaryrefslogtreecommitdiff
path: root/engine/learn.asm
blob: 8f599208d08befbbe1aa93c8c3aa5c09b3f74633 (plain)
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
LearnMove:
	call LoadTileMapToTempTileMap
	ld a, [wCurPartyMon]
	ld hl, wPartyMon1Nickname
	call GetNick
	ld hl, wStringBuffer1
	ld de, wMonOrItemNameBuffer
	ld bc, $b
	call CopyBytes
.loop
	ld hl, wPartyMon1Moves
	ld bc, $30
	ld a, [wCurPartyMon]
	call AddNTimes
	ld d, h
	ld e, l
	ld b, $4
.asm_660f
	ld a, [hl]
	and a
	jr z, .asm_6643
	inc hl
	dec b
	jr nz, .asm_660f
	push de
	call .AlreadyHaveFourMoves
	pop de
	jp c, .ConfirmStopLearning
	push hl
	push de
	ld [wd151], a
	ld b, a
	ld a, [wBattleMode]
	and a
	jr z, .asm_6638
	ld a, [wcbd3]
	cp b
	jr nz, .asm_6638
	xor a
	ld [wcbd3], a
	ld [wcb53], a
.asm_6638
	call GetMoveName
	ld hl, Text_1_2_and_Poof
	call PrintText
	pop de
	pop hl
.asm_6643
	ld a, [wd14d]
	ld [hl], a
	ld bc, $15
	add hl, bc
	push hl
	push de
	dec a
	ld hl, Moves + MOVE_PP ; $5b03
	ld bc, $7
	call AddNTimes
	ld a, BANK(Moves)
	call GetFarByte
	pop de
	pop hl
	ld [hl], a
	ld a, [wBattleMode]
	and a
	jp z, .LearnedMove
	ld a, [wCurPartyMon]
	ld b, a
	ld a, [wCurBattleMon]
	cp b
	jp nz, .LearnedMove
	ld a, [wPlayerSubStatus5]
	bit 3, a
	jp nz, .LearnedMove
	ld h, d
	ld l, e
	ld de, wBattleMonMoves
	ld bc, $4
	call CopyBytes
	ld bc, $11
	add hl, bc
	ld de, wBattleMonPP
	ld bc, $4
	call CopyBytes
	jp .LearnedMove

.ConfirmStopLearning: ; 6694 (1:6694)
	ld hl, Text_StopLearning
	call PrintText
	call YesNoBox
	jp c, .loop
	ld hl, Text_DidNotLearn
	call PrintText
	ld b, $0
	ret

.LearnedMove: ; 66a9 (1:66a9)
	ld hl, Text_LearnedMove
	call PrintText
	ld b, $1
	ret

.AlreadyHaveFourMoves: ; 66b2 (1:66b2)
	push hl
	ld hl, Text_TryingToLearn
	call PrintText
	call YesNoBox
	pop hl
	ret c
	ld bc, -4
	add hl, bc
	push hl
	ld de, wd149
	ld bc, $4
	call CopyBytes
	pop hl
.asm_66cd
	push hl
	ld hl, Text_ForgetWhich
	call PrintText
	hlcoord 5, 2
	ld b, $8
	ld c, $d
	call Textbox
	hlcoord 7, 4
	ld a, $28
	ld [wBuffer1], a
	predef ListMoves
	ld a, $4
	ld [wMenuDataEnd], a
	ld a, $6
	ld [wced9], a
	ld a, [wcfe3]
	inc a
	ld [wceda], a
	ld a, $1
	ld [wcedb], a
	ld [wMenuCursorY], a
	ld [wcee1], a
	ld a, $3
	ld [wMenuJoypadFilter], a
	ld a, $20
	ld [w2DMenuFlags1], a
	xor a
	ld [wcedd], a
	ld a, $20
	ld [wcede], a
	call StaticMenuJoypad
	push af
	call Call_LoadTempTileMapToTileMap
	pop af
	pop hl
	bit 1, a
	jr nz, .asm_6748
	push hl
	ld a, [wMenuCursorY]
	dec a
	ld c, a
	ld b, $0
	add hl, bc
	ld a, [hl]
	push af
	push bc
	call IsHMMove
	pop bc
	pop de
	ld a, d
	jr c, .asm_673f
	pop hl
	add hl, bc
	and a
	ret

.asm_673f
	ld hl, Text_CantForgetHM
	call PrintText
	pop hl
	jr .asm_66cd

.asm_6748
	scf
	ret

Text_LearnedMove:
	text_far Text_LearnedMove_
	db "@"

Text_ForgetWhich:
	text_far Text_ForgetWhich_
	db "@"

Text_StopLearning:
	text_far Text_StopLearning_
	db "@"

Text_DidNotLearn:
	text_far Text_DidNotLearn_
	db "@"

Text_TryingToLearn:
	text_far Text_TryingToLearn_
	db "@"

Text_1_2_and_Poof:
	text_far Text_1_2_and_Poof_
	text_asm
	push de
	ld de, SFX_SWITCH_POKEMON
	call PlaySFX
	pop de
	ld hl, .PoofForgot
	ret

.PoofForgot:
	text_far Text_PoofForgot_
	db "@"

Text_CantForgetHM:
	text_far Text_CantForgetHM_
	db "@"