summaryrefslogtreecommitdiff
path: root/scripts/daycarem.asm
blob: 1830d2c0598995dd8142fda949bdda3d8c9c976f (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
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
DayCareMScript: ; 5624f (15:624f)
	jp EnableAutoTextBoxDrawing

DayCareMTextPointers: ; 56252 (15:6252)
	dw DayCareMText1

DayCareMText1: ; 56254 (15:6254)
	db $8
	call SaveScreenTilesToBuffer2
	ld a, [W_DAYCARE_IN_USE]
	and a
	jp nz, DayCareMScript_562e1
	ld hl, DayCareMText_5640f
	call PrintText
	call YesNoChoice
	ld a, [wCurrentMenuItem]
	and a
	ld hl, DayCareMText_5643b
	jp nz, DayCareMScript_56409
	ld a, [wPartyCount]
	dec a
	ld hl, DayCareMText_56445
	jp z, DayCareMScript_56409
	ld hl, DayCareMText_56414
	call PrintText
	xor a
	ld [wUpdateSpritesEnabled], a
	ld [wd07d], a
	ld [wMenuItemToSwap], a
	call DisplayPartyMenu
	push af
	call GBPalWhiteOutWithDelay3
	call RestoreScreenTilesAndReloadTilePatterns
	call LoadGBPal
	pop af
	ld hl, DayCareMText_56437
	jp c, DayCareMScript_56409
	callab Func_2171b
	ld hl, DayCareMText_5644a
	jp c, DayCareMScript_56409
	xor a
	ld [wcc2b], a
	ld a, [wWhichPokemon]
	ld hl, wPartyMonNicks
	call GetPartyMonName
	ld hl, DayCareMText_56419
	call PrintText
	ld a, $1
	ld [W_DAYCARE_IN_USE], a
	ld a, $3
	ld [wcf95], a
	call Func_3a68
	xor a
	ld [wcf95], a
	call RemovePokemon
	ld a, [wcf91]
	call PlayCry
	ld hl, DayCareMText_5641e
	jp DayCareMScript_56409

DayCareMScript_562e1: ; 562e1 (15:62e1)
	xor a
	ld hl, W_DAYCAREMONNAME
	call GetPartyMonName
	ld a, $3
	ld [wcc49], a
	call LoadMonData
	callab CalcLevelFromExperience
	ld a, d
	cp MAX_LEVEL
	jr c, .asm_56315
	ld d, MAX_LEVEL
	callab CalcExperience
	ld hl, wDayCareMonExp
	ld a, [H_NUMTOPRINT]
	ld [hli], a
	ld a, [$ff97]
	ld [hli], a
	ld a, [$ff98]
	ld [hl], a
	ld d, MAX_LEVEL

.asm_56315
	xor a
	ld [wTrainerEngageDistance], a
	ld hl, wDayCareMonBoxLevel
	ld a, [hl]
	ld [wTrainerSpriteOffset], a
	cp d
	ld [hl], d
	ld hl, DayCareMText_56432
	jr z, .asm_56333
	ld a, [wTrainerSpriteOffset]
	ld b, a
	ld a, d
	sub b
	ld [wTrainerEngageDistance], a
	ld hl, DayCareMText_56423

.asm_56333
	call PrintText
	ld a, [wPartyCount]
	cp PARTY_LENGTH
	ld hl, DayCareMText_56440
	jp z, .asm_56403
	ld de, wTrainerFacingDirection
	xor a
	ld [de], a
	inc de
	ld [de], a
	ld hl, wTrainerScreenX
	ld a, $1
	ld [hli], a
	ld [hl], $0
	ld a, [wTrainerEngageDistance]
	inc a
	ld b, a
	ld c, $2
.asm_56357
	push hl
	push de
	push bc
	predef AddBCDPredef
	pop bc
	pop de
	pop hl
	dec b
	jr nz, .asm_56357
	ld hl, DayCareMText_56428
	call PrintText
	ld a, $13
	ld [wTextBoxID], a
	call DisplayTextBoxID
	call YesNoChoice
	ld hl, DayCareMText_56437
	ld a, [wCurrentMenuItem]
	and a
	jp nz, .asm_56403
	ld hl, wTrainerFacingDirection
	ld [$ff9f], a
	ld a, [hli]
	ld [$ffa0], a
	ld a, [hl]
	ld [$ffa1], a
	call HasEnoughMoney
	jr nc, .asm_56396
	ld hl, DayCareMText_56454
	jp .asm_56403

.asm_56396
	xor a
	ld [W_DAYCARE_IN_USE], a
	ld hl, wTrainerEngageDistance
	ld [hli], a
	inc hl
	ld de, wPlayerMoney + 2
	ld c, $3
	predef SubBCDPredef
	ld a, (SFX_02_5a - SFX_Headers_02) / 3
	call PlaySoundWaitForCurrent
	ld a, $13
	ld [wTextBoxID], a
	call DisplayTextBoxID
	ld hl, DayCareMText_5644f
	call PrintText
	ld a, $2
	ld [wcf95], a
	call Func_3a68
	ld a, [wDayCareMonSpecies]
	ld [wcf91], a
	ld a, [wPartyCount]
	dec a
	push af
	ld bc, $002c
	push bc
	ld hl, wPartyMon1Moves
	call AddNTimes
	ld d, h
	ld e, l
	ld a, $1
	ld [wHPBarMaxHP], a
	predef WriteMonMoves
	pop bc
	pop af
	ld hl, wPartyMon1HP
	call AddNTimes
	ld d, h
	ld e, l
	ld bc, $0021
	add hl, bc
	ld a, [hli]
	ld [de], a
	inc de
	ld a, [hl]
	ld [de], a
	ld a, [wcf91]
	call PlayCry
	ld hl, DayCareMText_5642d
	jr DayCareMScript_56409

.asm_56403
	ld a, [wTrainerSpriteOffset]
	ld [wDayCareMonBoxLevel], a

DayCareMScript_56409: ; 56409 (15:6409)
	call PrintText
	jp TextScriptEnd

DayCareMText_5640f: ; 5640f (15:640f)
	TX_FAR _DayCareMText_5640f
	db "@"

DayCareMText_56414: ; 56414 (15:6414)
	TX_FAR _DayCareMText_56414
	db "@"

DayCareMText_56419: ; 56419 (15:6419)
	TX_FAR _DayCareMText_56419
	db "@"

DayCareMText_5641e: ; 5641e (15:641e)
	TX_FAR _DayCareMText_5641e
	db "@"

DayCareMText_56423: ; 56423 (15:6423)
	TX_FAR _DayCareMText_56423
	db "@"

DayCareMText_56428: ; 56428 (15:6428)
	TX_FAR _DayCareMText_56428
	db "@"

DayCareMText_5642d: ; 5642d (15:642d)
	TX_FAR _DayCareMText_5642d
	db "@"

DayCareMText_56432: ; 56432 (15:6432)
	TX_FAR _DayCareMText_56432
	db "@"

DayCareMText_56437: ; 56437 (15:6437)
	TX_FAR _DayCareMText_56437 ; 0x8c000
DayCareMText_5643b: ; 5643b (15:643b)
	TX_FAR _DayCareMText_5643b ; 0x8c013
	db "@"

DayCareMText_56440: ; 56440 (15:6440)
	TX_FAR _DayCareMText_56440
	db "@"

DayCareMText_56445: ; 56445 (15:6445)
	TX_FAR _DayCareMText_56445
	db "@"

DayCareMText_5644a: ; 5644a (15:644a)
	TX_FAR _DayCareMText_5644a
	db "@"

DayCareMText_5644f: ; 5644f (15:644f)
	TX_FAR _DayCareMText_5644f
	db "@"

DayCareMText_56454: ; 56454 (15:6454)
	TX_FAR _DayCareMText_56454
	db "@"