summaryrefslogtreecommitdiff
path: root/battle/anim_commands.asm
blob: cfd40220d467e0e514a4b5f1d2298d80b81f5eab (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
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
; Battle animation command interpreter.


PlayBattleAnim: ; cc0d6

	ld a, [rSVBK]
	push af

	ld a, 5
	ld [rSVBK], a

	call _PlayBattleAnim

	pop af
	ld [rSVBK], a
	ret
; cc0e4

_PlayBattleAnim: ; cc0e4

	ld c, 6
.wait
	call BattleAnimDelayFrame
	dec c
	jr nz, .wait

	call BattleAnimAssignPals
	call BattleAnimRequestPals
	call BattleAnimDelayFrame

	ld c, 1
	ld a, [rKEY1]
	bit 7, a
	jr nz, .asm_cc0ff
	ld c, 3

.asm_cc0ff
	ld hl, $ff9e
	ld a, [hl]
	push af

	ld [hl], c
	call Functioncc11c

	pop af
	ld [$ff9e], a

	ld a, $1
	ld [hBGMapMode], a

	call BattleAnimDelayFrame
	call BattleAnimDelayFrame
	call BattleAnimDelayFrame
	call WaitSFX
	ret
; cc11c

Functioncc11c: ; cc11c

	ld a, [FXAnimIDHi]
	and a
	jr nz, .asm_cc156

	callba CheckBattleScene
	jr c, .asm_cc141

	call BattleAnimClearHud
	call Functioncc163

	call BattleAnimAssignPals
	call BattleAnimRequestPals

	xor a
	ld [hSCX], a
	ld [hSCY], a
	call BattleAnimDelayFrame
	call BattleAnimRestoreHuds

.asm_cc141
	ld a, [$cfca]
	and a
	jr z, .asm_cc15f

	ld l, a
	ld h, 0
	ld de, $10e
	add hl, de
	ld a, l
	ld [FXAnimIDLo], a
	ld a, h
	ld [FXAnimIDHi], a

.asm_cc156
	call WaitSFX
	call Functioncc881
	call Functioncc163

.asm_cc15f
	call Functioncc8f6
	ret
; cc163

Functioncc163: ; cc163

	call Functioncc8d3

.playframe
	call Functioncc25f
	call Functionccb48
	call Functioncc96e
	call Function3b0c
	call BattleAnimRequestPals

; Speed up Rollout's animation.
	ld a, [FXAnimIDHi]
	or a
	jr nz, .asm_cc193

	ld a, [FXAnimIDLo]
	cp ROLLOUT
	jr nz, .asm_cc193

	ld a, $2e
	ld b, 5
	ld de, 4
	ld hl, ActiveBGEffects
.asm_cc18c
	cp [hl]
	jr z, .asm_cc196
	add hl, de
	dec b
	jr nz, .asm_cc18c

.asm_cc193
	call BattleAnimDelayFrame

.asm_cc196
	ld a, [$d40f]
	bit 0, a
	jr z, .playframe

	call Functioncc23d
	ret
; cc1a1

BattleAnimClearHud: ; cc1a1

	call BattleAnimDelayFrame
	call WaitTop
	call ClearActorHud
	ld a, $1
	ld [hBGMapMode], a
	call BattleAnimDelayFrame
	call BattleAnimDelayFrame
	call BattleAnimDelayFrame
	call WaitTop
	ret
; cc1bb

BattleAnimRestoreHuds: ; cc1bb

	call BattleAnimDelayFrame
	call WaitTop

	ld a, [rSVBK]
	push af
	ld a, $1
	ld [rSVBK], a

	ld hl, UpdateBattleHuds
	ld a, $f
	rst FarCall

	pop af
	ld [rSVBK], a

	ld a, $1
	ld [hBGMapMode], a
	call BattleAnimDelayFrame
	call BattleAnimDelayFrame
	call BattleAnimDelayFrame
	call WaitTop
	ret
; cc1e2

BattleAnimRequestPals: ; cc1e2

	ld a, [hCGB]
	and a
	ret z

	ld a, [rBGP]
	ld b, a
	ld a, [$cfc7]
	cp b
	call nz, Functioncc91a

	ld a, [rOBP0]
	ld b, a
	ld a, [$cfc8]
	cp b
	call nz, Functioncc94b
	ret
; cc1fb

BattleAnimDelayFrame: ; cc1fb
; Like DelayFrame but wastes battery life.

	ld a, 1
	ld [VBlankOccurred], a
.wait
	ld a, [VBlankOccurred]
	and a
	jr nz, .wait
	ret
; cc207

ClearActorHud: ; cc207

	ld a, [hBattleTurn]
	and a
	jr z, .player

	hlcoord 1, 0
	lb bc, 4, 10
	call ClearBox
	ret

.player
	hlcoord 9, 7
	lb bc, 5, 11
	call ClearBox
	ret
; cc220

INCBIN "baserom.gbc",$cc220,$cc23d - $cc220


Functioncc23d: ; cc23d

	ld a, [$d40f]
	bit 3, a
	jr z, .asm_cc254

	ld hl, Sprites + 3
	ld c, (SpritesEnd - Sprites) / 4
.asm_cc249
	ld a, [hl]
	and $f0
	ld [hli], a
	inc hl
	inc hl
	inc hl
	dec c
	jr nz, .asm_cc249
	ret

.asm_cc254
	ld hl, Sprites
	ld c, SpritesEnd - Sprites
	xor a
.asm_cc25a
	ld [hli], a
	dec c
	jr nz, .asm_cc25a
	ret
; cc25f

Functioncc25f: ; cc25f
	call Functioncc267
	ret nc
	call Functioncc275
	ret
; cc267

Functioncc267: ; cc267
	ld a, [$d412]
	and a
	jr z, .asm_cc273

	dec a
	ld [$d412], a
	and a
	ret

.asm_cc273
	scf
	ret
; cc275

Functioncc275: ; cc275

	call GetBattleAnimByte

	cp $ff
	jr nz, .asm_cc286

; Return from a subroutine.
	ld hl, $d40f
	bit 1, [hl]
	jr nz, .asm_cc28e

	set 0, [hl]
	ret

.asm_cc286
	cp $d0
	jr nc, .asm_cc28e

	ld [$d412], a
	ret

.asm_cc28e
	call Functioncc293

	jr Functioncc275
; cc293

Functioncc293: ; cc293
; Execute battle animation command in [$d417].
	ld a, [$d417]
	sub $d0

	ld e, a
	ld d, 0
	ld hl, BattleAnimCommands
	add hl, de
	add hl, de

	ld a, [hli]
	ld h, [hl]
	ld l, a
	jp [hl]
; cc2a4


; no known jump sources
BattleAnimCommands:: ; cc2a4 (33:42a4)
	dw BattleAnimCmd_D0
	dw BattleAnimCmd_D1
	dw BattleAnimCmd_D2
	dw BattleAnimCmd_D3
	dw BattleAnimCmd_D4
	dw BattleAnimCmd_D5
	dw BattleAnimCmd_D6
	dw BattleAnimCmd_D7
	dw BattleAnimCmd_D8
	dw BattleAnimCmd_D9
	dw BattleAnimCmd_DA
	dw BattleAnimCmd_DB
	dw BattleAnimCmd_DC
	dw BattleAnimCmd_DD
	dw BattleAnimCmd_DE
	dw BattleAnimCmd_DF
	dw BattleAnimCmd_E0
	dw BattleAnimCmd_E1
	dw BattleAnimCmd_E2
	dw BattleAnimCmd_E3
	dw BattleAnimCmd_E4
	dw BattleAnimCmd_E5
	dw BattleAnimCmd_E6
	dw BattleAnimCmd_E7
	dw BattleAnimCmd_E8
	dw BattleAnimCmd_E9
	dw BattleAnimCmd_EA
	dw BattleAnimCmd_EB
	dw BattleAnimCmd_EC
	dw BattleAnimCmd_ED
	dw BattleAnimCmd_EE
	dw BattleAnimCmd_EF
	dw BattleAnimCmd_F0
	dw BattleAnimCmd_F1
	dw BattleAnimCmd_F2
	dw BattleAnimCmd_F3
	dw BattleAnimCmd_F4
	dw BattleAnimCmd_F5
	dw BattleAnimCmd_F6
	dw BattleAnimCmd_F7
	dw BattleAnimCmd_F8
	dw BattleAnimCmd_F9
	dw BattleAnimCmd_FA
	dw BattleAnimCmd_FB
	dw BattleAnimCmd_FC
	dw BattleAnimCmd_FD
	dw BattleAnimCmd_FE
	dw BattleAnimCmd_FF


; no known jump sources
BattleAnimCmd_EA:
BattleAnimCmd_EB:
BattleAnimCmd_EC:
BattleAnimCmd_ED: ; cc304 (33:4304)
	ret

; no known jump sources
BattleAnimCmd_FF: ; cc305 (33:4305)
	ld hl, $d40f
	res 1, [hl]
	ld hl, $d413
	ld e, [hl]
	inc hl
	ld d, [hl]
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ret

; no known jump sources
BattleAnimCmd_FE: ; cc317 (33:4317)
	call GetBattleAnimByte
	ld e, a
	call GetBattleAnimByte
	ld d, a
	push de
	ld hl, $d410
	ld e, [hl]
	inc hl
	ld d, [hl]
	ld hl, $d413
	ld [hl], e
	inc hl
	ld [hl], d
	pop de
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ld hl, $d40f
	set 1, [hl]
	ret

; no known jump sources
BattleAnimCmd_FC: ; cc339 (33:4339)
	call GetBattleAnimByte
	ld e, a
	call GetBattleAnimByte
	ld d, a
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ret

; no known jump sources
BattleAnimCmd_FD: ; cc348 (33:4348)
	call GetBattleAnimByte
	ld hl, $d40f
	bit 2, [hl]
	jr nz, .asm_cc35b
	and a
	jr z, .asm_cc363
	dec a
	set 2, [hl]
	ld [$d415], a
.asm_cc35b
	ld hl, $d415
	ld a, [hl]
	and a
	jr z, .asm_cc372
	dec [hl]
.asm_cc363
	call GetBattleAnimByte
	ld e, a
	call GetBattleAnimByte
	ld d, a
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ret
.asm_cc372
	ld hl, $d40f
	res 2, [hl]
	ld hl, $d410
	ld e, [hl]
	inc hl
	ld d, [hl]
	inc de
	inc de
	ld [hl], d
	dec hl
	ld [hl], e
	ret

; no known jump sources
BattleAnimCmd_EF: ; cc383 (33:4383)
	ld hl, $c689
	ld a, [hl]
	and a
	jr z, .asm_cc39a

	dec [hl]
	call GetBattleAnimByte
	ld e, a
	call GetBattleAnimByte
	ld d, a
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ret

.asm_cc39a
	ld hl, $d410
	ld e, [hl]
	inc hl
	ld d, [hl]
	inc de
	inc de
	ld [hl], d
	dec hl
	ld [hl], e
	ret

; no known jump sources
BattleAnimCmd_F9: ; cc3a6 (33:43a6)
	call GetBattleAnimByte
	ld [$d416], a
	ret

; no known jump sources
BattleAnimCmd_FA: ; cc3ad (33:43ad)
	ld hl, $d416
	inc [hl]
	ret

; no known jump sources
BattleAnimCmd_FB: ; cc3b2 (33:43b2)
	call GetBattleAnimByte
	ld hl, $d416
	cp [hl]
	jr z, .jump

	ld hl, $d410
	ld e, [hl]
	inc hl
	ld d, [hl]
	inc de
	inc de
	ld [hl], d
	dec hl
	ld [hl], e
	ret

.jump
	call GetBattleAnimByte
	ld e, a
	call GetBattleAnimByte
	ld d, a
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ret

; no known jump sources
BattleAnimCmd_F8: ; cc3d6 (33:43d6)
	call GetBattleAnimByte
	ld hl, $c689
	cp [hl]
	jr z, .jump

	ld hl, $d410
	ld e, [hl]
	inc hl
	ld d, [hl]
	inc de
	inc de
	ld [hl], d
	dec hl
	ld [hl], e
	ret

.jump
	call GetBattleAnimByte
	ld e, a
	call GetBattleAnimByte
	ld d, a
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ret

; no known jump sources
BattleAnimCmd_EE: ; cc3fa (33:43fa)
	call GetBattleAnimByte
	ld e, a
	ld a, [$c689]
	and e
	jr nz, .jump

	ld hl, $d410
	ld e, [hl]
	inc hl
	ld d, [hl]
	inc de
	inc de
	ld [hl], d
	dec hl
	ld [hl], e
	ret
.jump
	call GetBattleAnimByte
	ld e, a
	call GetBattleAnimByte
	ld d, a
	ld hl, $d410
	ld [hl], e
	inc hl
	ld [hl], d
	ret

; no known jump sources
BattleAnimCmd_D0: ; cc41f (33:441f)
	call GetBattleAnimByte
	ld [$d419], a
	call GetBattleAnimByte
	ld [$d41a], a
	call GetBattleAnimByte
	ld [$d41b], a
	call GetBattleAnimByte
	ld [$d41c], a
	call Functioncc9a1
	ret

; no known jump sources
BattleAnimCmd_F0: ; cc43b (33:443b)
	call GetBattleAnimByte
	ld [$d419], a
	call GetBattleAnimByte
	ld [$d41a], a
	call GetBattleAnimByte
	ld [$d41b], a
	call GetBattleAnimByte
	ld [$d41c], a
	call Functionccb4f
	ret

; no known jump sources
BattleAnimCmd_F1: ; cc457 (33:4457)
	call GetBattleAnimByte
	ld [$cfc7], a
	ret

; no known jump sources
BattleAnimCmd_F2: ; cc45e (33:445e)
	call GetBattleAnimByte
	ld [$cfc8], a
	ret

; no known jump sources
BattleAnimCmd_F3: ; cc465 (33:4465)
	call GetBattleAnimByte
	ld [$cfc9], a
	ret

; no known jump sources
BattleAnimCmd_DF: ; cc46c (33:446c)
	ld a, [hSGB] ; $ff00+$e7
	and a
	ld a, $e0
	jr z, .asm_cc475
	ld a, $f0
.asm_cc475
	ld [$cfc8], a
	ret

; no known jump sources
BattleAnimCmd_E5: ; cc479 (33:4479)
	ld hl, $d30a
	ld a, $a0
.asm_cc47e
	ld [hl], $0
	inc hl
	dec a
	jr nz, .asm_cc47e
	ret

; no known jump sources
BattleAnimCmd_D1:
BattleAnimCmd_D2:
BattleAnimCmd_D3:
BattleAnimCmd_D4:
BattleAnimCmd_D5: ; cc485 (33:4485)
	ld a, [$d417]
	and $f
	ld c, a
	ld hl, $d300
	xor a
	ld [$d419], a
.asm_cc492
	ld a, [$d419]
	cp $4f
	ret nc
	call GetBattleAnimByte
	ld [hli], a
	ld a, [$d419]
	ld [hli], a
	push bc
	push hl
	ld l, a
	ld h, $0
	add hl, hl
	add hl, hl
	add hl, hl
	add hl, hl
	ld de, $8310
	add hl, de
	ld a, [$d417]
	call Functionce846
	ld a, [$d419]
	add c
	ld [$d419], a
	pop hl
	pop bc
	dec c
	jr nz, .asm_cc492
	ret

; no known jump sources
BattleAnimCmd_D6: ; cc4c0 (33:44c0)
	call GetBattleAnimByte
	ld e, $a
	ld bc, $d30a
.asm_cc4c8
	ld hl, $0
	add hl, bc
	ld d, [hl]
	ld a, [$d417]
	cp d
	jr z, .asm_cc4dd
	ld hl, $18
	add hl, bc
	ld c, l
	ld b, h
	dec e
	jr nz, .asm_cc4c8
	ret
.asm_cc4dd
	ld hl, $e
	add hl, bc
	inc [hl]
	ret

; no known jump sources
BattleAnimCmd_D8: ; cc4e3 (33:44e3)
	call GetBattleAnimByte
	ld e, $5
	ld bc, $d3fa
.asm_cc4eb
	ld hl, $0
	add hl, bc
	ld d, [hl]
	ld a, [$d417]
	cp d
	jr z, .asm_cc500
	ld hl, $4
	add hl, bc
	ld c, l
	ld b, h
	dec e
	jr nz, .asm_cc4eb
	ret
.asm_cc500
	ld hl, $1
	add hl, bc
	inc [hl]
	ret

; no known jump sources
BattleAnimCmd_D7: ; cc506 (33:4506)
	call GetBattleAnimByte
	ld e, $a
	ld bc, $d30a
.asm_cc50e
	ld hl, $0
	add hl, bc
	ld d, [hl]
	ld a, [$d417]
	cp d
	jr z, .asm_cc523
	ld hl, $18
	add hl, bc
	ld c, l
	ld b, h
	dec e
	jr nz, .asm_cc50e
	ret
.asm_cc523
	call GetBattleAnimByte
	ld hl, $e
	add hl, bc
	ld [hl], a
	ret

; no known jump sources
BattleAnimCmd_D9: ; cc52c (33:452c)

	ld hl, $d300
.asm_cc52f
	ld a, [hl]
	and a
	jr z, .asm_cc537
	inc hl
	inc hl
	jr .asm_cc52f

.asm_cc537
	ld a, $28
	ld [hli], a
	ld a, $42
	ld [hli], a
	ld a, $29
	ld [hli], a
	ld a, $49
	ld [hl], a

	ld hl, $8730
	ld de, $9060
	ld a, $70
	ld [$d419], a
	ld a, $7
	call Functioncc561
	ld de, $9310
	ld a, $60
	ld [$d419], a
	ld a, $6
	call Functioncc561
	ret

; known jump sources: cc550 (33:4550), cc55d (33:455d), cc57b (33:457b)
Functioncc561: ; cc561 (33:4561)
	push af
	push hl
	push de
	ld bc, $3301
	call Request2bpp
	pop de
	ld a, [$d419]
	ld l, a
	ld h, $0
	add hl, de
	ld e, l
	ld d, h
	pop hl
	ld bc, $10
	add hl, bc
	pop af
	dec a
	jr nz, Functioncc561
	ret

; no known jump sources
BattleAnimCmd_DA: ; cc57e (33:457e)

	ld hl, $d300
.asm_cc581
	ld a, [hl]
	and a
	jr z, .asm_cc589
	inc hl
	inc hl
	jr .asm_cc581

.asm_cc589
	ld a, $28
	ld [hli], a
	ld a, $35
	ld [hli], a
	ld a, $29
	ld [hli], a
	ld a, $43
	ld [hl], a

	ld hl, $8660
	ld de, $9050
	ld a, $70
	ld [$d419], a
	ld a, $7
	call Functioncc5b3
	ld de, $9310
	ld a, $60
	ld [$d419], a
	ld a, $6
	call Functioncc5b3
	ret

; known jump sources: cc5a2 (33:45a2), cc5af (33:45af), cc5cd (33:45cd)
Functioncc5b3: ; cc5b3 (33:45b3)
	push af
	push hl
	push de
	ld bc, $3302
	call Request2bpp
	pop de
	ld a, [$d419]
	ld l, a
	ld h, $0
	add hl, de
	ld e, l
	ld d, h
	pop hl
	ld bc, $20
	add hl, bc
	pop af
	dec a
	jr nz, Functioncc5b3
	ret

; no known jump sources
BattleAnimCmd_DB: ; cc5d0 (33:45d0)
	callab GetPokeBallWobble
	ld a, c
	ld [$d416], a
	ret

; no known jump sources
BattleAnimCmd_E7: ; cc5db (33:45db)
	ret

; no known jump sources
BattleAnimCmd_DC: ; cc5dc (33:45dc)
	ld a, [rSVBK] ; $ff00+$70
	push af
	ld a, 1
	ld [rSVBK], a ; $ff00+$70
	ld a, [CurPartySpecies] ; $d108
	push af

	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr z, .player

	ld a, [TempBattleMonSpecies] ; $d205
	ld [CurPartySpecies], a ; $d108
	ld hl, BattleMonDVs ; $c632
	ld a, PREDEF_GET_UNOWN_LETTER
	call Predef
	ld de, $8000
	ld a, $3c
	call Predef
	jr .done

.player
	ld a, [TempEnemyMonSpecies] ; $d204
	ld [CurPartySpecies], a ; $d108
	ld hl, EnemyMonDVs ; $d20c
	ld a, PREDEF_GET_UNOWN_LETTER
	call Predef
	ld de, $8000
	ld a, $3d
	call Predef

.done
	pop af
	ld [CurPartySpecies], a ; $d108
	pop af
	ld [rSVBK], a ; $ff00+$70
	ret

; no known jump sources
BattleAnimCmd_E8: ; cc622 (33:4622)

	ld de, $8000
	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr z, .player

	ld hl, $9000
	ld b, 0
	ld c, $31
	call Request2bpp
	ret

.player
	ld hl, $9310
	ld b, 0
	ld c, $24
	call Request2bpp
	ret

; no known jump sources
BattleAnimCmd_DD: ; cc640 (33:4640)

	ld a, [rSVBK] ; $ff00+$70
	push af
	ld a, 1
	ld [rSVBK], a ; $ff00+$70
	xor a
	call GetSRAMBank

GetSubstitutePic: ; cc64c

	ld hl, $a000
	ld bc, $310
.loop
	xor a
	ld [hli], a
	dec bc
	ld a, c
	or b
	jr nz, .loop

	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr z, .player

	ld hl, MonsterSpriteGFX
	ld de, $a000 + $130
	call CopyMonsterSpriteTile
	ld hl, MonsterSpriteGFX + $10
	ld de, $a000 + $1a0
	call CopyMonsterSpriteTile
	ld hl, MonsterSpriteGFX + $20
	ld de, $a000 + $140
	call CopyMonsterSpriteTile
	ld hl, MonsterSpriteGFX + $30
	ld de, $a000 + $1b0
	call CopyMonsterSpriteTile

	ld hl, $9000
	ld de, $a000
	lb bc, BANK(GetSubstitutePic), 7 * 7
	call Request2bpp
	jr .done

.player
	ld hl, MonsterSpriteGFX + $40
	ld de, $a000 + $100
	call CopyMonsterSpriteTile
	ld hl, MonsterSpriteGFX + $50
	ld de, $a000 + $160
	call CopyMonsterSpriteTile
	ld hl, MonsterSpriteGFX + $60
	ld de, $a000 + $110
	call CopyMonsterSpriteTile
	ld hl, MonsterSpriteGFX + $70
	ld de, $a000 + $170
	call CopyMonsterSpriteTile

	ld hl, $9310
	ld de, $a000
	lb bc, BANK(GetSubstitutePic), 6 * 6
	call Request2bpp

.done
	call CloseSRAM
	pop af
	ld [rSVBK], a ; $ff00+$70
	ret

; known jump sources: cc663 (33:4663), cc66c (33:466c), cc675 (33:4675), cc67e (33:467e), cc695 (33:4695), cc69e (33:469e), cc6a7 (33:46a7), cc6b0 (33:46b0)
CopyMonsterSpriteTile: ; cc6c6 (33:46c6)
	ld bc, $10
	ld a, BANK(MonsterSpriteGFX)
	call FarCopyBytes
	ret

; no known jump sources
BattleAnimCmd_E2: ; cc6cf (33:46cf)
	ld a, [rSVBK] ; $ff00+$70
	push af
	ld a, $1
	ld [rSVBK], a ; $ff00+$70
	xor a
	call GetSRAMBank
	call GetMinimizePic
	call Request2bpp
	call CloseSRAM
	pop af
	ld [rSVBK], a ; $ff00+$70
	ret

; known jump sources: cc6da (33:46da), cc740 (33:4740)
GetMinimizePic: ; cc6e7 (33:46e7)
	ld hl, $a000
	ld bc, $310
.loop
	xor a
	ld [hli], a
	dec bc
	ld a, c
	or b
	jr nz, .loop

	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr z, .player

	ld de, $a1a0
	call CopyMinimizePic
	ld hl, $9000
	ld de, $a000
	lb bc, BANK(GetMinimizePic), $31
	ret

.player
	ld de, $a160
	call CopyMinimizePic
	ld hl, $9310
	ld de, $a000
	lb bc, BANK(GetMinimizePic), $24
	ret

; known jump sources: cc6fc (33:46fc), cc70c (33:470c)
CopyMinimizePic: ; cc719 (33:4719)
	ld hl, MinimizePic
	ld bc, $10
	ld a, BANK(MinimizePic)
	call FarCopyBytes
	ret
; cc725 (33:4725)

MinimizePic: ; cc725
INCBIN "gfx/battle/minimize.2bpp"
; cc735

; no known jump sources
BattleAnimCmd_E9: ; cc735 (33:4735)
	ld a, [rSVBK] ; $ff00+$70
	push af
	ld a, $1
	ld [rSVBK], a ; $ff00+$70
	xor a
	call GetSRAMBank
	call GetMinimizePic
	ld hl, $8000
	call Request2bpp
	call CloseSRAM
	pop af
	ld [rSVBK], a ; $ff00+$70
	ret

; no known jump sources
BattleAnimCmd_DE: ; cc750 (33:4750)
	ld a, [rSVBK] ; $ff00+$70
	push af
	ld a, $1
	ld [rSVBK], a ; $ff00+$70

	ld a, [CurPartySpecies] ; $d108
	push af
	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr z, .player

	callab Function3f486
	jr .done

.player
	callab Function3f447

.done
	pop af
	ld [CurPartySpecies], a ; $d108
	pop af
	ld [rSVBK], a ; $ff00+$70
	ret

; no known jump sources
BattleAnimCmd_E6: ; cc776 (33:4776)
	ld a, [rSVBK] ; $ff00+$70
	push af
	ld a, $1
	ld [rSVBK], a ; $ff00+$70
	ld a, [CurPartySpecies] ; $d108
	push af

	ld a, [$c689]
	ld [CurPartySpecies], a ; $d108

	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr z, .player

	ld hl, BattleMonDVs ; $c632
	ld a, PREDEF_GET_UNOWN_LETTER
	call Predef
	ld de, $9000
	ld a, $3c
	call Predef
	jr .done

.player
	ld hl, EnemyMonDVs ; $d20c
	ld a, PREDEF_GET_UNOWN_LETTER
	call Predef
	ld de, $9310
	ld a, $3d
	call Predef

.done
	pop af
	ld [CurPartySpecies], a ; $d108
	ld b, $1
	call GetSGBLayout
	pop af
	ld [rSVBK], a ; $ff00+$70
	ret

; no known jump sources
BattleAnimCmd_E3: ; cc7bb (33:47bb)
	xor a
	ld [hOAMUpdate], a ; $ff00+$d8
	ret

; no known jump sources
BattleAnimCmd_E4: ; cc7bf (33:47bf)
	ld a, $1
	ld [hOAMUpdate], a ; $ff00+$d8
	ret

; no known jump sources
BattleAnimCmd_F4: ; cc7c4 (33:47c4)
	ld hl, $d40f
	set 3, [hl]
	ret

; no known jump sources
BattleAnimCmd_F5: ; cc7ca (33:47ca)
	ret

; no known jump sources
BattleAnimCmd_F6: ; cc7cb (33:47cb)
	ret

; no known jump sources
BattleAnimCmd_F7: ; cc7cc (33:47cc)
	ret

; no known jump sources
BattleAnimCmd_E0: ; cc7cd (33:47cd)
	call GetBattleAnimByte
	ld e, a
	srl a
	srl a
	ld [$c2be], a
	call Functioncc7fc
	and 3
	ld [CryTracks], a ; $c2bd

	ld e, a
	ld d, 0
	ld hl, Datacc7f8
	add hl, de
	ld a, [hl]
	ld [$c2bc], a

	call GetBattleAnimByte
	ld e, a
	ld d, 0
	callab PlayStereoSFX

	ret
; cc7f8 (33:47f8)

Datacc7f8: ; cc7f8
	db $f0, $0f, $f0, $0f
; cc7fc

; known jump sources: cc7d8 (33:47d8)
Functioncc7fc: ; cc7fc (33:47fc)
	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr nz, .enemy

	ld a, e
	ret

.enemy
	ld a, e
	xor 1
	ret

; no known jump sources
BattleAnimCmd_E1: ; cc807 (33:4807)
	call GetBattleAnimByte
	and 3
	ld e, a
	ld d, 0
	ld hl, Datacc871
	add hl, de
	add hl, de
	add hl, de
	add hl, de

	ld a, [rSVBK] ; $ff00+$70
	push af
	ld a, 1
	ld [rSVBK], a ; $ff00+$70

	ld a, [hBattleTurn] ; $ff00+$e4
	and a
	jr nz, .enemy

	ld a, $f0
	ld [CryTracks], a ; $c2bd
	ld a, [BattleMonSpecies] ; $c62c
	jr .asm_cc834

.enemy
	ld a, $0f
	ld [CryTracks], a ; $c2bd
	ld a, [EnemyMonSpecies] ; $d206

.asm_cc834
	push hl
	call Function37f3
	pop hl
	jr c, .done

	ld a, [hli]
	ld c, a
	ld a, [hli]
	ld b, a

	push hl
	ld hl, CryPitch ; $c2b0
	ld a, [hli]
	ld h, [hl]
	ld l, a
	add hl, bc
	ld a, l
	ld [CryPitch], a ; $c2b0
	ld a, h
	ld [CryEcho], a ; $c2b1
	pop hl

	ld a, [hli]
	ld c, a
	ld b, [hl]
	ld hl, CryLength ; $c2b2
	ld a, [hli]
	ld h, [hl]
	ld l, a
	add hl, bc

	ld a, l
	ld [CryLength], a ; $c2b2
	ld a, h
	ld [CryLength + 1], a
	ld a, 1
	ld [$c2bc], a

	callab PlayCry

.done
	pop af
	ld [rSVBK], a ; $ff00+$70
	ret
; cc871 (33:4871)

Datacc871: ; cc871
; +pitch, +echo, +length
	db $00, $00, $c0, $00
	db $00, $00, $40, $00
	db $00, $00, $00, $00
	db $00, $00, $00, $00
; cc881


Functioncc881: ; cc881
	ld a, [$cfca]
	cp $1
	jr z, .asm_cc88b
	cp $4
	ret nz

.asm_cc88b
	ld a, [TypeModifier]
	and $7f
	ret z

	cp 10
	ld de, SFX_DAMAGE
	jr z, .play

	ld de, SFX_SUPER_EFFECTIVE
	jr nc, .play

	ld de, SFX_NOT_VERY_EFFECTIVE

.play
	call PlaySFX
	ret
; cc8a4

BattleAnimAssignPals: ; cc8a4
	ld a, [hCGB]
	and a
	jr nz, .asm_cc8be
	ld a, [hSGB]
	and a
	ld a, $e0
	jr z, .asm_cc8b2
	ld a, $f0

.asm_cc8b2
	ld [$cfc8], a
	ld a, $e4
	ld [$cfc7], a
	ld [$cfc9], a
	ret

.asm_cc8be
	ld a, $e4
	ld [$cfc7], a
	ld [$cfc8], a
	ld [$cfc9], a
	call DmgToCgbBGPals
	ld de, $e4e4
	call DmgToCgbObjPals
	ret
; cc8d3

Functioncc8d3: ; cc8d3
	ld hl, LYOverrides
	ld bc, $0354
.asm_cc8d9
	ld [hl], $0
	inc hl
	dec bc
	ld a, c
	or b
	jr nz, .asm_cc8d9
	ld hl, FXAnimIDLo
	ld e, [hl]
	inc hl
	ld d, [hl]
	ld hl, BattleAnimations
	add hl, de
	add hl, de
	call Function3ae1
	call BattleAnimAssignPals
	call BattleAnimDelayFrame
	ret
; cc8f6

Functioncc8f6: ; cc8f6
	call WaitTop
	ld a, $e4
	ld [$cfc7], a
	ld [$cfc8], a
	ld [$cfc9], a
	call DmgToCgbBGPals
	ld de, $e4e4
	call DmgToCgbObjPals
	xor a
	ld [hSCX], a
	ld [hSCY], a
	call BattleAnimDelayFrame
	ld a, $1
	ld [hBGMapMode], a
	ret
; cc91a

Functioncc91a: ; cc91a
	ld [rBGP], a
	ld a, [hCGB]
	and a
	ret z
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld hl, $d080
	ld de, $d000
	ld a, [rBGP]
	ld b, a
	ld c, $7
	call CopyPals
	ld hl, $d0c0
	ld de, MartPointer
	ld a, [rBGP]
	ld b, a
	ld c, $2
	call CopyPals
	pop af
	ld [rSVBK], a
	ld a, $1
	ld [hCGBPalUpdate], a
	ret
; cc94b

Functioncc94b: ; cc94b
	ld [rOBP0], a
	ld a, [hCGB]
	and a
	ret z
	ld a, [rSVBK]
	push af
	ld a, $5
	ld [rSVBK], a
	ld hl, $d0d0
	ld de, $d050
	ld a, [rOBP0]
	ld b, a
	ld c, $2
	call CopyPals
	pop af
	ld [rSVBK], a
	ld a, $1
	ld [hCGBPalUpdate], a
	ret
; cc96e

Functioncc96e: ; cc96e
	ld a, $0
	ld [$d418], a
	ld hl, $d30a
	ld e, $a
.asm_cc978
	ld a, [hl]
	and a
	jr z, .asm_cc98a
	ld c, l
	ld b, h
	push hl
	push de
	call Functionccfbe
	call Functioncca09
	pop de
	pop hl
	jr c, .asm_cc9a0

.asm_cc98a
	ld bc, $0018
	add hl, bc
	dec e
	jr nz, .asm_cc978
	ld a, [$d418]
	ld l, a
	ld h, $c4
.asm_cc997
	ld a, l
	cp $a0
	jr nc, .asm_cc9a0
	xor a
	ld [hli], a
	jr .asm_cc997

.asm_cc9a0
	ret
; cc9a1