forked from snesrev/zelda3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
overworld.cpp
4082 lines (3795 loc) · 132 KB
/
overworld.cpp
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
#include "overworld.h"
#include "hud.h"
#include "load_gfx.h"
#include "dungeon.h"
#include "tagalong.h"
#include "sprite.h"
#include "ancilla.h"
#include "player.h"
#include "misc.h"
#include "messaging.h"
#include "player_oam.h"
#include "tables/generated_map32_to_map16.h"
#include "tables/generated_map16_to_map8.h"
#include "tables/generated_overworld_tables.h"
#include "tables/generated_overworld.h"
#include "tables/generated_enemy_damage_data.h"
const uint16 kOverworld_OffsetBaseX[64] = {
0, 0, 0x400, 0x600, 0x600, 0xa00, 0xa00, 0xe00,
0, 0, 0x400, 0x600, 0x600, 0xa00, 0xa00, 0xe00,
0, 0x200, 0x400, 0x600, 0x800, 0xa00, 0xc00, 0xe00,
0, 0, 0x400, 0x600, 0x600, 0xa00, 0xc00, 0xc00,
0, 0, 0x400, 0x600, 0x600, 0xa00, 0xc00, 0xc00,
0, 0x200, 0x400, 0x600, 0x800, 0xa00, 0xc00, 0xe00,
0, 0, 0x400, 0x600, 0x800, 0xa00, 0xa00, 0xe00,
0, 0, 0x400, 0x600, 0x800, 0xa00, 0xa00, 0xe00,
};
const uint16 kOverworld_OffsetBaseY[64] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0x200, 0, 0, 0, 0, 0x200,
0x400, 0x400, 0x400, 0x400, 0x400, 0x400, 0x400, 0x400,
0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600, 0x600,
0x600, 0x600, 0x800, 0x600, 0x600, 0x800, 0x600, 0x600,
0xa00, 0xa00, 0xa00, 0xa00, 0xa00, 0xa00, 0xa00, 0xa00,
0xc00, 0xc00, 0xc00, 0xc00, 0xc00, 0xc00, 0xc00, 0xc00,
0xc00, 0xc00, 0xe00, 0xe00, 0xe00, 0xc00, 0xc00, 0xe00,
};
static const uint16 kOverworld_UpDownScrollTarget[64] = {
0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20,
0xff20, 0xff20, 0x120, 0xff20, 0xff20, 0xff20, 0xff20, 0x120,
0x320, 0x320, 0x320, 0x320, 0x320, 0x320, 0x320, 0x320,
0x520, 0x520, 0x520, 0x520, 0x520, 0x520, 0x520, 0x520,
0x520, 0x520, 0x720, 0x520, 0x520, 0x720, 0x520, 0x520,
0x920, 0x920, 0x920, 0x920, 0x920, 0x920, 0x920, 0x920,
0xb20, 0xb20, 0xb20, 0xb20, 0xb20, 0xb20, 0xb20, 0xb20,
0xb20, 0xb20, 0xd20, 0xd20, 0xd20, 0xb20, 0xb20, 0xd20,
};
static const uint16 kOverworld_LeftRightScrollTarget[64] = {
0xff00, 0xff00, 0x300, 0x500, 0x500, 0x900, 0x900, 0xd00,
0xff00, 0xff00, 0x300, 0x500, 0x500, 0x900, 0x900, 0xd00,
0xff00, 0x100, 0x300, 0x500, 0x700, 0x900, 0xb00, 0xd00,
0xff00, 0xff00, 0x300, 0x500, 0x500, 0x900, 0xb00, 0xb00,
0xff00, 0xff00, 0x300, 0x500, 0x500, 0x900, 0xb00, 0xb00,
0xff00, 0x100, 0x300, 0x500, 0x700, 0x900, 0xb00, 0xd00,
0xff00, 0xff00, 0x300, 0x500, 0x700, 0x900, 0x900, 0xd00,
0xff00, 0xff00, 0x300, 0x500, 0x700, 0x900, 0x900, 0xd00,
};
#if 0
static const uint16 kSpExit_Top[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0x200, 0x200, 0, 0, 0, 0, 0, 0 };
static const uint16 kSpExit_Bottom[16] = { 0x120, 0x20, 0x320, 0x20, 0, 0, 0x320, 0x320, 0x320, 0x220, 0, 0, 0, 0, 0x320, 0x320 };
static const uint16 kSpExit_Left[16] = { 0, 0x100, 0x200, 0x600, 0x600, 0xa00, 0xc00, 0xc00, 0, 0x100, 0x200, 0x600, 0x600, 0xa00, 0xc00, 0xc00 };
static const uint16 kSpExit_Right[16] = { 0, 0x100, 0x500, 0x600, 0x600, 0xa00, 0xc00, 0xc00, 0, 0x100, 0x400, 0x600, 0x600, 0xa00, 0xc00, 0xc00 };
static const uint16 kSpExit_Tab4[16] = { 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0xff20, 0x120, 0xff20, 0xff20, 0xff20, 0xff20, 0x120 };
static const int16 kSpExit_Tab6[16] = { -4, 0x100, 0x300, 0x100, 0x500, 0x900, 0xb00, 0xb00, -4, 0x100, 0x300, 0x500, 0x500, 0x900, 0xb00, 0xb00 };
static const int16 kSpExit_Tab5[16] = { -0xe0, -0xe0, -0xe0, -0xe0, -0xe0, -0xe0, 0x400, 0x400, -0xe0, -0xe0, 0x120, -0xe0, -0xe0, -0xe0, 0x400, 0x400 };
static const uint16 kSpExit_Tab7[16] = { 4, 0x104, 0x300, 0x100, 0x500, 0x900, 0xb00, 0xb00, 4, 0x104, 0x300, 0x100, 0x500, 0x900, 0xb00, 0xb00 };
static const uint16 kSpExit_LeftEdgeOfMap[16] = { 0, 0, 0x200, 0x600, 0x600, 0xa00, 0xc00, 0xc00, 0, 0, 0x200, 0x600, 0x600, 0xa00, 0xc00, 0xc00 };
static const uint8 kSpExit_Dir[16] = { 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static const uint8 kSpExit_SprGfx[16] = { 0xc, 0xc, 0xe, 0xe, 0xe, 0x10, 0x10, 0x10, 0xe, 0xe, 0xe, 0xe, 0x10, 0x10, 0x10, 0x10 };
static const uint8 kSpExit_AuxGfx[16] = { 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f, 0x2f };
static const uint8 kSpExit_PalBg[16] = { 0xa, 0xa, 0xa, 0xa, 2, 2, 2, 0xa, 2, 2, 0xa, 2, 2, 2, 2, 0xa };
static const uint8 kSpExit_PalSpr[16] = { 1, 8, 8, 8, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 2 };
#endif
#define turtlerock_ctr (g_ram[0xc8])
#define ganonentrance_ctr (g_ram[0xc8])
static PlayerHandlerFunc *const kOverworld_EntranceSequence[5] = {
&Overworld_AnimateEntrance_PoD,
&Overworld_AnimateEntrance_Skull,
&Overworld_AnimateEntrance_Mire,
&Overworld_AnimateEntrance_TurtleRock,
&Overworld_AnimateEntrance_GanonsTower,
};
#ifndef map16_decode_0
#define map16_decode_0 ((uint8*)(g_ram+0x14400))
#define map16_decode_1 ((uint8*)(g_ram+0x14410))
#define map16_decode_2 ((uint8*)(g_ram+0x14420))
#define map16_decode_3 ((uint8*)(g_ram+0x14430))
#define map16_decode_last (*(uint16*)(g_ram+0x14440))
#define map16_decode_tmp (*(uint16*)(g_ram+0x14442))
#endif
static const uint16 kSecondaryOverlayPerOw[128] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0x1c0c, 0x1c0c, 0, 0, 0, 0, 0, 0, 0x1c0c, 0x1c0c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0x3b0, 0x180c, 0x180c, 0x288, 0, 0, 0, 0, 0, 0x180c, 0x180c, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1ab6, 0x1ab6, 0, 0xe2e, 0xe2e, 0, 0, 0,
0x1ab6, 0x1ab6, 0, 0xe2e, 0xe2e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x3b0, 0, 0, 0x288,
0, 0, 0, 0, 0, 0, 0, 0,
};
#define XY(x, y) ((y)*64+(x))
// this alternate entry point is for scrolling OW area loads
// b/c drawing a door only applies to when you transition from a dungeon to the OW
// the exceptioon is OW areas 0x80 and above which are handled similar to entrances
static const uint16 kOverworld_DrawStrip_Tab[3] = { 0x3d0, 0x410, 0xf410 };
static const uint16 kOverworld_Func2_Tab[4] = { 8, 4, 2, 1 };
static const uint16 kOverworld_Entrance_Tab0[44] = {
0xfe, 0xc5, 0xfe, 0x114, 0x115, 0x175, 0x156, 0xf5, 0xe2, 0x1ef, 0x119, 0xfe, 0x172, 0x177, 0x13f, 0x172, 0x112, 0x161, 0x172, 0x14c, 0x156, 0x1ef, 0xfe, 0xfe, 0xfe, 0x10b, 0x173, 0x143, 0x149, 0x175, 0x103, 0x100,
0x1cc, 0x15e, 0x167, 0x128, 0x131, 0x112, 0x16d, 0x163, 0x173, 0xfe, 0x113, 0x177,
};
static const uint16 kOverworld_Entrance_Tab1[44] = {
0x14a, 0xc4, 0x14f, 0x115, 0x114, 0x174, 0x155, 0xf5, 0xee, 0x1eb, 0x118, 0x146, 0x171, 0x155, 0x137, 0x174, 0x173, 0x121, 0x164, 0x155, 0x157, 0x128, 0x114, 0x123, 0x113, 0x109, 0x118, 0x161, 0x149, 0x117, 0x174, 0x101,
0x1cc, 0x131, 0x51, 0x14e, 0x131, 0x112, 0x17a, 0x163, 0x172, 0x1bd, 0x152, 0x167,
};
static const uint16 kDwPaletteAnim[35] = {
0x884, 0xcc7, 0x150a, 0x154d, 0x7ff6, 0x5944, 0x7ad1,
0x884, 0xcc7, 0x150a, 0x154d, 0x5bff, 0x7ad1, 0x21af,
0x1084, 0x48c0, 0x6186, 0x7e6d, 0x7fe0, 0x5944, 0x7e20,
0x1084, 0x000e, 0x1059, 0x291f, 0x7fe0, 0x5944, 0x7e20,
0x1084, 0x1508, 0x196c, 0x21af, 0x7ff6, 0x1d4c, 0x7ad1,
};
static const uint16 kDwPaletteAnim2[40] = {
0x7fff, 0x884, 0x1cc8, 0x1dce, 0x3694, 0x4718, 0x1d4a, 0x18ac,
0x7fff, 0x1908, 0x2d2f, 0x3614, 0x4eda, 0x471f, 0x1d4a, 0x390f,
0x7fff, 0x34cd, 0x5971, 0x5635, 0x7f1b, 0x7fff, 0x1d4a, 0x3d54,
0x7fff, 0x1908, 0x2d2f, 0x3614, 0x4eda, 0x471f, 0x1d4a, 0x390f,
0x7fff, 0x884, 0x52a, 0x21ef, 0x3ab5, 0x4b39, 0x1d4c, 0x18ac,
};
static const uint16 kSpecialSwitchArea_Map8[4] = { 0x105, 0x1e4, 0xad, 0xb9 };
static const uint16 kSpecialSwitchArea_Screen[4] = { 0, 45, 15, 129 };
static const uint8 kSpecialSwitchArea_Direction[4] = { 8, 2, 8, 8 };
static const uint16 kSpecialSwitchArea_Exit[4] = { 0x180, 0x181, 0x182, 0x189 };
const uint8 kVariousPacks[16] = {
0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x5b, 0x01, 0x5a,
0x42, 0x43, 0x44, 0x45, 0x3f, 0x59, 0x0b, 0x5a
};
static const uint16 kSpecialSwitchAreaB_Map8[3] = { 0x17c, 0x1e4, 0xad };
static const uint16 kSpecialSwitchAreaB_Screen[3] = { 0x80, 0x80, 0x81 };
static const uint16 kSpecialSwitchAreaB_Direction[3] = { 4, 1, 4 };
static const int16 kSwitchAreaTab0[4] = { 0xf80, 0xf80, 0x3f, 0x3f };
static const int16 kSwitchAreaTab1[256] = {
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x1060, 0x1060, 0x1060, 0x1060, 0x60,
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
0x60, 0x60, 0x60, 0x1060, 0x1060, 0x60, 0x1060, 0x1060, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60,
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x1060, 0x1060, 0x60,
0x80, 0x80, 0x40, 0x80, 0x80, 0x80, 0x80, 0x40, 0x1080, 0x1080, 0x40, 0x1080, 0x1080, 0x1080, 0x1080, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x40, 0x80, 0x80, 0x40, 0x80, 0x80,
0x1080, 0x1080, 0x40, 0x1080, 0x1080, 0x40, 0x1080, 0x1080, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0x80, 0x80, 0x40, 0x40, 0x40, 0x80, 0x80, 0x40, 0x1080, 0x1080, 0x40, 0x40, 0x40, 0x1080, 0x1080, 0x40,
0x1800, 0x1840, 0x1800, 0x1800, 0x1840, 0x1800, 0x1840, 0x1800, 0x1800, 0x1840, 0x1800, 0x1800, 0x1840, 0x1800, 0x1840, 0x1800,
0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1840, 0x1800, 0x1800, 0x1840, 0x1800, 0x1800, 0x1840,
0x1800, 0x1840, 0x1800, 0x1800, 0x1840, 0x1800, 0x1800, 0x1840, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800, 0x1800,
0x1800, 0x1840, 0x1800, 0x1800, 0x1800, 0x1800, 0x1840, 0x1800, 0x1800, 0x1840, 0x1800, 0x1800, 0x1800, 0x1800, 0x1840, 0x1800,
0x2000, 0x2040, 0x1000, 0x2000, 0x2040, 0x2000, 0x2040, 0x1000, 0x2000, 0x2040, 0x1000, 0x2000, 0x2040, 0x2000, 0x2040, 0x1000,
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x2000, 0x2040, 0x1000, 0x2000, 0x2040, 0x1000, 0x2000, 0x2040,
0x2000, 0x2040, 0x1000, 0x2000, 0x2040, 0x1000, 0x2000, 0x2040, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000,
0x2000, 0x2040, 0x1000, 0x1000, 0x1000, 0x2000, 0x2040, 0x1000, 0x2000, 0x2040, 0x1000, 0x1000, 0x1000, 0x2000, 0x2040, 0x1000,
};
static const int16 kSwitchAreaTab3[4] = { 2, -2, 16, -16 };
// kOverworldAreaHeads[i] != i for subregions of a big area
static const uint8 kOverworldAreaHeads[64] = {
0, 0, 2, 3, 3, 5, 5, 7,
0, 0, 10, 3, 3, 5, 5, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 24, 26, 27, 27, 29, 30, 30,
24, 24, 34, 27, 27, 37, 30, 30,
40, 41, 42, 43, 44, 45, 46, 47,
48, 48, 50, 51, 52, 53, 53, 55,
48, 48, 58, 59, 60, 53, 53, 63,
};
static const uint16 kOverworld_Size1[2] = { 0x11e, 0x31e };
static const uint16 kOverworld_Size2[2] = { 0x100, 0x300 };
static const uint16 kOverworld_UpDownScrollSize[2] = { 0x2e0, 0x4e0 };
static const uint16 kOverworld_LeftRightScrollSize[2] = { 0x300, 0x500 };
static const int16 kOverworld_Func6B_Tab1[4] = { -8, 8, -8, 8 };
static const int16 kOverworld_Func6B_Tab2[4] = { 27, 27, 30, 30 };
static const int16 kOverworld_Func6B_Tab3[4] = { -0x70, 0x70, -0x70, 0x70 };
static const int16 kOverworld_Func6B_AreaDelta[4] = { -8, 8, -1, 1 };
static const uint8 kOverworld_Func8_tab[4] = { 0xe0, 8, 0xe0, 0x10 };
static const uint16 kDoorAnimTiles[56] = {
0xda8, 0xda9, 0xdaa, 0xdab,
0xdac, 0xdad, 0xdae, 0xdaf,
0xdb0, 0xdb1, 0xdb2, 0xdb3,
0xdb6, 0xdb7, 0xdb8, 0xdb9,
0xdba, 0xdbb, 0xdbc, 0xdbd,
0xdcd, 0xdce, 0xdcf, 0xdd0,
0xdd3, 0xdd4, 0xdd5, 0xdd6,
0xdd7, 0xdd8, 0xdd9, 0xdda,
0xdd1, 0xdd2, 0xdd3, 0xdd4,
0xdd1, 0xdd2, 0xdd7, 0xdd8,
0x918, 0x919, 0x91a, 0x91b,
0xddb, 0xddc, 0xddd, 0xdde,
0xdd1, 0xdd2, 0xddb, 0xddc,
0xe21, 0xe22, 0xe23, 0xe24,
};
static PlayerHandlerFunc *const kOverworldSubmodules[48] = {
&Module09_00_PlayerControl,
&Module09_LoadAuxGFX,
&Overworld_FinishTransGfx,
&Module09_LoadNewMapAndGFX,
&Module09_LoadNewSprites,
&Overworld_StartScrollTransition,
&Overworld_RunScrollTransition,
&Overworld_EaseOffScrollTransition,
&Overworld_FinalizeEntryOntoScreen,
&Module09_09_OpenBigDoorFromExiting,
&Module09_0A_WalkFromExiting_FacingDown,
&Module09_0B_WalkFromExiting_FacingUp,
&Module09_0C_OpenBigDoor,
&Overworld_StartMosaicTransition,
&PreOverworld_LoadOverlays,
&Module09_LoadAuxGFX,
&Overworld_FinishTransGfx,
&Module09_LoadNewMapAndGFX,
&Module09_LoadNewSprites,
&Overworld_StartScrollTransition,
&Overworld_RunScrollTransition,
&Overworld_EaseOffScrollTransition,
&Module09_FadeBackInFromMosaic,
&Overworld_StartMosaicTransition,
&Overworld_Func18,
&Overworld_Func19,
&Module09_LoadAuxGFX,
&Overworld_FinishTransGfx,
&Overworld_Func1C,
&Overworld_Func1D,
&Overworld_Func1E,
&Overworld_Func1F,
&Overworld_LoadOverlays2,
&Overworld_LoadAmbientOverlay,
&Overworld_Func22,
&Module09_MirrorWarp,
&Overworld_StartMosaicTransition,
&Overworld_LoadOverlays,
&Module09_LoadAuxGFX,
&Overworld_FinishTransGfx,
&Overworld_LoadAndBuildScreen,
&Module09_FadeBackInFromMosaic,
&Module09_2A_RecoverFromDrowning,
&Overworld_Func2B,
&Module09_MirrorWarp,
&Overworld_WeathervaneExplosion,
&Module09_2E_Whirlpool,
&Overworld_Func2F,
};
static PlayerHandlerFunc *const kModule_PreOverworld[3] = {
&PreOverworld_LoadProperties,
&PreOverworld_LoadOverlays,
&Module08_02_LoadAndAdvance,
};
const uint8 *GetMap8toTileAttr() {
return kMap8DataToTileAttr;
}
const uint16 *GetMap16toMap8Table() {
return kMap16ToMap8;
}
bool LookupInOwEntranceTab(uint16 r0, uint16 r2) {
for (int i = countof(kOverworld_Entrance_Tab0) - 1; i >= 0; i--) {
if (r0 == kOverworld_Entrance_Tab0[i] && r2 == kOverworld_Entrance_Tab1[i])
return true;
}
return false;
}
int LookupInOwEntranceTab2(uint16 pos) {
for (int i = 128; i >= 0; i--) {
if (pos == kOverworld_Entrance_Pos[i] && overworld_area_index == kOverworld_Entrance_Area[i])
return i;
}
return -1;
}
bool CanEnterWithTagalong(int e) {
uint8 t = savegame_tagalong;
return t == 0 || t == 5 || t == 14 || t == 1 || (t == 7 || t == 8) && e >= 59;
}
int DirToEnum(int dir) {
int xx = 3;
while (!(dir & 1))
xx--, dir >>= 1;
return xx;
}
void Overworld_ResetMosaicDown() {
if (palette_filter_countdown & 1)
mosaic_level -= 0x10;
BGMODE_copy = 9;
MOSAIC_copy = mosaic_level | 7;
}
void Overworld_Func1D() {
assert(0);
}
void Overworld_Func1E() {
assert(0);
}
uint16 Overworld_GetSignText(int area) {
return kOverworld_SignText[area];
}
const uint8 *GetOverworldSpritePtr(int area) {
int base = (sram_progress_indicator == 3) ? 2 :
(sram_progress_indicator == 2) ? 1 : 0;
return kOverworldSprites + kOverworldSpriteOffs[area + base * 144];
}
uint8 GetOverworldBgPalette(int idx) {
return kOverworldBgPalettes[idx];
}
void Sprite_LoadGraphicsProperties() { // 80fc41
memcpy(overworld_sprite_gfx + 64, kOverworldSpriteGfx + 0xc0, 64);
memcpy(overworld_sprite_palettes + 64, kOverworldSpritePalettes + 0xc0, 64);
Sprite_LoadGraphicsProperties_light_world_only();
}
void Sprite_LoadGraphicsProperties_light_world_only() { // 80fc62
int i = sram_progress_indicator < 2 ? 0 :
sram_progress_indicator != 3 ? 1 : 2;
memcpy(overworld_sprite_gfx, kOverworldSpriteGfx + i * 64, 64);
memcpy(overworld_sprite_palettes, kOverworldSpritePalettes + i * 64, 64);
}
void InitializeMirrorHDMA() { // 80fdee
HDMAEN_copy = 0;
mirror_vars.var0 = 0;
mirror_vars.var6 = 0;
mirror_vars.var5 = 0;
mirror_vars.var7 = 0;
mirror_vars.var8 = 0;
mirror_vars.var10 = mirror_vars.var11 = 8;
mirror_vars.var9 = 21;
mirror_vars.var1[0] = -0x200;
mirror_vars.var1[1] = 0x200;
mirror_vars.var3[0] = -0x40;
mirror_vars.var3[1] = 0x40;
HdmaSetup(0xF2FB, 0xF2FB, 0x42, (uint8)BG1HOFS, (uint8)BG2HOFS, 0);
uint16 v = BG2HOFS_copy2;
for (int i = 0; i < 32 * 7; i++)
mode7_hdma_table[i] = v;
HDMAEN_copy = 0xc0;
}
void MirrorWarp_BuildWavingHDMATable() { // 80fe64
MirrorWarp_RunAnimationSubmodules();
if (frame_counter & 1)
return;
int x = 0x1a0 / 2, y = 0x1b0 / 2;
do {
mode7_hdma_table[y] = mode7_hdma_table[y + 2] = mode7_hdma_table[y + 4] = mode7_hdma_table[y + 6] = mode7_hdma_table[x];
x -= 8, y -= 8;
} while (y != 0);
int i = mirror_vars.var0 >> 1;
int t = mirror_vars.var6 + mirror_vars.var3[i];
if (!sign16(t - mirror_vars.var1[i] ^ mirror_vars.var1[i])) {
t = mirror_vars.var1[i];
mirror_vars.var5 = 0;
mirror_vars.var7 = 0;
mirror_vars.var0 ^= 2;
}
mirror_vars.var6 = t;
t += mirror_vars.var7;
mirror_vars.var7 = t & 0xff;
if (sign16(t))
t |= 0xff;
else
t &= ~0xff;
t = mirror_vars.var5 + swap16(t);
mirror_vars.var5 = t;
if (palette_filter_countdown >= 0x30 && !(t & ~7)) {
mirror_vars.var1[0] = -0x100;
mirror_vars.var1[1] = 0x100;
subsubmodule_index++;
t = 0;
}
mode7_hdma_table[0] = mode7_hdma_table[2] = mode7_hdma_table[4] = mode7_hdma_table[6] = t + BG2HOFS_copy2;
}
void MirrorWarp_BuildDewavingHDMATable() { // 80ff2f
MirrorWarp_RunAnimationSubmodules();
if (frame_counter & 1)
return;
int x = 0x1a0 / 2, y = 0x1b0 / 2;
do {
mode7_hdma_table[y] = mode7_hdma_table[y + 2] = mode7_hdma_table[y + 4] = mode7_hdma_table[y + 6] = mode7_hdma_table[x];
x -= 8, y -= 8;
} while (y != 0);
uint16 t = mode7_hdma_table[0xc0] | mode7_hdma_table[0xc8] | mode7_hdma_table[0xd0] | mode7_hdma_table[0xd8];
if (t == BG2HOFS_copy2) {
HDMAEN_copy = 0;
subsubmodule_index++;
Overworld_SetFixedColAndScroll();
if ((overworld_screen_index & 0x3f) != 0x1b) {
BG1HOFS_copy2 = BG1HOFS_copy = BG2HOFS_copy = BG2HOFS_copy2;
BG1VOFS_copy2 = BG1VOFS_copy = BG2VOFS_copy = BG2VOFS_copy2;
}
}
}
void TakeDamageFromPit() { // 81ffd9
link_visibility_status = 12;
submodule_index = player_is_indoors ? 20 : 42;
link_health_current -= 8;
if (link_health_current >= 0xa8)
link_health_current = 0;
}
void Module08_OverworldLoad() { // 8283bf
kModule_PreOverworld[submodule_index]();
}
void PreOverworld_LoadProperties() { // 8283c7
CGWSEL_copy = 0x82;
dung_unk6 = 0;
AdjustLinkBunnyStatus();
if (main_module_index == 8)
LoadOverworldFromDungeon();
else
LoadOverworldFromSpecialOverworld();
Overworld_SetSongList();
link_num_keys = 0xff;
Hud_RefillLogic();
uint8 sc = overworld_screen_index, dr = dungeon_room_index;
uint8 ow_anim_tiles = 0x58;
uint8 xt = 2;
if (sc == 3 || sc == 5 || sc == 7) {
xt = 2;
} else if (sc == 0x43 || sc == 0x45 || sc == 0x47) {
xt = 9;
} else if (ow_anim_tiles = 0x5a, sc >= 0x40) {
goto dark;
} else if (dr == 0xe3 || dr == 0x18 || dr == 0x2f || dr == 0x1f && sc == 0x18) {
xt = sram_progress_indicator < 3 ? 7 : 2;
} else {
xt = savegame_has_master_sword_flags & 0x40 ? 2 : 5;
if (dr != 0 && dr != 0xe1) {
dark:
xt = 0xf3;
if (buffer_for_playing_songs == 0xf2)
goto setsong;
xt = sram_progress_indicator < 2 ? 3 : 2;
}
}
if (savegame_is_darkworld) {
xt = sc == 0x40 || sc == 0x43 || sc == 0x45 || sc == 0x47 ? 13 : 9;
if (!link_item_moon_pearl)
xt = 4;
}
setsong:
buffer_for_playing_songs = xt;
DecompressAnimatedOverworldTiles(ow_anim_tiles);
InitializeTilesets();
OverworldLoadScreensPaletteSet();
Overworld_LoadPalettes(kOverworldBgPalettes[sc], overworld_sprite_palettes[sc]);
Palette_SetOwBgColor();
if (main_module_index == 8) {
Overworld_LoadPalettesInner();
} else {
SpecialOverworld_CopyPalettesToCache();
}
Overworld_SetFixedColAndScroll();
overworld_fixed_color_plusminus = 0;
Follower_Initialize();
if (!(BYTE(overworld_screen_index) & 0x3f))
DecodeAnimatedSpriteTile_variable(0x1e);
saved_module_for_menu = 9;
Sprite_ReloadAll_Overworld();
if (!(overworld_screen_index & 0x40))
Sprite_InitializeMirrorPortal();
sound_effect_ambient = sram_progress_indicator < 2 ? 1 : 5;
if (savegame_tagalong == 6)
savegame_tagalong = 0;
is_standing_in_doorway = 0;
button_mask_b_y = 0;
button_b_frames = 0;
link_cant_change_direction = 0;
link_speed_setting = 0;
draw_water_ripples_or_grass = 0;
Dungeon_ResetTorchBackgroundAndPlayerInner();
if (!link_item_moon_pearl && savegame_is_darkworld) {
link_is_bunny = link_is_bunny_mirror = 1;
link_player_handler_state = kPlayerState_PermaBunny;
LoadGearPalettes_bunny();
}
BGMODE_copy = 9;
dung_want_lights_out = 0;
dung_hdr_collision = 0;
link_is_on_lower_level = 0;
link_is_on_lower_level_mirror = 0;
submodule_index++;
flag_update_hud_in_nmi++;
dung_savegame_state_bits = 0;
LoadOWMusicIfNeeded();
}
void AdjustLinkBunnyStatus() { // 82856a
if (link_item_moon_pearl)
ForceNonbunnyStatus();
}
void ForceNonbunnyStatus() { // 828570
link_player_handler_state = kPlayerState_Ground;
link_timer_tempbunny = 0;
link_need_for_poof_for_transform = 0;
link_is_bunny = 0;
link_is_bunny_mirror = 0;
}
void RecoverPositionAfterDrowning() { // 829583
link_x_coord = link_x_coord_cached;
link_y_coord = link_y_coord_cached;
ow_scroll_vars0.ystart = room_scroll_vars_y_vofs1_cached;
ow_scroll_vars0.xstart = room_scroll_vars_y_vofs2_cached;
ow_scroll_vars1.ystart = room_scroll_vars_x_vofs1_cached;
ow_scroll_vars1.xstart = room_scroll_vars_x_vofs2_cached;
up_down_scroll_target = up_down_scroll_target_cached;
up_down_scroll_target_end = up_down_scroll_target_end_cached;
left_right_scroll_target = left_right_scroll_target_cached;
left_right_scroll_target_end = left_right_scroll_target_end_cached;
if (player_is_indoors) {
camera_y_coord_scroll_low = camera_y_coord_scroll_low_cached;
camera_y_coord_scroll_hi = camera_y_coord_scroll_low + 2;
camera_x_coord_scroll_low = camera_x_coord_scroll_low_cached;
camera_x_coord_scroll_hi = camera_x_coord_scroll_low + 2;
}
WORD(quadrant_fullsize_x) = WORD(quadrant_fullsize_x_cached);
WORD(link_quadrant_x) = WORD(link_quadrant_x_cached);
if (!player_is_indoors) {
camera_y_coord_scroll_hi = camera_y_coord_scroll_low - 2;
camera_x_coord_scroll_hi = camera_x_coord_scroll_low - 2;
}
link_direction_facing = link_direction_facing_cached;
link_is_on_lower_level = link_is_on_lower_level_cached;
link_is_on_lower_level_mirror = link_is_on_lower_level_mirror_cached;
is_standing_in_doorway = is_standing_in_doorway_cahed;
dung_cur_floor = dung_cur_floor_cached;
link_visibility_status = 0;
countdown_for_blink = 0x90;
Dungeon_PlayBlipAndCacheQuadrantVisits();
link_disable_sprite_damage = 0;
Link_ResetStateAfterDamagingPit();
tagalong_var5 = 0;
Follower_Initialize();
dung_flag_statechange_waterpuzzle = 0;
overworld_map_state = 0;
subsubmodule_index = 0;
overworld_screen_transition = 0;
submodule_index = 0;
if (!link_health_current) {
mapbak_TM = TM_copy;
mapbak_TS = TS_copy;
saved_module_for_menu = main_module_index;
main_module_index = 18;
submodule_index = 1;
countdown_for_blink = 0;
}
}
void Module0F_SpotlightClose() { // 829982
static const uint8 kTab[4] = { 8, 4, 2, 1 };
Sprite_Main();
if (submodule_index == 0)
Dungeon_PrepExitWithSpotlight();
else
Spotlight_ConfigureTableAndControl();
if (!player_is_indoors) {
if (BYTE(overworld_screen_index) == 0xf)
draw_water_ripples_or_grass = 1;
link_speed_setting = 6;
Link_HandleVelocity();
link_x_vel = link_y_vel = 0;
}
int i = link_direction_facing >> 1;
if (!player_is_indoors)
i = (which_entrance == 0x43) ? 1 : 0;
link_direction = link_direction_last = kTab[i];
Link_HandleMovingAnimation_FullLongEntry();
LinkOam_Main();
}
void Dungeon_PrepExitWithSpotlight() { // 8299ca
is_nmi_thread_active = 0;
nmi_flag_update_polyhedral = 0;
if (!player_is_indoors) {
Ancilla_TerminateWaterfallSplashes();
link_y_coord_exit = link_y_coord;
}
uint8 m = GetEntranceMusicTrack(which_entrance);
if (m != 3 || (m = sram_progress_indicator) >= 2) {
if (m != 0xf2)
m = 0xf1;
else if (music_unk1 == 0xc)
m = 7;
music_control = m;
}
hud_floor_changed_timer = 0;
Hud_FloorIndicator();
flag_update_hud_in_nmi++;
IrisSpotlight_close();
submodule_index++;
}
void Spotlight_ConfigureTableAndControl() { // 829a19
IrisSpotlight_ConfigureTable();
is_nmi_thread_active = 0;
nmi_flag_update_polyhedral = 0;
if (submodule_index)
return;
if (main_module_index == 6)
link_y_coord = link_y_coord_exit;
OpenSpotlight_Next2();
}
void OpenSpotlight_Next2() { // 829a37
if (main_module_index != 9) {
EnableForceBlank();
Link_ItemReset_FromOverworldThings();
}
if (main_module_index == 9) {
if (dungeon_room_index != 0x20)
submodule_index = link_direction_facing ? 0xa : 0xb;
ow_countdown_transition = 16;
if ((BYTE(ow_entrance_value) | BYTE(big_rock_starting_address)) && HIBYTE(big_rock_starting_address)) { // wtf
BYTE(door_open_closed_counter) = (big_rock_starting_address & 0x8000) ? 0x18 : 0;
big_rock_starting_address &= 0x7fff;
BYTE(door_animation_step_indicator) = 0;
submodule_index = 9;
subsubmodule_index = 0;
sound_effect_2 = 21;
}
}
W12SEL_copy = 0;
W34SEL_copy = 0;
WOBJSEL_copy = 0;
TMW_copy = 0;
TSW_copy = 0;
link_force_hold_sword_up = 0;
uint8 sc = overworld_screen_index;
if (sc == 3 || sc == 5 || sc == 7) {
COLDATA_copy0 = 0x26;
COLDATA_copy1 = 0x4c;
COLDATA_copy2 = 0x8c;
} else if (sc == 0x43 || sc == 0x45 || sc == 0x47) {
COLDATA_copy0 = 0x26;
COLDATA_copy1 = 0x4a;
COLDATA_copy2 = 0x87;
}
}
void Module10_SpotlightOpen() { // 829ad7
Sprite_Main();
if (submodule_index == 0)
Module10_00_OpenIris();
else
Spotlight_ConfigureTableAndControl();
LinkOam_Main();
}
void Module10_00_OpenIris() { // 829ae6
Spotlight_open();
submodule_index++;
}
void SetTargetOverworldWarpToPyramid() { // 829e5f
if (main_module_index != 21)
return;
LoadOverworldFromDungeon();
DecompressAnimatedOverworldTiles(0x5a);
ResetAncillaAndCutscene();
}
void ResetAncillaAndCutscene() { // 829e6e
Ancilla_TerminateSelectInteractives(0);
link_disable_sprite_damage = 0;
button_b_frames = 0;
button_mask_b_y = 0;
link_force_hold_sword_up = 0;
flag_is_link_immobilized = 0;
}
void Module09_Overworld() { // 82a475
kOverworldSubmodules[submodule_index]();
int bg2x = BG2HOFS_copy2;
int bg2y = BG2VOFS_copy2;
int bg1x = BG1HOFS_copy2;
int bg1y = BG1VOFS_copy2;
BG2HOFS_copy2 = BG2HOFS_copy = bg2x + bg1_x_offset;
BG2VOFS_copy2 = BG2VOFS_copy = bg2y + bg1_y_offset;
BG1HOFS_copy2 = BG1HOFS_copy = bg1x + bg1_x_offset;
BG1VOFS_copy2 = BG1VOFS_copy = bg1y + bg1_y_offset;
Sprite_Main();
BG2HOFS_copy2 = bg2x;
BG2VOFS_copy2 = bg2y;
BG1HOFS_copy2 = bg1x;
BG1VOFS_copy2 = bg1y;
LinkOam_Main();
Hud_RefillLogic();
OverworldOverlay_HandleRain();
}
void OverworldOverlay_HandleRain() { // 82a4cd
static const uint8 kOverworld_DrawBadWeather_X[4] = { 1, 0, 1, 0 };
static const uint8 kOverworld_DrawBadWeather_Y[4] = { 0, 17, 0, 17 };
if (BYTE(overworld_screen_index) != 0x70 && sram_progress_indicator >= 2 || (save_ow_event_info[0x70] & 0x20))
return;
if (frame_counter == 3 || frame_counter == 88) {
CGADSUB_copy = 0x32;
} else if (frame_counter == 5 || frame_counter == 44 || frame_counter == 90) {
CGADSUB_copy = 0x72;
} else if (frame_counter == 36) {
sound_effect_1 = 54;
CGADSUB_copy = 0x32;
}
if (frame_counter & 3)
return;
int i = (move_overlay_ctr + 1) & 3;
move_overlay_ctr = i;
BG1HOFS_copy2 += kOverworld_DrawBadWeather_X[i] << 8;
BG1VOFS_copy2 += kOverworld_DrawBadWeather_Y[i] << 8;
}
void Module09_00_PlayerControl() { // 82a53c
if (!(flag_custom_spell_anim_active | flag_is_link_immobilized | flag_block_link_menu | trigger_special_entrance)) {
if (filtered_joypad_H & 0x10) {
overworld_map_state = 0;
submodule_index = 1;
saved_module_for_menu = main_module_index;
main_module_index = 14;
return;
}
if (filtered_joypad_L & 0x40) {
overworld_map_state = 0;
submodule_index = 7;
saved_module_for_menu = main_module_index;
main_module_index = 14;
return;
}
if (joypad1H_last & 0x20) {
choice_in_multiselect_box_bak = choice_in_multiselect_box;
dialogue_message_index = 0x186;
int bak = main_module_index;
Main_ShowTextMessage();
main_module_index = bak;
subsubmodule_index = 0;
submodule_index = 11;
saved_module_for_menu = main_module_index;
main_module_index = 14;
return;
}
}
if (trigger_special_entrance)
Overworld_AnimateEntrance();
Link_Main();
if (super_bomb_indicator_unk2 != 0xff)
Hud_SuperBombIndicator();
current_area_of_player = (link_y_coord & 0x1e00) >> 5 | (link_x_coord & 0x1e00) >> 8;
Graphics_LoadChrHalfSlot();
Overworld_OperateCameraScroll();
if (main_module_index != 11) {
Overworld_UseEntrance();
Overworld_DwDeathMountainPaletteAnimation();
OverworldHandleTransitions();
} else {
ScrollAndCheckForSOWExit();
}
}
void OverworldHandleTransitions() { // 82a9c4
if (BYTE(overworld_screen_trans_dir_bits2))
OverworldHandleMapScroll();
int dir;
uint16 x, y, t;
if (link_y_vel != 0) {
dir = link_direction & 12;
t = link_y_coord - kOverworld_OffsetBaseY[BYTE(current_area_of_player) >> 1];
if ((y = 6, x = 8, t < 4) || (y = 4, x = 4, t >= overworld_right_bottom_bound_for_scroll))
goto compare;
}
if (link_x_vel != 0) {
dir = link_direction & 3;
t = link_x_coord - kOverworld_OffsetBaseX[BYTE(current_area_of_player) >> 1];
if ((y = 2, x = 2, t < 6) || (y = 0, x = 1, t >= (uint16)(overworld_right_bottom_bound_for_scroll + 4))) {
compare:
if (x == dir && !Link_CheckForEdgeScreenTransition())
goto after;
}
}
Overworld_CheckSpecialSwitchArea();
return;
after:
y >>= 1;
Dungeon_ResetTorchBackgroundAndPlayerInner();
map16_load_src_off &= kSwitchAreaTab0[y];
uint16 pushed = current_area_of_player + kSwitchAreaTab3[y];
map16_load_src_off += kSwitchAreaTab1[(y * 128 | pushed) >> 1];
uint8 old_screen = overworld_screen_index;
if (old_screen == 0x2a)
sound_effect_ambient = 0x80;
uint8 new_area = kOverworldAreaHeads[pushed >> 1] | savegame_is_darkworld;
BYTE(overworld_screen_index) = new_area;
BYTE(overworld_area_index) = new_area;
if (!savegame_is_darkworld || link_item_moon_pearl) {
uint8 music = overworld_music[new_area];
if ((music & 0xf0) == 0)
sound_effect_ambient = 5;
if ((music & 0xf) != music_unk1)
music_control = 0xf1;
}
Overworld_LoadGFXAndScreenSize();
submodule_index = 1;
BYTE(overworld_screen_trans_dir_bits) = dir;
BYTE(overworld_screen_trans_dir_bits2) = dir;
byte_7E069C = overworld_screen_transition = DirToEnum(dir);
BYTE(ow_entrance_value) = 0;
BYTE(big_rock_starting_address) = 0;
transition_counter = 0;
if (!(old_screen & 0x3f) || !(overworld_screen_index & 0xbf)) {
subsubmodule_index = 0;
submodule_index = 13;
MOSAIC_copy = 0;
mosaic_level = 0;
} else {
uint8 sc = overworld_screen_index;
Overworld_LoadPalettes(kOverworldBgPalettes[sc], overworld_sprite_palettes[sc]);
Overworld_CopyPalettesToCache();
}
}
void Overworld_LoadGFXAndScreenSize() { // 82ab08
int i = BYTE(overworld_screen_index);
incremental_counter_for_vram = 0;
sprite_graphics_index = overworld_sprite_gfx[i];
aux_tile_theme_index = kOverworldAuxTileThemeIndexes[i];
overworld_area_is_big_backup = overworld_area_is_big;
BYTE(overworld_area_is_big) = kOverworldMapIsSmall[i & 0x3f] ? 0 : 0x20;
((uint8 *)&overworld_right_bottom_bound_for_scroll)[1] = kOverworldMapIsSmall[i & 0x3f] ? 1 : 3;
main_tile_theme_index = overworld_screen_index & 0x40 ? 0x21 : 0x20;
misc_sprites_graphics_index = kVariousPacks[6 + (overworld_screen_index & 0x40 ? 8 : 0)];
int j = overworld_screen_index & 0xbf;
overworld_offset_base_y = kOverworld_OffsetBaseY[j];
overworld_offset_base_x = kOverworld_OffsetBaseX[j] >> 3;
int m = overworld_area_is_big ? 0x3f0 : 0x1f0;
overworld_offset_mask_y = m;
overworld_offset_mask_x = m >> 3;
}
void ScrollAndCheckForSOWExit() { // 82ab7b
if (BYTE(overworld_screen_trans_dir_bits2))
OverworldHandleMapScroll();
const uint16 *map8 = Overworld_GetMap16OfLink_Mult8();
int a = map8[0] & 0x1ff;
for (int i = 2; i >= 0; i--) {
if (kSpecialSwitchAreaB_Map8[i] == a && kSpecialSwitchAreaB_Screen[i] == overworld_screen_index) {
link_direction = kSpecialSwitchAreaB_Direction[i];
byte_7E069C = overworld_screen_transition = DirToEnum(link_direction);
submodule_index = 36;
subsubmodule_index = 0;
BYTE(dungeon_room_index) = 0;
break;
}
}
}
void Module09_LoadAuxGFX() { // 82ab88
save_ow_event_info[0x3b] &= ~0x20;
save_ow_event_info[0x7b] &= ~0x20;
save_dung_info[267] &= ~0x80;
save_dung_info[40] &= ~0x100;
LoadTransAuxGFX();
PrepTransAuxGfx();
nmi_disable_core_updates = nmi_subroutine_index = 9;
submodule_index++;
}
void Overworld_FinishTransGfx() { // 82abbc
nmi_disable_core_updates = nmi_subroutine_index = 10;
submodule_index++;
}
void Module09_LoadNewMapAndGFX() { // 82abc6
word_7E04C8 = 0;
SomeTileMapChange();
nmi_disable_core_updates++;
CreateInitialNewScreenMapToScroll();
LoadNewSpriteGFXSet();
}
void Overworld_RunScrollTransition() { // 82abda
Link_HandleMovingAnimation_FullLongEntry();
Graphics_IncrementalVRAMUpload();
uint8 rv = OverworldScrollTransition();
if (!(rv & 0xf)) {
BYTE(overworld_screen_trans_dir_bits2) = BYTE(overworld_screen_trans_dir_bits);
OverworldTransitionScrollAndLoadMap();
BYTE(overworld_screen_trans_dir_bits2) = 0;
}
}
void Module09_LoadNewSprites() { // 82abed
if (overworld_screen_transition == 1) {
BG2VOFS_copy2 += 2;
link_y_coord += 2;
}
Sprite_OverworldReloadAll_justLoad();
num_memorized_tiles = 0;
if (sram_progress_indicator >= 2 && submodule_index != 18)
Overworld_SetFixedColAndScroll();
Overworld_StartScrollTransition();
}
void Overworld_StartScrollTransition() { // 82ac27
submodule_index++;
if (BYTE(overworld_screen_trans_dir_bits) >= 4) {
BYTE(overworld_screen_trans_dir_bits2) = BYTE(overworld_screen_trans_dir_bits);
OverworldTransitionScrollAndLoadMap();
BYTE(overworld_screen_trans_dir_bits2) = 0;
}
}
void Overworld_EaseOffScrollTransition() { // 82ac3a
if (kOverworldMapIsSmall[BYTE(overworld_screen_index)]) {
BYTE(overworld_screen_trans_dir_bits2) = BYTE(overworld_screen_trans_dir_bits);
OverworldTransitionScrollAndLoadMap();
BYTE(overworld_screen_trans_dir_bits2) = 0;
}
if (++subsubmodule_index < 8)
return;
if ((BYTE(overworld_screen_trans_dir_bits) == 8 || BYTE(overworld_screen_trans_dir_bits) == 2) && subsubmodule_index < 9)
return;
subsubmodule_index = 0;
BYTE(overworld_screen_trans_dir_bits) = 0;
if (kOverworldMapIsSmall[BYTE(overworld_screen_index)]) {
map16_load_src_off = orange_blue_barrier_state;
map16_load_dst_off = word_7EC174;
map16_load_var2 = word_7EC176;
}
submodule_index++;
Follower_Disable();
}
void Module09_0A_WalkFromExiting_FacingDown() { // 82ac8f
link_direction_last = 4;
Link_HandleMovingAnimation_FullLongEntry();
link_y_coord += 1;
if (--ow_countdown_transition)
return;
submodule_index = 0;
link_y_coord += 3;
link_y_vel = 3;
Overworld_OperateCameraScroll();
if (BYTE(overworld_screen_trans_dir_bits2))
OverworldHandleMapScroll();
}
void Module09_0B_WalkFromExiting_FacingUp() { // 82acc2
Link_HandleMovingAnimation_FullLongEntry();
link_y_coord -= 1;
if (--ow_countdown_transition)
return;
submodule_index = 0;
}
void Module09_09_OpenBigDoorFromExiting() { // 82ad4a
if (BYTE(door_animation_step_indicator) != 3) {