summaryrefslogtreecommitdiff
path: root/src/code_8057824_1.c
blob: 0d48f71254dadf6dde25914c5cfc3ea01806593a (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
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
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
#include "global.h"
#include "constants/direction.h"
#include "dungeon_global_data.h"
#include "dungeon_entity.h"
#include "dungeon_util.h"
#include "item.h"
#include "pokemon.h"

extern u32 gUnknown_202EDC8;
extern u8 gUnknown_202E038[0x50];
extern u8 gAvailablePokemonNames[0x58];

extern s16 gUnknown_80F57CA;
extern s16 gUnknown_80F57D2;
extern s16 gUnknown_80F57D0;
extern s16 gUnknown_80F57CE;

extern u32 gUnknown_8103D8C;
extern u32 gUnknown_8103D98;
extern u32 gUnknown_8103DD8;
extern u32 gUnknown_8103E28;
extern u32 gUnknown_8103BD8;
extern u32 gUnknown_8103C00;
extern u32 gUnknown_8103C3C;
extern u32 gUnknown_8103C74;
extern u32 gUnknown_8103CC4;
extern u32 gUnknown_8103D0C;
extern u32 gUnknown_8103D50;
extern u32 gUnknown_8103B58;
extern u32 gUnknown_8103904;
extern u32 gUnknown_8103938;
extern u32 gUnknown_8103AA4;
extern u32 gUnknown_8103AE4;
extern u32 gUnknown_8103B30;
extern u32 gUnknown_8103690;
extern u32 gUnknown_8103844;
extern u32 gUnknown_8103874;
extern u32 gUnknown_81038A8;
extern u32 gUnknown_81038F8;
extern u32 gUnknown_8103500;
extern u32 gUnknown_810352C;
extern u32 gUnknown_8103578;
extern u32 gUnknown_81035D4;
extern u32 gUnknown_8103618;
extern u32 gUnknown_810367C;
extern u32 gUnknown_8103690;
extern u32 gUnknown_81036C8;
extern u32 gUnknown_81037A0;
extern u32 gUnknown_81037D4;
extern u32 gUnknown_8103820;
extern u32 gUnknown_8102C30;
extern u32 gUnknown_8102C54;
extern u32 gUnknown_8102C98;
extern u32 gUnknown_8102CB0;
extern u32 gUnknown_8102CF8;
extern u32 gUnknown_8102D34;
extern u32 gUnknown_8102D4C;
extern u32 gUnknown_8102D7C;
extern u32 gUnknown_8102DFC;
extern u32 gUnknown_8102E2C;
extern u32 gUnknown_8102E54;
extern u32 gUnknown_8102BE4;
extern u32 gUnknown_8102BC4;
extern u32 gUnknown_8102B54;
extern u32 gUnknown_8102B1C;
extern u32 gUnknown_8103488;
extern u32 gUnknown_81033A0;
extern u32 gUnknown_81033AC;
extern u32 gUnknown_810343C;
extern u32 gUnknown_810347C;
extern u32 gUnknown_8103188;
extern u32 gUnknown_8103228;
extern u32 gUnknown_8103310;
extern u32 gUnknown_8103340;
extern u32 gUnknown_8102E70;
extern u32 gUnknown_8102EBC;
extern u32 gUnknown_8102EE0;
extern u32 gUnknown_8102EF8;
extern u32 gUnknown_8102F30;
extern u32 gUnknown_8102F64;
extern u32 gUnknown_8102F84;
extern u32 gUnknown_8102FAC;
extern u32 gUnknown_8102FC4;
extern u32 gUnknown_8102FD8;
extern u32 gUnknown_8103054;
extern u32 gUnknown_81030D8;
extern u32 gUnknown_8103110;
extern u32 gUnknown_8103140;
extern u32 gUnknown_8102B10;
extern u32 gUnknown_8105244;
extern u32 gUnknown_810517C;
extern u32 gUnknown_81050B4;
extern u32 gUnknown_81051D0;
extern u32 gUnknown_810510C;
extern u32 gUnknown_8105040;
extern u32 gUnknown_810554C;
extern u32 gUnknown_8105558;
extern u32 gUnknown_81055F4;
extern u32 gUnknown_8105028;
extern u32 gUnknown_8104FD4;
extern u32 gUnknown_8104930;
extern u32 gUnknown_8104980;
extern u32 gUnknown_8104998;
extern u32 gUnknown_8105034;
extern u32 gUnknown_8105438;
extern u32 gUnknown_81054A0;
extern u32 gUnknown_81054E4;
extern u32 gUnknown_810550C;
extern u32 gUnknown_8104F64;
extern u32 gUnknown_8104EFC;
extern u32 gUnknown_8104F30;
extern u32 gUnknown_8104E60;
extern u32 gUnknown_8104CEC;
extern u32 gUnknown_8104D60;
extern u32 gUnknown_8104DDC;
extern u32 gUnknown_8104E0C;
extern u32 gUnknown_8104E54;
extern u32 gUnknown_8104AD4;
extern u32 gUnknown_8104BEC;
extern u32 gUnknown_8104C10;
extern u32 gUnknown_8104C54;
extern u32 gUnknown_8104CB4;
extern u32 gUnknown_8104CE0;
extern u32 gUnknown_8104AC8;
extern u32 gUnknown_81049D4;
extern u32 gUnknown_8104A80;
extern u32 gUnknown_8104A9C;
extern u32 gUnknown_8104784;
extern u32 gUnknown_8104790;
extern u32 gUnknown_81047B0;
extern u32 gUnknown_810484C;
extern u32 gUnknown_8104888;
extern u32 gUnknown_81048C8;
extern u32 gUnknown_8104914;
extern u32 gUnknown_810476C;
extern u32 gUnknown_8104778;
extern u32 gUnknown_81046CC;
extern u32 gUnknown_8104744;
extern u32 gUnknown_81045F8;
extern u32 gUnknown_8104674;
extern u32 gUnknown_81046A0;
extern u32 gUnknown_8104450;
extern u32 gUnknown_81044B4;
extern u32 gUnknown_8104510;
extern u32 gUnknown_810453C;
extern u32 gUnknown_8104570;
extern u32 gUnknown_81045B0;
extern u32 gUnknown_81043DC;
extern u32 gUnknown_8104310;
extern u32 gUnknown_810439C;
extern u32 gUnknown_81043C0;
extern u32 gUnknown_8104240;
extern u32 gUnknown_81042AC;
extern u32 gUnknown_81042B8;
extern u32 gUnknown_8104FC8;
extern u32 gUnknown_8104150;
extern u32 gUnknown_81041AC;
extern u32 gUnknown_81041F8;
extern u32 gUnknown_8104144;
extern u32 gUnknown_8104114;
extern u32 gUnknown_81040CC;
extern u32 gUnknown_8104050;
extern u32 gUnknown_8104044;
extern u32 gUnknown_8104008;
extern u32 gUnknown_8103EA4;
extern u32 gUnknown_8103F0C;
extern u32 gUnknown_8103F4C;
extern u32 gUnknown_8103FCC;
extern u32 gUnknown_8103E34;
extern u32 gUnknown_8102A9C;
extern u32 gUnknown_8102984;
extern u32 gUnknown_81029B4;
extern u32 gUnknown_8102A18;
extern u32 gUnknown_8102A24;
extern u32 gUnknown_8102A74;
extern u32 gUnknown_81028D4;
extern u32 gUnknown_8102918;
extern u32 gUnknown_8102948;
extern u32 gUnknown_8102478;
extern u32 gUnknown_81025B4;
extern u32 gUnknown_81025D4;
extern u32 gUnknown_8102610;
extern u32 gUnknown_81026C4;
extern u32 gUnknown_810270C;
extern u32 gUnknown_810272C;
extern u32 gUnknown_81027BC;
extern u32 gUnknown_8102810;
extern u32 gUnknown_8102840;
extern u32 gUnknown_810286C;
extern u32 gUnknown_81028B8;
extern u32 gUnknown_810232C;
extern u32 gUnknown_8102398;
extern u32 gUnknown_81023C4;
extern u32 gUnknown_8102400;
extern u32 gUnknown_8102454;
extern u32 gUnknown_8100D3C;
extern u32 gUnknown_8102158;
extern u32 gUnknown_8102190;
extern u32 gUnknown_8102200;
extern u32 gUnknown_8102254;
extern u32 gUnknown_81022F8;
extern u32 gUnknown_8101A9C;
extern u32 gUnknown_8101AD4;
extern u32 gUnknown_8101C30;
extern u32 gUnknown_8101CBC;
extern u32 gUnknown_8101D8C;
extern u32 gUnknown_8101DA0;
extern u32 gUnknown_8101E1C;
extern u32 gUnknown_8101EAC;
extern u32 gUnknown_8102070;
extern u32 gUnknown_81020A4;
extern u32 gUnknown_81020D4;
extern u32 gUnknown_8102108;
extern u32 gUnknown_810193C;
extern u32 gUnknown_8101970;
extern u32 gUnknown_8101994;
extern u32 gUnknown_81019E4;
extern u32 gUnknown_8101A04;
extern u32 gUnknown_8101A38;

extern struct DungeonEntity *xxx_call_GetLeaderEntity(void);
extern struct DungeonEntity *sub_8085680(u32);
extern void sub_808BBA8(struct DungeonEntity * );
extern void sub_80855E4(void *);
extern void sub_8041888(u32);
extern void sub_80861B8(struct DungeonEntity *, u32, u32);
extern void sub_8083ED8(u32);
extern void sub_803E708(u32, u32);
extern void DisplayDungeonDialogue(u32 *r0);
extern void sub_8083E88(u32);
extern void sub_808BC20(struct DungeonEntity *);

extern void sub_80862BC(struct DungeonEntity *);
extern void sub_8086448();
extern void SpriteLookAroundEffect(struct DungeonEntity *);
extern u32 sub_80861F8(u32, struct DungeonEntity *, u32);
extern void SetupBossFightHP(struct DungeonEntity *, u32, u32);
extern void sub_80858AC(u32 *, u32);

extern void sub_8097FA8(u32);
extern void JirachiWish();
extern u8 sub_80860A8(u32);
extern void sub_8040A84();
extern void sub_8086A3C(struct DungeonEntity *);
extern u8 HasRecruitedMon(u32);
extern void sub_80854D4();
extern void sub_8085930(u32);
extern void sub_8068FE0(struct DungeonEntity *, u32, u32);
extern void SetFacingDirection(struct DungeonEntity *, u32);
extern void sub_8049ED4();
extern void sub_8085860(s32 r0, u32 r1);
extern void sub_806CE68(struct DungeonEntity *, u32);

extern void sub_8052D44(u8 *, struct DungeonEntity *, struct DungeonEntity *);
extern void sub_8097FD0(u32);
extern void SetMessageArgument(u8 *, struct DungeonEntity *, u32);
extern struct DungeonEntity *GetLeaderEntity();
extern void sub_80421C0(struct DungeonEntity *, u32);
extern void sub_8046D20();
extern void sub_808B1CC(u8);
extern void sub_80464C8(struct DungeonEntity *, u32 *, struct ItemSlot *);
extern void sub_8098044(u32);
extern void PlaySoundEffect(u32);
extern void sub_8085C54(u32, u32, u32, u32, u32);
extern void sub_803E46C(u32);
extern void sub_8085EB0();
extern void sub_80866C4(u32 *);
extern void sub_808692C();

extern void sub_8083E58(u32);
extern void sub_80868F4();
extern void sub_8086910();
extern u32 sub_8085EC8(u32, u32, u32, u32 *, u32);
extern void sub_808680C();
extern void sub_808682C();
extern void sub_8086854();
extern void sub_80867F4();
extern void sub_8086838(u32, u32, u32);
extern void sub_80426C8(u32, u32);
extern void sub_807EAA0(u32, u32);

extern void sub_808563C(void *);
extern void sub_808BCE4(void);
extern void sub_808BBB8(struct DungeonEntity *param_1);
extern u8 sub_8098100(u32);
extern void sub_8086794();

void EnteiScreenFlash(void);
void RaikouScreenFlash(void);
void sub_808A528(struct DungeonEntity * param_1);
void SuicuneScreenFlash();
void sub_808A904(struct DungeonEntity * param_1);
void HoOhScreenFlash(void);
void LatiosScreenFlash(void);
void SetupRegiFacingDirection(struct DungeonEntity *r0);
void SetupRegirockFightHP(struct DungeonEntity *r0);
void SetupRegiceFightHP(struct DungeonEntity *r0);
void SetupRegisteelFightHP(struct DungeonEntity *r0);
void sub_808B50C(void);
void sub_8089B64(struct DungeonEntity *param_1);
void MewtwoScreenFlash(void);
void sub_80898F8(struct DungeonEntity *r0);
void sub_8089908(struct DungeonEntity *r0);
void sub_8089620(struct DungeonEntity *param_1);
void RayquazaScreenFlash(void);
void sub_80891F0(void);
void sub_8089294(void);
void sub_80891B0();
void sub_8089224();
void sub_80891D0();
void sub_808919C();
void GroudonScreenFlash2(void);

extern void sub_8083F14();
extern u8 sub_8086AE4(u32);


extern void sub_8072008(struct DungeonEntity *, struct DungeonEntity *, s16, u32, u32);
extern struct DungeonEntity *GetPartnerEntity();
extern void sub_80856E0(struct DungeonEntity *, u32);
extern void sub_80869E4(struct DungeonEntity *, u32, u32, u32);
extern void sub_804539C(struct DungeonEntity *, u32, u32);
extern void sub_806CDD4(struct DungeonEntity *, u32, u32);
extern void sub_8085374();

extern void sub_8086848(u32 ,u32);
extern void sub_80856C8(struct DungeonEntity *, s32, s32);
extern void sub_80861D4(struct DungeonEntity *, u32, u32);
extern void sub_8086738();
extern void sub_8086A54(struct DungeonEntity *);
extern void sub_8086764();

extern u32 sub_803F994();
extern s32 sub_803F9B0();
extern void sub_803F878(u32,s32);

void SceneGroudonMovement(struct DungeonEntity * param_1);
void GroudonScreenFlash(void);
void ArticunoScreenFlash(void);
void sub_8088484(struct DungeonEntity *param_1);
void sub_8088574(void);

void sub_8087D30(struct DungeonEntity * param_1);
void sub_8087D80(s32 r0, s32 r1);
void sub_8087DE8(s32 r0, s32 r1);
void sub_8087EB0(void);
void sub_808654C(void);

extern void sub_8086598();
extern void sub_80865E8();


extern void sub_8086500(void);
extern void sub_8086690(void);
void sub_8087F24(void);
extern void sub_808663C(void);
void sub_8087704(struct DungeonEntity *param_1);
void sub_808775C(int param_1);

extern u32 gUnknown_81017E4;
extern u32 gUnknown_81015A0;
extern u32 gUnknown_8101898;
extern u32 gUnknown_81018EC;
extern u32 gUnknown_8101918;


void ZapdosReFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *ZapdosEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  ZapdosEntity = sub_8085680(8);
  sub_8086448();
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_81017E4);
  sub_803E708(10,0x46);
  PlaySoundEffect(0x1da);
  DisplayDungeonDialogue(&gUnknown_81015A0);
  sub_803E708(10,0x46);
  sub_8087704(ZapdosEntity);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8101898);
  sub_808775C(1);
  DisplayDungeonDialogue(&gUnknown_81018EC);
  sub_808775C(2);
  DisplayDungeonDialogue(&gUnknown_8101918);
  SetupBossFightHP(ZapdosEntity,300,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void ZapdosPostStoryPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * ZapdosEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  ZapdosEntity = sub_8085680(8);
  sub_8086448();
  if (sub_8086AE4(SPECIES_ZAPDOS)) {
    sub_80866C4(&gUnknown_8101A38);
  }
  else {
    sub_808775C(1);
    PlaySoundEffect(0x1da);
    DisplayDungeonDialogue(&gUnknown_810193C);
    sub_8087704(ZapdosEntity);
    DisplayDungeonDialogue(&gUnknown_8101970);
    sub_808775C(1);
    DisplayDungeonDialogue(&gUnknown_8101994);
    sub_808775C(2);
    DisplayDungeonDialogue(&gUnknown_81019E4);
    sub_808775C(2);
    DisplayDungeonDialogue(&gUnknown_8101A04);
    sub_803E708(10,0x46);
    SetupBossFightHP(ZapdosEntity,300,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}


void sub_8087704(struct DungeonEntity *param_1)
{
  int iVar1;

  param_1->entityData->unk15C = 1;
  param_1->entityData->unk15E = 0;
  param_1->entityData->unk174 = 200;
  PlaySoundEffect(0x1ea);
  for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5)
  {
    param_1->entityData->unk174 = iVar1 * 256;
    sub_803E46C(0x46);
  }
  sub_803E708(0x1e,0x46);
}

void sub_808775C(int param_1)
{
  int iVar1;
  int iVar2;

  PlaySoundEffect(0x1f6);
  if (2 < param_1) {
    for(iVar2 = 250; iVar2 > 199; iVar2 -= 10)
    {
      sub_8085C54(iVar2,iVar2,iVar2 / 2,1,1);
      sub_803E46C(0x46);
    }
  }
  if (1 < param_1) {
    for(iVar2 = 250; iVar2 > 199; iVar2 -= 10)
    {
      sub_8085C54(iVar2,iVar2,iVar2 / 2,1,1);
      sub_803E46C(0x46);
    }
  }
  for(iVar2 = 250; iVar2 >= 0; iVar2 -= 10)
  {
    iVar1 = iVar2;
    if (iVar2 < 0) {
      iVar1 = iVar2 + 3;
    }
    sub_8085C54(iVar2,iVar2,iVar1 >> 2,1,1);
    sub_803E46C(0x46);
  }
  sub_8085EB0();
}



void sub_80877E8(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * MoltresEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  MoltresEntity = sub_8085680(9);
  sub_8083E88(0x26);
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_WEST);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(MoltresEntity, DIRECTION_SOUTH);
  sub_8086A3C(MoltresEntity);
  sub_8085860(LeaderEntity->posWorld.x + -3,LeaderEntity->posWorld.y + -2);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_MOLTRES);
}

void sub_8087848(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *MoltresEntity;

  u32 uVar4;
  s32 iVar3;

  LeaderEntity = xxx_call_GetLeaderEntity();
  MoltresEntity = sub_8085680(9);
  sub_8083E88(0x26);
  sub_80854D4();
  sub_8085930(DIRECTION_WEST);
  sub_80855E4(sub_8086A3C);
  if (sub_8086AE4(SPECIES_MOLTRES)) {
    sub_8068FE0(MoltresEntity,0x21c,0);
  }
  else {
    sub_8072008(MoltresEntity,MoltresEntity,gUnknown_80F57CE,0,0);
    SetFacingDirection(MoltresEntity, DIRECTION_SOUTH);
    sub_8086A3C(MoltresEntity);
  }
  sub_8085860(LeaderEntity->posWorld.x - 5, LeaderEntity->posWorld.y);
  uVar4 = sub_803F994();
  iVar3 = sub_803F9B0();
  sub_803F878(uVar4,iVar3 + -0x1000);
  CopySpeciesNametoBuffer(gUnknown_202E038,SPECIES_MOLTRES);
}



void sub_80878F4(char param_1, s32 param_2)
{
  if ((((param_2 * 0x1000000) + 0xF6000000U) >> 0x18 < 3) && (param_1 == 0x9)) {
    sub_8097FA8(0x7);
    gDungeonGlobalData->unk2 = 1;
  }
}

void MoltresPreFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *PartnerEntity;
  struct DungeonEntity *MoltresEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  PartnerEntity = GetPartnerEntity();
  MoltresEntity = sub_8085680(9);
  sub_8087D80(0xc,5);
  sub_8086500();
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8101A9C);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,1,5);
  sub_803E708(4,0x46);
  SpriteLookAroundEffect(PartnerEntity);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8101AD4);
  sub_803E708(10,0x46);
  sub_8087D80(0xc,5);
  sub_8087DE8(9,5);
  DisplayDungeonDialogue(&gUnknown_8101C30);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,1,2);
  sub_80869E4(LeaderEntity,4,2,6);
  DisplayDungeonDialogue(&gUnknown_8101CBC);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,2,6);
  sub_8086690();
  DisplayDungeonDialogue(&gUnknown_8101D8C);
  sub_803E708(10,0x46);
  sub_8085930(DIRECTION_NORTHWEST);
  sub_803E708(4,0x46);
  sub_8085930(DIRECTION_NORTH);
  PlaySoundEffect(0x2f2);
  sub_8083F14();
  sub_8087F24();
  DisplayDungeonDialogue(&gUnknown_8101DA0);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8101E1C);
  sub_803E708(10,0x46);
  PlaySoundEffect(0x1cf);
  sub_80856E0(PartnerEntity,4);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8101EAC);
  sub_803E708(10,0x46);
  sub_8087EB0();
  PlaySoundEffect(0x1da);
  DisplayDungeonDialogue(&gUnknown_8102070);
  sub_803E708(10,0x46);
  sub_8087D80(9,5);
  sub_8087DE8(0xb,5);
  DisplayDungeonDialogue(&gUnknown_81020A4);
  sub_803E708(10,0x46);
  sub_8087D80(0xc,5);
  sub_8087DE8(9,5);
  sub_8087D30(MoltresEntity);
  sub_808663C();
  sub_8087EB0();
  DisplayDungeonDialogue(&gUnknown_81020D4);
  sub_803E708(10,0x46);
  sub_8087DE8(0xb,6);
  DisplayDungeonDialogue(&gUnknown_8102108);
  sub_803E708(10,0x46);
  SetupBossFightHP(MoltresEntity,400,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}


void MoltresReFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *PartnerEntity;
  struct DungeonEntity *MoltresEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  PartnerEntity = GetPartnerEntity();
  MoltresEntity = sub_8085680(9);
  sub_8087D80(10,5);
  sub_8086500();
  sub_803E708(10,0x46);
  SpriteLookAroundEffect(PartnerEntity);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8102158);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,1,2);
  sub_80869E4(LeaderEntity,4,2,6);
  DisplayDungeonDialogue(&gUnknown_8102190);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,2,6);
  sub_80869E4(LeaderEntity,4,2,6);
  sub_8086690();
  sub_8087F24();
  sub_803E708(10,0x46);
  sub_8085930(DIRECTION_NORTHWEST);
  sub_803E708(4,0x46);
  sub_8085930(DIRECTION_NORTH);
  sub_8087D30(MoltresEntity);
  sub_808663C();
  sub_8087EB0();
  DisplayDungeonDialogue(&gUnknown_8102200);
  sub_803E708(10,0x46);
  sub_8087DE8(0xb,6);
  DisplayDungeonDialogue(&gUnknown_8102254);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_81022F8);
  sub_803E708(10,0x46);
  SetupBossFightHP(MoltresEntity,400,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void MoltresPostStoryPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * MoltresEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  MoltresEntity = sub_8085680(9);
  sub_8087D80(0xc,5);
  sub_808654C();
  if (sub_8086AE4(SPECIES_MOLTRES)) {
    sub_8085930(DIRECTION_NORTHWEST);
    sub_803E708(4,0x46);
    sub_8085930(DIRECTION_NORTH);
    sub_803E708(4,0x46);
    sub_803E708(10,0x46);
    DisplayDungeonDialogue(&gUnknown_8100D3C);
    sub_803E708(10,0x46);
    gDungeonGlobalData->unk2 = 1;
  }
  else {
    DisplayDungeonDialogue(&gUnknown_810232C);
    sub_8085930(DIRECTION_NORTHWEST);
    sub_803E708(4,0x46);
    sub_8085930(DIRECTION_NORTH);
    sub_8087D30(MoltresEntity);
    DisplayDungeonDialogue(&gUnknown_8102398);
    sub_8087D80(0xc,5);
    sub_8087DE8(9,5);
    DisplayDungeonDialogue(&gUnknown_81023C4);
    sub_8087EB0();
    DisplayDungeonDialogue(&gUnknown_8102400);
    sub_8087DE8(0xb,6);
    DisplayDungeonDialogue(&gUnknown_8102454);
    sub_803E708(10,0x46);
    SetupBossFightHP(MoltresEntity,400,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void sub_8087D30(struct DungeonEntity * param_1)
{
  s32 iVar1;

  param_1->entityData->unk15C = 1;
  param_1->entityData->unk15E = 0;
  param_1->entityData->unk174 = 0xc800;
  PlaySoundEffect(0x1f8);
  iVar1 = 200;
  for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5)
  {
    param_1->entityData->unk174 = iVar1 * 256;
    sub_803E46C(0x46);
  }
}

NAKED
void sub_8087D80(s32 r0, s32 r1)
{
	asm_unified("\tpush {lr}\n"
	"\tsub sp, 0x8\n"
	"\tadds r3, r1, 0\n"
	"\tlsls r1, r0, 1\n"
	"\tadds r1, r0\n"
	"\tlsls r1, 11\n"
	"\tmovs r2, 0xC0\n"
	"\tlsls r2, 4\n"
	"\tadds r0, r1, r2\n"
	"\tcmp r0, 0\n"
	"\tbge _08087D98\n"
	"\tadds r0, 0xFF\n"
"_08087D98:\n"
	"\tlsls r0, 8\n"
	"\tlsrs r0, 16\n"
	"\tldr r1, _08087DE0\n"
	"\tldr r2, [sp, 0x4]\n"
	"\tands r2, r1\n"
	"\torrs r2, r0\n"
	"\tstr r2, [sp, 0x4]\n"
	"\tlsls r0, r3, 1\n"
	"\tadds r0, r3\n"
	"\tlsls r0, 11\n"
	"\tmovs r1, 0x80\n"
	"\tlsls r1, 5\n"
	"\tadds r0, r1\n"
	"\tcmp r0, 0\n"
	"\tbge _08087DB8\n"
	"\tadds r0, 0xFF\n"
"_08087DB8:\n"
	"\tlsls r0, 8\n"
	"\tlsrs r0, 16\n"
	"\tlsls r0, 16\n"
	"\tldr r1, _08087DE4\n"
	"\tands r2, r1\n"
	"\torrs r2, r0\n"
	"\tstr r2, [sp, 0x4]\n"
	"\tmovs r0, 0xB9\n"
	"\tlsls r0, 1\n"
	"\tmovs r1, 0\n"
	"\tstr r1, [sp]\n"
	"\tmovs r1, 0x10\n"
	"\tmovs r2, 0\n"
	"\tadd r3, sp, 0x4\n"
	"\tbl sub_8085EC8\n"
	"\tadd sp, 0x8\n"
	"\tpop {r0}\n"
	"\tbx r0\n"
	"\t.align 2, 0\n"
"_08087DE0: .4byte 0xffff0000\n"
"_08087DE4: .4byte 0x0000ffff");
}

NAKED
void sub_8087DE8(s32 r0, s32 r1)
{
	asm_unified("\tpush {r4-r6,lr}\n"
	"\tsub sp, 0x8\n"
	"\tadds r3, r1, 0\n"
	"\tlsls r1, r0, 1\n"
	"\tadds r1, r0\n"
	"\tlsls r1, 11\n"
	"\tmovs r2, 0xC0\n"
	"\tlsls r2, 4\n"
	"\tadds r0, r1, r2\n"
	"\tcmp r0, 0\n"
	"\tbge _08087E00\n"
	"\tadds r0, 0xFF\n"
"_08087E00:\n"
	"\tlsls r0, 8\n"
	"\tlsrs r0, 16\n"
	"\tldr r1, _08087EA8\n"
	"\tldr r2, [sp, 0x4]\n"
	"\tands r2, r1\n"
	"\torrs r2, r0\n"
	"\tstr r2, [sp, 0x4]\n"
	"\tlsls r0, r3, 1\n"
	"\tadds r0, r3\n"
	"\tlsls r0, 11\n"
	"\tmovs r1, 0x80\n"
	"\tlsls r1, 5\n"
	"\tadds r0, r1\n"
	"\tcmp r0, 0\n"
	"\tbge _08087E20\n"
	"\tadds r0, 0xFF\n"
"_08087E20:\n"
	"\tlsls r0, 8\n"
	"\tlsrs r0, 16\n"
	"\tlsls r0, 16\n"
	"\tldr r1, _08087EAC\n"
	"\tands r2, r1\n"
	"\torrs r2, r0\n"
	"\tstr r2, [sp, 0x4]\n"
	"\tmovs r0, 0xB9\n"
	"\tlsls r0, 1\n"
	"\tmovs r1, 0\n"
	"\tstr r1, [sp]\n"
	"\tmovs r1, 0x16\n"
	"\tmovs r2, 0\n"
	"\tadd r3, sp, 0x4\n"
	"\tbl sub_8085EC8\n"
	"\tadds r6, r0, 0\n"
	"\tmovs r0, 0xF6\n"
	"\tlsls r0, 1\n"
	"\tbl PlaySoundEffect\n"
	"\tmovs r4, 0xFA\n"
	"\tmovs r5, 0x1\n"
"_08087E4E:\n"
	"\tstr r5, [sp]\n"
	"\tadds r0, r4, 0\n"
	"\tmovs r1, 0\n"
	"\tmovs r2, 0\n"
	"\tmovs r3, 0x1\n"
	"\tbl sub_8085C54\n"
	"\tmovs r0, 0x46\n"
	"\tbl sub_803E46C\n"
	"\tsubs r4, 0xA\n"
	"\tcmp r4, 0x13\n"
	"\tbgt _08087E4E\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tmovs r4, 0xFA\n"
	"\tmovs r5, 0x1\n"
"_08087E74:\n"
	"\tstr r5, [sp]\n"
	"\tadds r0, r4, 0\n"
	"\tmovs r1, 0\n"
	"\tmovs r2, 0\n"
	"\tmovs r3, 0x1\n"
	"\tbl sub_8085C54\n"
	"\tmovs r0, 0x46\n"
	"\tbl sub_803E46C\n"
	"\tsubs r4, 0xA\n"
	"\tcmp r4, 0\n"
	"\tbge _08087E74\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tbl sub_8085EB0\n"
	"\tadds r0, r6, 0\n"
	"\tbl sub_8085F44\n"
	"\tadd sp, 0x8\n"
	"\tpop {r4-r6}\n"
	"\tpop {r0}\n"
	"\tbx r0\n"
	"\t.align 2, 0\n"
"_08087EA8: .4byte 0xffff0000\n"
"_08087EAC: .4byte 0x0000ffff");
}

void sub_8087EB0(void)
{
  int iVar1;

  PlaySoundEffect(0x1ed);
  iVar1 = 0xfa;
  for(iVar1 = 250; iVar1 > 9; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1 / 2,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(0x1e,0x46);
  PlaySoundEffect(0x1ed);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1 / 2,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(0x1e,0x46);
  sub_8085EB0();
}

void sub_8087F24(void)
{
  s32 iVar1;

  for(iVar1 = 0; iVar1 >= -80; iVar1 -= 8)
  {
    sub_8085C54(iVar1,iVar1,iVar1,0,0);
    sub_803E46C(0x46);
  }
}


void sub_8087F54(void)
{
  struct DungeonEntity  *LeaderEntity;
  struct DungeonEntity *ArticunoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  ArticunoEntity = sub_8085680(0xd);
  sub_8083E88(0x72);
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(ArticunoEntity, DIRECTION_SOUTH);
  sub_8086A3C(ArticunoEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y + -3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_ARTICUNO);
}

void sub_8087FB4(void)
{
  struct DungeonEntity  *ArticunoEntity;

  ArticunoEntity = sub_8085680(0xd);
  sub_8083E88(0x72);
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  SetFacingDirection(ArticunoEntity, DIRECTION_SOUTH);
  sub_806CDD4(ArticunoEntity, 0xF, DIRECTION_SOUTH);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_ARTICUNO);
}

void sub_8087FF8(void)
{
  struct DungeonEntity  *LeaderEntity;
  struct DungeonEntity *ArticunoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  ArticunoEntity = sub_8085680(0xd);
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  if (sub_8086AE4(SPECIES_ARTICUNO)) {
    sub_8068FE0(ArticunoEntity,0x21c,0);
  }
  else {
    sub_8072008(ArticunoEntity,ArticunoEntity,gUnknown_80F57D0,0,0);
    SetFacingDirection(ArticunoEntity, DIRECTION_SOUTH);
    sub_8086A3C(ArticunoEntity);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y + -3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_ARTICUNO);
}



void sub_8088088(char param_1, s32 param_2)
{
  if ((((param_2 * 0x1000000) + 0xF3000000U) >> 0x18 < 3) && (param_1 == 0xD)) {
    sub_8097FA8(0x9);
    gDungeonGlobalData->unk2 = 1;
  }
}

void ArticunoPreFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *PartnerEntity;
  struct DungeonEntity *ArticunoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  PartnerEntity = GetPartnerEntity();
  ArticunoEntity = sub_8085680(0xd);
  sub_8086448();
  SpriteLookAroundEffect(PartnerEntity);
  DisplayDungeonDialogue(&gUnknown_8102478);
  sub_803E708(10,0x46);
  sub_8086598();
  sub_8083F14();
  DisplayDungeonDialogue(&gUnknown_81025B4);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,1,2);
  sub_80869E4(LeaderEntity,4,2,6);
  DisplayDungeonDialogue(&gUnknown_81025D4);
  sub_803E708(10,0x46);
  SetFacingDirection(LeaderEntity, DIRECTION_WEST);
  sub_803E708(4,0x46);
  SetFacingDirection(LeaderEntity, DIRECTION_NORTHWEST);
  sub_803E708(4,0x46);
  SetFacingDirection(LeaderEntity, DIRECTION_WEST);
  sub_803E708(4,0x46);
  SetFacingDirection(LeaderEntity, DIRECTION_SOUTHWEST);
  sub_803E708(4,0x46);
  SetFacingDirection(LeaderEntity, DIRECTION_WEST);
  sub_803E708(4,0x46);
  SetFacingDirection(LeaderEntity, DIRECTION_NORTHWEST);
  sub_803E708(4,0x46);
  SetFacingDirection(LeaderEntity, DIRECTION_WEST);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8102610);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_81026C4);
  sub_803E708(10,0x46);
  sub_80869E4(LeaderEntity,4,1,4);
  sub_80869E4(PartnerEntity,4,2,4);
  PlaySoundEffect(0x1d5);
  SpriteLookAroundEffect(PartnerEntity);
  PlaySoundEffect(0x1d5);
  SpriteLookAroundEffect(LeaderEntity);
  DisplayDungeonDialogue(&gUnknown_810270C);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_810272C);
  sub_803E708(10,0x46);
  PlaySoundEffect(0); // snow flurry
  gDungeonGlobalData->unkE265 = 7;
  sub_807EAA0(0,1);
  PlaySoundEffect(0x1ee); // flash effect?
  sub_8088574();
  DisplayDungeonDialogue(&gUnknown_81027BC);
  sub_803E708(10,0x46);
  ArticunoScreenFlash();
  sub_8086738();
  PlaySoundEffect(0x1da);
  DisplayDungeonDialogue(&gUnknown_8102810);
  sub_803E708(10,0x46);
  PlaySoundEffect(0x1ea);
  sub_8088484(ArticunoEntity);
  sub_80865E8();
  ArticunoScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8102840);
  sub_806CDD4(ArticunoEntity,0xf,DIRECTION_SOUTH);
  ArticunoScreenFlash();
  DisplayDungeonDialogue(&gUnknown_810286C);
  sub_806CDD4(ArticunoEntity,0x10,DIRECTION_SOUTH);
  ArticunoScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81028B8);
  sub_806CDD4(ArticunoEntity,0xf,DIRECTION_SOUTH);
  sub_803E708(0x10,0x46);
  SetupBossFightHP(ArticunoEntity,0x1c2,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void ArticunoReFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *ArticunoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  ArticunoEntity = sub_8085680(0xd);
  gDungeonGlobalData->unkE265 = 7;
  sub_807EAA0(0,1);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_81028D4);
  sub_806CDD4(ArticunoEntity,0x10,DIRECTION_SOUTH);
  ArticunoScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8102918);
  ArticunoScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8102948);
  sub_806CDD4(ArticunoEntity,0xf,DIRECTION_SOUTH);
  sub_803E708(0x28,0x46);
  SetupBossFightHP(ArticunoEntity,0x1c2,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void ArticunoPostStoryPreFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *ArticunoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  ArticunoEntity = sub_8085680(0xd);
  sub_8086448();
  if (sub_8086AE4(SPECIES_ARTICUNO)) {
    sub_80866C4(&gUnknown_8102A9C);
  }
  else {
    gDungeonGlobalData->unkE265 = 7;
    sub_807EAA0(0,1);
    ArticunoScreenFlash();
    sub_8086738();
    PlaySoundEffect(0x1da);
    DisplayDungeonDialogue(&gUnknown_8102984);
    sub_803E708(10,0x46);
    sub_8088484(ArticunoEntity);
    ArticunoScreenFlash();
    DisplayDungeonDialogue(&gUnknown_81029B4);
    sub_806CDD4(ArticunoEntity,0xf,DIRECTION_SOUTH);
    ArticunoScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8102A18);
    sub_806CDD4(ArticunoEntity,0x10,DIRECTION_SOUTH);
    ArticunoScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8102A24);
    ArticunoScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8102A74);
    sub_806CDD4(ArticunoEntity,0xf,DIRECTION_SOUTH);
    sub_803E708(0x28,0x46);
    SetupBossFightHP(ArticunoEntity,0x1c2,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void sub_8088484(struct DungeonEntity *param_1)
{
  int iVar1;

  param_1->entityData->unk15C = 1;
  param_1->entityData->unk15E = 0;
  PlaySoundEffect(0x1ea);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 5)
  {
    param_1->entityData->unk174 = iVar1 * 256;
    sub_8085C54(iVar1,iVar1,iVar1 / 2,1,0);
    sub_803E46C(0x46);
  }
}

void ArticunoScreenFlash(void)
{
  int iVar1;

  PlaySoundEffect(0x2ad);
  for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10)
  {
    sub_8085C54(iVar1 / 2,iVar1,iVar1,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(4,0x46);
  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(0,iVar1,iVar1,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(4,0x46);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1 / 2,iVar1,iVar1,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(4,0x46);
  sub_8085EB0();
}

void sub_8088574(void)
{
  int iVar1;

  for(iVar1 = 0; iVar1 <= 80; iVar1 += 8)
  {
    sub_8085C54(iVar1,iVar1,iVar1,0,0);
    sub_803E46C(0x46);
  }
}

void sub_80885A0(void)
{
  sub_8083ED8(0x3c);
  sub_803E708(0x3c,0x46);
  sub_8083F14();
  gDungeonGlobalData->unk7 = 1;
}

void sub_80885C4(void)
{
  struct DungeonEntity * LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8083ED8(0x3c);
  sub_803E708(0x3c,0x46);
  sub_8083F14();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
}

void sub_8088608(void)
{
    gDungeonGlobalData->unk2 = 1;
}

void sub_8088618(void)
{
    sub_8086448();
    // The mountain's summit...
    // But there is no one here
    // It's time to go back
    sub_80866C4(&gUnknown_8102B10);
}

void sub_808862C(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * AlakazamEntity;
  struct DungeonEntity * GroudonEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  AlakazamEntity = sub_8085680(10);
  GroudonEntity = sub_8085680(0xe);
  sub_8083E88(0x72);
  sub_80867F4();
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(AlakazamEntity, DIRECTION_NORTH);
  sub_80861D4(AlakazamEntity,0xd,4);
  SetFacingDirection(GroudonEntity, DIRECTION_SOUTH);
  sub_8086A3C(GroudonEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y -3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_GROUDON);
  CopySpeciesNametoBuffer(gUnknown_202E038 + 0x50, SPECIES_ALAKAZAM);
}

void sub_80886C4(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * AlakazamEntity;
  struct DungeonEntity * GroudonEntity;

  u32 uVar4;
  s32 iVar2;

  LeaderEntity = xxx_call_GetLeaderEntity();
  AlakazamEntity = sub_8085680(10);
  GroudonEntity = sub_8085680(0xe);
  PlaySoundEffect(0x3e5);
  sub_80867F4();
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_8068FE0(AlakazamEntity,0x21c,0);
  SetFacingDirection(GroudonEntity, DIRECTION_SOUTH);
  sub_8086A3C(GroudonEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  uVar4 = sub_803F994();
  iVar2 = sub_803F9B0();
  sub_803F878(uVar4,iVar2 + -0x1000);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_GROUDON);
  CopySpeciesNametoBuffer(gUnknown_202E038 + 0x50, SPECIES_ALAKAZAM);
}

void sub_808875C(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * AlakazamEntity;
  struct DungeonEntity * GroudonEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  AlakazamEntity = sub_8085680(10);
  GroudonEntity = sub_8085680(0xe);
  sub_80867F4();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  sub_8068FE0(AlakazamEntity,0x21c,0);
  if (sub_8086AE4(SPECIES_GROUDON)) {
    sub_8068FE0(GroudonEntity,0x21c,0);
  }
  else {
    sub_8072008(GroudonEntity,GroudonEntity,gUnknown_80F57D2,0,0);
    SetFacingDirection(GroudonEntity, DIRECTION_SOUTH);
    sub_80861D4(GroudonEntity,0xf,0);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_GROUDON);
  CopySpeciesNametoBuffer(gUnknown_202E038 + 0x50, SPECIES_ALAKAZAM);
}

void sub_8088818(char param_1, s32 param_2)
{
  if ((((param_2 * 0x1000000) + 0xEE000000U) >> 0x18 < 3) && (param_1 == 0xE)) {
    sub_8097FA8(0xC);
    gDungeonGlobalData->unk2 = 1;
  }
}

void sub_8088848(void)
{
    sub_8086854();
}

void GroudonPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * PartnerEntity;
  struct DungeonEntity * AlakazamEntity;
  struct DungeonEntity * GroudonEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  PartnerEntity = GetPartnerEntity();
  AlakazamEntity = sub_8085680(10);
  GroudonEntity = sub_8085680(0xe);
  sub_8086448();
  DisplayDungeonDialogue(&gUnknown_8102E70);
  sub_803E708(10,0x46);
  sub_803E708(0x3c,0x46);
  DisplayDungeonDialogue(&gUnknown_8102EBC);
  sub_803E708(10,0x46);
  sub_8086838(1,1,1);
  sub_808680C();
  sub_803E708(0x3c,0x46);
  sub_808682C();
  sub_803E708(0x1e,0x46);
  DisplayDungeonDialogue(&gUnknown_8102EE0);
  sub_803E708(10,0x46);
  sub_8086838(1,1,1);
  sub_808680C();
  sub_803E708(0x3c,0x46);
  DisplayDungeonDialogue(&gUnknown_8102EF8);
  sub_803E708(10,0x46);
  GroudonScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8102F30);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8102F64);
  sub_803E708(10,0x46);
  PlaySoundEffect(0x1d5);
  SpriteLookAroundEffect(PartnerEntity);
  DisplayDungeonDialogue(&gUnknown_8102F84);
  sub_803E708(10,0x46);
  sub_808682C();
  sub_803E708(0x3c,0x46);
  sub_80861B8(AlakazamEntity,6,4);
  PlaySoundEffect(0x205);
  sub_8086738();
  sub_8068FE0(AlakazamEntity,0x21c,0);
  DisplayDungeonDialogue(&gUnknown_8102FAC);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8102FC4);
  sub_803E708(10,0x46);
  sub_8085930(DIRECTION_NORTH);
  sub_8086764();
  sub_803E708(0x28,0x46);
  PlaySoundEffect(0x1d5);
  SpriteLookAroundEffect(PartnerEntity);
  DisplayDungeonDialogue(&gUnknown_8102FD8);
  sub_803E708(10,0x46);
  sub_8086838(1,1,1);
  sub_808680C();
  sub_803E708(0x3c,0x46);
  DisplayDungeonDialogue(&gUnknown_8103054);
  sub_803E708(10,0x46);
  sub_8083F14();
  GroudonScreenFlash2();
  sub_803E708(0x1e,0x46);
  DisplayDungeonDialogue(&gUnknown_81030D8);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8103110);
  sub_803E708(10,0x46);
  sub_803E708(0x1e,0x46);
  sub_808682C();
  sub_803E708(0x3c,0x46);
  PlaySoundEffect(0x1fa);
  sub_8086738();
  sub_8085930(DIRECTION_NORTH);
  DisplayDungeonDialogue(&gUnknown_8103140);
  sub_803E708(10,0x46);
  sub_8086A54(GroudonEntity);
  sub_8085930(DIRECTION_NORTH);
  sub_8086764();
  SetupBossFightHP(GroudonEntity,500,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void GroudonReFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * GroudonEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  GroudonEntity = sub_8085680(0xe);
  sub_8086838(1,1,1);
  sub_808680C();
  sub_803E708(0x3c,0x46);
  DisplayDungeonDialogue(&gUnknown_8103188);
  sub_803E708(10,0x46);
  GroudonScreenFlash();
  sub_803E708(0x1e,0x46);
  DisplayDungeonDialogue(&gUnknown_8103228);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8103310);
  sub_803E708(10,0x46);
  sub_808682C();
  sub_803E708(0x3c,0x46);
  sub_8083F14();
  PlaySoundEffect(0x1fa);
  sub_8086738();
  DisplayDungeonDialogue(&gUnknown_8103340);
  sub_803E708(10,0x46);
  sub_8086A54(GroudonEntity);
  sub_8085930(DIRECTION_NORTH);
  sub_8086764();
  SetupBossFightHP(GroudonEntity,500,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void GroudonPostStoryPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * GroudonEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  GroudonEntity = sub_8085680(0xe);
  sub_8086448();
  if (sub_8086AE4(SPECIES_GROUDON)) {
      sub_80866C4(&gUnknown_8103488);
  }
  else{
    DisplayDungeonDialogue(&gUnknown_81033A0);
    sub_803E708(10,0x46);
    SceneGroudonMovement(GroudonEntity);
    SceneGroudonMovement(GroudonEntity);
    DisplayDungeonDialogue(&gUnknown_81033AC);
    PlaySoundEffect(0x1f6);
    GroudonScreenFlash();
    DisplayDungeonDialogue(&gUnknown_810343C);
    PlaySoundEffect(0x1f6);
    GroudonScreenFlash();
    DisplayDungeonDialogue(&gUnknown_810347C);
    sub_803E708(10,0x46);
    SetupBossFightHP(GroudonEntity,500,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

// Moves Groudon down in a walking fashion
void SceneGroudonMovement(struct DungeonEntity * param_1)
{
  int iVar1;

  sub_8086848(0x18,0x10);
  sub_806CDD4(param_1,0,DIRECTION_SOUTH);
  for(iVar1 = 0; iVar1 < 0x2C; iVar1++)
  {
    if ((iVar1 == 10) || (iVar1 == 0x20)) {
      PlaySoundEffect(0x1f9);
      sub_8086838(0,1,0);
      sub_808680C();
    }
    if ((iVar1 - 10U < 0xc) || (iVar1 > 0x1f)) {
      sub_804539C(param_1,0,0x100);
    }
    sub_803E46C(0x46);
  }
  sub_80856C8(param_1,param_1->posWorld.x,param_1->posWorld.y + 1);
  sub_80861D4(param_1,0xf,0);
  sub_803E708(10,0x46);
  sub_808682C();
  sub_8085930(DIRECTION_NORTH);
  sub_803E708(0x22,0x46);
}

void GroudonScreenFlash(void)
{
  s32 iVar1;

  for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1 / 2,iVar1 / 2,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);

  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1 / 2,0,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);

  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1 / 2,iVar1 / 2,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);
  sub_8085EB0();
}

void GroudonScreenFlash2(void)
{
  s32 iVar1;

  for(iVar1 = 250; iVar1 > 0x95; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1 / 2,iVar1 / 2,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);

  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1 / 2,0,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);

  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1 / 2,iVar1 / 2,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);
  sub_8085EB0();
}


void sub_8088DC0(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * uVar2;
  struct DungeonEntity * uVar3;

  LeaderEntity = xxx_call_GetLeaderEntity();
  uVar2 = sub_8085680(0xb);
  uVar3 = sub_8085680(0xc);
  sub_80867F4();
  sub_8086838(0,1,0);
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  sub_8086A3C(uVar2);
  sub_806CDD4(uVar2,0xe,DIRECTION_SOUTH);
  sub_8086A3C(uVar3);
  sub_806CDD4(uVar3,0xe,DIRECTION_SOUTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_GROUDON);
  CopySpeciesNametoBuffer(gUnknown_202E038 + 0x50, SPECIES_ALAKAZAM);
}

void sub_8088E5C(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * uVar2;
  struct DungeonEntity * uVar3;

  LeaderEntity = xxx_call_GetLeaderEntity();
  uVar2 = sub_8085680(0xb);
  uVar3 = sub_8085680(0xc);
  sub_80867F4();
  sub_8086838(0,1,0);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  sub_8068FE0(uVar2,0x21c,0);
  sub_8068FE0(uVar3,0x21c,0);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y + -3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_GROUDON);
  CopySpeciesNametoBuffer(gUnknown_202E038 + 0x50, SPECIES_ALAKAZAM);
}

void sub_8088EE8(void)
{
    sub_8086854();
}


void MagmaCavernMidDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * PartnerEntity;
  struct DungeonEntity * iVar3;
  struct DungeonEntity * iVar4;
  u8 auStack36 [4];
  s32 local_20[2];

  LeaderEntity = xxx_call_GetLeaderEntity();
  PartnerEntity = GetPartnerEntity();
  iVar3 = sub_8085680(0xb);
  iVar4 = sub_8085680(0xc);
  sub_8052D44(auStack36,LeaderEntity,PartnerEntity);
  sub_8086448();
  SpriteLookAroundEffect(PartnerEntity);
  // Let's see..
  // I wonder where we are?
  DisplayDungeonDialogue(&gUnknown_8102B1C);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,1,2);
  sub_80869E4(LeaderEntity,4,2,6);
  // I know we've come pretty
  // far...
  //
  // I'm certain we've come quite
  // far already..
  DisplayDungeonDialogue(&gUnknown_8102B54);
  sub_803E708(10,0x46);
  sub_8083F14();
  sub_80855E4(sub_80868F4);
  sub_808680C();
  PlaySoundEffect(0x1c5);
  sub_803E708(0x28,0x46);
  // Waaah!
  // Qu-quake!
  DisplayDungeonDialogue(&gUnknown_8102BC4);
  sub_803E708(0x78,0x46);
  sub_8083E58(0x1c5);
  sub_808682C();
  sub_80855E4(sub_8086910);
  sub_803E708(0x14,0x46);
  sub_8085930(DIRECTION_NORTH);
  sub_803E708(10,0x46);
  // Whew!
  // It settled down.
  //
  // Whew
  // It's over.
  DisplayDungeonDialogue(&gUnknown_8102BE4);
  sub_803E708(10,0x46);
  PlaySoundEffect(0x1d5);
  SpriteLookAroundEffect(PartnerEntity);
  PlaySoundEffect(0x1c7);
  sub_80856E0(PartnerEntity,4);
  // Hey! {ARG_POKEMON_0}!
  // Over there!
  DisplayDungeonDialogue(&gUnknown_8102C30);
  iVar3->entityData->unk15E = 0;
  iVar4->entityData->unk15E =0;
  local_20[0] = (iVar3->posPixel.x + iVar4->posPixel.x) / 2;
  local_20[1] = (iVar3->posPixel.y + iVar4->posPixel.y) / 2 + 0x800;
  sub_80858AC(local_20,0x20);
  sub_803E708(0x3c,0x46);
  sub_80891F0();
  // Hey!
  // Are you OK?!
  //
  // Hey!
  // Snap out of it!
  DisplayDungeonDialogue(&gUnknown_8102C54);
  sub_803E708(10,0x46);
  // Urrrrgh...
  DisplayDungeonDialogue(&gUnknown_8102C98);
  sub_803E708(10,0x46);
  sub_80869E4(LeaderEntity,4,2,5);
  // What happened to you?
  //
  // What happened here?
  DisplayDungeonDialogue(&gUnknown_8102CB0);
  sub_803E708(10,0x46);
  // We challenged..
  // {ARG_POKEMON_2}...
  // And wiped out..
  DisplayDungeonDialogue(&gUnknown_8102CF8);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8102D34);
  sub_803E708(10,0x46);
  sub_80869E4(LeaderEntity,4,1,3);
  sub_80869E4(PartnerEntity,4,1,3);
  // Grrgh..
  // We... It crushed us
  DisplayDungeonDialogue(&gUnknown_8102D4C);
  sub_803E708(10,0x46);
  PlaySoundEffect(0x1d5);
  SpriteLookAroundEffect(PartnerEntity);
  // That's right...
  // What happened to {ARG_POKEMON_3}?
  // Where is {ARG_POKEMON_3}?
  //
  // Wait...
  // What about {ARG_POKEMON_3}?
  // Where did {ARG_POKEMON_3} go?
  DisplayDungeonDialogue(&gUnknown_8102D7C);
  sub_803E708(0x1e,0x46);
  // {ARG_POKEMON_3} is...
  // Still battling {ARG_POKEMON_2}...
  DisplayDungeonDialogue(&gUnknown_8102DFC);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,1,2);
  sub_80869E4(LeaderEntity,4,2,6);
  // {ARG_POKEMON_0}!
  // We've got to hurry!
  DisplayDungeonDialogue(&gUnknown_8102E2C);
  sub_8089294();
  // Be careful!
  DisplayDungeonDialogue(&gUnknown_8102E54);
  sub_803E708(10,0x46);
  gDungeonGlobalData->unk2 = 1;
}

void sub_8089168(void)
{
  struct DungeonEntity *LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8086448();
  sub_803E708(10,0x46);
  SpriteLookAroundEffect(LeaderEntity);
  sub_803E708(10,0x46);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void sub_808919C(struct DungeonEntity *r0)
{
    sub_804539C(r0, 0, 0xfffffe00);
}

void sub_80891B0(struct DungeonEntity *r0)
{
    sub_806CDD4(r0, 0, DIRECTION_NORTH);
    r0->entityData->unk15F = 1;
}


void sub_80891D0(struct DungeonEntity *r0)
{
    sub_806CDD4(r0, 7, DIRECTION_NORTH);
    r0->entityData->unk15F = 0;
}

void sub_80891F0(void)
{
  s32 iVar1;

  sub_80855E4(sub_80891B0);
  for(iVar1 = 0; iVar1 < 0x30; iVar1++)
  {
    sub_80855E4(sub_808919C);
    sub_803E46C(0x46);
  }
  sub_80855E4(sub_80891D0);
}

void sub_8089224(struct DungeonEntity * param_1)
{
  s32 iVar1;

  if (param_1->posPixel.y < 0x9001) {
    return;
  }
  iVar1 = param_1->posPixel.x;

  if(iVar1 < 0xE400)
  {
      if(iVar1 <= 0xB400)
      {
          // 0 - 0xB400
          sub_804539C(param_1, 0, 0xfffffe00);
      }
      else
      {
          // 0xB401 - 0xE3FF
           sub_804539C(param_1, 0xfffffe00, 0);
      }
  }
  else
  {
      if(iVar1 < 0xFC00)
      {
            sub_804539C(param_1, 0, 0xfffffe00);
      }
      else
      {
          if(iVar1 <= 0x11400)
          {
              sub_804539C(param_1, 0x200, 0);
          }
          else
          {
              sub_804539C(param_1, 0, 0xfffffe00);
          }
      }
  }
}

void sub_8089294(void)
{
  s32 iVar1;

  sub_80855E4(sub_80891B0);
  for(iVar1 = 0; iVar1 <= 0x77; iVar1++)
  {
    sub_80855E4(sub_8089224);
    sub_803E46C(0x46);
  }
  sub_80855E4(sub_80891D0);
}

void sub_80892C8(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RayquazaEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RayquazaEntity = sub_8085680(0xf);
  sub_8083E88(0x1a);
  sub_8085374();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(RayquazaEntity, DIRECTION_SOUTH);
  sub_8086A3C(RayquazaEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038,SPECIES_RAYQUAZA);
}

void sub_8089328(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RayquazaEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RayquazaEntity = sub_8085680(0xf);
  sub_8083E88(0x1a);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  if (sub_8086AE4(SPECIES_RAYQUAZA)) {
    sub_8068FE0(RayquazaEntity,0x21c,0);
  }
  else {
    sub_8072008(RayquazaEntity,RayquazaEntity,gUnknown_80F57CA,0,0);
    sub_8086A3C(RayquazaEntity);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038,SPECIES_RAYQUAZA);
}

void sub_80893B4(char param_1, s32 param_2)
{
  if ((((param_2 * 0x1000000) + 0xE9000000U) >> 0x18 < 3) && (param_1 == 0xF)) {
    sub_8097FA8(0xF);
    gDungeonGlobalData->unk2 = 1;
  }
}

void RayquazaPreFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *PartnerEntity;
  struct DungeonEntity *RayquazaEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  PartnerEntity = GetPartnerEntity();
  RayquazaEntity = sub_8085680(0xf);
  sub_8086448();
  DisplayDungeonDialogue(&gUnknown_8103500);
  RayquazaScreenFlash();
  DisplayDungeonDialogue(&gUnknown_810352C);
  sub_80856E0(PartnerEntity,4);
  SpriteLookAroundEffect(PartnerEntity);
  sub_803E708(10,0x46);
  sub_80869E4(PartnerEntity,4,1,2);
  sub_80869E4(LeaderEntity,4,2,6);
  DisplayDungeonDialogue(&gUnknown_8103578);
  sub_80869E4(PartnerEntity,4,2,4);
  sub_80869E4(LeaderEntity,4,1,4);
  DisplayDungeonDialogue(&gUnknown_81035D4);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_8103618);
  sub_803E708(10,0x46);
  DisplayDungeonDialogue(&gUnknown_810367C);
  RayquazaScreenFlash();
  PlaySoundEffect(0x1da); // Rayquaza Cry
  DisplayDungeonDialogue(&gUnknown_8103690);
  sub_8089620(RayquazaEntity);
  DisplayDungeonDialogue(&gUnknown_81036C8);
  RayquazaScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81037A0);
  RayquazaScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81037D4);
  RayquazaScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8103820);
  SetupBossFightHP(RayquazaEntity,600,0x20);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void RayquazaReFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *RayquazaEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RayquazaEntity = sub_8085680(0xf);
  sub_8086448();
  RayquazaScreenFlash();
  PlaySoundEffect(0x1da); // Rayquaza Cry
  DisplayDungeonDialogue(&gUnknown_8103690);
  sub_803E708(10,0x46);
  sub_8089620(RayquazaEntity);
  DisplayDungeonDialogue(&gUnknown_8103844);
  RayquazaScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8103874);
  RayquazaScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81038A8);
  RayquazaScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81038F8);
  SetupBossFightHP(RayquazaEntity,600,0x20);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void RayquazaPostStoryPreFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *RayquazaEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RayquazaEntity = sub_8085680(0xf);
  sub_8086448();
  if (sub_8086AE4(SPECIES_RAYQUAZA)) {
    sub_80866C4(&gUnknown_8103B58);
  }
  else {
    PlaySoundEffect(0x1da); // Rayquaza Cry
    DisplayDungeonDialogue(&gUnknown_8103904);
    sub_8089620(RayquazaEntity);
    DisplayDungeonDialogue(&gUnknown_8103938);
    RayquazaScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8103AA4);
    RayquazaScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8103AE4);
    RayquazaScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8103B30);
    SetupBossFightHP(RayquazaEntity,600,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void sub_8089620(struct DungeonEntity *param_1)
{
  s32 iVar1;
  s32 iVar2;

  param_1->entityData->unk15E = 0;
  iVar2 = 51200;
  iVar1 = 0x600;
  PlaySoundEffect(0x1f8);
  while( 1 ) {
    iVar2 = iVar2 - iVar1;
    iVar1 = iVar1 -= 0x18;
    if (iVar1 < 0x14) {
      iVar1 = 0x14;
    }
    if (iVar2 < 0) break;
    param_1->entityData->unk174 = iVar2;
    sub_803E46C(0x46);
  }
  param_1->entityData->unk174 = 0;
}

void RayquazaScreenFlash(void)
{
  s32 iVar1;

  PlaySoundEffect(0x1f6);
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10)
  {
    sub_8085C54(iVar1 / 2, iVar1, iVar1 / 2, 1, 1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1 / 2, iVar1, 0, 1, 1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1 / 2, iVar1, iVar1 / 2, 1, 1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  sub_8085EB0();
}


void sub_808970C(void)
{
  struct DungeonEntity *LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8083E88(0x7D);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  sub_808563C(sub_8089908);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y + -3);
}

void sub_808974C(void)
{
  struct DungeonEntity *LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  sub_808563C(sub_80898F8);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y + -3);
}

void sub_8089788(struct DungeonEntity *param_1, u8 param_2, s32 param_3)
{
  struct DungeonEntity *iVar2;
  s32 iVar3;
  u32 unk1;

  unk1 = 0;

  if ((((param_3 * 0x1000000) + 0xe6000000U) >> 0x18) < 2) {
    for(iVar3 = 0; iVar3 < DUNGEON_MAX_WILD_POKEMON; iVar3++)
    {
      iVar2 = gDungeonGlobalData->wildPokemon[iVar3];
      if ((EntityExists(iVar2) != '\0') && (iVar2 != param_1) && (iVar2->entityData->clientType == param_2)) {
        return;
      }
    }
    // WTF is this??
    if(!unk1){
        sub_8097FA8(0x11);
        gDungeonGlobalData->unk2 = 1;
    }
  }
}

void sub_80897F0(void)
{
  struct DungeonEntity *LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8086448();
  sub_803E708(10,0x46);
  sub_808563C(sub_80862BC);
  sub_803E708(0x20,0x46);
  sub_808692C();
  DisplayDungeonDialogue(&gUnknown_8103BD8);
  // We don't like to brag or
  // nothing, but
  DisplayDungeonDialogue(&gUnknown_8103C00);
  // We get furious real easy
  // You know that?!
  DisplayDungeonDialogue(&gUnknown_8103C3C);
  // What really irritates us is
  // when we see some dim witted face
  DisplayDungeonDialogue(&gUnknown_8103C74);
  // .........
  // Wrooooooar!
  // That vacant expression
  DisplayDungeonDialogue(&gUnknown_8103CC4);
  // Gwoooh
  // It's ticking me off!
  // I'm seeing red!
  DisplayDungeonDialogue(&gUnknown_8103D0C);
  // Mukkkeeeeeh
  // Get 'em! It's frenzy time!
  DisplayDungeonDialogue(&gUnknown_8103D50);
  sub_803E708(10,0x46);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}



void sub_8089878(void)
{
  struct DungeonEntity *LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8086448();
  sub_803E708(10,0x46);
  sub_808563C(sub_80862BC);
  sub_803E708(0x20,0x46);
  sub_808692C();
  DisplayDungeonDialogue(&gUnknown_8103D8C);
  DisplayDungeonDialogue(&gUnknown_8103D98);
  DisplayDungeonDialogue(&gUnknown_8103DD8);
  DisplayDungeonDialogue(&gUnknown_8103E28);
  sub_803E708(10,0x46);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void sub_80898E4(void)
{
    sub_8086448();
    sub_80866C4(&gUnknown_8103E34);
}

void sub_80898F8(struct DungeonEntity *r0)
{
    sub_8068FE0(r0, 0x21C, 0);
}

void sub_8089908(struct DungeonEntity *r0)
{
    SetFacingDirection(r0, DIRECTION_NORTH);
}

void sub_8089914(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *MewtwoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  MewtwoEntity = sub_8085680(0x11);
  sub_8083F14();
  gDungeonGlobalData->unk7 = 1;
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(MewtwoEntity, DIRECTION_SOUTH);
  sub_8086A3C(MewtwoEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038,SPECIES_MEWTWO);
}

void sub_8089978(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *MewtwoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  MewtwoEntity = sub_8085680(0x11);
  sub_8083F14();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  if(HasRecruitedMon(SPECIES_MEWTWO)){
    sub_8083E88(0x23);
    sub_8068FE0(MewtwoEntity,0x21c,0);
  }
  else {
    gDungeonGlobalData->unk7 = 1;
    SetFacingDirection(MewtwoEntity, DIRECTION_SOUTH);
    sub_8086A3C(MewtwoEntity);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038,SPECIES_MEWTWO);
}

void sub_8089A00(char param_1, s32 param_2)
{
  if ((((param_2 * 0x1000000) + 0xE3000000U) >> 0x18 < 3) && (param_1 == 0x11)) {
    sub_8097FA8(0x13);
    gDungeonGlobalData->unk2 = 1;
  }
}

void MewtwoPreFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *MewtwoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  MewtwoEntity = sub_8085680(0x11);
  sub_8086448();
  DisplayDungeonDialogue(&gUnknown_8103EA4);
  sub_803E708(10,0x46);
  sub_8083E88(0x23);
  sub_8086794();
  sub_803E708(0x1e,0x46);
  sub_8089B64(MewtwoEntity);
  sub_803E708(0x3c,0x46);
  DisplayDungeonDialogue(&gUnknown_8103F0C);
  DisplayDungeonDialogue(&gUnknown_8103F4C);
  sub_803E708(10,0x46);
  MewtwoScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8103FCC);
  MewtwoScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104008);
  sub_803E708(10,0x46);
  SetupBossFightHP(MewtwoEntity,900,0x20);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void MewtwoPreFightDialogue1(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *MewtwoEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  MewtwoEntity = sub_8085680(0x11);
  sub_8086448();
  if(HasRecruitedMon(SPECIES_MEWTWO)) {
    sub_80866C4(&gUnknown_8104144);
  }
  else {
    DisplayDungeonDialogue(&gUnknown_8104044);
    sub_8083E88(0x23);
    sub_8086794();
    sub_8089B64(MewtwoEntity);
    sub_803E708(0x3c,0x46);
    DisplayDungeonDialogue(&gUnknown_8104050);
    MewtwoScreenFlash();
    DisplayDungeonDialogue(&gUnknown_81040CC);
    MewtwoScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8104114);
    SetupBossFightHP(MewtwoEntity,900,0x20);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void sub_8089B64(struct DungeonEntity *param_1)
{
  s32 iVar1;
  s32 iVar2;

  param_1->entityData->unk15E = 0;
  iVar2 = 51200;
  iVar1 = 0x400;
  PlaySoundEffect(0x1f8);
  while( 1 ) {
    iVar2 = iVar2 - iVar1;
    iVar1 = iVar1 -= 11;
    if (iVar1 < 0x1e) {
      iVar1 = 0x1e;
    }
    if (iVar2 < 0) break;
    param_1->entityData->unk174 = iVar2;
    sub_803E46C(0x46);
  }
  param_1->entityData->unk174 = 0;
}

void MewtwoScreenFlash(void)
{
  int iVar1;

  PlaySoundEffect(0x1f6);
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);
  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,0,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);
  sub_8085EB0();
}

void sub_8089C44(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * EnteiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  EnteiEntity = sub_8085680(0x12);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  SetFacingDirection(EnteiEntity, DIRECTION_SOUTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_ENTEI);
}


void sub_8089C90(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * EnteiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  EnteiEntity = sub_8085680(0x12);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  if (HasRecruitedMon(SPECIES_ENTEI)) {
      sub_8068FE0(EnteiEntity,0x21c,0);
  }
  else {
      SetFacingDirection(EnteiEntity, DIRECTION_SOUTH);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_ENTEI);
}


void sub_8089CFC(char param_1,int param_2)
{
  if ((((param_2 * 0x1000000) + 0xE0000000U) >> 0x18 < 3) && (param_1 == 0x12)) {
    sub_8097FA8(0x15);
    gDungeonGlobalData->unk2 = 1;
  }
}


void EnteiPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * EnteiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  EnteiEntity = sub_8085680(0x12);
  EnteiScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104150);
  EnteiScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81041AC);
  EnteiScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81041F8);
  sub_803E708(10,70);
  SetupBossFightHP(EnteiEntity,600,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void EnteiPreFightDialogue1(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * EnteiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  EnteiEntity = sub_8085680(0x12);
  EnteiScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104240);
  EnteiScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81042AC);
  EnteiScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81042B8);
  sub_803E708(10,70);
  SetupBossFightHP(EnteiEntity,600,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void EnteiPreFightDialogue2(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * EnteiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  EnteiEntity = sub_8085680(0x12);
  if (HasRecruitedMon(SPECIES_ENTEI)) {
    sub_80866C4(&gUnknown_81043DC);
  }
  else {
    EnteiScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8104310);
    EnteiScreenFlash();
    DisplayDungeonDialogue(&gUnknown_810439C);
    EnteiScreenFlash();
    DisplayDungeonDialogue(&gUnknown_81043C0);
    sub_803E708(10,70);
    SetupBossFightHP(EnteiEntity,600,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void EnteiScreenFlash(void)
{
  s32 iVar1;

  PlaySoundEffect(0x1ed);
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10)
  {
    sub_8085C54(iVar1, iVar1 / 2, iVar1 / 2, 1, 1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1, 0, 0, 1, 1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1, iVar1 / 2, iVar1 / 2, 1, 1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  sub_8085EB0();
}

void sub_8089EFC(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RaikouEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RaikouEntity = sub_8085680(0x13);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  SetFacingDirection(RaikouEntity, DIRECTION_SOUTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_RAIKOU);
}


void sub_8089F44(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RaikouEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RaikouEntity = sub_8085680(0x13);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  SetFacingDirection(RaikouEntity, DIRECTION_SOUTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_RAIKOU);
}


void sub_8089F8C(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RaikouEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RaikouEntity = sub_8085680(0x13);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  if (HasRecruitedMon(SPECIES_RAIKOU)) {
      sub_8068FE0(RaikouEntity,0x21c,0);
  }
  else {
      SetFacingDirection(RaikouEntity, DIRECTION_SOUTH);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_RAIKOU);
}

void sub_8089FF0(char param_1,int param_2)
{
  if ((((param_2 * 0x1000000) + 0xdD000000U) >> 0x18 < 3) && (param_1 == 0x13)) {
    sub_8097FA8(0x17);
    gDungeonGlobalData->unk2 = 1;
  }
}


void RaikouPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RaikouEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RaikouEntity = sub_8085680(0x13);
  DisplayDungeonDialogue(&gUnknown_8104450);
  RaikouScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81044B4);
  gDungeonGlobalData->unkE265 = 4;
  sub_807EAA0(0,1);
  sub_803E708(10,70);
  DisplayDungeonDialogue(&gUnknown_8104510);
  RaikouScreenFlash();
  DisplayDungeonDialogue(&gUnknown_810453C);
  RaikouScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104570);
  RaikouScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81045B0);
  sub_803E708(10,70);
  SetupBossFightHP(RaikouEntity,0x28a,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void RaikouPreFightDialogue1(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RaikouEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RaikouEntity = sub_8085680(0x13);
  gDungeonGlobalData->unkE265 = 4;
  sub_807EAA0(0,1);
  RaikouScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81045F8);
  RaikouScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104674);
  RaikouScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81046A0);
  sub_803E708(10,70);
  SetupBossFightHP(RaikouEntity,0x28a,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void RaikouPreFightDialogue2(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * RaikouEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  RaikouEntity = sub_8085680(0x13);
  if (HasRecruitedMon(SPECIES_RAIKOU)) {
    sub_80866C4(&gUnknown_8104778);
  }
  else {
    gDungeonGlobalData->unkE265 = 4;
    sub_807EAA0(0,1);
    DisplayDungeonDialogue(&gUnknown_81046CC);
    RaikouScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8104744);
    RaikouScreenFlash();
    DisplayDungeonDialogue(&gUnknown_810476C);
    sub_803E708(10,70);
    SetupBossFightHP(RaikouEntity,0x28a,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void RaikouScreenFlash(void)
{
  s32 iVar1;

  PlaySoundEffect(0x1f6);
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  sub_8085EB0();
}

void sub_808A264(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * SuicuneEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  SuicuneEntity = sub_8085680(0x14);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH);
  sub_8086A3C(SuicuneEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_SUICUNE);
}

void sub_808A2C0(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * SuicuneEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  SuicuneEntity = sub_8085680(0x14);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_SUICUNE);
}

void sub_808A308(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * SuicuneEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  SuicuneEntity = sub_8085680(0x14);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  if (HasRecruitedMon(SPECIES_SUICUNE)) {
     sub_8068FE0(SuicuneEntity,0x21c,0);
  }
  else {
     SetFacingDirection(SuicuneEntity, DIRECTION_SOUTH);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_SUICUNE);
}

void sub_808A36C(char param_1,int param_2)
{
  if ((((param_2 * 0x1000000) + 0xda000000U) >> 0x18 < 3) && (param_1 == 0x14)) {
    sub_8097FA8(0x19);
    gDungeonGlobalData->unk2 = 1;
  }
}

void SuicunePreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * SuicuneEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  SuicuneEntity = sub_8085680(0x14);
  sub_8086448();
  DisplayDungeonDialogue(&gUnknown_8104784);
  sub_803E708(10,70);
  DisplayDungeonDialogue(&gUnknown_8104790);
  sub_803E708(10,70);
  sub_80426C8(1,2);
  sub_803E708(0x3c,70);
  DisplayDungeonDialogue(&gUnknown_81047B0);
  sub_803E708(10,70);
  sub_808A528(SuicuneEntity);
  DisplayDungeonDialogue(&gUnknown_810484C);
  DisplayDungeonDialogue(&gUnknown_8104888);
  SuicuneScreenFlash();
  DisplayDungeonDialogue(&gUnknown_81048C8);
  SuicuneScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104914);
  sub_803E708(10,70);
  SetupBossFightHP(SuicuneEntity,0x28a,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void SuicunePreFightDialogue1(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * SuicuneEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  SuicuneEntity = sub_8085680(0x14);
  DisplayDungeonDialogue(&gUnknown_8104930);
  SuicuneScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104980);
  SuicuneScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104998);
  sub_803E708(10,70);
  SetupBossFightHP(SuicuneEntity,0x28a,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void SuicunePreFightDialogue2(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * SuicuneEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  SuicuneEntity = sub_8085680(0x14);
  if (HasRecruitedMon(SPECIES_SUICUNE)) {
    sub_80866C4(&gUnknown_8104AC8);
  }
  else {
    DisplayDungeonDialogue(&gUnknown_81049D4);
    SuicuneScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8104A80);
    SuicuneScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8104A9C);
    sub_803E708(10,70);
    SetupBossFightHP(SuicuneEntity,0x28a,0xb);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void sub_808A528(struct DungeonEntity * param_1)
{
  s32 iVar1;
  s32 iVar2;

  param_1->entityData->unk15E = 0;
  iVar2 = 51200;
  iVar1 = 3072;
  PlaySoundEffect(0x1f8);
  while( 1 ) {
    iVar2 = iVar2 - iVar1;
    iVar1 -= 96;
    if (iVar1 < 20) {
      iVar1 = 20;
    }
    if (iVar2 < 0) break;
    param_1->entityData->unk174 = iVar2;
    sub_803E46C(70);
  }
  param_1->entityData->unk174 = 0;
}

void SuicuneScreenFlash(void)
{
  s32 iVar1;

  PlaySoundEffect(0x1ee);
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  sub_8085EB0();
}

void sub_808A608(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * HoOhEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  HoOhEntity = sub_8085680(0x15);
  sub_8083E88(0x1c);
  sub_80867F4();
  sub_8086838(0,0,0);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  SetFacingDirection(HoOhEntity, DIRECTION_SOUTH);
  sub_8086A3C(HoOhEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y + -6);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_HO_OH);
}

void sub_808A668(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * HoOhEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  HoOhEntity = sub_8085680(0x15);
  sub_8083E88(0x1c);
  sub_80867F4();
  sub_8086838(0,0,0);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  if (HasRecruitedMon(SPECIES_HO_OH)) {
    sub_8068FE0(HoOhEntity,0x21c,0);
  }
  else {
    SetFacingDirection(HoOhEntity, DIRECTION_SOUTH);
    sub_8086A3C(HoOhEntity);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 6);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_HO_OH);
}

void sub_808A6E8(char param_1, s32 param_2)
{
  if ((((param_2 * 0x1000000) + 0xd7000000U) >> 0x18 < 2) && (param_1 == 0x15)) {
    sub_8097FA8(0x1A);
    gDungeonGlobalData->unk2 = 1;
  }
}


void sub_808A718(void)
{
    sub_8086854();
}

void HoOhPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * HoOhEntity;
  int local_14[2];

  LeaderEntity = xxx_call_GetLeaderEntity();
  HoOhEntity = sub_8085680(0x15);
  local_14[0] = LeaderEntity->posPixel.x;
  local_14[1] = LeaderEntity->posPixel.y + -0x1000;
  sub_80858AC(local_14,0x88);
  sub_803E708(0x40,70);
  DisplayDungeonDialogue(&gUnknown_8104AD4);
  sub_803E708(10,70);
  HoOhScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104BEC);
  sub_803E708(10,70);
  sub_80855E4(sub_80868F4);
  sub_808680C();
  PlaySoundEffect(0x1c5);
  sub_803E708(0xfa,70);
  sub_808A904(HoOhEntity);
  sub_8083E58(0x1c5);
  sub_808682C();
  sub_80855E4(sub_8086910);
  sub_8085930(DIRECTION_NORTH);
  DisplayDungeonDialogue(&gUnknown_8104C10);
  DisplayDungeonDialogue(&gUnknown_8104C54);
  sub_803E708(0x1e,70);
  sub_803E708(0x1e,70);
  HoOhScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104CB4);
  HoOhScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104CE0);
  sub_803E708(10,70);
  SetupBossFightHP(HoOhEntity,800,0x20);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void HoOhPreFightDialogue1(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * HoOhEntity;
  u32 local_14[2];

  LeaderEntity = xxx_call_GetLeaderEntity();
  HoOhEntity = sub_8085680(0x15);

  local_14[0] = LeaderEntity->posPixel.x;
  local_14[1] = LeaderEntity->posPixel.y + -0x1000;
  sub_80858AC(local_14,0x88);
  sub_803E708(0x40,70);
  if (HasRecruitedMon(SPECIES_HO_OH)) {
    sub_80866C4(&gUnknown_8104E54);
  }
  else {
    DisplayDungeonDialogue(&gUnknown_8104CEC);
    HoOhScreenFlash();
    sub_80855E4(sub_80868F4);
    sub_808680C();
    sub_803E708(10,70);
    sub_808A904(HoOhEntity);
    sub_808682C();
    sub_80855E4(sub_8086910);
    sub_8085930(DIRECTION_NORTH);
    DisplayDungeonDialogue(&gUnknown_8104D60);
    HoOhScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8104DDC);
    HoOhScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8104E0C);
    sub_803E708(10,70);
    SetupBossFightHP(HoOhEntity,800,0x20);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void sub_808A904(struct DungeonEntity * param_1)
{
  s32 iVar1;
  s32 iVar2;

  param_1->entityData->unk15E = 0;
  iVar2 = 51200;
  iVar1 = 3072;
  PlaySoundEffect(0x1f8);
  while( 1 ) {
    iVar2 = iVar2 - iVar1;
    iVar1 -= 96;
    if (iVar1 < 20) {
      iVar1 = 20;
    }
    if (iVar2 < 0) break;
    param_1->entityData->unk174 = iVar2;
    sub_803E46C(70);
  }
  param_1->entityData->unk174 = 0;
}

void HoOhScreenFlash(void)
{
  s32 iVar1;

  PlaySoundEffect(0x1ed);
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 > 199; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  sub_8085EB0();
}

void sub_808A9E4(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * LatiosEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  LatiosEntity = sub_8085680(0x16);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(LatiosEntity, DIRECTION_NORTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 4);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_LATIOS);
}

void sub_808AA3C(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * LatiosEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  LatiosEntity = sub_8085680(0x16);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(LatiosEntity, DIRECTION_NORTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_LATIOS);
}

void sub_808AA94(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * LatiosEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  LatiosEntity = sub_8085680(0x16);
  sub_8083E88(0x72);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  sub_8068FE0(LatiosEntity,0x21c,0);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_LATIOS);
}

void sub_808AAF0(char param_1, s32 param_2)
{
  if ((((param_2 * 0x1000000) + 0xd5000000U) >> 0x18 < 3) && (param_1 == 0x16)) {
    sub_8097FA8(0x1c);
    gDungeonGlobalData->unk2 = 1;
  }
}

void LatiosPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * LatiosEntity;
  u32 local_18[3];

  LeaderEntity = xxx_call_GetLeaderEntity();
  LatiosEntity = sub_8085680(0x16);

  local_18[0] = LatiosEntity->posPixel.x;
  local_18[1] = LatiosEntity->posPixel.y + (0x80 << 6);
  local_18[2] = 0x7000fc;
  sub_8085EC8(0x1bd,0,0,&local_18[2],1);

  sub_803E708(0x1e,70);
  sub_8086448();
  sub_80858AC(local_18,0x18);
  sub_803E708(2,70);
  sub_80862BC(LatiosEntity);
  sub_803E708(0x20,70);
  sub_808692C();
  DisplayDungeonDialogue(&gUnknown_8104E60);
  LatiosScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104EFC);
  LatiosScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104F30);
  sub_803E708(10,70);
  SetupBossFightHP(LatiosEntity,600,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void LatiosReFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * LatiosEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  LatiosEntity = sub_8085680(0x16);
  sub_8086448();
  sub_808692C();
  DisplayDungeonDialogue(&gUnknown_8104F64);
  LatiosScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104EFC);
  LatiosScreenFlash();
  DisplayDungeonDialogue(&gUnknown_8104F30);
  sub_803E708(10,70);
  SetupBossFightHP(LatiosEntity,600,0xb);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void sub_808AC3C(void)
{
    sub_8086448();
    // There appears to be no one here
    sub_80866C4(&gUnknown_8104FC8);
}

void LatiosScreenFlash(void)
{
  s32 iVar1;

  PlaySoundEffect(0x1ee);
  gUnknown_202EDC8 = 0x1f;
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  for(iVar1 = 250; iVar1 >= 0; iVar1 -= 10)
  {
    sub_8085C54(iVar1,iVar1,iVar1,1,1);
    sub_803E46C(70);
  }
  sub_803E708(10,70);
  sub_8085EB0();
}

void sub_808ACC0(void)
{
  struct DungeonEntity * uVar2;

  if (HasRecruitedMon(SPECIES_REGIROCK)) {
    uVar2 = sub_8085680(0x17);
    sub_8068FE0(uVar2,0x21c,0);
    sub_8097FA8(0x22);
    sub_8097FA8(0x1d);
    sub_808B1CC(ITEM_ID_ROCK_PART);
  }
  else {
    if (sub_80860A8(ITEM_ID_ROCK_PART) != 0) {
        sub_8098044(0x22);
        sub_8097FA8(0x1d);
    }
    else
    {
      if (sub_80860A8(ITEM_ID_MUSIC_BOX) != 0) {
        sub_8098044(0x22);
        sub_8097FA8(0x1d);
      }
      else {
        sub_8098044(0x22);
        sub_8098044(0x1d);
        sub_80855E4(SetupRegiFacingDirection);
        CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_REGIROCK);
     }
    }
  }
}

void sub_808AD48(void)
{
  struct DungeonEntity * uVar2;

  if (HasRecruitedMon(SPECIES_REGICE)) {
    uVar2 = sub_8085680(0x18);
    sub_8068FE0(uVar2,0x21c,0);
    sub_8097FA8(0x22);
    sub_8097FA8(0x1d);
    sub_808B1CC(ITEM_ID_ICE_PART);
  }
  else {
    if (sub_80860A8(ITEM_ID_ICE_PART) != 0) {
        sub_8098044(0x22);
        sub_8097FA8(0x1d);
    }
    else
    {
      if (sub_80860A8(ITEM_ID_MUSIC_BOX) != 0) {
        sub_8098044(0x22);
        sub_8097FA8(0x1d);
      }
      else {
        sub_8098044(0x22);
        sub_8098044(0x1d);
        sub_80855E4(SetupRegiFacingDirection);
        CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_REGICE);
     }
    }
  }
}

void sub_808ADCC(void)
{

  struct DungeonEntity * uVar2;

  if (HasRecruitedMon(SPECIES_REGISTEEL)) {
    uVar2 = sub_8085680(0x19);
    sub_8068FE0(uVar2,0x21c,0);
    sub_8097FA8(0x22);
    sub_8097FA8(0x1d);
    sub_808B1CC(ITEM_ID_STEEL_PART);
  }
  else {
    if (sub_80860A8(ITEM_ID_STEEL_PART) != 0) {
        sub_8098044(0x22);
        sub_8097FA8(0x1d);
    }
    else
    {
      if (sub_80860A8(ITEM_ID_MUSIC_BOX) != 0) {
        sub_8098044(0x22);
        sub_8097FA8(0x1d);
      }
      else {
        sub_8098044(0x22);
        sub_8098044(0x1d);
        sub_80855E4(SetupRegiFacingDirection);
        CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_REGISTEEL);
     }
    }
  }
}

void sub_808AE54(char param_1,char param_2,u32 *param_3)
{
  struct DungeonEntity * LeaderEntity;
  u8 auStack24 [4];
  struct ItemSlot auStack20;


  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8052D44(auStack24,LeaderEntity,0);
  if ((sub_8098100(0x22) == 0) && (param_2 == 0x2E) && (param_1 == 0x17)) {
    sub_808B1CC(0);
    if (sub_8098100(0x1d) == 0) {
      xxx_init_itemslot_8090A8C(&auStack20,ITEM_ID_ROCK_PART,0);
      sub_80464C8(GetLeaderEntity(),param_3,&auStack20);
      sub_8083E88(0x72);
      // Something fell from Regirock's body
      // Regirock was apparently guarding this item
      DisplayDungeonDialogue(&gUnknown_8105040);
    }
  }
}


void sub_808AEC8(char param_1,char param_2,u32 *param_3)
{
  struct DungeonEntity * LeaderEntity;
  u8 auStack24 [4];
  struct ItemSlot auStack20;


  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8052D44(auStack24,LeaderEntity,0);
  if ((sub_8098100(0x22) == 0) && (param_2 == 0x2F) && (param_1 == 0x18)) {
    sub_808B1CC(0);
    if (sub_8098100(0x1d) == 0) {
      xxx_init_itemslot_8090A8C(&auStack20,ITEM_ID_ICE_PART,0);
      sub_80464C8(GetLeaderEntity(),param_3,&auStack20);
      sub_8083E88(0x72);
      // Something fell from Regice's body
      // Regice was apparently guarding this item
      DisplayDungeonDialogue(&gUnknown_810510C);
    }
  }
}

void sub_808AF3C(char param_1,char param_2,u32 *param_3)
{
  struct DungeonEntity * LeaderEntity;
  u8 auStack24 [4];
  struct ItemSlot auStack20;


  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8052D44(auStack24,LeaderEntity,0);
  if ((sub_8098100(0x22) == 0) && (param_2 == 0x30) && (param_1 == 0x19)) {
    sub_808B1CC(0);
    if (sub_8098100(0x1d) == 0) {
      xxx_init_itemslot_8090A8C(&auStack20,ITEM_ID_STEEL_PART,0);
      sub_80464C8(GetLeaderEntity(),param_3, &auStack20);
      sub_8083E88(0x72);
      // Something fell from Registeel's body
      // Registeel was apparently guarding this item
      DisplayDungeonDialogue(&gUnknown_81051D0);
    }
  }
}

void sub_808AFB0(char param_1)
{
  struct DungeonEntity * LeaderEntity;
  u8 auStack12 [4];

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8052D44(auStack12,LeaderEntity,0);
  if ((sub_8098100(0x22) == 0) && (param_1 == 0x2E) && (sub_8098100(0x1d) == 0) && (sub_80860A8(ITEM_ID_ROCK_PART) != 0)) {
    sub_8097FD0(0x1d);
    SetMessageArgument(gAvailablePokemonNames,GetLeaderEntity(),0);
    // {ARG_POKEMON_0} obtained the Rock Part that Regirock was guarding
    DisplayDungeonDialogue(&gUnknown_81050B4);
    sub_80421C0(0,0xd4);
    sub_803E708(10,70);
    sub_8046D20();
  }
}

void sub_808B030(char param_1)
{
  struct DungeonEntity * LeaderEntity;
  u8 auStack12 [4];

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8052D44(auStack12,LeaderEntity,0);
  if ((sub_8098100(0x22) == 0) && (param_1 == 0x2F) && (sub_8098100(0x1d) == 0) && (sub_80860A8(ITEM_ID_ICE_PART) != 0)) {
    sub_8097FD0(0x1d);
    SetMessageArgument(gAvailablePokemonNames,GetLeaderEntity(),0);
    // {ARG_POKEMON_0} obtained the Ice Part that Regice was guarding
    DisplayDungeonDialogue(&gUnknown_810517C);
    sub_80421C0(0,0xd4);
    sub_803E708(10,70);
    sub_8046D20();
  }
}

void sub_808B0B0(char param_1)
{
  struct DungeonEntity * LeaderEntity;
  u8 auStack12 [4];

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8052D44(auStack12,LeaderEntity,0);
  if ((sub_8098100(0x22) == 0) && (param_1 == 0x30) && (sub_8098100(0x1d) == 0) && (sub_80860A8(ITEM_ID_STEEL_PART) != 0)) {
    sub_8097FD0(0x1d);
    SetMessageArgument(gAvailablePokemonNames, GetLeaderEntity(), 0);
    // {ARG_POKEMON_0} obtained the Steel Part that Registeel was guarding
    DisplayDungeonDialogue(&gUnknown_8105244);
    sub_80421C0(0,0xd4);
    sub_803E708(10,70);
    sub_8046D20();
  }
}

void RegirockPreFightDialogue(void)
{
  if (sub_8098100(0x22) == '\0') {
    sub_8085930(DIRECTION_NORTH);
    // INTRUDER ALERT
    // EXTERMINATE
    DisplayDungeonDialogue(&gUnknown_8104FD4);
    sub_803E708(10,70);
    sub_808563C(SetupRegirockFightHP);
  }
}

void RegicePreFightDialogue(void)
{
  if (sub_8098100(0x22) == '\0') {
    sub_8085930(DIRECTION_NORTH);
    // INTRUDER ALERT
    // EXTERMINATE
    DisplayDungeonDialogue(&gUnknown_8105028);
    sub_803E708(10,70);
    sub_808563C(SetupRegiceFightHP);
  }
}

void RegisteelPreFightDialogue(void)
{
  if (sub_8098100(0x22) == '\0') {
    sub_8085930(DIRECTION_NORTH);
    // INTRUDER ALERT
    // EXTERMINATE
    DisplayDungeonDialogue(&gUnknown_8105034);
    sub_803E708(10,70);
    sub_808563C(SetupRegisteelFightHP);
  }
}

NAKED
void sub_808B1CC(u8 r0)
{
    asm_unified(
	"\tpush {r4-r7,lr}\n"
	"\tsub sp, 0x8\n"
	"\tlsls r0, 24\n"
	"\tlsrs r6, r0, 24\n"
	"\tldr r7, _0808B21C\n"
	"\tldr r2, [r7]\n"
	"\tldr r1, _0808B220\n"
	"\tadds r0, r2, r1\n"
	"\tldrh r0, [r0]\n"
	"\tldr r5, _0808B224\n"
	"\tldr r1, [sp]\n"
	"\tands r1, r5\n"
	"\torrs r1, r0\n"
	"\tstr r1, [sp]\n"
	"\tldr r3, _0808B228\n"
	"\tadds r2, r3\n"
	"\tldrh r0, [r2]\n"
	"\tlsls r0, 16\n"
	"\tldr r4, _0808B22C\n"
	"\tadds r2, r4, 0\n"
	"\tands r2, r1\n"
	"\torrs r2, r0\n"
	"\tstr r2, [sp]\n"
	"\tmov r0, sp\n"
	"\tmovs r1, 0\n"
	"\tldrsh r0, [r0, r1]\n"
	"\tcmp r0, 0\n"
	"\tblt _0808B208\n"
	"\tcmp r2, 0\n"
	"\tbge _0808B244\n"
"_0808B208:\n"
	"\tbl GetLeaderEntity\n"
	"\tadds r2, r0, 0\n"
	"\tcmp r2, 0\n"
	"\tbne _0808B230\n"
	"\tldr r1, [r7]\n"
	"\tmovs r0, 0x1\n"
	"\tstrb r0, [r1, 0x2]\n"
	"\tb _0808B2A8\n"
	"\t.align 2, 0\n"
"_0808B21C: .4byte gDungeonGlobalData\n"
"_0808B220: .4byte 0x00000684\n"
"_0808B224: .4byte 0xffff0000\n"
"_0808B228: .4byte 0x00000686\n"
"_0808B22C: .4byte 0x0000ffff\n"
"_0808B230:\n"
	"\tldrh r0, [r2, 0x4]\n"
	"\tldr r1, [sp]\n"
	"\tands r1, r5\n"
	"\torrs r1, r0\n"
	"\tstr r1, [sp]\n"
	"\tldrh r0, [r2, 0x6]\n"
	"\tlsls r0, 16\n"
	"\tands r1, r4\n"
	"\torrs r1, r0\n"
	"\tstr r1, [sp]\n"
"_0808B244:\n"
	"\tmov r5, sp\n"
	"\tmov r0, sp\n"
	"\tmovs r1, 0\n"
	"\tbl sub_807FE04\n"
	"\tmov r0, sp\n"
	"\tmovs r2, 0\n"
	"\tldrsh r0, [r0, r2]\n"
	"\tmovs r3, 0x2\n"
	"\tldrsh r1, [r5, r3]\n"
	"\tbl GetMapTile_2\n"
	"\tldrh r2, [r0]\n"
	"\tmovs r3, 0x80\n"
	"\tlsls r3, 2\n"
	"\tadds r1, r3, 0\n"
	"\torrs r1, r2\n"
	"\tstrh r1, [r0]\n"
	"\tcmp r6, 0\n"
	"\tbeq _0808B2A0\n"
	"\tadds r0, r6, 0\n"
	"\tbl sub_80860A8\n"
	"\tlsls r0, 24\n"
	"\tcmp r0, 0\n"
	"\tbne _0808B2A0\n"
	"\tmovs r0, 0x7A\n"
	"\tbl sub_80860A8\n"
	"\tlsls r0, 24\n"
	"\tcmp r0, 0\n"
	"\tbne _0808B2A0\n"
	"\tadd r4, sp, 0x4\n"
	"\tadds r0, r4, 0\n"
	"\tadds r1, r6, 0\n"
	"\tmovs r2, 0\n"
	"\tbl xxx_init_itemslot_8090A8C\n"
	"\tldrh r0, [r5, 0x2]\n"
	"\tsubs r0, 0x1\n"
	"\tstrh r0, [r5, 0x2]\n"
	"\tmov r0, sp\n"
	"\tadds r1, r4, 0\n"
	"\tmovs r2, 0x1\n"
	"\tbl sub_80460F8\n"
"_0808B2A0:\n"
	"\tbl sub_8049ED4\n"
	"\tbl sub_8040A84\n"
"_0808B2A8:\n"
	"\tadd sp, 0x8\n"
	"\tpop {r4-r7}\n"
	"\tpop {r0}\n"
	"\tbx r0");
}


void SetupRegiFacingDirection(struct DungeonEntity *r0)
{
    r0->entityData->action.facingDir = DIRECTION_NORTH;
    sub_806CE68(r0, DIRECTION_NORTH);
}


void SetupRegirockFightHP(struct DungeonEntity *r0)
{
    SetupBossFightHP(r0, 0xE1 << 1, 0xB);
}


void SetupRegiceFightHP(struct DungeonEntity *r0)
{
    SetupBossFightHP(r0, 0xE1 << 1, 0xB);
}


void SetupRegisteelFightHP(struct DungeonEntity *r0)
{
    SetupBossFightHP(r0, 0xE1 << 1, 0xB);
}

void sub_808B2F4(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * JirachiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  JirachiEntity = sub_8085680(0x1a);
  sub_8083E88(0x79);
  sub_808BCE4();
  sub_8049ED4();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  SetFacingDirection(JirachiEntity, DIRECTION_SOUTH);
  sub_8086A3C(JirachiEntity);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_JIRACHI);
}

void sub_808B35C(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * JirachiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  JirachiEntity = sub_8085680(0x1a);
  sub_8083E88(0x79);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  if (HasRecruitedMon(SPECIES_JIRACHI)) {
    sub_8068FE0(JirachiEntity,0x21c,0);
  }
  else {
    SetFacingDirection(JirachiEntity, DIRECTION_SOUTH);
    sub_8086A3C(JirachiEntity);
    sub_808BCE4();
    sub_8049ED4();

  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_JIRACHI);
}

#ifdef NONMATCHING
void sub_808B3E4(u8 param_1,u8 param_2,u8 param_3)
{
  u8 uVar1;

  // TODO R1 and R2 shifts are switched ordering but matches
  if (((((param_2 * 0x1000000) + 0xcf000000U) >> 0x18) < 2) && (param_1 == 0x1A)){
    sub_8097FA8(0x1e);
    if (param_3 != 0) {
      gDungeonGlobalData->unk2 = 1;
    }
    else {
      uVar1 = gDungeonGlobalData->unk1356C;
      if (sub_80860A8(0x36) != 0) {
           JirachiWish();
      }
      else {
          sub_808B50C();
      }
      gDungeonGlobalData->unk1356C = uVar1;
      sub_8040A84();
    }
  }
}
#else
NAKED
void sub_808B3E4(u8 param_1, u8 param_2, u8 param_3)
{
    asm_unified(
	"\tpush {r4,lr}\n"
	"\tlsls r0, 24\n"
	"\tlsrs r0, 24\n"
	"\tlsls r1, 24\n"
	"\tlsls r2, 24\n"
	"\tlsrs r4, r2, 24\n"
	"\tmovs r2, 0xCF\n"
	"\tlsls r2, 24\n"
	"\tadds r1, r2\n"
	"\tlsrs r1, 24\n"
	"\tcmp r1, 0x1\n"
	"\tbhi _0808B44E\n"
	"\tcmp r0, 0x1A\n"
	"\tbne _0808B44E\n"
	"\tmovs r0, 0x1E\n"
	"\tbl sub_8097FA8\n"
	"\tcmp r4, 0\n"
	"\tbeq _0808B418\n"
	"\tldr r0, _0808B414\n"
	"\tldr r1, [r0]\n"
	"\tmovs r0, 0x1\n"
	"\tstrb r0, [r1, 0x2]\n"
	"\tb _0808B44E\n"
	"\t.align 2, 0\n"
"_0808B414: .4byte gDungeonGlobalData\n"
"_0808B418:\n"
	"\tldr r0, _0808B434\n"
	"\tldr r0, [r0]\n"
	"\tldr r1, _0808B438\n"
	"\tadds r0, r1\n"
	"\tldrb r4, [r0]\n"
	"\tmovs r0, 0x36\n"
	"\tbl sub_80860A8\n"
	"\tlsls r0, 24\n"
	"\tcmp r0, 0\n"
	"\tbeq _0808B43C\n"
	"\tbl JirachiWish\n"
	"\tb _0808B440\n"
	"\t.align 2, 0\n"
"_0808B434: .4byte gDungeonGlobalData\n"
"_0808B438: .4byte 0x0001356c\n"
"_0808B43C:\n"
	"\tbl sub_808B50C\n"
"_0808B440:\n"
	"\tldr r0, _0808B454\n"
	"\tldr r0, [r0]\n"
	"\tldr r2, _0808B458\n"
	"\tadds r0, r2\n"
	"\tstrb r4, [r0]\n"
	"\tbl sub_8040A84\n"
"_0808B44E:\n"
	"\tpop {r4}\n"
	"\tpop {r0}\n"
	"\tbx r0\n"
	"\t.align 2, 0\n"
"_0808B454: .4byte gDungeonGlobalData\n"
"_0808B458: .4byte 0x0001356c");
}
#endif

void JirachiPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * JirachiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  JirachiEntity = sub_8085680(0x1a);
  sub_8086448();
  sub_803E708(0x40,70);
  DisplayDungeonDialogue(&gUnknown_8105438);
  sub_803E708(10,70);
  SpriteLookAroundEffect(LeaderEntity);
  sub_803E708(10,70);
  DisplayDungeonDialogue(&gUnknown_81054A0);
  sub_80861F8(0x37,JirachiEntity,1);
  sub_80855E4(sub_80862BC);
  sub_803E708(0x3c,70);
  sub_808BBB8(JirachiEntity);
  sub_803E708(0x5a,70);
  DisplayDungeonDialogue(&gUnknown_81054E4);
  sub_803E708(10,70);
  DisplayDungeonDialogue(&gUnknown_810550C);
  sub_803E708(10,70);
  SetupBossFightHP(JirachiEntity,0x15e,0x20);
  sub_80858AC(&LeaderEntity->posPixel.x,0x10);
}

void sub_808B50C(void)
{
  struct DungeonEntity * JirachiEntity;

  JirachiEntity = sub_8085680(0x1a);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_JIRACHI);
  sub_80855E4(sub_808BBA8);
  sub_808BBA8(JirachiEntity);
  sub_8041888(0);
  JirachiEntity->entityData->unk15C = 1;
  JirachiEntity->entityData->unk15E = 0;
  sub_80861B8(JirachiEntity,0xe,0);
  sub_8083ED8(0x1e);
  sub_803E708(0x1e,70);
  // Fwaaaahhhh
  DisplayDungeonDialogue(&gUnknown_810554C);
  sub_8083E88(0x79);
  // I think I had a dream, and I was fighting in it
  // Did I imagine it?
  // I'm sleepy so I'm going back to sleep.
  DisplayDungeonDialogue(&gUnknown_8105558);
  sub_803E708(10,70);
  sub_808BC20(JirachiEntity);
  DisplayDungeonDialogue(&gUnknown_81055F4);
  sub_803E708(10,70);
  gDungeonGlobalData->unk2 = 1;
}