summaryrefslogtreecommitdiff
path: root/src/code_80521D0_1.c
blob: 2b23a14e32b7564965681f1b979f4baf45ddd147 (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
#include "global.h"
#include "constants/direction.h"
#include "constants/friend_area.h"
#include "dungeon_global_data.h"
#include "dungeon_entity.h"
#include "dungeon_random.h"
#include "dungeon_util.h"
#include "friend_area.h"
#include "map.h"
#include "pokemon.h"

extern struct DungeonEntity *xxx_call_GetLeaderEntity(void);
extern struct DungeonEntity *sub_8085680(u32);
extern char gUnknown_202E038[0x50];
extern u32 gUnknown_202EDC8;

extern u32 gUnknown_81062A8;
extern u32 gUnknown_8106074;
extern u32 gUnknown_81060BC;
extern u32 gUnknown_8106104;
extern u32 gUnknown_8106140;
extern u32 gUnknown_8106214;
extern u32 gUnknown_8106244;
extern u32 gUnknown_810627C;
extern u32 gUnknown_810697C;
extern u64 gUnknown_8107544[];
extern u32 gUnknown_8106778;
extern u32 gUnknown_81067BC;
extern u32 gUnknown_81067E0;
extern u32 gUnknown_8106834;
extern u32 gUnknown_810688C;
extern u32 gUnknown_81068D0;
extern u32 gUnknown_8106918;
extern u32 gUnknown_8106934;
extern u32 gUnknown_8106720;

extern u32 gUnknown_810663C;
extern u32 gUnknown_81063D0;
extern u32 gUnknown_8106400;
extern u32 gUnknown_810643C;
extern u32 gUnknown_8106468;
extern u32 gUnknown_810648C;
extern u32 gUnknown_81064BC;
extern u32 gUnknown_8106500;
extern u32 gUnknown_8106534;
extern u32 gUnknown_8106560;
extern u32 *gPtrPurityForestAllowCelebiToJoinText;
extern u32 gPurityForestAllowCelebiToJoinPrompt;
extern u32 *gPtrPurityForestRefuseCelebiConfirmText;
extern u32 gPurityForestRefuseCelebiConfirmPrompt;
extern u32 gUnknown_81062B4;
extern u32 gUnknown_81062E8;
extern u32 gUnknown_8106368;
extern u32 gUnknown_8106390;
extern u32 gUnknown_81063C4;
extern u32 gUnknown_8106068;
extern u32 gUnknown_8105E88;
extern u32 gUnknown_8105EF8;
extern u32 gUnknown_8105F38;
extern u32 gUnknown_8105F74;
extern u32 gUnknown_8105FA0;
extern u32 gUnknown_8105FD8;
extern u32 gUnknown_8106024;

extern u32 gUnknown_81058C4;
extern u32 gUnknown_81058A8;
extern u8 sub_800E9A8(u32);
extern void sub_800DC14(u32);
extern void sub_808BAA4();

extern void sub_8086A3C(struct DungeonEntity *r0);
extern void sub_8083E88(u32);
extern void sub_80854D4(void);
extern void sub_80855E4(void *);
extern void sub_8085930(u32);
extern void sub_8068FE0(struct DungeonEntity *, u32, u32);
extern void sub_8085860(s16 r0, u32 r1);
extern void sub_80866C4(u32 *);
extern void sub_8083EA8(u32, u32);
extern void sub_8086448();
extern void sub_80866C4(u32 *r0);

extern void sub_803E708(u32, u32);
extern void sub_8086448(void);
extern void sub_8086598(void);
extern void SpriteLookAroundEffect(struct DungeonEntity *);
extern void sub_80862BC(struct DungeonEntity *);
extern void PlaySoundEffect(u32);
extern void sub_806CDD4(struct DungeonEntity *, u32, u32);
extern void sub_80869E4(struct DungeonEntity *, u32, u32, u32);
extern void sub_806CE68(struct DungeonEntity *, u32);
extern void sub_804539C(struct DungeonEntity *, u32, u32);
extern void sub_803E46C(u32);
extern void sub_8042B0C(struct DungeonEntity *);
extern void SetFacingDirection(struct DungeonEntity *, u32);
extern void DisplayDungeonDialogue(u32 *);
extern void sub_803E708(u32, u32);
extern u8 HasRecruitedMon(u32);
extern u8 sub_806FD18(struct DungeonEntity *);
extern u8 sub_8083E74(u32);
extern s32 sub_8052C68(u32 *, u32 *, u32 *, u32);
extern void sub_8083F14();
extern void sub_80861D4(struct DungeonEntity *, u32, u32);
extern void sub_806FDF4(struct DungeonEntity *, struct DungeonEntity *, struct DungeonEntity **);
extern u32 sub_80861F8(u32, struct DungeonEntity *, u32);
extern void sub_8083ED8(u32);
extern u32 sub_803F994();
extern s32 sub_803F9B0();
extern void sub_803F878(u32, s32);
extern void SetupBossFightHP(struct DungeonEntity *, u32, u32);
extern void sub_8085C54(u32, u32, u32, u32, u32);
extern void sub_803E9D0(void);
extern void DeoxysScreenFlash(void);
extern void sub_8085EB0();
extern void sub_808563C(void *);
extern void sub_80858AC(u32 *, u32);

void SetupDeoxysFightHP(struct DungeonEntity *r0);
void sub_808C550(void);
void sub_808C590(struct DungeonEntity *r0);
void SetupDeoxysFacingDirection(struct DungeonEntity *r0);
void sub_808C9B0();
void sub_808C8E0(struct DungeonEntity *param_1);
void sub_808C360(void);
void KyogreScreenFlash();

void sub_808C0CC();
void sub_808BFA0();
void sub_808C02C();
extern void sub_80861B8(struct DungeonEntity *, u32, u32);

void nullsub_99();
extern bool8 *gFriendAreas;

extern void sub_8049884();
extern void sub_8049B8C();
extern void sub_8049ED4();
extern void sub_8040A84();
extern void sub_8086A54(struct DungeonEntity *);

extern struct MapTile *GetMapEntity(u32, u32);
extern void sub_806BFC0(struct DungeonEntityData *, u32);

void sub_808BBA8(struct DungeonEntity *param_1)
{
  sub_806BFC0(param_1->entityData,0);
}

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

  sub_80861F8(0x1b,param_1,0);
  sub_8086A54(param_1);
  sub_80861B8(param_1,0xe,0);
  iVar1 = 0xa000;
  iVar2 = 0x200;
  PlaySoundEffect(0x1f8);
  while( 1 ) {
    iVar1 = iVar1 - iVar2;
    if (iVar1 < 0x1800) {
      iVar2 = 0x100;
    }
    if (iVar1 < 0) break;
    param_1->entityData->unk174 = iVar1;
    sub_803E46C(0x46);
  }
 param_1->entityData->unk174 = 0;
}

void sub_808BC20(struct DungeonEntity * param_1)
{
  s32 uVar1;

  PlaySoundEffect(0x298);
  for(uVar1 = 0; uVar1 < 0x19; uVar1++){
    SetFacingDirection(param_1,uVar1 & DIRECTION_MASK);
    sub_803E708(3,0x46);
  }
  param_1->entityData->unk15E = 1;
  PlaySoundEffect(0x27f);
  sub_80861F8(99,param_1,1);
}

void JirachiWishGrantDialogue(struct DungeonEntity *param_1)
{
  u32 uVar2;

  param_1->entityData->unk15D = 1;
  // Nnnnnnnnnn!
  DisplayDungeonDialogue(&gUnknown_81058A8);
  PlaySoundEffect(0x375);
  sub_80861F8(0x67,param_1,1);
  PlaySoundEffect(0x2a8);
  uVar2 = sub_80861F8(0x68,param_1,0);
  // Taaaaaaaah!
  DisplayDungeonDialogue(&gUnknown_81058C4);
  if (sub_800E9A8(uVar2) != 0) {
    sub_800DC14(uVar2);
  }
  sub_803E708(10,0x46);
  sub_808BAA4();
}

void sub_808BCE4(void)
{
  struct MapTile *puVar1;

  puVar1 = GetMapEntity(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
  puVar1->tileType &= ~(TILE_TYPE_FLOOR | TILE_TYPE_LIQUID);
  puVar1->tileType |= TILE_TYPE_MAP_EDGE;
  puVar1->tileType &= ~TILE_TYPE_STAIRS;
  sub_8049884();
  sub_8049B8C();
  sub_8049ED4();
  sub_8040A84();
}

void sub_808BD38(void)
{
  struct MapTile *puVar1;

  puVar1 = GetMapEntity(gDungeonGlobalData->unkE23C, gDungeonGlobalData->unkE23E);
  puVar1->tileType &= ~(TILE_TYPE_FLOOR | TILE_TYPE_LIQUID);
  puVar1->tileType |= TILE_TYPE_FLOOR;
  puVar1->tileType &= ~TILE_TYPE_MAP_EDGE;
  puVar1->tileType |= TILE_TYPE_STAIRS;
  puVar1->unk8 = 1;
  sub_8049884();
  sub_8049B8C();
  sub_8049ED4();
  sub_8040A84();
}

u8 JirachiFriendAreaSearch(void)
{
  u8 unlockCondition;
  s32 friendAreaCounter;
  s32 numUnlockableAreas;
  u8 friendAreas[NUM_FRIEND_AREAS];
  u32 friendAreaIndex;

  // Build a copy of friend area list and keep track of
  // how many are only Story Unlockable
  numUnlockableAreas = 0;
  for(friendAreaCounter = 1; friendAreaCounter < NUM_FRIEND_AREAS; friendAreaCounter++){
    unlockCondition = GetFriendAreaUnlockCondition(friendAreaCounter);
    if (!(unlockCondition == UNLOCK_LEGENDARY_REQUEST)){
        if (!(unlockCondition == UNLOCK_WONDER_MAIL)){
            if(!gFriendAreas[friendAreaCounter]) {
                friendAreas[numUnlockableAreas] = friendAreaCounter;
                numUnlockableAreas++;
            }
        }
    }
  }

  if (numUnlockableAreas == 0) {
    return NUM_FRIEND_AREAS;
  }
  else {
      // Randomly pick 1
    friendAreaIndex = DungeonRandomCapped(numUnlockableAreas);
    return friendAreas[friendAreaIndex];
  }
}

void sub_808BDEC(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * LugiaEntity;

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

void sub_808BE70(u8 param_1,u8 param_2)
{
  if ((param_2 == 0x33) && (param_1 == 0x1B)) {
    gDungeonGlobalData->unk2 = 1;
  }
}


void LugiaPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * LugiaEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  LugiaEntity = sub_8085680(0x1b);
  if (HasRecruitedMon(SPECIES_LUGIA)) {
    sub_8086448();
    sub_80866C4(&gUnknown_8106068);
  }
  else {
    sub_8083F14();
    sub_8086448();
    DisplayDungeonDialogue(&gUnknown_8105E88);
    sub_8083EA8(0x23,0x3c);
    sub_808C0CC();
    DisplayDungeonDialogue(&gUnknown_8105EF8);
    sub_808BFA0();
    DisplayDungeonDialogue(&gUnknown_8105F38);
    sub_803E708(10,0x46);
    DisplayDungeonDialogue(&gUnknown_8105F74);
    PlaySoundEffect(0x1f8);
    sub_80861D4(LugiaEntity,0xd,0);
    sub_803E708(0x2b,0x46);
    sub_80861B8(LugiaEntity,0,0);
    DisplayDungeonDialogue(&gUnknown_8105FA0);
    sub_808BFA0();
    DisplayDungeonDialogue(&gUnknown_8105FD8);
    sub_808C02C();
    sub_8085C54(0xffffff06,0xffffff06,0xffffff06,1,0);
    sub_8083F14();
    sub_80861D4(LugiaEntity,7,0);
    DisplayDungeonDialogue(&gUnknown_8106024);
    sub_808BFA0();
    SetupBossFightHP(LugiaEntity,800,0x20);
    sub_8083E88(0x23);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void sub_808BFA0(void)
{
  s32 iVar1;

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

void sub_808C02C(void)
{
  s32 iVar1;

  PlaySoundEffect(0x1f6);

  for(iVar1 = 0; iVar1 < 200; iVar1 += 100){
    sub_8085C54(iVar1,iVar1,iVar1,1,0);
    sub_803E46C(0x46);
  }

  for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){
    sub_8085C54(iVar1,iVar1,iVar1,1,0);
    sub_803E46C(0x46);
  }

  sub_803E708(4,0x46);

  for(iVar1 = 0; iVar1 < 200; iVar1 += 100){
    sub_8085C54(iVar1,iVar1,iVar1,1,0);
    sub_803E46C(0x46);
  }

  for(iVar1 = 200; iVar1 >= 0; iVar1 -= 100){
    sub_8085C54(iVar1,iVar1,iVar1,1,0);
    sub_803E46C(0x46);
  }

  sub_803E708(10,0x46);
  sub_8085EB0();
}

void sub_808C0CC(void)
{
  gUnknown_202EDC8 = 0x1f;
  sub_8085C54(0,0,0,1,1);
  sub_803E9D0();
  sub_803E46C(0x46);
  gDungeonGlobalData->unk7 = 0;
  sub_808BFA0();
}

void sub_808C10C(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * KyogreEntity;

  u32 uVar3;
  s32 iVar2;

  LeaderEntity = xxx_call_GetLeaderEntity();
  KyogreEntity = sub_8085680(0x1c);
  sub_8083F14();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  if (HasRecruitedMon(SPECIES_KYOGRE)) {
    sub_8068FE0(KyogreEntity,0x21c,0);
  }
  else {
    gDungeonGlobalData->unk7 = 1;
    SetFacingDirection(KyogreEntity, DIRECTION_SOUTH);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  uVar3 = sub_803F994();
  iVar2 = sub_803F9B0();
  sub_803F878(uVar3,iVar2 + -0x1000);
  CopySpeciesNametoBuffer(gUnknown_202E038,SPECIES_KYOGRE);
  // TODO: gUnknown_202E088 doesn't match but gUnknown_202E038 + 0x50 does
  CopySpeciesNametoBuffer(gUnknown_202E038 + 0x50, SPECIES_GROUDON);
}

void sub_808C1A4(u8 param_1,u8 param_2)
{
  if ((param_2 == 0x34) && (param_1 == 0x1C)) {
    gDungeonGlobalData->unk2 = 1;
    sub_8083E88(0x23);
  }
}

void KyogrePreFightDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  struct DungeonEntity *KyogreEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  KyogreEntity = sub_8085680(0x1c);
  sub_8083F14();
  if (HasRecruitedMon(SPECIES_KYOGRE)) {
    sub_8083EA8(0x23,0x3c);
    SpriteLookAroundEffect(LeaderEntity);
    sub_803E708(10,0x46);
    DisplayDungeonDialogue(&gUnknown_81062A8);
    sub_803E708(10,0x46);
    gDungeonGlobalData->unk2 = 1;
  }
  else {
    DisplayDungeonDialogue(&gUnknown_8106074);
    sub_803E708(10,0x46);
    DisplayDungeonDialogue(&gUnknown_81060BC);
    sub_803E708(10,0x46);
    nullsub_99();
    sub_803E708(10,0x46);
    // Gwwwwwooooooooh
    DisplayDungeonDialogue(&gUnknown_8106104);
    sub_803E708(10,0x46);
    sub_8083EA8(0x23,0x3c);
    sub_808C360();
    // My duels against {ARG_POKEMON_3} (Groudon) left us both exhausted
    DisplayDungeonDialogue(&gUnknown_8106140);
    KyogreScreenFlash();
    // I am {ARG_POKEMON_2} (Kyogre)!
    // The lord of the sea!
    DisplayDungeonDialogue(&gUnknown_8106214);
    KyogreScreenFlash();
    // Witness the destructive force of my waves!
    DisplayDungeonDialogue(&gUnknown_8106244);
    KyogreScreenFlash();
    // Marvel at my awesome
    // power!
    DisplayDungeonDialogue(&gUnknown_810627C);
    sub_803E708(10,0x46);
    SetupBossFightHP(KyogreEntity,600,0xb);
    sub_8083E88(0x23);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void nullsub_99(void)
{
}

void KyogreScreenFlash(void)
{
  s32 iVar1;

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

void sub_808C360(void)
{
  gUnknown_202EDC8 = 0x1f;
  sub_8085C54(0,0,0,1,1);
  sub_803E9D0();
  sub_803E46C(0x46);
  gDungeonGlobalData->unk7 = 0;
  KyogreScreenFlash();
}

void sub_808C3A0(void)
{
  struct DungeonEntity * LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8083F14();
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  sub_80855E4(sub_8086A3C);
  if (HasRecruitedMon(SPECIES_DEOXYS_NORMAL)) {
    sub_808563C(sub_808C590);
  }
  else {
    gDungeonGlobalData->unk7 = 1;
    sub_808563C(SetupDeoxysFacingDirection);
  }
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y - 3);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_DEOXYS_NORMAL);
}

void sub_808C414(u8 param_1,u8 param_2)
{
  if ((param_2 == 0x35) && (param_1 == 0x1D)) {
    gDungeonGlobalData->unk2 = 1;
    sub_8083E88(0x1a);
  }
}

void DeoxysPreFightDialogue(void)
{
  struct DungeonEntity * LeaderEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  sub_8086448();
  if (HasRecruitedMon(SPECIES_DEOXYS_NORMAL)) {
    // There appears to be no one here.
    // It's impossible to go any further
    sub_80866C4(&gUnknown_81063C4);
  }
  else {
    DisplayDungeonDialogue(&gUnknown_81062B4);
    sub_8083EA8(0x1a,0x3c);
    sub_808C550();
    DisplayDungeonDialogue(&gUnknown_81062E8);
    DeoxysScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8106368);
    DeoxysScreenFlash();
    DisplayDungeonDialogue(&gUnknown_8106390);
    sub_803E708(10,0x46);
    sub_808563C(SetupDeoxysFightHP);
    sub_80858AC(&LeaderEntity->posPixel.x,0x10);
  }
}

void DeoxysScreenFlash(void)
{
  s32 iVar1;

  PlaySoundEffect(0x2c1);
  for(iVar1 = 250; iVar1 > 149; iVar1 -= 10){
    sub_8085C54(iVar1,0,0,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,0,0,1,1);
    sub_803E46C(0x46);
  }
  sub_803E708(10,0x46);
  sub_8085EB0();
}

void sub_808C550(void)
{
  gUnknown_202EDC8 = 0x1f;
  sub_8085C54(0,0,0,1,1);
  sub_803E9D0();
  sub_803E46C(0x46);
  gDungeonGlobalData->unk7 = 0;
  DeoxysScreenFlash();
}

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

void SetupDeoxysFacingDirection(struct DungeonEntity *r0)
{
    SetFacingDirection(r0, DIRECTION_SOUTH);
}

void SetupDeoxysFightHP(struct DungeonEntity *r0)
{
    SetupBossFightHP(r0, 950, 0x20);
}

void sub_808C5C0(void)
{
  struct DungeonEntity * LeaderEntity;
  struct DungeonEntity * CelebiEntity;

  u32 uVar3;
  s32 iVar2;

  LeaderEntity = xxx_call_GetLeaderEntity();
  CelebiEntity = sub_8085680(0x1e);
  sub_8083E88(0x7f);
  sub_80854D4();
  sub_8085930(DIRECTION_NORTH);
  SetFacingDirection(CelebiEntity, DIRECTION_SOUTH);
  sub_8085860(LeaderEntity->posWorld.x,LeaderEntity->posWorld.y);
  uVar3 = sub_803F994();
  iVar2 = sub_803F9B0();
  sub_803F878(uVar3,iVar2 + 0xfffff000);
  CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_CELEBI);
}

// Dummy Celebi Fight Dialogue??
void nullsub_100(u32 r0, u32 r1, u32 r2)
{
}

#ifdef NONMATCHING
void CelebiJoinDialogue(void)
{
  struct DungeonEntity *LeaderEntity;
  s32 state;
  s32 menuChoice;
  struct DungeonEntity *CelebiEntity;

  LeaderEntity = xxx_call_GetLeaderEntity();
  CelebiEntity = sub_8085680(0x1e);
  if ((HasRecruitedMon(SPECIES_CELEBI)) || (sub_806FD18(CelebiEntity) == '\0'))
  {
    sub_8068FE0(local_1c,0x21c,0);
    SpriteLookAroundEffect(LeaderEntity);
    sub_803E708(10,0x46);
    // .........
    DisplayDungeonDialogue(&gUnknown_810663C);
  }
  else
  {
    SpriteLookAroundEffect(LeaderEntity);
    sub_803E708(10,0x46);
    sub_80862BC(LeaderEntity);
    sub_803E708(10,0x46);
    // Oh? There's someone there.
    DisplayDungeonDialogue(&gUnknown_81063D0);
    sub_803E708(10,0x46);
    sub_8086598();
    sub_8086598();
    sub_8086598();
    sub_8086598();
    // The Time-Traveling Pokemon {ARG_POKEMON_2} (Celebi)!
    DisplayDungeonDialogue(&gUnknown_8106400);
    PlaySoundEffect(0x1c7);
    sub_806CDD4(CelebiEntity,10,DIRECTION_SOUTH);
    sub_803E708(0x14,0x46);
    sub_806CE68(CelebiEntity, DIRECTION_SOUTH);
    sub_803E708(4,0x46);
    PlaySoundEffect(0x1c7);
    sub_806CDD4(CelebiEntity,10,DIRECTION_SOUTH);
    DisplayDungeonDialogue(&gUnknown_810643C);
    sub_803E708(10,0x46);
    state = 0;
    do {
      switch(state)
      {
       case 0:
            do {
                // NOTE: 0 and Load of ptr switch order in compiler but else matches
                menuChoice = sub_8052C68(0,gPtrPurityForestAllowCelebiToJoinText,
                                &gPurityForestAllowCelebiToJoinPrompt,0x701);
            } while (menuChoice < 1);
            sub_803E708(10,0x46);
            if (menuChoice == 1)
            {
                sub_8083F14();
                PlaySoundEffect(0xcc);
                while (sub_8083E74(0xcc) != 0) {
                    sub_803E46C(0x46);
                }
                sub_8083E88(0x7f);
                PlaySoundEffect(0x1c7);
                sub_80861D4(CelebiEntity,0xd,0);
                sub_803E708(0x37,0x46);
                PlaySoundEffect(0x1d5);
                sub_803E708(0x1a,0x46);
                PlaySoundEffect(0x1d5);
                sub_803E708(0x1c,0x46);
                DisplayDungeonDialogue(&gUnknown_8106468);
                sub_803E708(10,0x46);
                sub_806FDF4(LeaderEntity,CelebiEntity,&CelebiEntity);
                sub_8083E88(0x7f);
                DisplayDungeonDialogue(&gUnknown_810648C);
                sub_803E708(10,0x46);
                PlaySoundEffect(0x1c7);
                sub_80861D4(CelebiEntity,0xd,0);
                sub_803E708(0x37,0x46);
                PlaySoundEffect(0x1d5);
                sub_803E708(0x1a,0x46);
                PlaySoundEffect(0x1d5);
                sub_803E708(0x1b,0x46);
                DisplayDungeonDialogue(&gUnknown_81064BC);
                sub_803E708(10,0x46);
                state = 2;
            }
            else
            {
                state = 1;
            }
            break;
        case 1:
            do {
                // NOTE: 0 and Load of ptr switch order in compiler but else matches
                menuChoice = sub_8052C68(0,gPtrPurityForestRefuseCelebiConfirmText,
                                    &gPurityForestRefuseCelebiConfirmPrompt,0x701);
            } while (menuChoice < 1);
            if (menuChoice == 1)
                state = 0;
            else
            {
                sub_803E708(10,0x46);
                DisplayDungeonDialogue(&gUnknown_8106500);
                sub_80861F8(0x3e,CelebiEntity,1);
                sub_803E708(0x18,0x46);
                sub_80861F8(0x3e,CelebiEntity,1);
                sub_803E708(0xe,0x46);
                DisplayDungeonDialogue(&gUnknown_8106534);
                sub_803E708(10,0x46);
                sub_808C8E0(CelebiEntity);
                DisplayDungeonDialogue(&gUnknown_8106560);
                sub_803E708(10,0x46);
                state = 2;
            }
            break;
      }
    } while (state != 2);
  }
  sub_8083ED8(0x1e);
  sub_803E708(0x1e,0x46);
  gDungeonGlobalData->unk2 = 1;
}
#else
NAKED
void CelebiJoinDialogue(void)
{
        asm_unified(
        "\tpush {r4-r7,lr}\n"
	"\tmov r7, r8\n"
	"\tpush {r7}\n"
	"\tsub sp, 0x4\n"
	"\tbl xxx_call_GetLeaderEntity\n"
	"\tadds r7, r0, 0\n"
	"\tmovs r0, 0x1E\n"
	"\tbl sub_8085680\n"
	"\tstr r0, [sp]\n"
	"\tmovs r0, 0x8A\n"
	"\tlsls r0, 1\n"
	"\tbl HasRecruitedMon\n"
	"\tlsls r0, 24\n"
	"\tcmp r0, 0\n"
	"\tbne _0808C658\n"
	"\tldr r0, [sp]\n"
	"\tbl sub_806FD18\n"
	"\tlsls r0, 24\n"
	"\tcmp r0, 0\n"
	"\tbne _0808C680\n"
"_0808C658:\n"
	"\tmovs r1, 0x87\n"
	"\tlsls r1, 2\n"
	"\tldr r0, [sp]\n"
	"\tmovs r2, 0\n"
	"\tbl sub_8068FE0\n"
	"\tadds r0, r7, 0\n"
	"\tbl SpriteLookAroundEffect\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, _0808C67C\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tb _0808C8AC\n"
	"\t.align 2, 0\n"
"_0808C67C: .4byte gUnknown_810663C\n"
"_0808C680:\n"
	"\tadds r0, r7, 0\n"
	"\tbl SpriteLookAroundEffect\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tadds r0, r7, 0\n"
	"\tbl sub_80862BC\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, _0808C71C\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tbl sub_8086598\n"
	"\tbl sub_8086598\n"
	"\tbl sub_8086598\n"
	"\tbl sub_8086598\n"
	"\tldr r0, _0808C720\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tldr r4, _0808C724\n"
	"\tadds r0, r4, 0\n"
	"\tbl PlaySoundEffect\n"
	"\tldr r0, [sp]\n"
	"\tmovs r1, 0xA\n"
	"\tmovs r2, 0\n"
	"\tbl sub_806CDD4\n"
	"\tmovs r0, 0x14\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, [sp]\n"
	"\tmovs r1, 0\n"
	"\tbl sub_806CE68\n"
	"\tmovs r0, 0x4\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tadds r0, r4, 0\n"
	"\tbl PlaySoundEffect\n"
	"\tldr r0, [sp]\n"
	"\tmovs r1, 0xA\n"
	"\tmovs r2, 0\n"
	"\tbl sub_806CDD4\n"
	"\tldr r0, _0808C728\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tmovs r0, 0\n"
	"\tmov r8, r4\n"
	"\tldr r6, _0808C72C\n"
"_0808C70E:\n"
	"\tcmp r0, 0\n"
	"\tbeq _0808C730\n"
	"\tcmp r0, 0x1\n"
	"\tbne _0808C718\n"
	"\tb _0808C828\n"
"_0808C718:\n"
	"\tb _0808C8A6\n"
	"\t.align 2, 0\n"
"_0808C71C: .4byte gUnknown_81063D0\n"
"_0808C720: .4byte gUnknown_8106400\n"
"_0808C724: .4byte 0x000001c7\n"
"_0808C728: .4byte gUnknown_810643C\n"
"_0808C72C: .4byte 0x000001d5\n"
"_0808C730:\n"
	"\tldr r5, _0808C75C\n"
"_0808C732:\n"
	"\tmovs r0, 0\n"
	"\tldr r1, [r5]\n"
	"\tldr r2, _0808C760\n"
	"\tldr r3, _0808C764\n"
	"\tbl sub_8052C68\n"
	"\tadds r4, r0, 0\n"
	"\tcmp r4, 0\n"
	"\tble _0808C732\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tcmp r4, 0x1\n"
	"\tbne _0808C824\n"
	"\tbl sub_8083F14\n"
	"\tmovs r0, 0xCC\n"
	"\tbl PlaySoundEffect\n"
	"\tb _0808C76E\n"
	"\t.align 2, 0\n"
"_0808C75C: .4byte gPtrPurityForestAllowCelebiToJoinText\n"
"_0808C760: .4byte gPurityForestAllowCelebiToJoinPrompt\n"
"_0808C764: .4byte 0x00000701\n"
"_0808C768:\n"
	"\tmovs r0, 0x46\n"
	"\tbl sub_803E46C\n"
"_0808C76E:\n"
	"\tmovs r0, 0xCC\n"
	"\tbl sub_8083E74\n"
	"\tlsls r0, 24\n"
	"\tcmp r0, 0\n"
	"\tbne _0808C768\n"
	"\tmovs r0, 0x7F\n"
	"\tbl sub_8083E88\n"
	"\tmov r0, r8\n"
	"\tbl PlaySoundEffect\n"
	"\tldr r0, [sp]\n"
	"\tmovs r1, 0xD\n"
	"\tmovs r2, 0\n"
	"\tbl sub_80861D4\n"
	"\tmovs r0, 0x37\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tadds r0, r6, 0\n"
	"\tbl PlaySoundEffect\n"
	"\tmovs r0, 0x1A\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tadds r0, r6, 0\n"
	"\tbl PlaySoundEffect\n"
	"\tmovs r0, 0x1C\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, _0808C818\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r1, [sp]\n"
	"\tadds r0, r7, 0\n"
	"\tmov r2, sp\n"
	"\tbl sub_806FDF4\n"
	"\tmovs r0, 0x7F\n"
	"\tbl sub_8083E88\n"
	"\tldr r0, _0808C81C\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tmov r0, r8\n"
	"\tbl PlaySoundEffect\n"
	"\tldr r0, [sp]\n"
	"\tmovs r1, 0xD\n"
	"\tmovs r2, 0\n"
	"\tbl sub_80861D4\n"
	"\tmovs r0, 0x37\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tadds r0, r6, 0\n"
	"\tbl PlaySoundEffect\n"
	"\tmovs r0, 0x1A\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tadds r0, r6, 0\n"
	"\tbl PlaySoundEffect\n"
	"\tmovs r0, 0x1B\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, _0808C820\n"
	"\tb _0808C898\n"
	"\t.align 2, 0\n"
"_0808C818: .4byte gUnknown_8106468\n"
"_0808C81C: .4byte gUnknown_810648C\n"
"_0808C820: .4byte gUnknown_81064BC\n"
"_0808C824:\n"
	"movs r0, 0x1\n"
	"b _0808C8A6\n"
"_0808C828:\n"
	"\tldr r5, _0808C844\n"
"_0808C82A:\n"
	"\tmovs r0, 0\n"
	"\tldr r1, [r5]\n"
	"\tldr r2, _0808C848\n"
	"\tldr r3, _0808C84C\n"
	"\tbl sub_8052C68\n"
	"\tadds r4, r0, 0\n"
	"\tcmp r4, 0\n"
	"\tble _0808C82A\n"
	"\tcmp r4, 0x1\n"
	"\tbne _0808C850\n"
	"\tmovs r0, 0\n"
	"\tb _0808C8A6\n"
	"\t.align 2, 0\n"
"_0808C844: .4byte gPtrPurityForestRefuseCelebiConfirmText\n"
"_0808C848: .4byte gPurityForestRefuseCelebiConfirmPrompt\n"
"_0808C84C: .4byte 0x00000701\n"
"_0808C850:\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, _0808C8D0\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tldr r1, [sp]\n"
	"\tmovs r0, 0x3E\n"
	"\tmovs r2, 0x1\n"
	"\tbl sub_80861F8\n"
	"\tmovs r0, 0x18\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r1, [sp]\n"
	"\tmovs r0, 0x3E\n"
	"\tmovs r2, 0x1\n"
	"\tbl sub_80861F8\n"
	"\tmovs r0, 0xE\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, _0808C8D4\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, [sp]\n"
	"\tbl sub_808C8E0\n"
	"\tldr r0, _0808C8D8\n"
"_0808C898:\n"
	"\tbl DisplayDungeonDialogue\n"
	"\tmovs r0, 0xA\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tmovs r0, 0x2\n"
"_0808C8A6:\n"
	"\tcmp r0, 0x2\n"
	"\tbeq _0808C8AC\n"
	"\tb _0808C70E\n"
"_0808C8AC:\n"
	"\tmovs r0, 0x1E\n"
	"\tbl sub_8083ED8\n"
	"\tmovs r0, 0x1E\n"
	"\tmovs r1, 0x46\n"
	"\tbl sub_803E708\n"
	"\tldr r0, _0808C8DC\n"
	"\tldr r1, [r0]\n"
	"\tmovs r0, 0x1\n"
	"\tstrb r0, [r1, 0x2]\n"
	"\tadd sp, 0x4\n"
	"\tpop {r3}\n"
	"\tmov r8, r3\n"
	"\tpop {r4-r7}\n"
	"\tpop {r0}\n"
	"\tbx r0\n"
	"\t.align 2, 0\n"
"_0808C8D0: .4byte gUnknown_8106500\n"
"_0808C8D4: .4byte gUnknown_8106534\n"
"_0808C8D8: .4byte gUnknown_8106560\n"
"_0808C8DC: .4byte gDungeonGlobalData");
}
#endif

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

  PlaySoundEffect(0x1a5);
  sub_806CDD4(param_1, 0, DIRECTION_SOUTH);
  for(iVar1 = 0; iVar1 < 16; iVar1++){
    param_1->entityData->unk174 = iVar1 * 256;
    sub_803E46C(0x46);
  }
  for(iVar1 = 16; iVar1 < 200; iVar1 += 4){
    param_1->entityData->unk174 = iVar1 * 256;
    sub_803E46C(0x46);
  }
  sub_8086A3C(param_1);
}

void sub_808C938(void)
{
    sub_80855E4(sub_808C9B0);
}

void sub_808C948(struct DungeonEntity *param_1, u8 param_2)
{
  bool8 flag;
  s32 iVar3;
  struct DungeonEntity *iVar2;

  if (param_2 == 0x37) {
    flag = FALSE;
    for(iVar3 = 0; iVar3 < DUNGEON_MAX_WILD_POKEMON; iVar3++){
      iVar2 = gDungeonGlobalData->wildPokemon[iVar3];
      if ((iVar2 != param_1) && (EntityExists(iVar2) != 0)) {
        flag = TRUE;
        break;
      }
    }
    if (!flag) {
      gDungeonGlobalData->unk2 = 1;
    }
  }
}

void sub_808C998(void)
{
    // Defeat the opposing team to win
    // Be careful, your opponents are tough
    DisplayDungeonDialogue(&gUnknown_8106720);
    sub_803E708(0xA, 0x46);
}

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

void sub_808C9C4(void)
{
    struct DungeonEntity *LeaderEntity;
    struct DungeonEntity *MedichamEntity;

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

// Medicham Rescue Dialogue?
void MedichamRescueDialogue(void)
{
    struct DungeonEntity *MedichamEntity;
    s32 counter;

    MedichamEntity = sub_8085680(7);
    SpriteLookAroundEffect(MedichamEntity);
    sub_803E708(0xA, 0x46);
    // Oh my I can't seem to find a way out...
    DisplayDungeonDialogue(&gUnknown_8106778);
    sub_803E708(0xA, 0x46);
    sub_80869E4(MedichamEntity, 4, 2, 4);
    sub_803E708(0xA, 0x46);
    // What am I to do...?
    DisplayDungeonDialogue(&gUnknown_81067BC);
    sub_803E708(0xA, 0x46);
    sub_8086448();
    sub_8086598();
    sub_803E708(0x20, 0x46);
    sub_80862BC(MedichamEntity);
    sub_803E708(0x20, 0x46);
    sub_80869E4(MedichamEntity, 4, 2, 0);
    DisplayDungeonDialogue(&gUnknown_81067E0);
    sub_803E708(0xA, 0x46);
    PlaySoundEffect(0x1c7);
    sub_806CDD4(MedichamEntity, 0xA, DIRECTION_SOUTH);
    sub_803E708(0x14, 0x46);
    sub_806CE68(MedichamEntity, DIRECTION_SOUTH);
    sub_803E708(0x4, 0x46);
    PlaySoundEffect(0x1c7);
    sub_806CDD4(MedichamEntity, 0xA, DIRECTION_SOUTH);
    sub_803E708(0x14, 0x46);
    // Yes Yes
    // I am so lucky
    //
    // There appears to be no one here
    DisplayDungeonDialogue(&gUnknown_8106834);
    sub_803E708(0xA, 0x46);
    sub_806CDD4(MedichamEntity, 0, DIRECTION_SOUTH);
    for(counter = 0x17; counter >= 0; counter--)
    {
        sub_804539C(MedichamEntity, 0, 0x80 << 1);
        sub_803E46C(0x46);
    }
    sub_806CE68(MedichamEntity, DIRECTION_SOUTH);
    sub_803E708(0x20, 0x46);
    sub_8042B0C(MedichamEntity);
    sub_8068FE0(MedichamEntity, 0x21C, 0);
    gDungeonGlobalData->unk4 = 1;
    gDungeonGlobalData->unk11 = 4;
}

void sub_808CB5C(void)
{
    struct DungeonEntity *LeaderEntity;
    struct DungeonEntity *MedichamEntity;

    LeaderEntity = xxx_call_GetLeaderEntity();
    MedichamEntity = sub_8085680(7);
    sub_8083E88(0x72);
    sub_80854D4();
    sub_8085930(DIRECTION_NORTH);
    sub_8068FE0(MedichamEntity, 0x21C, 0);
    sub_8085860(LeaderEntity->posWorld.x, LeaderEntity->posWorld.y);
    CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_MEDICHAM);
}

void DummyFightDialogue(void)
{
}

void sub_808CBB0(void)
{
    struct DungeonEntity *LeaderEntity;
    struct DungeonEntity *SmeargleEntity;

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

// Smeargle Rescue dialogue scene
void SmeargleRescueDialogue(void)
{
    struct DungeonEntity *SmeargleEntity;
    s32 counter;

    SmeargleEntity = sub_8085680(0x1F);
    SpriteLookAroundEffect(SmeargleEntity);
    sub_803E708(0xA, 0x46);
    // Ohhh...
    // I've lost my bearings
    DisplayDungeonDialogue(&gUnknown_810688C);
    sub_803E708(0xA, 0x46);
    sub_80869E4(SmeargleEntity, 4, 2, 4);
    sub_803E708(0xA, 0x46);
    // I can't get out...
    // I'm hungry...
    // I'm in trouble
    DisplayDungeonDialogue(&gUnknown_81068D0);
    sub_803E708(0xA, 0x46);
    sub_8086448();
    sub_8086598();
    sub_803E708(0x20, 0x46);
    sub_80862BC(SmeargleEntity);
    sub_803E708(0x20, 0x46);
    sub_80869E4(SmeargleEntity, 4, 2, 0);
    // Oh! You are?
    DisplayDungeonDialogue(&gUnknown_8106918);
    sub_803E708(0xA, 0x46);
    PlaySoundEffect(0x1c7);
    sub_806CDD4(SmeargleEntity, 0xA, DIRECTION_SOUTH);
    sub_803E708(0x14, 0x46);
    sub_806CE68(SmeargleEntity, DIRECTION_SOUTH);
    sub_803E708(0x4, 0x46);
    PlaySoundEffect(0x1c7);
    sub_806CDD4(SmeargleEntity, 0xA, DIRECTION_SOUTH);
    sub_803E708(0x14, 0x46);
    // Did you maybe come to rescue me?
    // Am I glad to see you
    DisplayDungeonDialogue(&gUnknown_8106934);
    sub_803E708(0xA, 0x46);
    sub_806CDD4(SmeargleEntity, 0, DIRECTION_SOUTH);
    for(counter = 0x17; counter >= 0; counter--)
    {
        sub_804539C(SmeargleEntity, 0, 0x80 << 1);
        sub_803E46C(0x46);
    }
    sub_806CE68(SmeargleEntity, DIRECTION_SOUTH);
    sub_803E708(0x20, 0x46);
    sub_8042B0C(SmeargleEntity);
    sub_8068FE0(SmeargleEntity, 0x21C, 0);
    gDungeonGlobalData->unk4 = 1;
    gDungeonGlobalData->unk11 = 4;

}

void sub_808CD44(void)
{
    struct DungeonEntity *LeaderEntity;
    struct DungeonEntity *SmeargleEntity;

    LeaderEntity = xxx_call_GetLeaderEntity();
    SmeargleEntity = sub_8085680(0x1F);
    sub_8083E88(0x72);
    sub_80854D4();
    sub_8085930(DIRECTION_NORTH);
    sub_80855E4(sub_8086A3C);
    sub_8068FE0(SmeargleEntity, 0x21C, 0);
    sub_8085860(LeaderEntity->posWorld.x, LeaderEntity->posWorld.y - 3);
    CopySpeciesNametoBuffer(gUnknown_202E038, SPECIES_SMEARGLE);
}

void sub_808CD9C(u8 r0)
{
    sub_8086448();
    // There appears to be no one here.
    // It's impossible to go any further
    sub_80866C4(&gUnknown_810697C);
}

u64 *sub_808CDB0(u8 r0)
{
    return &gUnknown_8107544[r0];
}