-
Notifications
You must be signed in to change notification settings - Fork 806
/
evolution_animation.asm
360 lines (308 loc) · 4.93 KB
/
evolution_animation.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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
EvolutionAnimation:
push hl
push de
push bc
ld a, [wCurSpecies]
push af
ldh a, [rOBP0]
push af
ld a, [wBaseDexNo]
push af
call .EvolutionAnimation
pop af
ld [wBaseDexNo], a
pop af
ldh [rOBP0], a
pop af
ld [wCurSpecies], a
pop bc
pop de
pop hl
ld a, [wEvolutionCanceled]
and a
ret z
scf
ret
.EvolutionAnimation:
ld a, %11100100
ldh [rOBP0], a
ld de, MUSIC_NONE
call PlayMusic
farcall ClearSpriteAnims
ld de, .GFX
ld hl, vTiles0
lb bc, BANK(.GFX), 8
call Request2bpp
xor a
ld [wLowHealthAlarm], a
call WaitBGMap
xor a
ldh [hBGMapMode], a
ld a, [wEvolutionOldSpecies]
ld [wPlayerHPPal], a
ld c, FALSE
call .GetSGBLayout
ld a, [wEvolutionOldSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
call .PlaceFrontpic
ld de, vTiles2
ld hl, vTiles2 tile $31
ld bc, 7 * 7
call Request2bpp
ld a, 7 * 7
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
ld a, [wEvolutionNewSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
call .LoadFrontpic
ld a, [wEvolutionOldSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
ld a, 1
ldh [hBGMapMode], a
call .check_statused
jr c, .skip_cry
ld a, [wEvolutionOldSpecies]
call PlayMonCry
.skip_cry
ld de, MUSIC_EVOLUTION
call PlayMusic
ld c, 80
call DelayFrames
ld c, TRUE
call .GetSGBLayout
call .AnimationSequence
jr c, .cancel_evo
ld a, -7 * 7
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
xor a
ld [wEvolutionCanceled], a
ld a, [wEvolutionNewSpecies]
ld [wPlayerHPPal], a
ld c, FALSE
call .GetSGBLayout
call .PlayEvolvedSFX
farcall ClearSpriteAnims
call .check_statused
jr c, .no_anim
ld a, [wBoxAlignment]
push af
ld a, $1
ld [wBoxAlignment], a
ld a, [wCurPartySpecies]
push af
ld a, [wPlayerHPPal]
ld [wCurPartySpecies], a
hlcoord 7, 2
ld d, $0
ld e, ANIM_MON_EVOLVE
predef AnimateFrontpic
pop af
ld [wCurPartySpecies], a
pop af
ld [wBoxAlignment], a
ret
.no_anim
ret
.cancel_evo
ld a, TRUE
ld [wEvolutionCanceled], a
ld a, [wEvolutionOldSpecies]
ld [wPlayerHPPal], a
ld c, FALSE
call .GetSGBLayout
call .PlayEvolvedSFX
farcall ClearSpriteAnims
call .check_statused
ret c
ld a, [wPlayerHPPal]
call PlayMonCry
ret
.GetSGBLayout:
ld b, SCGB_EVOLUTION
jp GetSGBLayout
.PlaceFrontpic:
call GetBaseData
hlcoord 7, 2
jp PrepMonFrontpic
.LoadFrontpic:
call GetBaseData
ld a, $1
ld [wBoxAlignment], a
ld de, vTiles2
predef GetAnimatedFrontpic
xor a
ld [wBoxAlignment], a
ret
.AnimationSequence:
call ClearJoypad
lb bc, 1, 2 * 7 ; flash b times, wait c frames in between
.loop
push bc
call .WaitFrames_CheckPressedB
pop bc
jr c, .exit_sequence
push bc
call .Flash
pop bc
inc b
dec c
dec c
jr nz, .loop
and a
ret
.exit_sequence
scf
ret
.Flash:
ld a, -7 * 7 ; new stage
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
ld a, 7 * 7 ; previous stage
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
dec b
jr nz, .Flash
ret
.ReplaceFrontpic:
push bc
xor a
ldh [hBGMapMode], a
hlcoord 7, 2
lb bc, 7, 7
ld de, SCREEN_WIDTH - 7
.loop1
push bc
.loop2
ld a, [wEvolutionPicOffset]
add [hl]
ld [hli], a
dec c
jr nz, .loop2
pop bc
add hl, de
dec b
jr nz, .loop1
ld a, $1
ldh [hBGMapMode], a
call WaitBGMap
pop bc
ret
.WaitFrames_CheckPressedB:
call DelayFrame
push bc
call JoyTextDelay
ldh a, [hJoyDown]
pop bc
and B_BUTTON
jr nz, .pressed_b
.loop3
dec c
jr nz, .WaitFrames_CheckPressedB
and a
ret
.pressed_b
ld a, [wForceEvolution]
and a
jr nz, .loop3
scf
ret
.check_statused
ld a, [wCurPartyMon]
ld hl, wPartyMon1Species
call GetPartyLocation
ld b, h
ld c, l
farcall CheckFaintedFrzSlp
ret
.PlayEvolvedSFX:
ld a, [wEvolutionCanceled]
and a
ret nz
ld de, SFX_EVOLVED
call PlaySFX
ld hl, wJumptableIndex
ld a, [hl]
push af
ld [hl], $0
.loop4
call .balls_of_light
jr nc, .done
call .AnimateBallsOfLight
jr .loop4
.done
ld c, 32
.loop5
call .AnimateBallsOfLight
dec c
jr nz, .loop5
pop af
ld [wJumptableIndex], a
ret
.balls_of_light
ld hl, wJumptableIndex
ld a, [hl]
cp 32
ret nc
ld d, a
inc [hl]
and $1
jr nz, .done_balls
ld e, $0
call .GenerateBallOfLight
ld e, $10
call .GenerateBallOfLight
.done_balls
scf
ret
.GenerateBallOfLight:
push de
depixel 9, 11
ld a, SPRITE_ANIM_OBJ_EVOLUTION_BALL_OF_LIGHT
call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
add hl, bc
ld a, [wJumptableIndex]
and %1110
sla a
pop de
add e
ld [hl], a
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $0
ld hl, SPRITEANIMSTRUCT_VAR1
add hl, bc
ld [hl], $10
ret
.AnimateBallsOfLight:
push bc
callfar PlaySpriteAnimations
; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES
ldh a, [hVBlankCounter]
and %1110
srl a
inc a
inc a
and $7
ld b, a
ld hl, wShadowOAMSprite00Attributes
ld c, NUM_SPRITE_OAM_STRUCTS
.loop6
ld a, [hl]
or b
ld [hli], a ; attributes
rept SPRITEOAMSTRUCT_LENGTH - 1
inc hl
endr
dec c
jr nz, .loop6
pop bc
call DelayFrame
ret
.GFX:
INCBIN "gfx/evo/bubble_large.2bpp"
INCBIN "gfx/evo/bubble.2bpp"