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
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
|
; Draws a "frame block". Frame blocks are blocks of tiles that are put
; together to form frames in battle animations.
DrawFrameBlock: ; 78000 (1e:4000)
ld l,c
ld h,b
ld a,[hli]
ld [W_NUMFBTILES],a
ld a,[W_FBDESTADDR + 1]
ld e,a
ld a,[W_FBDESTADDR]
ld d,a
xor a
ld [W_FBTILECOUNTER],a ; loop counter
.loop
ld a,[W_FBTILECOUNTER]
inc a
ld [W_FBTILECOUNTER],a
ld a,[W_SUBANIMTRANSFORM]
dec a
jr z,.flipHorizontalAndVertical ; 1
dec a
jp z,.flipHorizontalTranslateDown ; 2
dec a
jr z,.flipBaseCoords ; 3
.noTransformation
ld a,[W_BASECOORDY]
add [hl]
ld [de],a ; store Y
inc hl
inc de
ld a,[W_BASECOORDX]
jr .finishCopying
.flipBaseCoords
ld a,[W_BASECOORDY]
ld b,a
ld a,136
sub b ; flip Y base coordinate
add [hl] ; Y offset
ld [de],a ; store Y
inc hl
inc de
ld a,[W_BASECOORDX]
ld b,a
ld a,168
sub b ; flip X base coordinate
.finishCopying ; finish copying values to OAM (when [W_SUBANIMTRANSFORM] not 1 or 2)
add [hl] ; X offset
ld [de],a ; store X
inc hl
inc de
ld a,[hli]
add a,$31 ; base tile ID for battle animations
ld [de],a ; store tile ID
inc de
ld a,[hli]
ld [de],a ; store flags
inc de
jp .nextTile
.flipHorizontalAndVertical
ld a,[W_BASECOORDY]
add [hl] ; Y offset
ld b,a
ld a,136
sub b ; flip Y coordinate
ld [de],a ; store Y
inc hl
inc de
ld a,[W_BASECOORDX]
add [hl] ; X offset
ld b,a
ld a,168
sub b ; flip X coordinate
ld [de],a ; store X
inc hl
inc de
ld a,[hli]
add a,$31 ; base tile ID for battle animations
ld [de],a ; store tile ID
inc de
; toggle horizontal and vertical flip
ld a,[hli] ; flags
and a
ld b,OAM_VFLIP | OAM_HFLIP
jr z,.storeFlags1
cp a,OAM_HFLIP
ld b,OAM_VFLIP
jr z,.storeFlags1
cp a,OAM_VFLIP
ld b,OAM_HFLIP
jr z,.storeFlags1
ld b,0
.storeFlags1
ld a,b
ld [de],a
inc de
jp .nextTile
.flipHorizontalTranslateDown
ld a,[W_BASECOORDY]
add [hl]
add a,40 ; translate Y coordinate downwards
ld [de],a ; store Y
inc hl
inc de
ld a,[W_BASECOORDX]
add [hl]
ld b,a
ld a,168
sub b ; flip X coordinate
ld [de],a ; store X
inc hl
inc de
ld a,[hli]
add a,$31 ; base tile ID for battle animations
ld [de],a ; store tile ID
inc de
ld a,[hli]
bit 5,a ; is horizontal flip enabled?
jr nz,.disableHorizontalFlip
.enableHorizontalFlip
set 5,a
jr .storeFlags2
.disableHorizontalFlip
res 5,a
.storeFlags2
ld [de],a
inc de
.nextTile
ld a,[W_FBTILECOUNTER]
ld c,a
ld a,[W_NUMFBTILES]
cp c
jp nz,.loop ; go back up if there are more tiles to draw
.afterDrawingTiles
ld a,[W_FBMODE]
cp a,2
jr z,.advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer
ld a,[W_SUBANIMFRAMEDELAY]
ld c,a
call DelayFrames
ld a,[W_FBMODE]
cp a,3
jr z,.advanceFrameBlockDestAddr ; skip cleaning OAM buffer
cp a,4
jr z,.done ; skip cleaning OAM buffer and don't advance the frame block destination address
ld a,[W_ANIMATIONID]
cp a,GROWL
jr z,.resetFrameBlockDestAddr
call AnimationCleanOAM
.resetFrameBlockDestAddr
ld hl,wOAMBuffer ; OAM buffer
ld a,l
ld [W_FBDESTADDR + 1],a
ld a,h
ld [W_FBDESTADDR],a ; set destination address to beginning of OAM buffer
ret
.advanceFrameBlockDestAddr
ld a,e
ld [W_FBDESTADDR + 1],a
ld a,d
ld [W_FBDESTADDR],a
.done
ret
PlayAnimation: ; 780f1 (1e:40f1)
xor a
ld [$FF8B],a ; it looks like nothing reads this
ld [W_SUBANIMTRANSFORM],a
ld a,[W_ANIMATIONID] ; get animation number
dec a
ld l,a
ld h,0
add hl,hl
ld de,AttackAnimationPointers ; animation command stream pointers
add hl,de
ld a,[hli]
ld h,[hl]
ld l,a
.animationLoop
ld a,[hli]
cp a,$FF
jr z,.AnimationOver
cp a,$C0 ; is this subanimation or a special effect?
jr c,.playSubanimation
.doSpecialEffect
ld c,a
ld de,SpecialEffectPointers
.searchSpecialEffectTableLoop
ld a,[de]
cp c
jr z,.foundMatch
inc de
inc de
inc de
jr .searchSpecialEffectTableLoop
.foundMatch
ld a,[hli]
cp a,$FF ; is there a sound to play?
jr z,.skipPlayingSound
ld [wAnimSoundID],a ; store sound
push hl
push de
call GetMoveSound
call PlaySound
pop de
pop hl
.skipPlayingSound
push hl
inc de
ld a,[de]
ld l,a
inc de
ld a,[de]
ld h,a
ld de,.nextAnimationCommand
push de
jp [hl] ; jump to special effect function
.playSubanimation
ld c,a
and a,%00111111
ld [W_SUBANIMFRAMEDELAY],a
xor a
sla c
rla
sla c
rla
ld [wWhichBattleAnimTileset],a
ld a,[hli] ; sound
ld [wAnimSoundID],a ; store sound
ld a,[hli] ; subanimation ID
ld c,l
ld b,h
ld l,a
ld h,0
add hl,hl
ld de,SubanimationPointers
add hl,de
ld a,l
ld [W_SUBANIMADDRPTR],a
ld a,h
ld [W_SUBANIMADDRPTR + 1],a
ld l,c
ld h,b
push hl
ld a,[rOBP0]
push af
ld a,[wAnimPalette]
ld [rOBP0],a
call LoadAnimationTileset
call LoadSubanimation
call PlaySubanimation
pop af
ld [rOBP0],a
.nextAnimationCommand
pop hl
jr .animationLoop
.AnimationOver ; 417B
ret
LoadSubanimation: ; 7817c (1e:417c)
ld a,[W_SUBANIMADDRPTR + 1]
ld h,a
ld a,[W_SUBANIMADDRPTR]
ld l,a
ld a,[hli]
ld e,a
ld a,[hl]
ld d,a ; de = address of subanimation
ld a,[de]
ld b,a
and a,31
ld [W_SUBANIMCOUNTER],a ; number of frame blocks
ld a,b
and a,%11100000
cp a,5 << 5 ; is subanimation type 5?
jr nz,.isNotType5
.isType5
call GetSubanimationTransform2
jr .saveTransformation
.isNotType5
call GetSubanimationTransform1
.saveTransformation
; place the upper 3 bits of a into bits 0-2 of a before storing
srl a
swap a
ld [W_SUBANIMTRANSFORM],a
cp a,4 ; is the animation reversed?
ld hl,0
jr nz,.storeSubentryAddr
; if the animation is reversed, then place the initial subentry address at the end of the list of subentries
ld a,[W_SUBANIMCOUNTER]
dec a
ld bc,3
.loop
add hl,bc
dec a
jr nz,.loop
.storeSubentryAddr
inc de
add hl,de
ld a,l
ld [W_SUBANIMSUBENTRYADDR],a
ld a,h
ld [W_SUBANIMSUBENTRYADDR + 1],a
ret
; called if the subanimation type is not 5
; sets the transform to 0 (i.e. no transform) if it's the player's turn
; sets the transform to the subanimation type if it's the enemy's turn
GetSubanimationTransform1: ; 781c2 (1e:41c2)
ld b,a
ld a,[H_WHOSETURN]
and a
ld a,b
ret nz
xor a
ret
; called if the subanimation type is 5
; sets the transform to 2 (i.e. horizontal and vertical flip) if it's the player's turn
; sets the transform to 0 (i.e. no transform) if it's the enemy's turn
GetSubanimationTransform2: ; 781ca (1e:41ca)
ld a,[H_WHOSETURN]
and a
ld a,2 << 5
ret z
xor a
ret
; loads tile patterns for battle animations
LoadAnimationTileset: ; 781d2 (1e:41d2)
ld a,[wWhichBattleAnimTileset]
add a
add a
ld hl,AnimationTilesetPointers
ld e,a
ld d,0
add hl,de
ld a,[hli]
ld [wTempTilesetNumTiles],a ; number of tiles
ld a,[hli]
ld e,a
ld a,[hl]
ld d,a ; de = address of tileset
ld hl,vSprites + $310
ld b, BANK(AnimationTileset1) ; ROM bank
ld a,[wTempTilesetNumTiles]
ld c,a ; number of tiles
jp CopyVideoData ; load tileset
AnimationTilesetPointers: ; 781f2 (1e:41f2)
db 79 ; number of tiles
dw AnimationTileset1
db $FF
db 79 ; number of tiles
dw AnimationTileset2
db $FF
db 64 ; number of tiles
dw AnimationTileset1
db $FF
AnimationTileset1: ; 781fe (1e:41fe)
INCBIN "gfx/attack_anim_1.2bpp"
AnimationTileset2: ; 786ee (1e:46ee)
INCBIN "gfx/attack_anim_2.2bpp"
SlotMachineTiles2: ; 78bde (1e:4bde)
IF DEF(_RED)
INCBIN "gfx/red/slotmachine2.2bpp"
ENDC
IF DEF(_BLUE)
INCBIN "gfx/blue/slotmachine2.2bpp"
ENDC
IF DEF(_YELLOW)
INCBIN "gfx/yellow/slotmachine2.2bpp"
ENDC
MoveAnimation: ; 78d5e (1e:4d5e)
push hl
push de
push bc
push af
call WaitForSoundToFinish
call SetAnimationPalette
ld a,[W_ANIMATIONID]
and a
jr z,.AnimationFinished
; if throwing a Poké Ball, skip the regular animation code
cp a,TOSS_ANIM
jr nz,.MoveAnimation
ld de,.AnimationFinished
push de
jp TossBallAnimation
.MoveAnimation
; check if battle animations are disabled in the options
ld a,[W_OPTIONS]
bit 7,a
jr nz,.AnimationsDisabled
call ShareMoveAnimations
call PlayAnimation
jr .next4
.AnimationsDisabled
ld c,30
call DelayFrames
.next4
call PlayApplyingAttackAnimation ; shake the screen or flash the pic in and out (to show damage)
.AnimationFinished
call WaitForSoundToFinish
xor a
ld [W_SUBANIMSUBENTRYADDR],a
ld [wUnusedD09B],a
ld [W_SUBANIMTRANSFORM],a
dec a
ld [wAnimSoundID],a
pop af
pop bc
pop de
pop hl
ret
ShareMoveAnimations: ; 78da6 (1e:4da6)
; some moves just reuse animations from status conditions
ld a,[H_WHOSETURN]
and a
ret z
; opponent’s turn
ld a,[W_ANIMATIONID]
cp a,AMNESIA
ld b,CONF_ANIM
jr z,.Replace
cp a,REST
ld b,SLP_ANIM
ret nz
.Replace
ld a,b
ld [W_ANIMATIONID],a
ret
PlayApplyingAttackAnimation: ; 78dbd (1e:4dbd)
; Generic animation that shows after the move's individual animation
; Different animation depending on whether the move has an additional effect and on whose turn it is
ld a,[wAnimationType]
and a
ret z
dec a
add a
ld c,a
ld b,0
ld hl,AnimationTypePointerTable
add hl,bc
ld a,[hli]
ld h,[hl]
ld l,a
jp [hl]
AnimationTypePointerTable: ; 78dcf (1e:4dcf)
dw ShakeScreenVertically ; enemy mon has used a damaging move without a side effect
dw ShakeScreenHorizontallyHeavy ; enemy mon has used a damaging move with a side effect
dw ShakeScreenHorizontallySlow ; enemy mon has used a non-damaging move
dw BlinkEnemyMonSprite ; player mon has used a damaging move without a side effect
dw ShakeScreenHorizontallyLight ; player mon has used a damaging move with a side effect
dw ShakeScreenHorizontallySlow2 ; player mon has used a non-damaging move
ShakeScreenVertically: ; 78ddb (1e:4ddb)
call PlayApplyingAttackSound
ld b, 8
jp AnimationShakeScreenVertically
ShakeScreenHorizontallyHeavy: ; 78de3 (1e:4de3)
call PlayApplyingAttackSound
ld b, 8
jp AnimationShakeScreenHorizontallyFast
ShakeScreenHorizontallySlow: ; 78deb (1e:4deb)
lb bc, 6, 2
jr AnimationShakeScreenHorizontallySlow
BlinkEnemyMonSprite: ; 78df0 (1e:4df0)
call PlayApplyingAttackSound
jp AnimationBlinkEnemyMon
ShakeScreenHorizontallyLight: ; 78df6 (1e:4df6)
call PlayApplyingAttackSound
ld b, 2
jp AnimationShakeScreenHorizontallyFast
ShakeScreenHorizontallySlow2: ; 78dfe (1e:4dfe)
lb bc, 3, 2
AnimationShakeScreenHorizontallySlow: ; 78e01 (1e:4e01)
push bc
push bc
.loop1
ld a, [rWX]
inc a
ld [rWX], a
ld c, 2
call DelayFrames
dec b
jr nz, .loop1
pop bc
.loop2
ld a, [rWX]
dec a
ld [rWX], a
ld c, 2
call DelayFrames
dec b
jr nz, .loop2
pop bc
dec c
jr nz, AnimationShakeScreenHorizontallySlow
ret
SetAnimationPalette: ; 78e23 (1e:4e23)
ld a, [wOnSGB]
and a
ld a, $e4
jr z, .notSGB
ld a, $f0
ld [wAnimPalette], a
ld b, $e4
ld a, [W_ANIMATIONID]
cp TRADE_BALL_DROP_ANIM
jr c, .next
cp TRADE_BALL_POOF_ANIM + 1
jr nc, .next
ld b, $f0
.next
ld a, b
ld [rOBP0], a
ld a, $6c
ld [rOBP1], a
ret
.notSGB
ld a, $e4
ld [wAnimPalette], a
ld [rOBP0], a
ld a, $6c
ld [rOBP1], a
ret
PlaySubanimation: ; 78e53 (1e:4e53)
ld a,[wAnimSoundID]
cp a,$FF
jr z,.skipPlayingSound
call GetMoveSound
call PlaySound
.skipPlayingSound
ld hl,wOAMBuffer ; base address of OAM buffer
ld a,l
ld [W_FBDESTADDR + 1],a
ld a,h
ld [W_FBDESTADDR],a
ld a,[W_SUBANIMSUBENTRYADDR + 1]
ld h,a
ld a,[W_SUBANIMSUBENTRYADDR]
ld l,a
.loop
push hl
ld c,[hl] ; frame block ID
ld b,0
ld hl,FrameBlockPointers
add hl,bc
add hl,bc
ld a,[hli]
ld c,a
ld a,[hli]
ld b,a
pop hl
inc hl
push hl
ld e,[hl] ; base coordinate ID
ld d,0
ld hl,FrameBlockBaseCoords ; base coordinate table
add hl,de
add hl,de
ld a,[hli]
ld [W_BASECOORDY],a
ld a,[hl]
ld [W_BASECOORDX],a
pop hl
inc hl
ld a,[hl] ; frame block mode
ld [W_FBMODE],a
call DrawFrameBlock
call DoSpecialEffectByAnimationId ; run animation-specific function (if there is one)
ld a,[W_SUBANIMCOUNTER]
dec a
ld [W_SUBANIMCOUNTER],a
ret z
ld a,[W_SUBANIMSUBENTRYADDR + 1]
ld h,a
ld a,[W_SUBANIMSUBENTRYADDR]
ld l,a
ld a,[W_SUBANIMTRANSFORM]
cp a,4 ; is the animation reversed?
ld bc,3
jr nz,.nextSubanimationSubentry
ld bc,-3
.nextSubanimationSubentry
add hl,bc
ld a,h
ld [W_SUBANIMSUBENTRYADDR + 1],a
ld a,l
ld [W_SUBANIMSUBENTRYADDR],a
jp .loop
AnimationCleanOAM: ; 78ec8 (1e:4ec8)
push hl
push de
push bc
push af
call DelayFrame
call ClearSprites
pop af
pop bc
pop de
pop hl
ret
; this runs after each frame block is drawn in a subanimation
; it runs a particular special effect based on the animation ID
DoSpecialEffectByAnimationId: ; 78ed7 (1e:4ed7)
push hl
push de
push bc
ld a,[W_ANIMATIONID]
ld hl,AnimationIdSpecialEffects
ld de,3
call IsInArray
jr nc,.done
inc hl
ld a,[hli]
ld h,[hl]
ld l,a
ld de,.done
push de
jp [hl]
.done
pop bc
pop de
pop hl
ret
; Format: Animation ID (1 byte), Address (2 bytes)
AnimationIdSpecialEffects: ; 78ef5 (1e:4ef5)
db MEGA_PUNCH
dw AnimationFlashScreen
db GUILLOTINE
dw AnimationFlashScreen
db MEGA_KICK
dw AnimationFlashScreen
db HEADBUTT
dw AnimationFlashScreen
db TAIL_WHIP
dw TailWhipAnimationUnused
db GROWL
dw DoGrowlSpecialEffects
db DISABLE
dw AnimationFlashScreen
db BLIZZARD
dw DoBlizzardSpecialEffects
db BUBBLEBEAM
dw AnimationFlashScreen
db HYPER_BEAM
dw FlashScreenEveryFourFrameBlocks
db THUNDERBOLT
dw FlashScreenEveryEightFrameBlocks
db REFLECT
dw AnimationFlashScreen
db SELFDESTRUCT
dw DoExplodeSpecialEffects
db SPORE
dw AnimationFlashScreen
db EXPLOSION
dw DoExplodeSpecialEffects
db ROCK_SLIDE
dw DoRockSlideSpecialEffects
db TRADE_BALL_DROP_ANIM
dw TradeHidePokemon
db TRADE_BALL_SHAKE_ANIM
dw TradeShakePokeball
db TRADE_BALL_TILT_ANIM
dw TradeJumpPokeball
db TOSS_ANIM
dw DoBallTossSpecialEffects
db SHAKE_ANIM
dw DoBallShakeSpecialEffects
db POOF_ANIM
dw DoPoofSpecialEffects
db GREATTOSS_ANIM
dw DoBallTossSpecialEffects
db ULTRATOSS_ANIM
dw DoBallTossSpecialEffects
db $FF ; terminator
DoBallTossSpecialEffects: ; 78f3e (1e:4f3e)
ld a,[wcf91]
cp a,3 ; is it a Master Ball or Ultra Ball?
jr nc,.skipFlashingEffect
.flashingEffect ; do a flashing effect if it's Master Ball or Ultra Ball
ld a,[rOBP0]
xor a,%00111100 ; complement colors 1 and 2
ld [rOBP0],a
.skipFlashingEffect
ld a,[W_SUBANIMCOUNTER]
cp a,11 ; is it the beginning of the subanimation?
jr nz,.skipPlayingSound
; if it is the beginning of the subanimation, play a sound
ld a,SFX_BALL_TOSS
call PlaySound
.skipPlayingSound
ld a,[W_ISINBATTLE]
cp a,02 ; is it a trainer battle?
jr z,.isTrainerBattle
ld a,[wd11e]
cp a,$10 ; is the enemy pokemon the Ghost Marowak?
ret nz
; if the enemy pokemon is the Ghost Marowak, make it dodge during the last 3 frames
ld a,[W_SUBANIMCOUNTER]
cp a,3
jr z,.moveGhostMarowakLeft
cp a,2
jr z,.moveGhostMarowakLeft
cp a,1
ret nz
.moveGhostMarowakLeft
coord hl, 17, 0
ld de,20
lb bc, 7, 7
.loop
push hl
push bc
call AnimCopyRowRight ; move row of tiles left
pop bc
pop hl
add hl,de
dec b
jr nz,.loop
ld a,%00001000
ld [$ff10],a ; Channel 1 sweep register
ret
.isTrainerBattle ; if it's a trainer battle, shorten the animation by one frame
ld a,[W_SUBANIMCOUNTER]
cp a,3
ret nz
dec a
ld [W_SUBANIMCOUNTER],a
ret
DoBallShakeSpecialEffects: ; 78f96 (1e:4f96)
ld a,[W_SUBANIMCOUNTER]
cp a,4 ; is it the beginning of a shake?
jr nz,.skipPlayingSound
; if it is the beginning of a shake, play a sound and wait 2/3 of a second
ld a,SFX_TINK
call PlaySound
ld c,40
call DelayFrames
.skipPlayingSound
ld a,[W_SUBANIMCOUNTER]
dec a
ret nz
; if it's the end of the ball shaking subanimation, check if more shakes are left and restart the subanimation
ld a,[wNumShakes] ; number of shakes
dec a ; decrement number of shakes
ld [wNumShakes],a
ret z
; if there are shakes left, restart the subanimation
ld a,[W_SUBANIMSUBENTRYADDR]
ld l,a
ld a,[W_SUBANIMSUBENTRYADDR + 1]
ld h,a
ld de,-(4 * 3) ; 4 subentries and 3 bytes per subentry
add hl,de
ld a,l
ld [W_SUBANIMSUBENTRYADDR],a
ld a,h
ld [W_SUBANIMSUBENTRYADDR + 1],a
ld a,5 ; number of subentries in the ball shaking subanimation plus one
ld [W_SUBANIMCOUNTER],a
ret
; plays a sound after the second frame of the poof animation
DoPoofSpecialEffects: ; 78fce (1e:4fce)
ld a,[W_SUBANIMCOUNTER]
cp a,5
ret nz
ld a,SFX_BALL_POOF
jp PlaySound
DoRockSlideSpecialEffects: ; 78fd9 (1e:4fd9)
ld a,[W_SUBANIMCOUNTER]
cp a,12
ret nc
cp a,8
jr nc,.shakeScreen
cp a,1
jp z,AnimationFlashScreen ; if it's the end of the subanimation, flash the screen
ret
; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically
.shakeScreen
ld b,1
predef PredefShakeScreenHorizontally ; shake horizontally
ld b,1
predef_jump PredefShakeScreenVertically ; shake vertically
FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7)
ld a,[W_SUBANIMCOUNTER]
and a,7 ; is the subanimation counter exactly 8?
call z,AnimationFlashScreen ; if so, flash the screen
ret
; flashes the screen if the subanimation counter is divisible by 4
FlashScreenEveryFourFrameBlocks: ; 79000 (1e:5000)
ld a,[W_SUBANIMCOUNTER]
and a,3
call z,AnimationFlashScreen
ret
; used for Explosion and Selfdestruct
DoExplodeSpecialEffects: ; 79009 (1e:5009)
ld a,[W_SUBANIMCOUNTER]
cp a,1 ; is it the end of the subanimation?
jr nz,FlashScreenEveryFourFrameBlocks
; if it's the end of the subanimation, make the attacking pokemon disappear
coord hl, 1, 5
jp AnimationHideMonPic ; make pokemon disappear
; flashes the screen when subanimation counter is 1 modulo 4
DoBlizzardSpecialEffects: ; 79016 (1e:5016)
ld a,[W_SUBANIMCOUNTER]
cp a,13
jp z,AnimationFlashScreen
cp a,9
jp z,AnimationFlashScreen
cp a,5
jp z,AnimationFlashScreen
cp a,1
jp z,AnimationFlashScreen
ret
; flashes the screen at 3 points in the subanimation
; unused
FlashScreenUnused: ; 7902e (1e:502e)
ld a,[W_SUBANIMCOUNTER]
cp a,14
jp z,AnimationFlashScreen
cp a,9
jp z,AnimationFlashScreen
cp a,2
jp z,AnimationFlashScreen
ret
; function to make the pokemon disappear at the beginning of the animation
TradeHidePokemon: ; 79041 (1e:5041)
ld a,[W_SUBANIMCOUNTER]
cp a,6
ret nz
ld a,2 * SCREEN_WIDTH + 7
jp ClearMonPicFromTileMap ; make pokemon disappear
; function to make a shaking pokeball jump up at the end of the animation
TradeShakePokeball: ; 7904c (1e:504c)
ld a,[W_SUBANIMCOUNTER]
cp a,1
ret nz
; if it's the end of the animation, make the ball jump up
ld de,BallMoveDistances1
.loop
ld hl,wOAMBuffer ; OAM buffer
ld bc,4
.innerLoop
ld a,[de]
cp a,$ff
jr z,.done
add [hl] ; add to Y value of OAM entry
ld [hl],a
add hl,bc
ld a,l
cp a,4 * 4 ; there are 4 entries, each 4 bytes
jr nz,.innerLoop
inc de
push bc
call Delay3
pop bc
jr .loop
.done
call AnimationCleanOAM
ld a,SFX_TRADE_MACHINE
jp PlaySound
BallMoveDistances1: ; 79078 (1e:5078)
db -12,-12,-8
db $ff ; terminator
; function to make the pokeball jump up
TradeJumpPokeball: ; 507C
ld de,BallMoveDistances2
.loop
ld hl,wOAMBuffer ; OAM buffer
ld bc,4
.innerLoop
ld a,[de]
cp a,$ff
jp z,ClearScreen
add [hl]
ld [hl],a
add hl,bc
ld a,l
cp a,4 * 4 ; there are 4 entries, each 4 bytes
jr nz,.innerLoop
inc de
push de
ld a,[de]
cp a,12
jr z,.playSound
cp a,$ff
jr nz,.skipPlayingSound
.playSound ; play sound if next move distance is 12 or this is the last one
ld a,SFX_BATTLE_18
call PlaySound
.skipPlayingSound
push bc
ld c,5
call DelayFrames
pop bc
ld a,[hSCX] ; background scroll X
sub a,8 ; scroll to the left
ld [hSCX],a
pop de
jr .loop
BallMoveDistances2: ; 790b3 (1e:50b3)
db 11,12,-12,-7,7,12,-8,8
db $ff ; terminator
; this function copies the current musical note graphic
; so that there are two musical notes flying towards the defending pokemon
DoGrowlSpecialEffects: ; 790bc (1e:50bc)
ld hl,wOAMBuffer ; OAM buffer
ld de,wOAMBuffer + $10
ld bc,$10
call CopyData ; copy the musical note graphic
ld a,[W_SUBANIMCOUNTER]
dec a
call z,AnimationCleanOAM ; clean up at the end of the subanimation
ret
; this is associated with Tail Whip, but Tail Whip doesn't use any subanimations
TailWhipAnimationUnused: ; 790d0 (1e:50d0)
ld a,1
ld [W_SUBANIMCOUNTER],a
ld c,20
jp DelayFrames
; Format: Special Effect ID (1 byte), Address (2 bytes)
SpecialEffectPointers: ; 790da (1e:50da)
db SE_DARK_SCREEN_FLASH ; $FE
dw AnimationFlashScreen
db SE_DARK_SCREEN_PALETTE ; $FD
dw AnimationDarkScreenPalette
db SE_RESET_SCREEN_PALETTE ; $FC
dw AnimationResetScreenPalette
db SE_SHAKE_SCREEN ; $FB
dw AnimationShakeScreen
db SE_WATER_DROPLETS_EVERYWHERE ; $FA
dw AnimationWaterDropletsEverywhere
db SE_DARKEN_MON_PALETTE ; $F9
dw AnimationDarkenMonPalette
db SE_FLASH_SCREEN_LONG ; $F8
dw AnimationFlashScreenLong
db SE_SLIDE_MON_UP ; $F7
dw AnimationSlideMonUp
db SE_SLIDE_MON_DOWN ; $F6
dw AnimationSlideMonDown
db SE_FLASH_MON_PIC ; $F5
dw AnimationFlashMonPic
db SE_SLIDE_MON_OFF ; $F4
dw AnimationSlideMonOff
db SE_BLINK_MON ; $F3
dw AnimationBlinkMon
db SE_MOVE_MON_HORIZONTALLY ; $F2
dw AnimationMoveMonHorizontally
db SE_RESET_MON_POSITION ; $F1
dw AnimationResetMonPosition
db SE_LIGHT_SCREEN_PALETTE ; $F0
dw AnimationLightScreenPalette
db SE_HIDE_MON_PIC ; $EF
dw AnimationHideMonPic
db SE_SQUISH_MON_PIC ; $EE
dw AnimationSquishMonPic
db SE_SHOOT_BALLS_UPWARD ; $ED
dw AnimationShootBallsUpward
db SE_SHOOT_MANY_BALLS_UPWARD ; $EC
dw AnimationShootManyBallsUpward
db SE_BOUNCE_UP_AND_DOWN ; $EB
dw AnimationBoundUpAndDown
db SE_MINIMIZE_MON ; $EA
dw AnimationMinimizeMon
db SE_SLIDE_MON_DOWN_AND_HIDE ; $E9
dw AnimationSlideMonDownAndHide
db SE_TRANSFORM_MON ; $E8
dw AnimationTransformMon
db SE_LEAVES_FALLING ; $E7
dw AnimationLeavesFalling
db SE_PETALS_FALLING ; $E6
dw AnimationPetalsFalling
db SE_SLIDE_MON_HALF_OFF ; $E5
dw AnimationSlideMonHalfOff
db SE_SHAKE_ENEMY_HUD ; $E4
dw AnimationShakeEnemyHUD
db SE_SHAKE_ENEMY_HUD_2 ; unused--same pointer as SE_SHAKE_ENEMY_HUD ($E4)
dw AnimationShakeEnemyHUD
db SE_SPIRAL_BALLS_INWARD ; $E2
dw AnimationSpiralBallsInward
db SE_DELAY_ANIMATION_10 ; $E1
dw AnimationDelay10
db SE_FLASH_ENEMY_MON_PIC ; unused--same as SE_FLASH_MON_PIC ($F5), but for the enemy mon
dw AnimationFlashEnemyMonPic
db SE_HIDE_ENEMY_MON_PIC ; $DF
dw AnimationHideEnemyMonPic
db SE_BLINK_ENEMY_MON ; $DE
dw AnimationBlinkEnemyMon
db SE_SHOW_MON_PIC ; $DD
dw AnimationShowMonPic
db SE_SHOW_ENEMY_MON_PIC ; $DC
dw AnimationShowEnemyMonPic
db SE_SLIDE_ENEMY_MON_OFF ; $DB
dw AnimationSlideEnemyMonOff
db SE_SHAKE_BACK_AND_FORTH ; $DA
dw AnimationShakeBackAndForth
db SE_SUBSTITUTE_MON ; $D9
dw AnimationSubstitute
db SE_WAVY_SCREEN ; $D8
dw AnimationWavyScreen
db $FF
AnimationDelay10: ; 79150 (1e:5150)
ld c,10
jp DelayFrames
; calls a function with the turn flipped from player to enemy or vice versa
; input - hl - address of function to call
CallWithTurnFlipped: ; 79155 (1e:5155)
ld a,[H_WHOSETURN]
push af
xor a,1
ld [H_WHOSETURN],a
ld de,.returnAddress
push de
jp [hl]
.returnAddress
pop af
ld [H_WHOSETURN],a
ret
; flashes the screen for an extended period (48 frames)
AnimationFlashScreenLong: ; 79165 (1e:5165)
ld a,3 ; cycle through the palettes 3 times
ld [wFlashScreenLongCounter],a
ld a,[wOnSGB] ; running on SGB?
and a
ld hl,FlashScreenLongMonochrome
jr z,.loop
ld hl,FlashScreenLongSGB
.loop
push hl
.innerLoop
ld a,[hli]
cp a,$01 ; is it the end of the palettes?
jr z,.endOfPalettes
ld [rBGP],a
call FlashScreenLongDelay
jr .innerLoop
.endOfPalettes
ld a,[wFlashScreenLongCounter]
dec a
ld [wFlashScreenLongCounter],a
pop hl
jr nz,.loop
ret
; BG palettes
FlashScreenLongMonochrome: ; 7918e (1e:518e)
db %11111001 ; 3, 3, 2, 1
db %11111110 ; 3, 3, 3, 2
db %11111111 ; 3, 3, 3, 3
db %11111110 ; 3, 3, 3, 2
db %11111001 ; 3, 3, 2, 1
db %11100100 ; 3, 2, 1, 0
db %10010000 ; 2, 1, 0, 0
db %01000000 ; 1, 0, 0, 0
db %00000000 ; 0, 0, 0, 0
db %01000000 ; 1, 0, 0, 0
db %10010000 ; 2, 1, 0, 0
db %11100100 ; 3, 2, 1, 0
db $01 ; terminator
; BG palettes
FlashScreenLongSGB: ; 7919b (1e:519b)
db %11111000 ; 3, 3, 2, 0
db %11111100 ; 3, 3, 3, 0
db %11111111 ; 3, 3, 3, 3
db %11111100 ; 3, 3, 3, 0
db %11111000 ; 3, 3, 2, 0
db %11100100 ; 3, 2, 1, 0
db %10010000 ; 2, 1, 0, 0
db %01000000 ; 1, 0, 0, 0
db %00000000 ; 0, 0, 0, 0
db %01000000 ; 1, 0, 0, 0
db %10010000 ; 2, 1, 0, 0
db %11100100 ; 3, 2, 1, 0
db $01 ; terminator
; causes a delay of 2 frames for the first cycle
; causes a delay of 1 frame for the second and third cycles
FlashScreenLongDelay: ; 791a8 (1e:51a8)
ld a,[wFlashScreenLongCounter]
cp a,4 ; never true since [wFlashScreenLongCounter] starts at 3
ld c,4
jr z,.delayFrames
cp a,3
ld c,2
jr z,.delayFrames
cp a,2 ; nothing is done with this
ld c,1
.delayFrames
jp DelayFrames
AnimationFlashScreen: ; 791be (1e:51be)
ld a,[rBGP]
push af ; save initial palette
ld a,%00011011 ; 0, 1, 2, 3 (inverted colors)
ld [rBGP],a
ld c,2
call DelayFrames
xor a ; white out background
ld [rBGP],a
ld c,2
call DelayFrames
pop af
ld [rBGP],a ; restore initial palette
ret
AnimationDarkScreenPalette: ; 791d6 (1e:51d6)
; Changes the screen's palette to a dark palette.
lb bc, $6f, $6f
jr SetAnimationBGPalette
AnimationDarkenMonPalette: ; 791db (1e:51db)
; Darkens the mon sprite's palette.
lb bc, $f9, $f4
jr SetAnimationBGPalette
AnimationUnusedPalette1: ; 791e0 (1e:51e0)
lb bc, $fe, $f8
jr SetAnimationBGPalette
AnimationUnusedPalette2: ; 791e5 (1e:51e5)
lb bc, $ff, $ff
jr SetAnimationBGPalette
AnimationResetScreenPalette: ; 791ea (1e:51ea)
; Restores the screen's palette to the normal palette.
lb bc, $e4, $e4
jr SetAnimationBGPalette
AnimationUnusedPalette3: ; 791ef (1e:51ef)
lb bc, $00, $00
jr SetAnimationBGPalette
AnimationLightScreenPalette: ; 791f4 (1e:51f4)
; Changes the screen to use a palette with light colors.
lb bc, $90, $90
jr SetAnimationBGPalette
AnimationUnusedPalette4: ; 791f9 (1e:51f9)
lb bc, $40, $40
SetAnimationBGPalette: ; 791fc (1e:51fc)
ld a, [wOnSGB]
and a
ld a, b
jr z, .next
ld a, c
.next
ld [rBGP], a
ret
ld b, $5
AnimationShakeScreenVertically: ; 79209 (1e:5209)
predef_jump PredefShakeScreenVertically
AnimationShakeScreen: ; 7920e (1e:520e)
; Shakes the screen for a while. Used in Earthquake/Fissure/etc. animations.
ld b, $8
AnimationShakeScreenHorizontallyFast: ; 79210 (1e:5210)
predef_jump PredefShakeScreenHorizontally
AnimationWaterDropletsEverywhere: ; 79215 (1e:5215)
; Draws water droplets all over the screen and makes them
; scroll. It's hard to describe, but it's the main animation
; in Surf/Mist/Toxic.
xor a
ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
ld d, 32
ld a, -16
ld [W_BASECOORDX], a
ld a, $71
ld [wDropletTile], a
.loop
ld a, 16
ld [W_BASECOORDY], a
ld a, 0
ld [wUnusedD08A], a
call _AnimationWaterDroplets
ld a, 24
ld [W_BASECOORDY], a
ld a, 32
ld [wUnusedD08A], a
call _AnimationWaterDroplets
dec d
jr nz, .loop
ret
_AnimationWaterDroplets: ; 79246 (1e:5246)
ld hl, wOAMBuffer
.loop
ld a, [W_BASECOORDY]
ld [hli], a ; Y
ld a, [W_BASECOORDX]
add 27
ld [W_BASECOORDX], a
ld [hli], a ; X
ld a, [wDropletTile]
ld [hli], a ; tile
xor a
ld [hli], a ; attribute
ld a, [W_BASECOORDX]
cp 144
jr c, .loop
sub 168
ld [W_BASECOORDX], a
ld a, [W_BASECOORDY]
add 16
ld [W_BASECOORDY], a
cp 112
jr c, .loop
call AnimationCleanOAM
jp DelayFrame
AnimationSlideMonUp: ; 7927a (1e:527a)
; Slides the mon's sprite upwards.
ld c, 7
ld a, [H_WHOSETURN]
and a
coord hl, 1, 6
coord de, 1, 5
ld a, $30
jr z, .next
coord hl, 12, 1
coord de, 12, 0
ld a, $ff
.next
ld [wSlideMonUpBottomRowLeftTile], a
jp _AnimationSlideMonUp
AnimationSlideMonDown: ; 79297 (1e:5297)
; Slides the mon's sprite down out of the screen.
xor a
call GetTileIDList
.loop
call GetMonSpriteTileMapPointerFromRowCount
push bc
push de
call CopyPicTiles
call Delay3
call AnimationHideMonPic
pop de
pop bc
dec b
jr nz, .loop
ret
AnimationSlideMonOff: ; 792af (1e:52af)
; Slides the mon's sprite off the screen horizontally.
ld e, 8
ld a, 3
ld [wSlideMonDelay], a
jp _AnimationSlideMonOff
AnimationSlideEnemyMonOff: ; 792b9 (1e:52b9)
; Slides the enemy mon off the screen horizontally.
ld hl, AnimationSlideMonOff
jp CallWithTurnFlipped
_AnimationSlideMonUp: ; 792bf (1e:52bf)
push de
push hl
push bc
; In each iteration, slide up all rows but the top one (which is overwritten).
ld b, 6
.slideLoop
push bc
push de
push hl
ld bc, 7
call CopyData
; Note that de and hl are popped in the same order they are pushed, swapping
; their values. When CopyData is called, hl points to a tile 1 row below
; the one de points to. To maintain this relationship, after swapping, we add 2
; rows to hl so that it is 1 row below again.
pop de
pop hl
ld bc, SCREEN_WIDTH * 2
add hl, bc
pop bc
dec b
jr nz, .slideLoop
; Fill in the bottom row of the mon pic with the next row's tile IDs.
ld a, [H_WHOSETURN]
and a
coord hl, 1, 11
jr z, .next
coord hl, 12, 6
.next
ld a, [wSlideMonUpBottomRowLeftTile]
inc a
ld [wSlideMonUpBottomRowLeftTile], a
ld c, 7
.fillBottomRowLoop
ld [hli], a
add 7
dec c
jr nz, .fillBottomRowLoop
ld c, 2
call DelayFrames
pop bc
pop hl
pop de
dec c
jr nz, _AnimationSlideMonUp
ret
ShakeEnemyHUD_WritePlayerMonPicOAM: ; 792fd (1e:52fd)
; Writes the OAM entries for a copy of the player mon's pic in OAM.
; The top 5 rows are reproduced in OAM, although only 2 are actually needed.
ld a, $10
ld [W_BASECOORDX], a
ld a, $30
ld [W_BASECOORDY], a
ld hl, wOAMBuffer
ld d, 0
ld c, 7
.loop
ld a, [W_BASECOORDY]
ld e, a
ld b, 5
.innerLoop
call BattleAnimWriteOAMEntry
inc d
dec b
jr nz, .innerLoop
dec c
ret z
inc d
inc d
ld a, [W_BASECOORDX]
add 8
ld [W_BASECOORDX], a
jr .loop
BattleAnimWriteOAMEntry: ; 79329 (1e:5329)
; Y coordinate = e (increased by 8 each call, before the write to OAM)
; X coordinate = [W_BASECOORDX]
; tile = d
; attributes = 0
ld a, e
add 8
ld e, a
ld [hli], a
ld a, [W_BASECOORDX]
ld [hli], a
ld a, d
ld [hli], a
xor a
ld [hli], a
ret
AdjustOAMBlockXPos: ; 79337 (1e:5337)
ld l, e
ld h, d
AdjustOAMBlockXPos2: ; 79339 (1e:5339)
ld de, 4
.loop
ld a, [wCoordAdjustmentAmount]
ld b, a
ld a, [hl]
add b
cp 168
jr c, .skipPuttingEntryOffScreen
; put off-screen if X >= 168
dec hl
ld a, 160
ld [hli], a
.skipPuttingEntryOffScreen
ld [hl], a
add hl, de
dec c
jr nz, .loop
ret
AdjustOAMBlockYPos: ; 79350 (1e:5350)
ld l, e
ld h, d
AdjustOAMBlockYPos2: ; 79352 (1e:5352)
ld de, 4
.loop
ld a, [wCoordAdjustmentAmount]
ld b, a
ld a, [hl]
add b
cp 112
jr c, .skipSettingPreviousEntrysAttribute
dec hl
ld a, 160 ; bug, sets previous OAM entry's attribute
ld [hli], a
.skipSettingPreviousEntrysAttribute
ld [hl], a
add hl, de
dec c
jr nz, .loop
ret
AnimationBlinkEnemyMon: ; 79369 (1e:5369)
; Make the enemy mon's sprite blink on and off for a second or two
ld hl, AnimationBlinkMon
jp CallWithTurnFlipped
AnimationBlinkMon: ; 7936f (1e:536f)
; Make the mon's sprite blink on and off for a second or two.
push af
ld c, 6
.loop
push bc
call AnimationHideMonPic
ld c, 5
call DelayFrames
call AnimationShowMonPic
ld c, 5
call DelayFrames
pop bc
dec c
jr nz, .loop
pop af
ret
AnimationFlashMonPic: ; 79389 (1e:5389)
; Flashes the mon's sprite on and off
ld a, [wBattleMonSpecies]
ld [wChangeMonPicPlayerTurnSpecies], a
ld a, [wEnemyMonSpecies]
ld [wChangeMonPicEnemyTurnSpecies], a
jp ChangeMonPic
AnimationFlashEnemyMonPic: ; 79398 (1e:5398)
; Flashes the enemy mon's sprite on and off
ld hl, AnimationFlashMonPic
jp CallWithTurnFlipped
AnimationShowMonPic: ; 7939e (1e:539e)
xor a
call GetTileIDList
call GetMonSpriteTileMapPointerFromRowCount
call CopyPicTiles
jp Delay3
AnimationShowEnemyMonPic: ; 793ab (1e:53ab)
; Shows the emenmy mon's front sprite. Used in animations like Seismic Toss
; to make the mon's sprite reappear after disappears offscreen.
ld hl, AnimationShowMonPic
jp CallWithTurnFlipped
AnimationShakeBackAndForth: ; 793b1 (1e:53b1)
; Shakes the mon's sprite back and forth rapidly. This is used in Double Team.
; The mon's sprite disappears after this animation.
ld a, [H_WHOSETURN]
and a
coord hl, 0, 5
coord de, 2, 5
jr z, .next
coord hl, 11, 0
coord de, 13, 0
.next
xor a
ld c, $10
.loop
push af
push bc
push de
push hl
push hl
push de
push af
push hl
push hl
call GetTileIDList
pop hl
call CopyPicTiles
call Delay3
pop hl
lb bc, 7, 9
call ClearScreenArea
pop af
call GetTileIDList
pop hl
call CopyPicTiles
call Delay3
pop hl
lb bc, 7, 9
call ClearScreenArea
pop hl
pop de
pop bc
pop af
dec c
jr nz, .loop
ret
AnimationMoveMonHorizontally: ; 793f9 (1e:53f9)
; Shifts the mon's sprite horizontally to a fixed location. Used by lots of
; animations like Tackle/Body Slam.
call AnimationHideMonPic
ld a, [H_WHOSETURN]
and a
coord hl, 2, 5
jr z, .next
coord hl, 11, 0
.next
xor a
push hl
call GetTileIDList
pop hl
call CopyPicTiles
ld c, 3
jp DelayFrames
AnimationResetMonPosition: ; 79415 (1e:5415)
; Resets the mon's sprites to be located at the normal coordinates.
ld a, [H_WHOSETURN]
and a
ld a, 5 * SCREEN_WIDTH + 2
jr z, .next
ld a, 11
.next
call ClearMonPicFromTileMap
jp AnimationShowMonPic
AnimationSpiralBallsInward: ; 79424 (1e:5424)
; Creates an effect that looks like energy balls spiralling into the
; player mon's sprite. Used in Focus Energy, for example.
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn
ld a, -40
ld [wSpiralBallsBaseY], a
ld a, 80
ld [wSpiralBallsBaseX], a
jr .next
.playerTurn
xor a
ld [wSpiralBallsBaseY], a
ld [wSpiralBallsBaseX], a
.next
ld d, $7a ; ball tile
ld c, 3 ; number of balls
xor a
call InitMultipleObjectsOAM
ld hl, SpiralBallAnimationCoordinates
.loop
push hl
ld c, 3
ld de, wOAMBuffer
.innerLoop
ld a, [hl]
cp $ff
jr z, .done
ld a, [wSpiralBallsBaseY]
add [hl]
ld [de], a ; Y
inc de
inc hl
ld a, [wSpiralBallsBaseX]
add [hl]
ld [de], a ; X
inc hl
inc de
inc de
inc de
dec c
jr nz, .innerLoop
ld c, 5
call DelayFrames
pop hl
inc hl
inc hl
jr .loop
.done
pop hl
call AnimationCleanOAM
jp AnimationFlashScreen
SpiralBallAnimationCoordinates: ; 79476 (1e:5476)
; y, x pairs
; This is the sequence of screen coordinates that the spiralling
; balls are positioned at.
db $38, $28
db $40, $18
db $50, $10
db $60, $18
db $68, $28
db $60, $38
db $50, $40
db $40, $38
db $40, $28
db $46, $1E
db $50, $18
db $5B, $1E
db $60, $28
db $5B, $32
db $50, $38
db $46, $32
db $48, $28
db $50, $20
db $58, $28
db $50, $30
db $50, $28
db $FF ; list terminator
AnimationSquishMonPic: ; 794a1 (1e:54a1)
; Squishes the mon's sprite horizontally making it
; disappear. Used by Teleport/Sky Attack animations.
ld c, 4
.loop
push bc
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn
coord hl, 16, 0
coord de, 14, 0
jr .next
.playerTurn
coord hl, 5, 5
coord de, 3, 5
.next
push de
xor a ; left
ld [wSquishMonCurrentDirection], a
call _AnimationSquishMonPic
pop hl
ld a, 1 ; right
ld [wSquishMonCurrentDirection], a
call _AnimationSquishMonPic
pop bc
dec c
jr nz, .loop
call AnimationHideMonPic
ld c, 2
jp DelayFrame
_AnimationSquishMonPic: ; 794d4 (1e:54d4)
ld c, 7
.loop
push bc
push hl
ld c, 3
ld a, [wSquishMonCurrentDirection]
cp 0
jr nz, .right
call AnimCopyRowLeft
dec hl
jr .next
.right
call AnimCopyRowRight
inc hl
.next
ld [hl], " "
pop hl
ld de, SCREEN_WIDTH
add hl, de
pop bc
dec c
jr nz, .loop
jp Delay3
AnimationShootBallsUpward: ; 794f9 (1e:54f9)
; Shoots one pillar of "energy" balls upwards. Used in Teleport/Sky Attack
; animations.
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn
lb bc, 0, 16 * 8
jr .next
.playerTurn
lb bc, 6 * 8, 5 * 8
.next
ld a, b
ld [W_BASECOORDY], a
ld a, c
ld [W_BASECOORDX], a
lb bc, 5, 1
call _AnimationShootBallsUpward
jp AnimationCleanOAM
_AnimationShootBallsUpward: ; 79517 (1e:5517)
push bc
xor a
ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
pop bc
ld d, $7a ; ball tile
ld hl, wOAMBuffer
push bc
ld a, [W_BASECOORDY]
ld e, a
.initOAMLoop
call BattleAnimWriteOAMEntry
dec b
jr nz, .initOAMLoop
call DelayFrame
pop bc
ld a, b
ld [wNumShootingBalls], a
.loop
push bc
ld hl, wOAMBuffer
.innerLoop
ld a, [W_BASECOORDY]
add 8
ld e, a
ld a, [hl]
cp e ; has the ball reached the top?
jr z, .reachedTop
add -4 ; ball hasn't reached the top. move it up 4 pixels
ld [hl], a
jr .next
.reachedTop
; remove the ball once it has reached the top
ld [hl], 0 ; put it off-screen
ld a, [wNumShootingBalls]
dec a
ld [wNumShootingBalls], a
.next
ld de, 4
add hl, de ; next OAM entry
dec b
jr nz, .innerLoop
call DelayFrames
pop bc
ld a, [wNumShootingBalls]
and a
jr nz, .loop
ret
AnimationShootManyBallsUpward: ; 79566 (1e:5566)
; Shoots several pillars of "energy" balls upward.
ld a, [H_WHOSETURN]
and a
ld hl, UpwardBallsAnimXCoordinatesPlayerTurn
ld a, $50 ; y coordinate for "energy" ball pillar
jr z, .player
ld hl, UpwardBallsAnimXCoordinatesEnemyTurn
ld a, $28 ; y coordinate for "energy" ball pillar
.player
ld [wSavedY], a
.loop
ld a, [wSavedY]
ld [W_BASECOORDY], a
ld a, [hli]
cp $ff
jp z, AnimationCleanOAM
ld [W_BASECOORDX], a
lb bc, 4, 1
push hl
call _AnimationShootBallsUpward
pop hl
jr .loop
UpwardBallsAnimXCoordinatesPlayerTurn: ; 79591 (1e:5591)
; List of x coordinates for each pillar of "energy" balls in the
; AnimationShootManyBallsUpward animation. It's unused in the game.
db $10, $40, $28, $18, $38, $30
db $FF ; list terminator
UpwardBallsAnimXCoordinatesEnemyTurn: ; 79598 (1e:5598)
; List of x coordinates for each pillar of "energy" balls in the
; AnimationShootManyBallsUpward animation. It's unused in the game.
db $60, $90, $78, $68, $88, $80
db $FF ; list terminator
AnimationMinimizeMon: ; 7959f (1e:559f)
; Changes the mon's sprite to a mini black sprite. Used by the
; Minimize animation.
ld hl, wTempPic
push hl
xor a
ld bc, $310
call FillMemory
pop hl
ld de, $194
add hl, de
ld de, MinimizedMonSprite
ld c, $5
.loop
ld a, [de]
ld [hli], a
ld [hli], a
inc de
dec c
jr nz, .loop
call CopyTempPicToMonPic
call Delay3
jp AnimationShowMonPic
MinimizedMonSprite: ; 795c4 (1e:55c4)
INCBIN "gfx/minimized_mon_sprite.1bpp"
AnimationSlideMonDownAndHide: ; 795c9 (1e:55c9)
; Slides the mon's sprite down and disappears. Used in Acid Armor.
ld a, $1
ld c, $2
.loop
push bc
push af
call AnimationHideMonPic
pop af
push af
call GetTileIDList
call GetMonSpriteTileMapPointerFromRowCount
call CopyPicTiles
ld c, 8
call DelayFrames
pop af
inc a
pop bc
dec c
jr nz, .loop
call AnimationHideMonPic
ld hl, wTempPic
ld bc, $0310
xor a
call FillMemory
jp CopyTempPicToMonPic
_AnimationSlideMonOff: ; 795f8 (1e:55f8)
; Slides the mon's sprite off the screen horizontally by e tiles and waits
; [wSlideMonDelay] V-blanks each time the pic is slid by one tile.
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn
coord hl, 12, 0
jr .next
.playerTurn
coord hl, 0, 5
.next
ld d, 8 ; d's value is unused
.slideLoop ; iterates once for each time the pic slides by one tile
push hl
ld b, 7
.rowLoop ; iterates once for each row
ld c, 8
.tileLoop ; iterates once for each tile in the row
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn2
call .EnemyNextTile
jr .next2
.playerTurn2
call .PlayerNextTile
.next2
ld [hli], a
dec c
jr nz, .tileLoop
push de
ld de, SCREEN_WIDTH - 8
add hl, de
pop de
dec b
jr nz, .rowLoop
ld a, [wSlideMonDelay]
ld c, a
call DelayFrames
pop hl
dec d
dec e
jr nz, .slideLoop
ret
; Since mon pic tile numbers go from top to bottom, left to right in order,
; adding the height of the mon pic in tiles to a tile number gives the tile
; number of the tile one column to the right (and thus subtracting the height
; gives the reverse). If the next tile would be past the edge of the pic, the 2
; functions below catch it by checking if the tile number is within the valid
; range and if not, replacing it with a blank tile.
.PlayerNextTile ; 79633 (1e:5633)
ld a, [hl]
add 7
; This is a bug. The lower right corner tile of the mon back pic is blanked
; while the mon is sliding off the screen. It should compare with the max tile
; plus one instead.
cp $61
ret c
ld a, " "
ret
.EnemyNextTile ; 7963c (1e:563c)
ld a, [hl]
sub 7
; This has the same problem as above, but it has no visible effect because
; the lower right tile is in the first column to slide off the screen.
cp $30
ret c
ld a, " "
ret
AnimationSlideMonHalfOff: ; 79645 (1e:5645)
; Slides the mon's sprite halfway off the screen. It's used in Softboiled.
ld e, 4
ld a, 4
ld [wSlideMonDelay], a
call _AnimationSlideMonOff
jp Delay3
CopyTempPicToMonPic: ; 79652 (1e:5652)
ld a, [H_WHOSETURN]
and a
ld hl, vBackPic ; player turn
jr z, .next
ld hl, vFrontPic ; enemy turn
.next
ld de, wTempPic
ld bc, 7 * 7
jp CopyVideoData
AnimationWavyScreen: ; 79666 (1e:5666)
; used in Psywave/Psychic etc.
ld hl, vBGMap0
call BattleAnimCopyTileMapToVRAM
call Delay3
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
ld d, $80 ; terminator
ld e, SCREEN_HEIGHT_PIXELS - 1
ld c, $ff
ld hl, WavyScreenLineOffsets
.loop
push hl
.innerLoop
call WavyScreen_SetSCX
ld a, [rLY]
cp e ; is it the last visible line in the frame?
jr nz, .innerLoop ; keep going if not
pop hl
inc hl
ld a, [hl]
cp d ; have we reached the end?
jr nz, .next
ld hl, WavyScreenLineOffsets ; go back to the beginning if so
.next
dec c
jr nz, .loop
xor a
ld [hWY], a
call SaveScreenTilesToBuffer2
call ClearScreen
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
call Delay3
call LoadScreenTilesFromBuffer2
ld hl, vBGMap1
call BattleAnimCopyTileMapToVRAM
ret
WavyScreen_SetSCX: ; 796ae (1e:56ae)
ld a, [rSTAT]
and $3 ; is it H-blank?
jr nz, WavyScreen_SetSCX ; wait until it's H-blank
ld a, [hl]
ld [rSCX], a
inc hl
ld a, [hl]
cp d ; have we reached the end?
ret nz
ld hl, WavyScreenLineOffsets ; go back to the beginning if so
ret
WavyScreenLineOffsets: ; 796bf (1e:56bf)
; Sequence of horizontal line pixel offsets for the wavy screen animation.
; This sequence vaguely resembles a sine wave.
db 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1
db 0, 0, 0, 0, 0, -1, -1, -1, -2, -2, -2, -2, -2, -1, -1, -1
db $80 ; terminator
AnimationSubstitute: ; 796e0 (1e:56e0)
; Changes the pokemon's sprite to the mini sprite
ld hl, wTempPic
xor a
ld bc, $0310
call FillMemory
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn
ld hl, SlowbroSprite ; facing down sprite
ld de, wTempPic + $120
call CopySlowbroSpriteData
ld hl, SlowbroSprite + $10
ld de, wTempPic + $120 + $70
call CopySlowbroSpriteData
ld hl, SlowbroSprite + $20
ld de, wTempPic + $120 + $10
call CopySlowbroSpriteData
ld hl, SlowbroSprite + $30
ld de, wTempPic + $120 + $10 + $70
call CopySlowbroSpriteData
jr .next
.playerTurn
ld hl, SlowbroSprite + $40 ; facing up sprite
ld de, wTempPic + $120 + $70
call CopySlowbroSpriteData
ld hl, SlowbroSprite + $50
ld de, wTempPic + $120 + $e0
call CopySlowbroSpriteData
ld hl, SlowbroSprite + $60
ld de, wTempPic + $120 + $80
call CopySlowbroSpriteData
ld hl, SlowbroSprite + $70
ld de, wTempPic + $120 + $f0
call CopySlowbroSpriteData
.next
call CopyTempPicToMonPic
jp AnimationShowMonPic
CopySlowbroSpriteData: ; 7973f (1e:573f)
ld bc, $0010
ld a, BANK(SlowbroSprite)
jp FarCopyData2
HideSubstituteShowMonAnim: ; 79747 (1e:5747)
ld a, [H_WHOSETURN]
and a
ld hl, wPlayerMonMinimized
ld a, [W_PLAYERBATTSTATUS2]
jr z, .next1
ld hl, wEnemyMonMinimized
ld a, [W_ENEMYBATTSTATUS2]
.next1
push hl
; if the substitute broke, slide it down, else slide it offscreen horizontally
bit HasSubstituteUp, a
jr nz, .substituteStillUp
call AnimationSlideMonDown
jr .next2
.substituteStillUp
call AnimationSlideMonOff
.next2
pop hl
ld a, [hl]
and a
jp nz, AnimationMinimizeMon
call AnimationFlashMonPic
jp AnimationShowMonPic
ReshowSubstituteAnim: ; 79771 (1e:5771)
call AnimationSlideMonOff
call AnimationSubstitute
jp AnimationShowMonPic
AnimationBoundUpAndDown: ; 7977a (1e:577a)
; Bounces the mon's sprite up and down several times. It is used
; by Splash's animation.
ld c, 5
.loop
push bc
call AnimationSlideMonDown
pop bc
dec c
jr nz, .loop
jp AnimationShowMonPic
AnimationTransformMon: ; 79787 (1e:5787)
; Redraws this mon's sprite as the back/front sprite of the opposing mon.
; Used in Transform.
ld a, [wEnemyMonSpecies]
ld [wChangeMonPicPlayerTurnSpecies], a
ld a, [wBattleMonSpecies]
ld [wChangeMonPicEnemyTurnSpecies], a
ChangeMonPic: ; 79793 (1e:5793)
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn
ld a, [wChangeMonPicEnemyTurnSpecies]
ld [wcf91], a
ld [wd0b5], a
xor a
ld [W_SPRITEFLIPPED], a
call GetMonHeader
coord hl, 12, 0
call LoadFrontSpriteByMonIndex
jr .done
.playerTurn
ld a, [wBattleMonSpecies2]
push af
ld a, [wChangeMonPicPlayerTurnSpecies]
ld [wBattleMonSpecies2], a
ld [wd0b5], a
call GetMonHeader
predef LoadMonBackPic
xor a
call GetTileIDList
call GetMonSpriteTileMapPointerFromRowCount
call CopyPicTiles
pop af
ld [wBattleMonSpecies2], a
.done
ld b, $1
jp GoPAL_SET
AnimationHideEnemyMonPic: ; 797d8 (1e:57d8)
; Hides the enemy mon's sprite
xor a
ld [H_AUTOBGTRANSFERENABLED], a
ld hl, AnimationHideMonPic
call CallWithTurnFlipped
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
jp Delay3
InitMultipleObjectsOAM: ; 797e8 (1e:57e8)
; Writes c OAM entries with tile d.
; Sets their Y coordinates to sequential multiples of 8, starting from 0.
; Sets their X coordinates to 0.
; Loads animation tileset a.
push bc
push de
ld [wWhichBattleAnimTileset], a
call LoadAnimationTileset
pop de
pop bc
xor a
ld e, a
ld [W_BASECOORDX], a
ld hl, wOAMBuffer
.loop
call BattleAnimWriteOAMEntry
dec c
jr nz, .loop
ret
AnimationHideMonPic: ; 79801 (1e:5801)
; Hides the mon's sprite.
ld a, [H_WHOSETURN]
and a
jr z, .playerTurn
ld a, 12
jr ClearMonPicFromTileMap
.playerTurn
ld a, 5 * SCREEN_WIDTH + 1
ClearMonPicFromTileMap: ; 7980c (1e:580c)
push hl
push de
push bc
ld e, a
ld d, 0
coord hl, 0, 0
add hl, de
lb bc, 7, 7
call ClearScreenArea
pop bc
pop de
pop hl
ret
; puts the tile map destination address of a mon sprite in hl, given the row count in b
; The usual row count is 7, but it may be smaller when sliding a mon sprite in/out,
; in order to show only a portion of the mon sprite.
GetMonSpriteTileMapPointerFromRowCount: ; 79820 (1e:5820)
push de
ld a, [H_WHOSETURN]
and a
jr nz, .enemyTurn
ld a, 20 * 5 + 1
jr .next
.enemyTurn
ld a, 12
.next
coord hl, 0, 0
ld e, a
ld d, 0
add hl, de
ld a, 7
sub b
and a
jr z, .done
ld de, 20
.loop
add hl, de
dec a
jr nz, .loop
.done
pop de
ret
; Input:
; a = tile ID list index
; Output:
; de = tile ID list pointer
; b = number of rows
; c = number of columns
GetTileIDList: ; 79842 (1e:5842)
ld hl, TileIDListPointerTable
ld e, a
ld d, 0
add hl, de
add hl, de
add hl, de
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld b, a
and $f
ld c, a
ld a, b
swap a
and $f
ld b, a
ret
AnimCopyRowLeft: ; 7985b (1e:585b)
; copy a row of c tiles 1 tile left
ld a, [hld]
ld [hli], a
inc hl
dec c
jr nz, AnimCopyRowLeft
ret
AnimCopyRowRight: ; 79862 (1e:5862)
; copy a row of c tiles 1 tile right
ld a, [hli]
ld [hld], a
dec hl
dec c
jr nz, AnimCopyRowRight
ret
; get the sound of the move id in b
GetMoveSoundB: ; 79869 (1e:5869)
ld a, b
call GetMoveSound
ld b, a
ret
; get the sound of the (move id - 1) in a
GetMoveSound: ; 7986f (1e:586f)
ld hl,MoveSoundTable
ld e,a
ld d,0
add hl,de
add hl,de
add hl,de
ld a,[hli]
ld b,a
call IsCryMove
jr nc,.NotCryMove
ld a,[H_WHOSETURN]
and a
jr nz,.next
ld a,[wBattleMonSpecies] ; get number of current monster
jr .Continue
.next
ld a,[wEnemyMonSpecies]
.Continue
push hl
call GetCryData
ld b,a
pop hl
ld a,[wc0f1]
add [hl]
ld [wc0f1],a
inc hl
ld a,[wc0f2]
add [hl]
ld [wc0f2],a
jr .done
.NotCryMove
ld a,[hli]
ld [wc0f1],a
ld a,[hli]
ld [wc0f2],a
.done
ld a,b
ret
IsCryMove: ; 798ad (1e:58ad)
; set carry if the move animation involves playing a monster cry
ld a,[W_ANIMATIONID]
cp a,GROWL
jr z,.CryMove
cp a,ROAR
jr z,.CryMove
and a ; clear carry
ret
.CryMove
scf
ret
MoveSoundTable: ; 798bc (1e:58bc)
db SFX_POUND, $00,$80 ; POUND
db SFX_BATTLE_0C, $10,$80 ; KARATE_CHOP
db SFX_DOUBLESLAP, $00,$80 ; DOUBLESLAP
db SFX_BATTLE_0B, $01,$80 ; COMET_PUNCH
db SFX_BATTLE_0D, $00,$40 ; MEGA_PUNCH
db SFX_SILPH_SCOPE, $00,$ff ; PAY_DAY
db SFX_BATTLE_0D, $10,$60 ; FIRE_PUNCH
db SFX_BATTLE_0D, $20,$80 ; ICE_PUNCH
db SFX_BATTLE_0D, $00,$a0 ; THUNDERPUNCH
db SFX_DAMAGE, $00,$80 ; SCRATCH
db SFX_BATTLE_0F, $20,$40 ; VICEGRIP
db SFX_BATTLE_0F, $00,$80 ; GUILLOTINE
db SFX_BATTLE_0E, $00,$a0 ; RAZOR_WIND
db SFX_NOT_VERY_EFFECTIVE,$10,$c0 ; SWORDS_DANCE
db SFX_NOT_VERY_EFFECTIVE,$00,$a0 ; CUT
db SFX_BATTLE_12, $00,$c0 ; GUST
db SFX_BATTLE_12, $10,$a0 ; WING_ATTACK
db SFX_BATTLE_13, $00,$e0 ; WHIRLWIND
db SFX_NOT_VERY_EFFECTIVE,$20,$c0 ; FLY
db SFX_BATTLE_14, $00,$80 ; BIND
db SFX_BATTLE_22, $00,$80 ; SLAM
db SFX_VINE_WHIP, $01,$80 ; VINE_WHIP
db SFX_BATTLE_20, $00,$80 ; STOMP
db SFX_BATTLE_17, $f0,$40 ; DOUBLE_KICK
db SFX_SUPER_EFFECTIVE, $00,$80 ; MEGA_KICK
db SFX_BATTLE_17, $00,$80 ; JUMP_KICK
db SFX_BATTLE_21, $10,$80 ; ROLLING_KICK
db SFX_BATTLE_1B, $01,$a0 ; SAND_ATTACK
db SFX_BATTLE_18, $00,$80 ; HEADBUTT
db SFX_BATTLE_1E, $00,$60 ; HORN_ATTACK
db SFX_BATTLE_1E, $01,$40 ; FURY_ATTACK
db SFX_HORN_DRILL, $00,$a0 ; HORN_DRILL
db SFX_SUPER_EFFECTIVE, $10,$a0 ; TACKLE
db SFX_BATTLE_20, $00,$c0 ; BODY_SLAM
db SFX_BATTLE_14, $10,$60 ; WRAP
db SFX_SUPER_EFFECTIVE, $00,$a0 ; TAKE_DOWN
db SFX_BATTLE_22, $11,$c0 ; THRASH
db SFX_SUPER_EFFECTIVE, $20,$c0 ; DOUBLE_EDGE
db SFX_BATTLE_21, $00,$80 ; TAIL_WHIP
db SFX_BATTLE_1B, $00,$80 ; POISON_STING
db SFX_BATTLE_1B, $20,$c0 ; TWINEEDLE
db SFX_BATTLE_19, $00,$80 ; PIN_MISSILE
db SFX_BATTLE_31, $ff,$40 ; LEER
db SFX_BATTLE_1E, $00,$80 ; BITE
db SFX_BATTLE_0B, $00,$c0 ; GROWL
db SFX_BATTLE_0B, $00,$40 ; ROAR
db SFX_BATTLE_35, $00,$80 ; SING
db SFX_BATTLE_27, $40,$60 ; SUPERSONIC
db SFX_BATTLE_27, $00,$80 ; SONICBOOM
db SFX_BATTLE_27, $ff,$40 ; DISABLE
db SFX_BATTLE_2A, $80,$c0 ; ACID
db SFX_BATTLE_19, $10,$a0 ; EMBER
db SFX_BATTLE_19, $21,$e0 ; FLAMETHROWER
db SFX_BATTLE_29, $00,$80 ; MIST
db SFX_BATTLE_24, $20,$60 ; WATER_GUN
db SFX_BATTLE_2A, $00,$80 ; HYDRO_PUMP
db SFX_BATTLE_2C, $00,$80 ; SURF
db SFX_BATTLE_28, $40,$80 ; ICE_BEAM
db SFX_BATTLE_29, $f0,$e0 ; BLIZZARD
db SFX_PSYBEAM, $00,$80 ; PSYBEAM
db SFX_BATTLE_2A, $f0,$60 ; BUBBLEBEAM
db SFX_BATTLE_28, $00,$80 ; AURORA_BEAM
db SFX_BATTLE_36, $00,$80 ; HYPER_BEAM
db SFX_PECK,$01, $a0 ; PECK
db SFX_BATTLE_13, $f0,$20 ; DRILL_PECK
db SFX_BATTLE_23, $01,$c0 ; SUBMISSION
db SFX_BATTLE_23, $00,$80 ; LOW_KICK
db SFX_SUPER_EFFECTIVE, $00,$e0 ; COUNTER
db SFX_BATTLE_26, $01,$60 ; SEISMIC_TOSS
db SFX_BATTLE_26, $20,$40 ; STRENGTH
db SFX_BATTLE_24, $00,$80 ; ABSORB
db SFX_BATTLE_24, $40,$c0 ; MEGA_DRAIN
db SFX_BATTLE_1B, $03,$60 ; LEECH_SEED
db SFX_BATTLE_25, $11,$e0 ; GROWTH
db SFX_BATTLE_12, $20,$e0 ; RAZOR_LEAF
db SFX_BATTLE_2E, $00,$80 ; SOLARBEAM
db SFX_BATTLE_1C, $00,$80 ; POISONPOWDER
db SFX_BATTLE_1C, $11,$a0 ; STUN_SPORE
db SFX_BATTLE_1C, $01,$c0 ; SLEEP_POWDER
db SFX_BATTLE_13, $14,$c0 ; PETAL_DANCE
db SFX_BATTLE_1B, $02,$a0 ; STRING_SHOT
db SFX_BATTLE_29, $f0,$80 ; DRAGON_RAGE
db SFX_BATTLE_29, $20,$c0 ; FIRE_SPIN
db SFX_BATTLE_2F, $00,$20 ; THUNDERSHOCK
db SFX_BATTLE_2F, $20,$80 ; THUNDERBOLT
db SFX_BATTLE_2E, $12,$60 ; THUNDER_WAVE
db SFX_BATTLE_26, $00,$80 ; THUNDER
db SFX_BATTLE_14, $01,$e0 ; ROCK_THROW
db SFX_BATTLE_29, $0f,$e0 ; EARTHQUAKE
db SFX_BATTLE_29, $11,$20 ; FISSURE
db SFX_DAMAGE, $10,$40 ; DIG
db SFX_BATTLE_0F, $10,$c0 ; TOXIC
db SFX_BATTLE_14, $00,$20 ; CONFUSION
db SFX_PSYCHIC_M, $00,$80 ; PSYCHIC_M
db SFX_BATTLE_35, $11,$18 ; HYPNOSIS
db SFX_BATTLE_09, $20,$c0 ; MEDITATE
db SFX_FAINT_FALL, $20,$c0 ; AGILITY
db SFX_BATTLE_25, $00,$10 ; QUICK_ATTACK
db SFX_BATTLE_26, $f0,$20 ; RAGE
db SFX_BATTLE_33, $f0,$c0 ; TELEPORT
db SFX_NOT_VERY_EFFECTIVE,$f0,$e0 ; NIGHT_SHADE
db SFX_BATTLE_09, $f0,$40 ; MIMIC
db SFX_BATTLE_31, $00,$80 ; SCREECH
db SFX_BATTLE_33, $80,$40 ; DOUBLE_TEAM
db SFX_BATTLE_33, $00,$80 ; RECOVER
db SFX_BATTLE_14, $11,$20 ; HARDEN
db SFX_BATTLE_14, $22,$10 ; MINIMIZE
db SFX_BATTLE_1B, $f1,$ff ; SMOKESCREEN
db SFX_BATTLE_13, $f1,$ff ; CONFUSE_RAY
db SFX_BATTLE_14, $33,$30 ; WITHDRAW
db SFX_BATTLE_32, $40,$c0 ; DEFENSE_CURL
db SFX_BATTLE_0E, $20,$20 ; BARRIER
db SFX_BATTLE_0E, $f0,$10 ; LIGHT_SCREEN
db SFX_BATTLE_0F, $f8,$10 ; HAZE
db SFX_NOT_VERY_EFFECTIVE,$f0,$10 ; REFLECT
db SFX_BATTLE_25, $00,$80 ; FOCUS_ENERGY
db SFX_BATTLE_18, $00,$c0 ; BIDE
db SFX_BATTLE_32, $c0,$ff ; METRONOME
db SFX_BATTLE_09, $f2,$20 ; MIRROR_MOVE
db SFX_BATTLE_34, $00,$80 ; SELFDESTRUCT
db SFX_BATTLE_34, $00,$40 ; EGG_BOMB
db SFX_BATTLE_09, $00,$40 ; LICK
db SFX_NOT_VERY_EFFECTIVE,$10,$ff ; SMOG
db SFX_BATTLE_2A, $20,$20 ; SLUDGE
db SFX_BATTLE_32, $00,$80 ; BONE_CLUB
db SFX_BATTLE_29, $1f,$20 ; FIRE_BLAST
db SFX_BATTLE_25, $2f,$80 ; WATERFALL
db SFX_BATTLE_0F, $1f,$ff ; CLAMP
db SFX_BATTLE_2B, $1f,$60 ; SWIFT
db SFX_BATTLE_26, $1e,$20 ; SKULL_BASH
db SFX_BATTLE_26, $1f,$18 ; SPIKE_CANNON
db SFX_BATTLE_14, $0f,$80 ; CONSTRICT
db SFX_BATTLE_09, $f8,$10 ; AMNESIA
db SFX_FAINT_FALL, $18,$20 ; KINESIS
db SFX_BATTLE_32, $08,$40 ; SOFTBOILED
db SFX_BATTLE_17, $01,$e0 ; HI_JUMP_KICK
db SFX_NOT_VERY_EFFECTIVE,$09,$ff ; GLARE
db SFX_BATTLE_35, $42,$01 ; DREAM_EATER
db SFX_BATTLE_1C, $00,$ff ; POISON_GAS
db SFX_BATTLE_32, $08,$e0 ; BARRAGE
db SFX_BATTLE_24, $00,$80 ; LEECH_LIFE
db SFX_BATTLE_09, $88,$10 ; LOVELY_KISS
db SFX_BATTLE_25, $48,$ff ; SKY_ATTACK
db SFX_FAINT_FALL, $ff,$ff ; TRANSFORM
db SFX_BATTLE_24, $ff,$10 ; BUBBLE
db SFX_FAINT_FALL, $ff,$04 ; DIZZY_PUNCH
db SFX_BATTLE_1C, $01,$ff ; SPORE
db SFX_BATTLE_13, $f8,$ff ; FLASH
db SFX_BATTLE_0C, $f0,$f0 ; PSYWAVE
db SFX_BATTLE_0F, $08,$10 ; SPLASH
db SFX_BATTLE_0D, $f0,$ff ; ACID_ARMOR
db SFX_SUPER_EFFECTIVE, $f0,$ff ; CRABHAMMER
db SFX_BATTLE_34, $10,$ff ; EXPLOSION
db SFX_BATTLE_0E, $f0,$20 ; FURY_SWIPES
db SFX_BATTLE_2B, $f0,$60 ; BONEMERANG
db SFX_BATTLE_21, $12,$10 ; REST
db SFX_BATTLE_36, $f0,$20 ; ROCK_SLIDE
db SFX_BATTLE_1E, $12,$ff ; HYPER_FANG
db SFX_BATTLE_31, $80,$04 ; SHARPEN
db SFX_BATTLE_33, $f0,$10 ; CONVERSION
db SFX_BATTLE_29, $f8,$ff ; TRI_ATTACK
db SFX_BATTLE_26, $f0,$ff ; SUPER_FANG
db SFX_NOT_VERY_EFFECTIVE,$01,$ff ; SLASH
db SFX_BATTLE_2C, $d8,$04 ; SUBSTITUTE
db SFX_BATTLE_0B, $00,$80 ; STRUGGLE
db SFX_BATTLE_0B, $00,$80
CopyPicTiles: ; 79aae (1e:5aae)
ld a, [H_WHOSETURN]
and a
ld a, $31 ; base tile ID of player mon sprite
jr z, .next
; enemy turn
xor a ; base tile ID of enemy mon sprite
.next
ld [hBaseTileID], a
jr CopyTileIDs_NoBGTransfer
; copy the tiles used when a mon is being sent out of or into a pokeball
CopyDownscaledMonTiles: ; 79aba (1e:5aba)
call GetPredefRegisters
ld a, [wDownscaledMonSize]
and a
jr nz, .smallerSize
ld de, DownscaledMonTiles_5x5
jr CopyTileIDs_NoBGTransfer
.smallerSize
ld de, DownscaledMonTiles_3x3
; fall through
CopyTileIDs_NoBGTransfer: ; 79acb (1e:5acb)
xor a
ld [H_AUTOBGTRANSFERENABLED], a
; fall through
; b = number of rows
; c = number of columns
CopyTileIDs: ; 79ace (1e:5ace)
push hl
.rowLoop
push bc
push hl
ld a, [hBaseTileID]
ld b, a
.columnLoop
ld a, [de]
add b
inc de
ld [hli], a
dec c
jr nz, .columnLoop
pop hl
ld bc, 20
add hl, bc
pop bc
dec b
jr nz, .rowLoop
ld a, $1
ld [H_AUTOBGTRANSFERENABLED], a
pop hl
ret
TileIDListPointerTable: ; 79aea (1e:5aea)
dw Unknown_79b24
db $77
dw Unknown_79b55
db $57
dw Unknown_79b78
db $37
dw Unknown_79b8d
db $77
dw Unknown_79bbe
db $77
dw Unknown_79bef
db $77
dw Unknown_79c20
db $86
dw Unknown_79c50
db $3C
DownscaledMonTiles_5x5: ; 79b02 (1e:5b02)
db $31,$38,$46,$54,$5B
db $32,$39,$47,$55,$5C
db $34,$3B,$49,$57,$5E
db $36,$3D,$4B,$59,$60
db $37,$3E,$4C,$5A,$61
DownscaledMonTiles_3x3: ; 79b1b (1e:5b1b)
db $31,$46,$5B
db $34,$49,$5E
db $37,$4C,$61
Unknown_79b24: ; 79b24 (1e:5b24)
db $00,$07,$0E,$15,$1C,$23,$2A
db $01,$08,$0F,$16,$1D,$24,$2B
db $02,$09,$10,$17,$1E,$25,$2C
db $03,$0A,$11,$18,$1F,$26,$2D
db $04,$0B,$12,$19,$20,$27,$2E
db $05,$0C,$13,$1A,$21,$28,$2F
db $06,$0D,$14,$1B,$22,$29,$30
Unknown_79b55: ; 79b55 (1e:5b55)
db $00,$07,$0E,$15,$1C,$23,$2A
db $01,$08,$0F,$16,$1D,$24,$2B
db $03,$0A,$11,$18,$1F,$26,$2D
db $04,$0B,$12,$19,$20,$27,$2E
db $05,$0C,$13,$1A,$21,$28,$2F
Unknown_79b78: ; 79b78 (1e:5b78)
db $00,$07,$0E,$15,$1C,$23,$2A
db $02,$09,$10,$17,$1E,$25,$2C
db $04,$0B,$12,$19,$20,$27,$2E
Unknown_79b8d: ; 79b8d (1e:5b8d)
db $00,$00,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$19,$00
db $02,$06,$0B,$10,$14,$1A,$00
db $00,$07,$0C,$11,$15,$1B,$00
db $03,$08,$0D,$12,$16,$1C,$00
db $04,$09,$0E,$13,$17,$1D,$1F
db $05,$0A,$0F,$01,$18,$1E,$20
Unknown_79bbe: ; 79bbe (1e:5bbe)
db $00,$00,$00,$30,$00,$37,$00
db $00,$00,$2B,$31,$34,$38,$3D
db $21,$26,$2C,$01,$35,$39,$3E
db $22,$27,$2D,$32,$36,$01,$00
db $23,$28,$2E,$33,$01,$3A,$00
db $24,$29,$2F,$01,$01,$3B,$00
db $25,$2A,$01,$01,$01,$3C,$00
Unknown_79bef: ; 79bef (1e:5bef)
db $00,$00,$00,$00,$00,$00,$00
db $00,$00,$47,$4D,$00,$00,$00
db $00,$00,$48,$4E,$52,$56,$5B
db $3F,$43,$49,$4F,$53,$57,$5C
db $40,$44,$4A,$50,$54,$58,$00
db $41,$45,$4B,$51,$4C,$59,$5D
db $42,$46,$4C,$4C,$55,$5A,$5E
Unknown_79c20: ; 79c20 (1e:5c20)
db $31,$32,$32,$32,$32,$33
db $34,$35,$36,$36,$37,$38
db $34,$39,$3A,$3A,$3B,$38
db $3C,$3D,$3E,$3E,$3F,$40
db $41,$42,$43,$43,$44,$45
db $46,$47,$43,$48,$49,$4A
db $41,$43,$4B,$4C,$4D,$4E
db $4F,$50,$50,$50,$51,$52
Unknown_79c50: ; 79c50 (1e:5c50)
db $43,$55,$56,$53,$53,$53,$53,$53,$53,$53,$53,$53
db $43,$57,$58,$54,$54,$54,$54,$54,$54,$54,$54,$54
db $43,$59,$5A,$43,$43,$43,$43,$43,$43,$43,$43,$43
AnimationLeavesFalling: ; 79c74 (1e:5c74)
; Makes leaves float down from the top of the screen. This is used
; in Razor Leaf's animation.
ld a, [rOBP0]
push af
ld a, [wAnimPalette]
ld [rOBP0], a
ld d, $37 ; leaf tile
ld a, 3 ; number of leaves
ld [wNumFallingObjects], a
call AnimationFallingObjects
pop af
ld [rOBP0], a
ret
AnimationPetalsFalling: ; 79c8a (1e:5c8a)
; Makes lots of petals fall down from the top of the screen. It's used in
; the animation for Petal Dance.
ld d, $71 ; petal tile
ld a, 20 ; number of petals
ld [wNumFallingObjects], a
call AnimationFallingObjects
jp ClearSprites
AnimationFallingObjects: ; 79c97 (1e:5c97)
ld c, a
ld a, 1
call InitMultipleObjectsOAM
call FallingObjects_InitXCoords
call FallingObjects_InitMovementData
ld hl, wOAMBuffer
ld [hl], 0
.loop
ld hl, wFallingObjectsMovementData
ld de, 0
ld a, [wNumFallingObjects]
ld c, a
.innerLoop
push bc
push hl
push de
ld a, [hl]
ld [wFallingObjectMovementByte], a
call FallingObjects_UpdateMovementByte
call FallingObjects_UpdateOAMEntry
pop de
ld hl, 4
add hl, de
ld e, l
ld d, h
pop hl
ld a, [wFallingObjectMovementByte]
ld [hli], a
pop bc
dec c
jr nz, .innerLoop
call Delay3
ld hl, wOAMBuffer
ld a, [hl] ; Y
cp 104 ; has the top falling object reached 104 yet?
jr nz, .loop ; keep moving the falling objects down until it does
ret
FallingObjects_UpdateOAMEntry: ; 79cdb (1e:5cdb)
; Increases Y by 2 pixels and adjusts X and X flip based on the falling object's
; movement byte.
ld hl, wOAMBuffer
add hl, de
ld a, [hl]
inc a
inc a
cp 112
jr c, .next
ld a, 160 ; if Y >= 112, put it off-screen
.next
ld [hli], a ; Y
ld a, [wFallingObjectMovementByte]
ld b, a
ld de, FallingObjects_DeltaXs
and $7f
add e
jr nc, .noCarry
inc d
.noCarry
ld e, a
ld a, b
and $80
jr nz, .movingLeft
; moving right
ld a, [de]
add [hl]
ld [hli], a ; X
inc hl
xor a ; no horizontal flip
jr .next2
.movingLeft
ld a, [de]
ld b, a
ld a, [hl]
sub b
ld [hli], a ; X
inc hl
ld a, (1 << OAM_X_FLIP)
.next2
ld [hl], a ; attribute
ret
FallingObjects_DeltaXs: ; 79d0d (1e:5d0d)
db 0, 1, 3, 5, 7, 9, 11, 13, 15
FallingObjects_UpdateMovementByte: ; 79d16 (1e:5d16)
ld a, [wFallingObjectMovementByte]
inc a
ld b, a
and $7f
cp 9 ; have we reached the end of the delta-Xs?
ld a, b
jr nz, .next
; We've reached the end of the delta-Xs, so wrap to the start and change
; direction from right to left or vice versa.
and $80
xor $80
.next
ld [wFallingObjectMovementByte], a
ret
FallingObjects_InitXCoords: ; 79d2a (1e:5d2a)
ld hl, wOAMBuffer + $01
ld de, FallingObjects_InitialXCoords
ld a, [wNumFallingObjects]
ld c, a
.loop
ld a, [de]
ld [hli], a
inc hl
inc hl
inc hl
inc de
dec c
jr nz, .loop
ret
FallingObjects_InitialXCoords: ; 79d3e (1e:5d3e)
db $38,$40,$50,$60,$70,$88,$90,$56,$67,$4A,$77,$84,$98,$32,$22,$5C,$6C,$7D,$8E,$99
FallingObjects_InitMovementData: ; 79d52 (1e:5d52)
ld hl, wFallingObjectsMovementData
ld de, FallingObjects_InitialMovementData
ld a, [wNumFallingObjects]
ld c, a
.loop
ld a, [de]
ld [hli], a
inc de
dec c
jr nz, .loop
ret
FallingObjects_InitialMovementData: ; 79d63 (1e:5d63)
db $00,$84,$06,$81,$02,$88,$01,$83,$05,$89,$09,$80,$07,$87,$03,$82,$04,$85,$08,$86
AnimationShakeEnemyHUD: ; 79d77 (1e:5d77)
; Shakes the enemy HUD.
; Make a copy of the back pic's tile patterns in sprite tile pattern VRAM.
ld de, vBackPic
ld hl, vSprites
ld bc, 7 * 7
call CopyVideoData
xor a
ld [hSCX], a
; Copy wTileMap to BG map 0. The regular BG (not the window) is set to use
; map 0 and can be scrolled with SCX, which allows a shaking effect.
ld hl, vBGMap0
call BattleAnimCopyTileMapToVRAM
; Now that the regular BG is showing the same thing the window was, move the
; window off the screen so that we can modify its contents below.
ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
; Copy wTileMap to VRAM such that the row below the enemy HUD (in wTileMap) is
; lined up with row 0 of the window.
ld hl, vBGMap1 - $20 * 7
call BattleAnimCopyTileMapToVRAM
; Move the window so that the row below the enemy HUD (in BG map 0) lines up
; with the top row of the window on the screen. This makes it so that the window
; covers everything below the enemy HD with a copy that looks just like what
; was there before.
ld a, 7 * 8
ld [hWY], a
; Write OAM entries so that the copy of the back pic from the top of this
; function shows up on screen. We need this because the back pic's Y coordinates
; range overlaps with that of the enemy HUD and we don't want to shake the top
; of the back pic when we shake the enemy HUD. The OAM copy won't be affected
; by SCX.
call ShakeEnemyHUD_WritePlayerMonPicOAM
ld hl, vBGMap0
call BattleAnimCopyTileMapToVRAM
; Remove the back pic from the BG map.
call AnimationHideMonPic
call Delay3
; Use SCX to shake the regular BG. The window and the back pic OAM copy are
; not affected.
lb de, 2, 8
call ShakeEnemyHUD_ShakeBG
; Restore the original graphics.
call AnimationShowMonPic
call ClearSprites
ld a, SCREEN_HEIGHT_PIXELS
ld [hWY], a
ld hl, vBGMap1
call BattleAnimCopyTileMapToVRAM
xor a
ld [hWY], a
call SaveScreenTilesToBuffer1
ld hl, vBGMap0
call BattleAnimCopyTileMapToVRAM
call ClearScreen
call Delay3
call LoadScreenTilesFromBuffer1
ld hl, vBGMap1
jp BattleAnimCopyTileMapToVRAM
; b = tile ID list index
; c = base tile ID
CopyTileIDsFromList: ; 79dda (1e:5dda)
call GetPredefRegisters
ld a, c
ld [hBaseTileID], a
ld a, b
push hl
call GetTileIDList
pop hl
jp CopyTileIDs
ShakeEnemyHUD_ShakeBG: ; 79de9 (1e:5de9)
ld a, [hSCX]
ld [wTempSCX], a
.loop
ld a, [wTempSCX]
add d
ld [hSCX], a
ld c, 2
call DelayFrames
ld a, [wTempSCX]
sub d
ld [hSCX], a
ld c, 2
call DelayFrames
dec e
jr nz, .loop
ld a, [wTempSCX]
ld [hSCX], a
ret
BattleAnimCopyTileMapToVRAM: ; 79e0d (1e:5e0d)
ld a, h
ld [H_AUTOBGTRANSFERDEST + 1], a
ld a, l
ld [H_AUTOBGTRANSFERDEST], a
jp Delay3
TossBallAnimation: ; 79e16 (1e:5e16)
ld a,[W_ISINBATTLE]
cp a,2
jr z,.BlockBall ; if in trainer battle, play different animation
ld a,[wPokeBallAnimData]
ld b,a
; upper nybble: how many animations (from PokeBallAnimations) to play
; this will be 4 for successful capture, 6 for breakout
and a,$F0
swap a
ld c,a
; lower nybble: number of shakes
; store these for later
ld a,b
and a,$F
ld [wNumShakes],a
ld hl,.PokeBallAnimations
; choose which toss animation to use
ld a,[wcf91]
cp a,POKE_BALL
ld b,TOSS_ANIM
jr z,.done
cp a,GREAT_BALL
ld b,GREATTOSS_ANIM
jr z,.done
ld b,ULTRATOSS_ANIM
.done
ld a,b
.PlayNextAnimation
ld [W_ANIMATIONID],a
push bc
push hl
call PlayAnimation
pop hl
ld a,[hli]
pop bc
dec c
jr nz,.PlayNextAnimation
ret
.PokeBallAnimations: ; 79e50 (1e:5e50)
; sequence of animations that make up the Poké Ball toss
db POOF_ANIM,HIDEPIC_ANIM,SHAKE_ANIM,POOF_ANIM,SHOWPIC_ANIM
.BlockBall ; 5E55
ld a,TOSS_ANIM
ld [W_ANIMATIONID],a
call PlayAnimation
ld a,SFX_FAINT_THUD
call PlaySound
ld a,BLOCKBALL_ANIM
ld [W_ANIMATIONID],a
jp PlayAnimation
PlayApplyingAttackSound: ; 79e6a (1e:5e6a)
; play a different sound depending if move is not very effective, neutral, or super-effective
; don't play any sound at all if move is ineffective
call WaitForSoundToFinish
ld a, [wDamageMultipliers]
and $7f
ret z
cp 10
ld a, $20
ld b, $30
ld c, SFX_DAMAGE
jr z, .playSound
ld a, $e0
ld b, $ff
ld c, SFX_SUPER_EFFECTIVE
jr nc, .playSound
ld a, $50
ld b, $1
ld c, SFX_NOT_VERY_EFFECTIVE
.playSound
ld [wc0f1], a
ld a, b
ld [wc0f2], a
ld a, c
jp PlaySound
|