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
|
; reads the animation commands from PointerTable_AttackAnimation
; of attack in wLoadedAttackAnimation and plays them
PlayAttackAnimationCommands:
ld a, [wLoadedAttackAnimation]
or a
ret z
ld l, a
ld h, 0
add hl, hl
ld de, PointerTable_AttackAnimation
add hl, de
ld e, [hl]
inc hl
ld d, [hl]
push de
ld hl, wce7e
ld a, [hl]
or a
jr nz, .read_command
ld [hl], $01
call Func_3b21
pop de
push de
ld a, DUEL_ANIM_SCREEN_MAIN_SCENE
ld [wDuelAnimationScreen], a
ld a, $01
ld [wd4b3], a
xor a
ld [wDuelAnimLocationParam], a
ld a, [de]
cp $04
jr z, .read_command
ld a, DUEL_ANIM_150
call PlayDuelAnimation
.read_command
pop de
; fallthrough
PlayAttackAnimationCommands_NextCommand:
ld a, [de]
inc de
ld hl, AnimationCommandPointerTable
jp JumpToFunctionInTable
AnimationCommand_AnimEnd:
ret
AnimationCommand_AnimPlayer:
ldh a, [hWhoseTurn]
ld [wDuelAnimDuelistSide], a
ld a, [wDuelType]
cp $00
jr nz, AnimationCommand_AnimNormal
ld a, PLAYER_TURN
ld [wDuelAnimDuelistSide], a
jr AnimationCommand_AnimNormal
AnimationCommand_AnimOpponent:
call SwapTurn
ldh a, [hWhoseTurn]
ld [wDuelAnimDuelistSide], a
call SwapTurn
ld a, [wDuelType]
cp $00
jr nz, AnimationCommand_AnimNormal
ld a, OPPONENT_TURN
ld [wDuelAnimDuelistSide], a
jr AnimationCommand_AnimNormal
AnimationCommand_AnimUnknown2:
ld a, [wce82]
and $7f
ld [wDuelAnimLocationParam], a
jr AnimationCommand_AnimNormal
AnimationCommand_AnimEnd2:
ret
AnimationCommand_AnimNormal:
ld a, [de]
inc de
cp DUEL_ANIM_SHOW_DAMAGE
jr z, .show_damage
cp DUEL_ANIM_SHAKE1
jr z, .shake_1
cp DUEL_ANIM_SHAKE2
jr z, .shake_2
cp DUEL_ANIM_SHAKE3
jr z, .shake_3
.play_anim
call PlayDuelAnimation
jr PlayAttackAnimationCommands_NextCommand
.show_damage
ld a, DUEL_ANIM_PRINT_DAMAGE
call PlayDuelAnimation
ld a, [wce81]
ld [wd4b3], a
push de
ld hl, wce7f
ld de, wDuelAnimDamage
ld a, [hli]
ld [de], a
inc de
ld a, [hli]
ld [de], a
pop de
ld a, $8c
call PlayDuelAnimation
ld a, [wDuelDisplayedScreen]
cp DUEL_MAIN_SCENE
jr nz, .skip_update_hud
ld a, DUEL_ANIM_UPDATE_HUD
call PlayDuelAnimation
.skip_update_hud
jp PlayAttackAnimationCommands_NextCommand
; screen shake happens differently
; depending on whose turn it is
.shake_1
ld c, DUEL_ANIM_SMALL_SHAKE_X
ld b, DUEL_ANIM_SMALL_SHAKE_Y
jr .check_duelist
.shake_2
ld c, DUEL_ANIM_BIG_SHAKE_X
ld b, DUEL_ANIM_BIG_SHAKE_Y
jr .check_duelist
.shake_3
ld c, DUEL_ANIM_SMALL_SHAKE_Y
ld b, DUEL_ANIM_SMALL_SHAKE_X
.check_duelist
ldh a, [hWhoseTurn]
cp PLAYER_TURN
ld a, c
jr z, .play_anim
ld a, [wDuelType]
cp $00
ld a, c
jr z, .play_anim
ld a, b
jr .play_anim
AnimationCommand_AnimUnknown:
ld a, [de]
inc de
ld [wd4b3], a
ld a, [wce82]
ld [wDuelAnimLocationParam], a
call SetDuelAnimationScreen
ld a, DUEL_ANIM_150
call PlayDuelAnimation
jp PlayAttackAnimationCommands_NextCommand
AnimationCommandPointerTable:
dw AnimationCommand_AnimEnd ; anim_end
dw AnimationCommand_AnimNormal ; anim_normal
dw AnimationCommand_AnimPlayer ; anim_player
dw AnimationCommand_AnimOpponent ; anim_opponent
dw AnimationCommand_AnimUnknown ; anim_unknown
dw AnimationCommand_AnimUnknown2 ; anim_unknown2
dw AnimationCommand_AnimEnd2 ; anim_end2 (unused)
; sets wDuelAnimationScreen according to wd4b3
; if wd4b3 == $01, set it to Main Scene
; if wd4b3 == $04, st it to Play Area scene
SetDuelAnimationScreen:
ld a, [wd4b3]
cp $04
jr z, .set_play_area_screen
cp $01
ret nz
ld a, DUEL_ANIM_SCREEN_MAIN_SCENE
ld [wDuelAnimationScreen], a
ret
.set_play_area_screen
ld a, [wDuelAnimLocationParam]
ld l, a
ld a, [wWhoseTurn]
ld h, a
cp PLAYER_TURN
jr z, .player
; opponent
ld a, [wDuelType]
cp $00
jr z, .asm_50c6
; link duel or vs. AI
bit 7, l
jr z, .asm_50e2
jr .asm_50d2
.asm_50c6
bit 7, l
jr z, .asm_50da
jr .asm_50ea
.player
bit 7, l
jr z, .asm_50d2
jr .asm_50e2
.asm_50d2
ld l, UNKNOWN_SCREEN_4
ld h, PLAYER_TURN
ld a, DUEL_ANIM_SCREEN_PLAYER_PLAY_AREA
jr .ok
.asm_50da
ld l, UNKNOWN_SCREEN_4
ld h, OPPONENT_TURN
ld a, DUEL_ANIM_SCREEN_PLAYER_PLAY_AREA
jr .ok
.asm_50e2
ld l, UNKNOWN_SCREEN_5
ld h, OPPONENT_TURN
ld a, DUEL_ANIM_SCREEN_OPP_PLAY_AREA
jr .ok
.asm_50ea
ld l, UNKNOWN_SCREEN_5
ld h, PLAYER_TURN
ld a, DUEL_ANIM_SCREEN_OPP_PLAY_AREA
.ok
ld [wDuelAnimationScreen], a
ret
Func_190f4:
ld a, [wd4b3]
cp $04
jr z, Func_1910f
; fallthrough
Func_190fb:
cp $01
jr nz, .done
ld a, DUEL_ANIM_SCREEN_MAIN_SCENE
ld [wDuelAnimationScreen], a
ld a, [wDuelDisplayedScreen]
cp $01
jr z, .done
bank1call DrawDuelMainScene
.done
ret
Func_1910f:
call SetDuelAnimationScreen
ld a, [wDuelDisplayedScreen]
cp l
jr z, .skip_change_screen
ld a, l
push af
ld l, PLAYER_TURN
ld a, [wDuelType]
cp $00
jr nz, .asm_5127
ld a, [wWhoseTurn]
ld l, a
.asm_5127
call DrawYourOrOppPlayAreaScreen_Bank0
pop af
ld [wDuelDisplayedScreen], a
.skip_change_screen
call DrawWideTextBox
ret
; prints text related to the damage received
; by card stored in wTempNonTurnDuelistCardID
; takes into account type effectiveness
PrintDamageText:
push hl
push bc
push de
ld a, [wLoadedAttackAnimation]
cp ATK_ANIM_HEAL
jr z, .skip
cp ATK_ANIM_HEALING_WIND_PLAY_AREA
jr z, .skip
ld a, [wTempNonTurnDuelistCardID]
ld e, a
ld d, $00
call LoadCardDataToBuffer1_FromCardID
ld a, 18
call CopyCardNameAndLevel
ld [hl], TX_END
ld hl, wTxRam2
xor a
ld [hli], a
ld [hl], a
ld hl, wce7f
ld a, [hli]
ld h, [hl]
ld l, a
call GetDamageText
ld a, l
or h
call nz, DrawWideTextBox_PrintText
.skip
pop de
pop bc
pop hl
ret
; returns in hl the text id associated with
; the damage in hl and its effectiveness
GetDamageText:
ld a, l
or h
jr z, .no_damage
call LoadTxRam3
ld a, [wce81]
ldtx hl, AttackDamageText
and (1 << RESISTANCE) | (1 << WEAKNESS)
ret z ; not weak or resistant
ldtx hl, WeaknessMoreDamage2Text
cp (1 << RESISTANCE) | (1 << WEAKNESS)
ret z ; weak and resistant
and (1 << WEAKNESS)
ldtx hl, WeaknessMoreDamageText
ret nz ; weak
ldtx hl, ResistanceLessDamageText
ret ; resistant
.no_damage
call CheckNoDamageOrEffect
ret c
ldtx hl, NoDamageText
ld a, [wce81]
and (1 << RESISTANCE)
ret z ; not resistant
ldtx hl, ResistanceNoDamageText
ret ; resistant
UpdateMainSceneHUD:
ld a, [wDuelDisplayedScreen]
cp DUEL_MAIN_SCENE
ret nz
bank1call DrawDuelHUDs
ret
Func_191a3:
ret
INCLUDE "data/duel/animations/attack_animations.asm"
|