-
Notifications
You must be signed in to change notification settings - Fork 993
/
Daycare.asm
270 lines (245 loc) · 4.73 KB
/
Daycare.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
Daycare_Script:
jp EnableAutoTextBoxDrawing
Daycare_TextPointers:
def_text_pointers
dw_const DaycareGentlemanText, TEXT_DAYCARE_GENTLEMAN
DaycareGentlemanText:
text_asm
call SaveScreenTilesToBuffer2
ld a, [wDayCareInUse]
and a
jp nz, .daycareInUse
ld hl, .IntroText
call PrintText
call YesNoChoice
ld a, [wCurrentMenuItem]
and a
ld hl, .ComeAgainText
jp nz, .done
ld a, [wPartyCount]
dec a
ld hl, .OnlyHaveOneMonText
jp z, .done
ld hl, .WhichMonText
call PrintText
xor a
ld [wUpdateSpritesEnabled], a
ld [wPartyMenuTypeOrMessageID], a
ld [wMenuItemToSwap], a
call DisplayPartyMenu
push af
call GBPalWhiteOutWithDelay3
call RestoreScreenTilesAndReloadTilePatterns
call LoadGBPal
pop af
ld hl, .AllRightThenText
jp c, .done
callfar KnowsHMMove
ld hl, .CantAcceptMonWithHMText
jp c, .done
xor a
ld [wPartyAndBillsPCSavedMenuItem], a
ld a, [wWhichPokemon]
ld hl, wPartyMonNicks
call GetPartyMonName
ld hl, .WillLookAfterMonText
call PrintText
ld a, 1
ld [wDayCareInUse], a
ld a, PARTY_TO_DAYCARE
ld [wMoveMonType], a
call MoveMon
xor a
ld [wRemoveMonFromBox], a
call RemovePokemon
ld a, [wCurPartySpecies]
call PlayCry
ld hl, .ComeSeeMeInAWhileText
jp .done
.daycareInUse
xor a
ld hl, wDayCareMonName
call GetPartyMonName
ld a, DAYCARE_DATA
ld [wMonDataLocation], a
call LoadMonData
callfar CalcLevelFromExperience
ld a, d
cp MAX_LEVEL
jr c, .skipCalcExp
ld d, MAX_LEVEL
callfar CalcExperience
ld hl, wDayCareMonExp
ldh a, [hExperience]
ld [hli], a
ldh a, [hExperience + 1]
ld [hli], a
ldh a, [hExperience + 2]
ld [hl], a
ld d, MAX_LEVEL
.skipCalcExp
xor a
ld [wDayCareNumLevelsGrown], a
ld hl, wDayCareMonBoxLevel
ld a, [hl]
ld [wDayCareStartLevel], a
cp d
ld [hl], d
ld hl, .MonNeedsMoreTimeText
jr z, .next
ld a, [wDayCareStartLevel]
ld b, a
ld a, d
sub b
ld [wDayCareNumLevelsGrown], a
ld hl, .MonHasGrownText
.next
call PrintText
ld a, [wPartyCount]
cp PARTY_LENGTH
ld hl, .NoRoomForMonText
jp z, .leaveMonInDayCare
ld de, wDayCareTotalCost
xor a
ld [de], a
inc de
ld [de], a
ld hl, wDayCarePerLevelCost
ld a, $1
ld [hli], a
ld [hl], $0
ld a, [wDayCareNumLevelsGrown]
inc a
ld b, a
ld c, 2
.calcPriceLoop
push hl
push de
push bc
predef AddBCDPredef
pop bc
pop de
pop hl
dec b
jr nz, .calcPriceLoop
ld hl, .OweMoneyText
call PrintText
ld a, MONEY_BOX
ld [wTextBoxID], a
call DisplayTextBoxID
call YesNoChoice
ld hl, .AllRightThenText
ld a, [wCurrentMenuItem]
and a
jp nz, .leaveMonInDayCare
ld hl, wDayCareTotalCost
ldh [hMoney], a
ld a, [hli]
ldh [hMoney + 1], a
ld a, [hl]
ldh [hMoney + 2], a
call HasEnoughMoney
jr nc, .enoughMoney
ld hl, .NotEnoughMoneyText
jp .leaveMonInDayCare
.enoughMoney
xor a
ld [wDayCareInUse], a
ld hl, wDayCareNumLevelsGrown
ld [hli], a
inc hl
ld de, wPlayerMoney + 2
ld c, $3
predef SubBCDPredef
ld a, SFX_PURCHASE
call PlaySoundWaitForCurrent
ld a, MONEY_BOX
ld [wTextBoxID], a
call DisplayTextBoxID
ld hl, .HeresYourMonText
call PrintText
ld a, DAYCARE_TO_PARTY
ld [wMoveMonType], a
call MoveMon
ld a, [wDayCareMonSpecies]
ld [wCurPartySpecies], a
ld a, [wPartyCount]
dec a
push af
ld bc, wPartyMon2 - wPartyMon1
push bc
ld hl, wPartyMon1Moves
call AddNTimes
ld d, h
ld e, l
ld a, 1
ld [wLearningMovesFromDayCare], a
predef WriteMonMoves
pop bc
pop af
; set mon's HP to max
ld hl, wPartyMon1HP
call AddNTimes
ld d, h
ld e, l
ld bc, wPartyMon1MaxHP - wPartyMon1HP
add hl, bc
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
ld a, [wCurPartySpecies]
call PlayCry
ld hl, .GotMonBackText
jr .done
.leaveMonInDayCare
ld a, [wDayCareStartLevel]
ld [wDayCareMonBoxLevel], a
.done
call PrintText
jp TextScriptEnd
.IntroText:
text_far _DaycareGentlemanIntroText
text_end
.WhichMonText:
text_far _DaycareGentlemanWhichMonText
text_end
.WillLookAfterMonText:
text_far _DaycareGentlemanWillLookAfterMonText
text_end
.ComeSeeMeInAWhileText:
text_far _DaycareGentlemanComeSeeMeInAWhileText
text_end
.MonHasGrownText:
text_far _DaycareGentlemanMonHasGrownText
text_end
.OweMoneyText:
text_far _DaycareGentlemanOweMoneyText
text_end
.GotMonBackText:
text_far _DaycareGentlemanGotMonBackText
text_end
.MonNeedsMoreTimeText:
text_far _DaycareGentlemanMonNeedsMoreTimeText
text_end
.AllRightThenText:
text_far _DaycareGentlemanAllRightThenText
.ComeAgainText:
text_far _DaycareGentlemanComeAgainText
text_end
.NoRoomForMonText:
text_far _DaycareGentlemanNoRoomForMonText
text_end
.OnlyHaveOneMonText:
text_far _DaycareGentlemanOnlyHaveOneMonText
text_end
.CantAcceptMonWithHMText:
text_far _DaycareGentlemanCantAcceptMonWithHMText
text_end
.HeresYourMonText:
text_far _DaycareGentlemanHeresYourMonText
text_end
.NotEnoughMoneyText:
text_far _DaycareGentlemanNotEnoughMoneyText
text_end