forked from snesrev/zelda3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messaging.c
3072 lines (2868 loc) · 101 KB
/
messaging.c
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 "messaging.h"
#include "zelda_rtl.h"
#include "variables.h"
#include "snes/snes_regs.h"
#include "dungeon.h"
#include "hud.h"
#include "load_gfx.h"
#include "dungeon.h"
#include "overworld.h"
#include "variables.h"
#include "ancilla.h"
#include "player.h"
#include "misc.h"
#include "sprite.h"
#include "player_oam.h"
#include "attract.h"
#include "nmi.h"
#include "tables/generated_dialogue.h"
#include "tables/generated_overworld_map.h"
#include "tables/generated_dungeon_map.h"
static const int8 kDungMap_Tab0[14] = {-1, -1, -1, -1, -1, 2, 0, 10, 4, 8, -1, 6, 12, 14};
static const uint16 kDungMap_Tab1[8] = {0x2108, 0x2109, 0x2109, 0x210a, 0x210b, 0x210c, 0x210d, 0x211d};
static const uint16 kDungMap_Tab2[8] = {0x2118, 0x2119, 0xa109, 0x211a, 0x211b, 0x211c, 0x2118, 0xa11d};
static const uint8 kDungMap_Tab3[14] = {0x60, 0x84, 0, 0xb, 0x32, 0x21, 0x33, 0x21, 0x38, 0x21, 0x3a, 0x21, 0x7f, 0x20};
static const uint8 kDungMap_Tab4[14] = {0x60, 0xa4, 0, 0xb, 0x42, 0x21, 0x43, 0x21, 0x49, 0x21, 0x4a, 0x21, 0x7f, 0x20};
static const uint16 kDungMap_Tab8[7] = {0x1b28, 0x1b29, 0x1b2a, 0x1b2b, 0x1b2c, 0x1b2d, 0x1b2e};
static const uint16 kDungMap_Tab6[21] = {0xaa10, 0x100, 0x1b2f, 0xc910, 0x300, 0x1b2f, 0x1b2e, 0xe510, 0xb00, 0x1b2f, 0x1b2e, 0x5b2f, 0x1b2f, 0x1b2e, 0x1b2e, 0x311, 0x100, 0x1b2f, 0x411, 0xc40, 0x1b2e};
static const uint16 kDungMap_Tab5[14] = {0x21, 0x23, 0x20, 0x21, 0x70, 0x12, 0x11, 0x212, 2, 0x217, 0x160, 0x12, 0x113, 0x171};
static const uint16 kDungMap_Tab7[9] = {0x1223, 0x1263, 0x12a3, 0x12e3, 0x1323, 0x11e3, 0x11a3, 0x1163, 0x1123};
static const uint16 kDungMap_Tab9[8] = {0xf26, 0xf27, 0x4f27, 0x4f26, 0x8f26, 0x8f27, 0xcf27, 0xcf26};
static const uint16 kDungMap_Tab10[4] = {0xe2, 0xf8, 0x3a2, 0x3b8};
static const uint16 kDungMap_Tab11[4] = {0x1f19, 0x5f19, 0x9f19, 0xdf19};
static const uint16 kDungMap_Tab12[2] = {0xe4, 0x3a4};
static const uint16 kDungMap_Tab13[2] = {0x1f1a, 0x9f1a};
static const uint16 kDungMap_Tab14[2] = {0x122, 0x138};
static const uint16 kDungMap_Tab15[2] = {0x1f1b, 0x5f1b};
static const uint16 kDungMap_Tab16[8] = {0x1f1e, 0x1f1f, 0x1f20, 0x1f21, 0x1f22, 0x1f23, 0x1f24, 0x1f25};
static const uint16 kDungMap_Tab23[744] = {
0xb61, 0x5361, 0x8b61, 0x8b62, 0xb60, 0xb63, 0x8b60, 0xb64, 0xb00, 0xb00, 0xb65, 0xb66, 0xb67, 0x4b67, 0x9367, 0xd367, 0xb60, 0x5360, 0x8b60, 0xcb60, 0xb6a, 0x4b6a, 0x4b6d, 0xb6d, 0x1368, 0x1369, 0xb00, 0xb00, 0xb6a, 0x136b, 0xb6c, 0xb6d,
0x136e, 0x4b6e, 0xb00, 0xb00, 0x136f, 0xb00, 0xb00, 0xb00, 0x1340, 0xb00, 0xb78, 0x1744, 0x536d, 0x136d, 0x4b76, 0xb76, 0xb70, 0xb71, 0xb72, 0x8b71, 0xb75, 0xb76, 0x8b75, 0x8b76, 0xb00, 0xb53, 0xb00, 0xb55, 0x1354, 0x5354, 0xb00, 0xb00,
0x4b53, 0xb00, 0xb56, 0xb57, 0xb00, 0xb59, 0xb00, 0x135e, 0x135a, 0x135b, 0x135f, 0x535f, 0xb5c, 0xb5d, 0x535e, 0xcb58, 0xb50, 0x4b50, 0x1352, 0x5352, 0xb00, 0xb40, 0x1345, 0xb46, 0x8b42, 0xb47, 0xb42, 0xb49, 0x1348, 0x5348, 0x174a, 0x574a,
0x4b47, 0xcb42, 0x4b49, 0x4b42, 0xb00, 0xb4b, 0xb00, 0xb4d, 0xb4c, 0x4b4c, 0xb4e, 0x4b4e, 0xb51, 0xb44, 0xb00, 0xb00, 0xb4f, 0x4b4f, 0x934f, 0xd34f, 0xb00, 0xb00, 0xb00, 0xb40, 0xb00, 0xb41, 0xb00, 0xb42, 0xb00, 0xb00, 0xb43, 0xb43,
0xb00, 0xb00, 0x9344, 0xb00, 0x1340, 0xb00, 0x1341, 0xb00, 0x1740, 0xb40, 0xb42, 0xb7d, 0x4b7a, 0xb7a, 0xb7e, 0x4b7e, 0xb40, 0x8b4d, 0x4bba, 0xb55, 0xb40, 0x8b55, 0x1378, 0xcb53, 0x4b76, 0x4b75, 0x13bb, 0x53bb, 0x4b7f, 0x4b42, 0xb83, 0x13bc,
0xb00, 0xb00, 0xb79, 0xb00, 0xb6e, 0x4b7c, 0xb00, 0xb41, 0x1340, 0x8b55, 0xb42, 0xb7b, 0x8b42, 0x9344, 0x1341, 0xb00, 0xb53, 0x9344, 0x8b53, 0x9344, 0x8b42, 0x9344, 0xb42, 0x9344, 0x934d, 0xb00, 0x8b53, 0x9344, 0xb00, 0xb00, 0xb40, 0xb00,
0xb41, 0xb00, 0x1384, 0xb00, 0xbb8, 0x13b9, 0x4b85, 0xcb7c, 0xb87, 0x13b0, 0x4b7b, 0x9344, 0xb00, 0xb00, 0xb40, 0xb00, 0xb91, 0x5391, 0xb9c, 0x4b9c, 0x8b42, 0x1392, 0xb93, 0x1394, 0xb95, 0xb96, 0x9395, 0x8b96, 0xb97, 0xb98, 0x8b97, 0x8b98,
0x1799, 0x5799, 0x9799, 0xd799, 0x4b98, 0x4b97, 0xcb98, 0xcb97, 0x937b, 0xb00, 0xb7b, 0xb00, 0xba6, 0x4ba6, 0xcb7a, 0x8b7a, 0xb8e, 0x4b8e, 0x938e, 0xcb8e, 0x934d, 0xb8f, 0x1390, 0x5390, 0xb00, 0xb00, 0xb00, 0x8b48, 0xb00, 0x934e, 0xb00, 0x8b4d,
0x8b72, 0x1346, 0xb45, 0xb46, 0x5744, 0x1744, 0xb00, 0xb00, 0x134d, 0xb00, 0x8b54, 0xb00, 0x1349, 0x1349, 0xb00, 0xb00, 0xb4b, 0x8b48, 0xb72, 0x4b72, 0xb00, 0xb74, 0xb00, 0xbb0, 0xb71, 0x1747, 0x17af, 0xb4b, 0xb6f, 0x1370, 0xb4b, 0xb00,
0xb6b, 0x8b6c, 0x8b6b, 0xbad, 0xb73, 0xb00, 0x13ae, 0xb46, 0x176b, 0x576b, 0xb6a, 0x4b6a, 0x1368, 0x5368, 0x1369, 0x5369, 0x8b4e, 0xb00, 0x9354, 0xb00, 0xb00, 0xb00, 0xb00, 0x5377, 0xb00, 0x974d, 0xb00, 0x4b7b, 0xb40, 0x8b4d, 0xb51, 0xb8d,
0x537a, 0x137a, 0x4b42, 0x8b40, 0xb00, 0xb00, 0xb00, 0xb00, 0xb00, 0xb00, 0xb40, 0xb00, 0xcb7a, 0x576e, 0xb00, 0xb00, 0xb6e, 0xb9f, 0xb00, 0x4ba5, 0x13a0, 0x13a1, 0xba2, 0xba3, 0xba4, 0xb00, 0xba5, 0xb00, 0xb40, 0x8b55, 0xb42, 0xcb87,
0x8b95, 0xba7, 0x8b42, 0xbaf, 0x4b78, 0xb00, 0x4b78, 0xb00, 0x8b42, 0xb51, 0xb78, 0x8b51, 0xba8, 0xba9, 0xbac, 0x8ba9, 0xbaa, 0x17ab, 0x13b4, 0x8bab, 0x17b1, 0xb41, 0x4b44, 0x4b42, 0xb00, 0xbad, 0xb00, 0x13ae, 0x1340, 0xbb7, 0xb42, 0xbb6,
0xb00, 0xb00, 0x139d, 0x139e, 0xb00, 0xb00, 0xb00, 0xb79, 0xb00, 0xb00, 0x8b42, 0xb86, 0xb42, 0x8b7b, 0x8b42, 0xb7b, 0xb87, 0x8b7b, 0x9387, 0xb7b, 0xb40, 0x13b3, 0x1378, 0xb8d, 0x8b42, 0xb88, 0x5378, 0xb40, 0x4b44, 0xd342, 0x97b5, 0x4b78,
0x13b3, 0x8b55, 0x4b7b, 0xb8d, 0xb89, 0x138a, 0xb8b, 0xb8c, 0xb00, 0xb7c, 0xb00, 0xb00, 0xb00, 0x9348, 0xb00, 0xb56, 0xb00, 0xb00, 0xb88, 0xb00, 0xb00, 0xb48, 0xb00, 0xb00, 0xb00, 0x9348, 0x1786, 0xb65, 0xb00, 0xb00, 0xcb5a, 0xb00,
0xb00, 0x5388, 0xb00, 0xb00, 0x4b5a, 0xb00, 0xb00, 0xb00, 0xb00, 0xcb5b, 0x13ab, 0xbac, 0xcb5a, 0xb00, 0x137e, 0xb00, 0xb00, 0x137e, 0xb00, 0xb00, 0xb00, 0x8b48, 0x1783, 0x1384, 0xb00, 0xb00, 0x1385, 0xb00, 0xb00, 0x537e, 0xb00, 0xb00,
0xb00, 0x8b48, 0xb43, 0xcb43, 0xb00, 0xb00, 0x1379, 0x137a, 0xb5a, 0x137b, 0xb00, 0xb00, 0xb00, 0x8b48, 0x137f, 0x1380, 0xb00, 0xb00, 0x1381, 0x1382, 0xb00, 0xb48, 0xb00, 0xb00, 0xb00, 0xb00, 0x1387, 0x1377, 0x5746, 0xb47, 0x1349, 0xb48,
0x1375, 0x4b42, 0x174a, 0x574a, 0xb43, 0x1344, 0xb45, 0x1746, 0x1742, 0x5742, 0x8b42, 0xcb42, 0x1375, 0x5375, 0x8b42, 0xcb42, 0x4b40, 0x1340, 0xb41, 0x4b41, 0x4b46, 0xb71, 0x1786, 0x8b71, 0x1347, 0xb4d, 0xb65, 0xb5b, 0xb00, 0xb00, 0x9348, 0xb00,
0xb00, 0xb00, 0xb00, 0x8b48, 0x4b66, 0x8b65, 0x4b5b, 0xb65, 0x9365, 0xb66, 0xb63, 0x8b66, 0x4b51, 0xb5f, 0xcb76, 0xb60, 0xb64, 0x4b4f, 0x4b60, 0x8b76, 0x4b76, 0xb61, 0xd376, 0x1362, 0x4b61, 0xb76, 0xcb58, 0x8b51, 0xb00, 0xb00, 0x5746, 0xb5e,
0xb00, 0xb00, 0xb5e, 0xb46, 0xb00, 0xb00, 0x8b48, 0xb00, 0xb4f, 0xb51, 0xcb76, 0x8b76, 0x5351, 0xb51, 0x8b4f, 0x8b51, 0x4b76, 0xb76, 0xcb51, 0x8b58, 0xb54, 0xb00, 0x8b66, 0xb00, 0x9348, 0x8b48, 0xb56, 0x4b45, 0xb00, 0xb57, 0xb00, 0xb59,
0x4b50, 0xb58, 0xcb50, 0x8b50, 0x5758, 0x1751, 0xcb58, 0x8b51, 0xb56, 0x4b56, 0xb65, 0x5756, 0x9348, 0x8b48, 0xb4c, 0xb4b, 0xb4d, 0xb00, 0x8b54, 0xb00, 0xb4f, 0xb50, 0x8b4f, 0x8b50, 0x4b50, 0xb51, 0xcb58, 0x8b51, 0xb52, 0xb54, 0xb53, 0x9354,
0x9748, 0x9748, 0x138d, 0x138e, 0x1391, 0x1392, 0x138c, 0x138f, 0x1393, 0x1390, 0x9393, 0x138f, 0x1394, 0x1395, 0x138e, 0x138c, 0x175d, 0x1399, 0x975d, 0x538f, 0x1397, 0x1398, 0x179a, 0x138c, 0x1399, 0x1766, 0x138f, 0xd75d, 0x538e, 0x538f, 0x1391, 0x1392,
0x139b, 0x539b, 0x139c, 0x539c, 0x138f, 0x138e, 0x5392, 0x5391, 0x138a, 0x538a, 0x138b, 0x538b, 0xb00, 0xcb5b, 0xb00, 0x8b54, 0x4b74, 0x13a6, 0xb00, 0x4b48, 0x13a0, 0x13a1, 0x538e, 0x138e, 0xd38e, 0x53a3, 0x13a4, 0xb00, 0x97aa, 0xb00, 0x538e, 0x1399,
0x13a4, 0xb00, 0x138e, 0xb00, 0xb00, 0x5393, 0xb00, 0x574e, 0x4b7d, 0xb00, 0x8b7d, 0x139f, 0x97aa, 0x13a4, 0x13a9, 0x53a9, 0x13a5, 0x13a6, 0x93a5, 0xd3a5, 0xd38e, 0x938e, 0x13a4, 0x13aa, 0xb00, 0x13a6, 0xb00, 0x8b5f, 0x139b, 0x13a6, 0x139c, 0x53a2,
0xb00, 0xb00, 0x138c, 0xb00, 0x9394, 0x139e, 0xb00, 0xb00,
};
static const uint16 kDungMap_Ptrs27[14] = {0xfc00, 0xfc08, 0xfc15, 0xfc21, 0xfc2b, 0xfc32, 0xfc3f, 0xfc4d, 0xfc5f, 0xfc68, 0xfc7d, 0xfc83, 0xfc8f, 0xfca0};
static const uint16 kDungMap_Tab21[3] = {137, 167, 79};
static const uint16 kDungMap_Tab22[3] = {169, 119, 190};
static const uint16 kDungMap_Tab24[2] = {0x1f, 0x7f};
static const uint16 kDungMap_Tab25[14] = {15, 15, 200, 51, 32, 6, 90, 144, 41, 222, 7, 172, 164, 13};
static const int16 kDungMap_Tab28[14] = {-1, -1, 1, 1, 6, 0xff, 0xff, 0xff, 0xfe, 0xf9, 5, 0xff, 0xfd, 6};
static PlayerHandlerFunc *const kDungMapInit[] = {
&Module0E_03_01_00_PrepMapGraphics,
&Module0E_03_01_01_DrawLEVEL,
&Module0E_03_01_02_DrawFloorsBackdrop,
&Module0E_03_01_03_DrawRooms,
&DungeonMap_DrawRoomMarkers,
};
static const uint8 kDungMap_Tab38[4] = {0x39, 0x3b, 0x3d, 0x3b};
static const int8 kDungMap_Tab29[4] = {-9, 8, -9, 8};
static const int8 kDungMap_Tab30[4] = {-8, -8, 9, 9};
static const uint8 kDungMap_Tab31[4] = {0xf1, 0xb1, 0x71, 0x31};
static const uint8 kDungMap_Tab32[4] = {0xc, 0xc, 8, 0xa};
static const uint8 kDungMap_Tab33[8] = {187, 171, 155, 139, 123, 107, 91, 75};
static const uint8 kDungMap_Tab34[8] = {0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25};
static const uint8 kDungMap_Tab35[2] = {0, 8};
static const uint8 kDungMap_Tab36[4] = {0x37, 0x38, 0x38, 0x37};
static const int16 kDungMap_Tab37[14] = { -1, -1, 0x808, 8, 0, 8, 0x808, 8, 0x808, 0x800, 0x404, 0x808, 8, 8 };
static const int8 kDungMap_Tab39[2] = {-4, 4};
static const int8 kDungMap_Tab40[2] = {4, -4};
static const int16 kDungMap_Tab26[2] = {0x60, -0x60};
static PlayerHandlerFunc *const kDungMapSubmodules[] = {
&DungMap_Backup,
&Module0E_03_01_DrawMap,
&DungMap_LightenUpMap,
&DungeonMap_HandleInputAndSprites,
&DungMap_4,
&DungMap_FadeMapToBlack,
&DungeonMap_RecoverGFX,
&ToggleStarTilesAndAdvance,
&DungMap_RestoreOld,
};
static const uint16 kText_Positions[2] = {0x6125, 0x6244};
static const uint16 kSrmOffsets[4] = {0, 0x500, 0xa00, 0xf00};
static const uint8 kTextDictionary[] = {
0x59, 0x59, 0x59, 0x59,
0x59, 0x59, 0x59,
0x59, 0x59,
0x51, 0x2c, 0x59,
0x1a, 0x27, 0x1d, 0x59,
0x1a, 0x2b, 0x1e, 0x59,
0x1a, 0x25, 0x25, 0x59,
0x1a, 0x22, 0x27,
0x1a, 0x27, 0x1d,
0x1a, 0x2d, 0x59,
0x1a, 0x2c, 0x2d,
0x1a, 0x27,
0x1a, 0x2d,
0x1b, 0x25, 0x1e,
0x1b, 0x1a,
0x1b, 0x1e,
0x1b, 0x28,
0x1c, 0x1a, 0x27, 0x59,
0x1c, 0x21, 0x1e,
0x1c, 0x28, 0x26,
0x1c, 0x24,
0x1d, 0x1e, 0x2c,
0x1d, 0x22,
0x1d, 0x28,
0x1e, 0x27, 0x59,
0x1e, 0x2b, 0x59,
0x1e, 0x1a, 0x2b,
0x1e, 0x27, 0x2d,
0x1e, 0x1d, 0x59,
0x1e, 0x27,
0x1e, 0x2b,
0x1e, 0x2f,
0x1f, 0x28, 0x2b,
0x1f, 0x2b, 0x28,
0x20, 0x22, 0x2f, 0x1e, 0x59,
0x20, 0x1e, 0x2d,
0x20, 0x28,
0x21, 0x1a, 0x2f, 0x1e,
0x21, 0x1a, 0x2c,
0x21, 0x1e, 0x2b,
0x21, 0x22,
0x21, 0x1a,
0x22, 0x20, 0x21, 0x2d, 0x59,
0x22, 0x27, 0x20, 0x59,
0x22, 0x27,
0x22, 0x2c,
0x22, 0x2d,
0x23, 0x2e, 0x2c, 0x2d,
0x24, 0x27, 0x28, 0x30,
0x25, 0x32, 0x59,
0x25, 0x1a,
0x25, 0x28,
0x26, 0x1a, 0x27,
0x26, 0x1a,
0x26, 0x1e,
0x26, 0x2e,
0x27, 0x51, 0x2d, 0x59,
0x27, 0x28, 0x27,
0x27, 0x28, 0x2d,
0x28, 0x29, 0x1e, 0x27,
0x28, 0x2e, 0x27, 0x1d,
0x28, 0x2e, 0x2d, 0x59,
0x28, 0x1f,
0x28, 0x27,
0x28, 0x2b,
0x29, 0x1e, 0x2b,
0x29, 0x25, 0x1e,
0x29, 0x28, 0x30,
0x29, 0x2b, 0x28,
0x2b, 0x1e, 0x59,
0x2b, 0x1e,
0x2c, 0x28, 0x26, 0x1e,
0x2c, 0x1e,
0x2c, 0x21,
0x2c, 0x28,
0x2c, 0x2d,
0x2d, 0x1e, 0x2b, 0x59,
0x2d, 0x21, 0x22, 0x27,
0x2d, 0x1e, 0x2b,
0x2d, 0x21, 0x1a,
0x2d, 0x21, 0x1e,
0x2d, 0x21, 0x22,
0x2d, 0x28,
0x2d, 0x2b,
0x2e, 0x29,
0x2f, 0x1e, 0x2b,
0x30, 0x22, 0x2d, 0x21,
0x30, 0x1a,
0x30, 0x1e,
0x30, 0x21,
0x30, 0x22,
0x32, 0x28, 0x2e,
0x7, 0x1e, 0x2b,
0x13, 0x21, 0x1a,
0x13, 0x21, 0x1e,
0x13, 0x21, 0x22,
0x18, 0x28, 0x2e,
};
static const uint16 kTextDictionary_Idx[] = {
0, 4, 7, 9, 12, 16, 20, 24, 27, 30, 33, 36, 38, 40, 43, 45, 47, 49, 53, 56, 59, 61, 64, 66, 68, 71, 74, 77, 80, 83, 85, 87, 89, 92, 95, 100, 103, 105, 109, 112, 115, 117, 119, 124, 128, 130, 132, 134, 138, 142, 145, 147, 149, 152, 154, 156, 158, 162, 165, 168, 172, 176, 180, 182, 184, 186, 189, 192, 195, 198, 201, 203, 207, 209, 211, 213, 215, 219, 223, 226, 229, 232, 235, 237, 239, 241, 244, 248, 250, 252, 254, 256, 259, 262, 265, 268, 271, 274
};
static const int8 kText_InitializationData[32] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0x39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1c, 4, 0, 0, 0, 0, 0};
static const uint16 kText_BorderTiles[9] = {0x28f3, 0x28f4, 0x68f3, 0x28c8, 0x387f, 0x68c8, 0xa8f3, 0xa8f4, 0xe8f3};
static const uint8 kText_CommandLengths[25] = {
1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 1, 1, 1, 1, 1,
};
static const uint8 kVWF_RenderCharacter_setMasks[8] = {0x80, 0x40, 0x20, 0x10, 8, 4, 2, 1};
static const uint16 kVWF_RenderCharacter_renderPos[3] = {0, 0x2a0, 0x540};
static const uint16 kVWF_RenderCharacter_linePositions[3] = {0, 0x40, 0x80};
static const uint8 kVWF_RenderCharacter_widths[99] = {
6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 7, 6, 6, 6, 6, 6, 6, 7, 6, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6,
6, 6, 3, 5, 6, 3, 7, 6, 6, 6, 6, 5, 6, 6, 6, 7, 7, 7, 7, 6, 6, 4, 6, 6, 6, 6, 6, 6, 6, 6, 3, 7,
6, 4, 4, 6, 8, 6, 6, 6, 6, 6, 8, 8, 8, 7, 7, 7, 7, 4, 8, 8, 8, 8, 8, 8, 8, 4, 8, 8, 8, 8, 8, 8,
8, 8, 4,
};
static const uint16 kVWF_RowPositions[3] = {0, 2, 4};
static const uint16 kVWF_LinePositions[3] = {0, 40, 80};
static const uint16 kVWF_Command7B[4] = {0x24b8, 0x24ba, 0x24bc, 0x24be};
static const uint16 kVWF_Command7C[8] = {0x24b8, 0x24ba, 0x24bc, 0x24be, 0x24b8, 0x24ba, 0x24bc, 0x24be};
static const uint16 kText_WaitDurations[16] = {31, 63, 94, 125, 156, 188, 219, 250, 281, 313, 344, 375, 406, 438, 469, 500};
static PlayerHandlerFunc *const kText_Render[] = {
&RenderText_Draw_Border,
&RenderText_Draw_BorderIncremental,
&RenderText_Draw_CharacterTilemap,
&RenderText_Draw_MessageCharacters,
&RenderText_Draw_Finish,
};
static PlayerHandlerFunc *const kMessaging_Text[] = {
&Text_Initialize,
&Text_Render,
&RenderText_PostDeathSaveOptions,
};
static const uint16 kOverworldMapPaletteData[256] = {
0, 0x94b, 0x1563, 0x1203, 0x2995, 0x5bdf, 0x2191, 0x2e37, 0x7c1f, 0x6f37, 0x7359, 0x777a, 0x7b9b, 0x7fbd, 0, 0,
0, 0x100, 0, 0, 0x7b9b, 0x11b6, 0x1a9b, 0x5fff, 0x2995, 0x6e94, 0x76d6, 0x7f39, 0x7f7b, 0x7fbd, 0, 0,
0, 0x100, 0x1d74, 0x67f9, 0x1ee9, 0x338e, 0x6144, 0x7e6a, 0xa44, 0x7c1f, 0x6144, 0x22eb, 0x3dca, 0x5ed2, 0x7fda, 0x316a,
0, 0x100, 0x14cc, 0x1910, 0x2995, 0x3e3a, 0x1963, 0x15e3, 0x25f5, 0x2e37, 0x15e3, 0x22eb, 0x6144, 0x7e33, 0x5d99, 0x771d,
0, 0xcec, 0x22eb, 0x2fb1, 0x1d70, 0x2e37, 0x25f5, 0x3e77, 0x473a, 0x6144, 0x7e6a, 0x15e3, 0x2e0b, 0x5354, 0x7fff, 0x16a6,
0, 0x100, 0x15c5, 0x16a6, 0x1ee9, 0x2f4d, 0x25f5, 0x3e77, 0x473a, 0x5354, 0x15e3, 0x22eb, 0x2918, 0x4a1f, 0x3f7f, 0x7c1f,
0, 0x100, 0x1563, 0x1203, 0x1ee9, 0x2fb0, 0x1d70, 0x2e37, 0x473a, 0x6144, 0x15e3, 0x22eb, 0x1d70, 0x2e37, 0x4f3f, 0x7fbd,
0, 0, 0, 0, 0, 0, 0, 0x25f5, 0x316a, 0x5ed2, 0x7fff, 0x15e3, 0x473a, 0x2918, 0x771d, 0,
0, 0x18c6, 0x948, 0x118a, 0x25cf, 0x57bf, 0x1971, 0x2a18, 0x7c1f, 0x52d8, 0x5af9, 0x5f1a, 0x633b, 0x6b5c, 0, 0,
0, 0x18c6, 5, 0x45fc, 0x633b, 0x1dce, 0x3694, 0x4718, 0x25cf, 0x1d40, 0x34ea, 0x616f, 0x771b, 0x26d6, 0x2b18, 0x2f5a,
0, 0x18c6, 0x2571, 0x63da, 0x2a32, 0x3a94, 0x1d40, 0x2580, 0x7c1f, 0x7c1f, 0xcc0, 0x1ecc, 0x3135, 0x1dce, 0x4718, 0x3694,
0, 0x18c6, 0x14e7, 0x216c, 0x25d0, 0x3a75, 0x2169, 0x2e0e, 0x21d6, 0x2a18, 0x1971, 0x2a32, 0x1d40, 0x2580, 0x597a, 0x72fe,
0, 0x18c6, 0x2a32, 0x3a94, 0x2171, 0x3238, 0x29f6, 0x4278, 0x4edb, 0x1d40, 0x35cd, 0x15ab, 0x198e, 0x3254, 0x731f, 0x1ed4,
0, 0x18c6, 0x16a, 0x21ce, 0x2a32, 0x3a94, 0x29f6, 0x4278, 0x4edb, 0x1d40, 0x1971, 0x2a32, 0x496c, 0x5a10, 0x3b5f, 0x7c1f,
0, 0x18c6, 0x948, 0x118a, 0x222e, 0x32f2, 0x1951, 0x2a18, 0x431b, 0x1d40, 0x1971, 0x2a32, 0x21d4, 0x2a18, 0x4b1f, 0x7b9d,
0, 0x7c1f, 0x7c1f, 0x7c1f, 0x7c1f, 0x2e31, 0xe4, 0x2169, 0x2e0e, 0x42f1, 0x7c1f, 0x7c1f, 0x7c1f, 0x4a1d, 0x4e3f, 0x5a5f,
};
static const uint8 kOverworldMap_tab1[333] = {
0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xdf,
0xde, 0xdd, 0xdc, 0xdb, 0xda, 0xd8, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0, 0xcf, 0xce,
0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, 0xc6, 0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe, 0xbd,
0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xb7, 0xb6, 0xb5, 0xb4, 0xb3, 0xb2, 0xb1, 0xb0, 0xaf, 0xae, 0xad,
0xac, 0xab, 0xaa, 0xa9, 0xa8, 0xa7, 0xa6, 0xa5, 0xa4, 0xa3, 0xa2, 0xa1, 0xa0, 0x9f, 0x9e, 0x9d,
0x9c, 0x9b, 0x9b, 0x9a, 0x99, 0x98, 0x97, 0x96, 0x95, 0x94, 0x93, 0x92, 0x91, 0x90, 0x8f, 0x8e,
0x8d, 0x8c, 0x8b, 0x8b, 0x8a, 0x89, 0x88, 0x87, 0x86, 0x85, 0x84, 0x83, 0x82, 0x81, 0x81, 0x80,
0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x79, 0x78, 0x77, 0x76, 0x75, 0x74, 0x73, 0x72, 0x72,
0x71, 0x70, 0x6f, 0x6e, 0x6d, 0x6c, 0x6c, 0x6b, 0x6a, 0x69, 0x68, 0x67, 0x67, 0x66, 0x65, 0x64,
0x63, 0x62, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5d, 0x5c, 0x5b, 0x5a, 0x59, 0x59, 0x58, 0x57,
0x56, 0x55, 0x55, 0x54, 0x53, 0x52, 0x51, 0x51, 0x50, 0x4f, 0x4e, 0x4e, 0x4d, 0x4c, 0x4b, 0x4a,
0x4a, 0x49, 0x48, 0x47, 0x47, 0x46, 0x45, 0x44, 0x44, 0x43, 0x42, 0x41, 0x41, 0x40, 0x3f, 0x3e,
0x3e, 0x3d, 0x3c, 0x3c, 0x3b, 0x3a, 0x39, 0x39, 0x38, 0x37, 0x36, 0x36, 0x35, 0x34, 0x34, 0x33,
0x32, 0x32, 0x31, 0x30, 0x2f, 0x2f, 0x2e, 0x2d, 0x2d, 0x2c, 0x2b, 0x2b, 0x2a, 0x29, 0x29, 0x28,
0x27, 0x27, 0x26, 0x25, 0x25, 0x24, 0x23, 0x23, 0x22, 0x21, 0x21, 0x20, 0x1f, 0x1f, 0x1e, 0x1d,
0x1d, 0x1c, 0x1c, 0x1b, 0x1a, 0x1a, 0x19, 0x18, 0x18, 0x17, 0x17, 0x16, 0x15, 0x15, 0x14, 0x14,
0x13, 0x12, 0x12, 0x11, 0x10, 0x10, 0xf, 0xf, 0xe, 0xe, 0xd, 0xc, 0xc, 0xb, 0xb, 0xa,
9, 9, 8, 8, 7, 7, 6, 5, 5, 4, 4, 3, 3, 2, 1, 1,
0, 0, 0, 0, 0xff, 0xfe, 0xfe, 0xfd, 0xfc, 0xfc, 0xfb, 0xfb, 0xfa, 0xf9, 0xf9, 0xf8,
0xf7, 0xf7, 0xf6, 0xf5, 0xf4, 0xf4, 0xf3, 0xf2, 0xf2, 0xf1, 0xf0, 0xef, 0xee, 0xee, 0xed, 0xec,
0xeb, 0xea, 0xe9, 0xe8, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0,
};
static const uint8 kOverworldMapData[7] = {0x79, 0x6e, 0x6f, 0x6d, 0x7c, 0x6c, 0x7f};
static const uint8 kBirdTravel_tab1[8] = {0x7f, 0x79, 0x6c, 0x6d, 0x6e, 0x6f, 0x7c, 0x7d};
static const uint8 kBirdTravel_x_lo[8] = {0x80, 0xcf, 0x10, 0xb8, 0x30, 0x70, 0x70, 0xf0};
static const uint8 kBirdTravel_x_hi[8] = {6, 0xc, 2, 8, 0xf, 0, 7, 0xe};
static const uint8 kBirdTravel_y_lo[8] = {0x5b, 0x98, 0xc0, 0x20, 0x50, 0xb0, 0x30, 0x80};
static const uint8 kBirdTravel_y_hi[8] = {3, 5, 7, 0xb, 0xb, 0xf, 0xf, 0xf};
static const uint8 kPendantBitMask[3] = {4, 1, 2};
static const uint8 kCrystalBitMask[7] = {2, 0x40, 8, 0x20, 1, 4, 0x10};
static const uint16 kOwMapCrystal0_x[9] = {0x7ff, 0x2c0, 0xd00, 0xf31, 0x6d, 0x7e0, 0xf40, 0xf40, 0x8dc};
static const uint16 kOwMapCrystal0_y[9] = {0x730, 0x6a0, 0x710, 0x620, 0x70, 0x640, 0x620, 0x620, 0x30};
static const uint16 kOwMapCrystal1_x[9] = {0xff00, 0xff00, 0xff00, 0x8d0, 0xff00, 0xff00, 0xff00, 0x82, 0xff00};
static const uint16 kOwMapCrystal1_y[9] = {0xff00, 0xff00, 0xff00, 0x80, 0xff00, 0xff00, 0xff00, 0xb0, 0xff00};
static const uint16 kOwMapCrystal2_x[9] = {0xff00, 0xff00, 0xff00, 0x108, 0xff00, 0xff00, 0xff00, 0xf11, 0xff00};
static const uint16 kOwMapCrystal2_y[9] = {0xff00, 0xff00, 0xff00, 0xd70, 0xff00, 0xff00, 0xff00, 0x103, 0xff00};
static const uint16 kOwMapCrystal3_x[9] = {0xff00, 0xff00, 0xff00, 0x6d, 0xff00, 0xff00, 0xff00, 0x1d0, 0xff00};
static const uint16 kOwMapCrystal3_y[9] = {0xff00, 0xff00, 0xff00, 0x70, 0xff00, 0xff00, 0xff00, 0x780, 0xff00};
static const uint16 kOwMapCrystal4_x[9] = {0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0x100, 0xff00};
static const uint16 kOwMapCrystal4_y[9] = {0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xca0, 0xff00};
static const uint16 kOwMapCrystal5_x[9] = {0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xca0, 0xff00};
static const uint16 kOwMapCrystal5_y[9] = {0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xda0, 0xff00};
static const uint16 kOwMapCrystal6_x[9] = {0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0x759, 0xff00};
static const uint16 kOwMapCrystal6_y[9] = {0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xed0, 0xff00};
static const uint16 kOwMapCrystal0_tab[9] = {0, 0, 0, 0x6038, 0x6234, 0x6632, 0x6434, 0x6434, 0x6632};
static const uint16 kOwMapCrystal1_tab[9] = {0, 0, 0, 0x6032, 0, 0, 0, 0x6434, 0};
static const uint16 kOwMapCrystal2_tab[9] = {0, 0, 0, 0x6034, 0, 0, 0, 0x6434, 0};
static const uint16 kOwMapCrystal3_tab[9] = {0, 0, 0, 0x6234, 0, 0, 0, 0x6434, 0};
static const uint16 kOwMapCrystal4_tab[9] = {0, 0, 0, 0, 0, 0, 0, 0x6434, 0};
static const uint16 kOwMapCrystal5_tab[9] = {0, 0, 0, 0, 0, 0, 0, 0x6434, 0};
static const uint16 kOwMapCrystal6_tab[9] = {0, 0, 0, 0, 0, 0, 0, 0x6434, 0};
static const uint8 kOwMap_tab2[4] = {0x68, 0x69, 0x78, 0x69};
static const uint8 kOverworldMap_Table4[4] = {0x34, 0x74, 0xf4, 0xb4};
static const uint8 kOverworldMap_Timer[2] = {33, 12};
static const int16 kOverworldMap_Table3[8] = {0, 0, 1, 2, -1, -2, 1, 2};
static const int16 kOverworldMap_Table2[8] = {0, 0, 224, 480, -72, -224, 0, 0};
static PlayerHandlerFunc *const kMessagingSubmodules[12] = {
&Module_Messaging_0,
&Hud_Module_Run,
&RenderText,
&Module0E_03_DungeonMap,
&Module0E_04_RedPotion,
&Module0E_05_DesertPrayer,
&Module_Messaging_6,
&Messaging_OverworldMap,
&Module0E_08_GreenPotion,
&Module0E_09_BluePotion,
&Module0E_0A_FluteMenu,
&Module0E_0B_SaveMenu,
};
static const uint8 kDeath_AnimCtr0[15] = {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 5};
static const uint8 kDeath_AnimCtr1[15] = {5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 0x62};
static const uint8 kDeath_SprFlags[2] = {0x20, 0x10};
static const uint8 kDeath_SprChar0[2] = {0xea, 0xec};
static const uint8 kDeath_SprY0[3] = {0x7f, 0x8f, 0x9f};
const uint8 kHealthAfterDeath[21] = {
0x18, 0x18, 0x18, 0x18, 0x18, 0x20, 0x20, 0x28, 0x28, 0x30, 0x30, 0x38, 0x38, 0x38, 0x40, 0x40,
0x40, 0x48, 0x48, 0x48, 0x50,
};
static PlayerHandlerFunc *const kModule_Death[16] = {
&GameOver_AdvanceImmediately,
&Death_Func1,
&GameOver_DelayBeforeIris,
&GameOver_IrisWipe,
&Death_Func4,
&GameOver_SplatAndFade,
&Death_Func6,
&Animate_GAMEOVER_Letters_bounce,
&GameOver_Finalize_GAMEOVR,
&GameOver_SaveAndOrContinue,
&GameOver_InitializeRevivalFairy,
&RevivalFairy_Main_bounce,
&GameOver_RiseALittle,
&GameOver_Restore0D,
&GameOver_Restore0E,
&GameOver_ResituateLink,
};
static const uint8 kLocationMenuStartPos[3] = {0, 1, 6};
static void RunInterface();
const uint8 *GetDungmapFloorLayout() {
return kDungMap_FloorLayout[cur_palace_index_x2 >> 1];
}
uint8 GetOtherDungmapInfo(int count) {
return kDungMap_Tiles[cur_palace_index_x2 >> 1][count];
}
void DungMap_4() {
BG2VOFS_copy2 += dungmap_var4;
dungmap_var5 -= dungmap_var4;
if (!--byte_7E0205)
overworld_map_state--;
}
const uint8 *GetCurrentTextPtr() {
return kDialogueText + kDialogueOffs[dialogue_message_index];
}
void Module_Messaging_6() {
assert(0);
}
void OverworldMap_SetupHdma() {
static const uint32 kOverworldMap_TableLow[2] = {0xabdcf, 0xabdd6};
uint32 a = kOverworldMap_TableLow[overworld_map_flags];
HdmaSetup(a, a, 0x42, (uint8)M7A, (uint8)M7D, 10);
}
const uint8 *GetLightOverworldTilemap() {
return kLightOverworldTilemap;
}
void SaveGameFile() { // 80894a
int offs = ((srm_var1 >> 1) - 1) * 0x500;
memcpy(g_zenv.sram + offs, save_dung_info, 0x500);
memcpy(g_zenv.sram + offs + 0xf00, save_dung_info, 0x500);
uint16 t = 0x5a5a;
for (int i = 0; i < 0x4fe; i += 2)
t -= *(uint16 *)((char *)save_dung_info + i);
word_7EF4FE = t;
WORD(g_zenv.sram[offs + 0x4fe]) = t;
WORD(g_zenv.sram[offs + 0x4fe + 0xf00]) = t;
ZeldaWriteSram();
}
void TransferMode7Characters() { // 80e399
uint16 *dst = g_zenv.vram;
const uint8 *src = kOverworldMapGfx;
for (int i = 0; i != 0x4000; i++)
HIBYTE(dst[i]) = src[i];
}
void Module0E_Interface() { // 80f800
bool skip_run = false;
if (player_is_indoors) {
if (submodule_index == 3) {
skip_run = (overworld_map_state != 0 && overworld_map_state != 7);
} else {
Dungeon_PushBlock_Handler();
}
} else {
skip_run = ((submodule_index == 7 || submodule_index == 10) && overworld_map_state);
}
if (!skip_run) {
Sprite_Main();
LinkOam_Main();
if (!player_is_indoors)
OverworldOverlay_HandleRain();
Hud_RefillLogic();
if (submodule_index != 2)
OrientLampLightCone();
}
RunInterface();
BG2HOFS_copy = BG2HOFS_copy2 + bg1_x_offset;
BG2VOFS_copy = BG2VOFS_copy2 + bg1_y_offset;
BG1HOFS_copy = BG1HOFS_copy2 + bg1_x_offset;
BG1VOFS_copy = BG1VOFS_copy2 + bg1_y_offset;
}
void Module_Messaging_0() { // 80f875
assert(0);
}
static void RunInterface() { // 80f89a
kMessagingSubmodules[submodule_index]();
}
void Module0E_05_DesertPrayer() { // 80f8b1
switch (subsubmodule_index) {
case 0: ResetTransitionPropsAndAdvance_ResetInterface(); break;
case 1: ApplyPaletteFilter_bounce(); break;
case 2:
DesertPrayer_InitializeIrisHDMA();
BYTE(palette_filter_countdown) = mosaic_target_level - 1;
mosaic_target_level = 0;
BYTE(darkening_or_lightening_screen) = 2;
break;
case 3:
ApplyPaletteFilter_bounce();
// fall through
case 4:
DesertPrayer_BuildIrisHDMATable();
break;
}
}
void Module0E_04_RedPotion() { // 80f8fb
if (Hud_RefillHealth()) {
button_mask_b_y &= ~0x40;
flag_update_hud_in_nmi++;
submodule_index = 0;
main_module_index = saved_module_for_menu;
}
}
void Module0E_08_GreenPotion() { // 80f911
if (Hud_RefillMagicPower()) {
button_mask_b_y &= ~0x40;
flag_update_hud_in_nmi++;
submodule_index = 0;
main_module_index = saved_module_for_menu;
}
}
void Module0E_09_BluePotion() { // 80f918
if (Hud_RefillHealth())
submodule_index = 8;
if (Hud_RefillMagicPower())
submodule_index = 4;
}
void Module0E_0B_SaveMenu() { // 80f9fa
// This is the continue / save and quit menu
if (!player_is_indoors)
Overworld_DwDeathMountainPaletteAnimation();
RenderText();
flag_update_hud_in_nmi = 0;
nmi_disable_core_updates = 0;
if (subsubmodule_index < 3)
subsubmodule_index++;
else
nmi_load_bg_from_vram = 0;
if (!submodule_index) {
subsubmodule_index = 0;
nmi_load_bg_from_vram = 1;
if (choice_in_multiselect_box) {
sound_effect_ambient = 15;
main_module_index = 23;
submodule_index = 1;
index_of_changable_dungeon_objs[0] = 0;
index_of_changable_dungeon_objs[1] = 0;
} else {
choice_in_multiselect_box = choice_in_multiselect_box_bak;
}
}
}
void Module1B_SpawnSelect() { // 828586
RenderText();
if (submodule_index)
return;
nmi_load_bg_from_vram = 0;
EnableForceBlank();
EraseTileMaps_normal();
uint8 bak = which_starting_point;
which_starting_point = kLocationMenuStartPos[choice_in_multiselect_box];
subsubmodule_index = 0;
LoadDungeonRoomRebuildHUD();
which_starting_point = bak;
}
void CleanUpAndPrepDesertPrayerHDMA() { // 82c7b8
HdmaSetup(0, 0x2c80c, 0x41, 0, (uint8)WH0, 0);
W12SEL_copy = 0x33;
W34SEL_copy = 3;
WOBJSEL_copy = 0x33;
TMW_copy = TM_copy;
TSW_copy = TS_copy;
HDMAEN_copy = 0x80;
memset(mode7_hdma_table, 0, 0x1e0);
}
void DesertPrayer_InitializeIrisHDMA() { // 87ea06
CleanUpAndPrepDesertPrayerHDMA();
spotlight_var1 = 0x26;
BYTE(spotlight_var2) = 0;
DesertPrayer_BuildIrisHDMATable();
subsubmodule_index++;
}
void DesertPrayer_BuildIrisHDMATable() { // 87ea27
uint16 r14 = link_y_coord - BG2VOFS_copy2 + 12;
spotlight_y_lower = r14 - spotlight_var1;
uint16 r4 = sign16(spotlight_y_lower) ? spotlight_y_lower : 0;
uint16 k;
spotlight_y_upper = spotlight_y_lower + spotlight_var1 * 2;
spotlight_var3 = link_x_coord - BG2HOFS_copy2 + 8;
spotlight_var4 = 1;
do {
uint16 r0 = 0x100, r2 = 0x100;
if (!(sign16(spotlight_y_lower) || (r4 >= spotlight_y_lower && r4 < spotlight_y_upper))) {
k = (r4 - 1);
} else if (spotlight_var1 < spotlight_var4) {
spotlight_var4 = 1;
spotlight_y_lower = 0;
r4 = spotlight_y_upper;
if (r4 >= 225)
break;
k = (r4 - 1);
} else {
Pair16U pair = DesertHDMA_CalculateIrisShapeLine();
if (pair.a == 0) {
spotlight_y_lower = 0;
} else {
r2 = spotlight_var3 + pair.b;
r0 = spotlight_var3 - pair.b;
}
k = (r14 - BYTE(spotlight_var4) - 1);
}
uint8 t6 = (r0 < 256) ? r0 : (r0 < 512) ? 255 : 0;
uint8 t7 = (r2 < 256) ? r2 : 255;
uint16 r6 = t7 << 8 | t6;
if (k < 224)
mode7_hdma_table[k] = (r6 == 0xffff) ? 0xff : r6;
if (sign16(spotlight_y_lower) || (r4 >= spotlight_y_lower && r4 < spotlight_y_upper)) {
k = BYTE(spotlight_var4) - 2 + r14;
if (k < 224)
mode7_hdma_table[k] = (r6 == 0xffff) ? 0xff : r6;
spotlight_var4++;
}
r4++;
} while (sign16(r4) || r4 < 225);
if (subsubmodule_index != 4)
return;
if (BYTE(spotlight_var2) != 1 && (filtered_joypad_H | filtered_joypad_L) & 0xc0) {
BYTE(spotlight_var2) = 1;
BYTE(spotlight_var1) >>= 1;
}
if (BYTE(spotlight_var2) && (BYTE(spotlight_var1) += 8) >= 0xc0) {
byte_7E02F0 ^= 1;
music_control = 0xf3;
sound_effect_ambient = 0;
flag_unk1 = 0;
some_animation_timer_steps = 0;
button_mask_b_y = 0;
link_state_bits = 0;
link_cant_change_direction &= ~1;
subsubmodule_index = 0;
submodule_index = 0;
main_module_index = saved_module_for_menu;
TMW_copy = 0;
TSW_copy = 0;
W12SEL_copy = 0;
W34SEL_copy = 0;
WOBJSEL_copy = 0;
IrisSpotlight_ResetTable();
} else {
static const uint8 kPrayingScene_Delays[5] = {22, 22, 22, 64, 1};
if (sign8(--link_delay_timer_spin_attack)) {
int i = some_animation_timer_steps + 1;
if (i != 4)
some_animation_timer_steps = i;
link_delay_timer_spin_attack = kPrayingScene_Delays[i];
}
}
}
Pair16U DesertHDMA_CalculateIrisShapeLine() { // 87ecdc
static const uint8 kPrayingScene_Tab1[129] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfe,
0xfd, 0xfd, 0xfd, 0xfd, 0xfc, 0xfc, 0xfc, 0xfb, 0xfb, 0xfb, 0xfa, 0xfa, 0xf9, 0xf9, 0xf8, 0xf8,
0xf7, 0xf7, 0xf6, 0xf6, 0xf5, 0xf5, 0xf4, 0xf3, 0xf3, 0xf2, 0xf1, 0xf1, 0xf0, 0xef, 0xee, 0xee,
0xed, 0xec, 0xeb, 0xea, 0xe9, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xdf, 0xde,
0xdd, 0xdc, 0xdb, 0xda, 0xd8, 0xd7, 0xd6, 0xd5, 0xd3, 0xd2, 0xd0, 0xcf, 0xcd, 0xcc, 0xca, 0xc9,
0xc7, 0xc6, 0xc4, 0xc2, 0xc1, 0xbf, 0xbd, 0xbb, 0xb9, 0xb7, 0xb6, 0xb4, 0xb1, 0xaf, 0xad, 0xab,
0xa9, 0xa7, 0xa4, 0xa2, 0x9f, 0x9d, 0x9a, 0x97, 0x95, 0x92, 0x8f, 0x8c, 0x89, 0x86, 0x82, 0x7f,
0x7b, 0x78, 0x74, 0x70, 0x6c, 0x67, 0x63, 0x5e, 0x59, 0x53, 0x4d, 0x46, 0x3f, 0x37, 0x2d, 0x1f,
0,
};
static const uint8 kPrayingScene_Tab0[129] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfe, 0xfd, 0xfd, 0xfc, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf1, 0xf0, 0xee, 0xed, 0xeb, 0xe9, 0xe8, 0xe6, 0xe4, 0xe2, 0xdf,
0xdd, 0xdb, 0xd8, 0xd6, 0xd3, 0xd0, 0xcd, 0xca, 0xc7, 0xc4, 0xc1, 0xbd, 0xb9, 0xb6, 0xb1, 0xad,
0xa9, 0xa4, 0x9f, 0x9a, 0x95, 0x8f, 0x89, 0x82, 0x7b, 0x74, 0x6c, 0x63, 0x59, 0x4d, 0x3f, 0x2d,
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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
};
uint8 t = snes_divide(BYTE(spotlight_var4) << 8, BYTE(spotlight_var1)) >> 1;
uint8 r6 = BYTE(spotlight_var2) ? kPrayingScene_Tab1[t] : kPrayingScene_Tab0[t];
uint16 r8 = r6 * BYTE(spotlight_var1) >> 8;
if (BYTE(spotlight_var2))
r8 <<= 1;
Pair16U ret = { r6, r8 };
return ret;
}
void Animate_GAMEOVER_Letters() { // 88f4ca
switch (ancilla_type[0]) {
case 0:
submodule_index++;
break;
case 1:
GameOverText_SweepLeft();
break;
case 2:
GameOverText_UnfurlRight();
break;
case 3:
GameOverText_Draw();
break;
}
}
void GameOverText_SweepLeft() { // 88f4f6
static const uint8 kGameOverText_Tab1[8] = {0x40, 0x50, 0x60, 0x70, 0x88, 0x98, 0xa8, 0x40};
int k = flag_for_boomerang_in_place;
cur_object_index = k;
ancilla_x_vel[k] = 0x80;
Ancilla_MoveX(k);
if (Ancilla_GetX(k) < kGameOverText_Tab1[k]) {
ancilla_x_lo[k] = kGameOverText_Tab1[k];
flag_for_boomerang_in_place = ++k;
if (k == 8) {
flag_for_boomerang_in_place = 7;
ancilla_type[0]++;
hookshot_effect_index = 0;
sound_effect_2 = 38;
goto draw;
}
}
if (k == 7) {
int j = 6;
while (j != hookshot_effect_index)
ancilla_x_lo[j--] = ancilla_x_lo[k];
if (Ancilla_GetX(k) < kGameOverText_Tab1[hookshot_effect_index])
hookshot_effect_index--;
}
draw:
GameOverText_Draw();
}
void GameOverText_UnfurlRight() { // 88f56d
static const uint8 kGameOverText_Tab2[8] = {0x58, 0x60, 0x68, 0x70, 0x88, 0x90, 0x98, 0xa0};
int k = flag_for_boomerang_in_place, end;
cur_object_index = k;
ancilla_x_vel[k] = 0x60;
Ancilla_MoveX(k);
int j = hookshot_effect_index;
if (ancilla_x_lo[k] >= kGameOverText_Tab2[j]) {
ancilla_x_lo[j] = kGameOverText_Tab2[j];
if (++hookshot_effect_index == 8) {
submodule_index++;
ancilla_type[0]++;
goto draw;
}
}
end = hookshot_effect_index - 1;
k = flag_for_boomerang_in_place;
j = k;
do {
ancilla_x_lo[j] = ancilla_x_lo[k];
} while (--j != end);
draw:
GameOverText_Draw();
}
void Module12_GameOver() { // 89f290
kModule_Death[submodule_index]();
if (submodule_index != 9)
LinkOam_Main();
}
void GameOver_AdvanceImmediately() { // 89f2a2
submodule_index++;
Death_Func1();
}
void Death_Func1() { // 89f2a4
music_unk1_death = music_unk1;
sound_effect_ambient_last_death = sound_effect_ambient_last;
music_control = 241;
sound_effect_ambient = 5;
overworld_map_state = 5;
byte_7E03F3 = 0;
byte_7E0322 = 0;
link_cape_mode = 0;
mapbak_bg1_x_offset = palette_filter_countdown;
mapbak_bg1_y_offset = darkening_or_lightening_screen;
memcpy(mapbak_palette, aux_palette_buffer, 256);
memset(aux_palette_buffer + 32, 0, 192);
palette_filter_countdown = 0;
darkening_or_lightening_screen = 0;
bg1_x_offset = 0;
bg1_y_offset = 0;
mapbak_CGWSEL = WORD(CGWSEL_copy);
g_ram[0xc8] = 32;
hud_floor_changed_timer = 0;
Hud_FloorIndicator();
flag_update_hud_in_nmi++;
sound_effect_ambient = 5;
submodule_index++;
}
void GameOver_DelayBeforeIris() { // 89f33b
if (--g_ram[0xc8])
return;
Death_InitializeGameOverLetters();
IrisSpotlight_close();
WOBJSEL_copy = 0x30;
W34SEL_copy = 0;
submodule_index++;
}
void GameOver_IrisWipe() { // 89f350
PaletteFilter_RestoreBGSubstractiveStrict();
main_palette_buffer[0] = main_palette_buffer[32];
uint8 bak = main_module_index;
IrisSpotlight_ConfigureTable();
main_module_index = bak;
if (submodule_index)
return;
for (int i = 0; i < 16; i++) {
main_palette_buffer[0x20 + i] = 0x18;
main_palette_buffer[0x30 + i] = 0x18;
main_palette_buffer[0x40 + i] = 0x18;
main_palette_buffer[0x50 + i] = 0x18;
main_palette_buffer[0x60 + i] = 0x18;
main_palette_buffer[0x70 + i] = 0x18;
}
main_palette_buffer[0] = main_palette_buffer[32] = 0x18;
IrisSpotlight_ResetTable();
COLDATA_copy0 = 32;
COLDATA_copy1 = 64;
COLDATA_copy2 = 128;
W12SEL_copy = 0;
W34SEL_copy = 0;
WOBJSEL_copy = 0;
submodule_index = 4;
flag_update_cgram_in_nmi++;
INIDISP_copy = 15;
TM_copy = 20;
TS_copy = 0;
CGADSUB_copy = 32;
g_ram[0xc8] = 64;
BYTE(palette_filter_countdown) = 0;
BYTE(darkening_or_lightening_screen) = 0;
Death_PrepFaint();
}
void GameOver_SplatAndFade() { // 89f3de
if (g_ram[0xc8]) {
g_ram[0xc8]--;
return;
}
PaletteFilter_RestoreBGSubstractiveStrict();
main_palette_buffer[0] = main_palette_buffer[32];
if (BYTE(darkening_or_lightening_screen) != 0xff)
return;
mosaic_level = 0;
mosaic_inc_or_dec = 0;
MOSAIC_copy = 3;
for (int i = 0; i != 4; i++) {
if (link_bottle_info[i] == 6) {
link_bottle_info[i] = 2;
g_ram[0xc8] = 12;
load_chr_halfslot_even_odd = 15;
Graphics_LoadChrHalfSlot();
load_chr_halfslot_even_odd = 0;
submodule_index = 10;
return;
}
}
index_of_changable_dungeon_objs[0] = 0;
index_of_changable_dungeon_objs[1] = 0;
nmi_subroutine_index = 22;
nmi_disable_core_updates = 22;
submodule_index++;
}
void Death_Func6() { // 89f458
g_ram[0xc8] = 12;
load_chr_halfslot_even_odd = 15;
Graphics_LoadChrHalfSlot();
load_chr_halfslot_even_odd = 0;
palette_sp6 = 5;
overworld_palette_aux_or_main = 0x200;
Palette_Load_SpriteEnvironment_Dungeon();
Palette_Load_SpriteMain();
flag_update_cgram_in_nmi++;
submodule_index++;
Death_PlayerSwoon();
}
void Death_Func4() { // 89f47e
Death_PlayerSwoon();
}
void Animate_GAMEOVER_Letters_bounce() { // 89f483
Animate_GAMEOVER_Letters();
}
void GameOver_Finalize_GAMEOVR() { // 89f488
Animate_GAMEOVER_Letters();
uint8 bak1 = main_module_index;
uint8 bak2 = submodule_index;
messaging_module = 2;
RenderText();
submodule_index = bak2 + 1;
main_module_index = bak1;
g_ram[0xc8] = 2;
music_control = 11;
}
void GameOver_SaveAndOrContinue() { // 89f4c1
GameOver_AnimateChoiceFairy();
if (ancilla_type)
Animate_GAMEOVER_Letters();
if (filtered_joypad_H & 0x20)
goto do_inc;
if (!--g_ram[0xc8]) {
g_ram[0xc8] = 1;
if (joypad1H_last & 12) {
if (joypad1H_last & 4) {
do_inc:
if (++subsubmodule_index >= 3)
subsubmodule_index = 0;
} else {
if (sign8(--subsubmodule_index))
subsubmodule_index = 2;
}
g_ram[0xc8] = 12;
sound_effect_2 = 32;
}
}
if (!((filtered_joypad_L & 0xc0 | filtered_joypad_H) & 0xd0))
return;
sound_effect_1 = 44;
Death_Func15();
}
void Death_Func15() { // 89f50f
music_control = 0xf1;
if (player_is_indoors)
Dungeon_FlagRoomData_Quadrants();
AdjustLinkBunnyStatus();
if (sram_progress_indicator < 3) {
savegame_is_darkworld = 0;
if (!link_item_moon_pearl)
ForceNonbunnyStatus();
}
if (dungeon_room_index == 0)
player_is_indoors = 0;
ResetSomeThingsAfterDeath((uint8)dungeon_room_index);
if (savegame_tagalong == 6 || savegame_tagalong == 9 || savegame_tagalong == 10 || savegame_tagalong == 13)
savegame_tagalong = 0;
death_var4 = link_health_current = kHealthAfterDeath[link_health_capacity >> 3];
uint8 i = BYTE(cur_palace_index_x2);
if (i != 0xff)
link_keys_earned_per_dungeon[(i == 2 ? 0 : i) >> 1] = link_num_keys;
Sprite_ResetAll();
if (death_var2 == 0xffff)
death_save_counter++;
death_var5++;
if (subsubmodule_index != 1) {
if (!player_is_indoors)
goto outdoors;
if (savegame_tagalong != 1 && BYTE(cur_palace_index_x2) != 255) {
death_var4 = 0;
} else {
buffer_for_playing_songs = 0;
player_is_indoors = 0;
outdoors:
if (savegame_is_darkworld)
dungeon_room_index = 32;
}
if (sram_progress_indicator) {
if (subsubmodule_index == 0)
SaveGameFile();
main_module_index = 5;
submodule_index = 0;
nmi_load_bg_from_vram = 0;
} else {
uint8 slot = srm_var1;
int offs = kSrmOffsets[(slot >> 1) - 1];
WORD(g_ram[0]) = offs;
death_var5 = 0;
CopySaveToWRAM();
}
} else {
if (sram_progress_indicator)
SaveGameFile();
TM_copy = 16;
player_is_indoors = 0;
Death_Func31();
death_var4 = 0;
death_var5 = 0;
buffer_for_playing_songs = 0;
zelda_snes_dummy_write(NMITIMEN, 0);
zelda_snes_dummy_write(HDMAEN, 0);
BG1HOFS_copy2 = 0;
BG2HOFS_copy2 = 0;
BG3HOFS_copy2 = 0;
BG1VOFS_copy2 = 0;
BG2VOFS_copy2 = 0;
BG3VOFS_copy2 = 0;
BG1HOFS_copy = 0;
BG2HOFS_copy = 0;
BG1VOFS_copy = 0;
BG2VOFS_copy = 0;
memset(save_dung_info, 0, 256 * 5);
flag_which_music_type = 0;
LoadOverworldSongs();
zelda_snes_dummy_write(NMITIMEN, 0x81);
}
}
void GameOver_AnimateChoiceFairy() { // 89f67a
int spr = 0x14;
bytewise_extended_oam[spr] = 2;
oam_buf[spr].x = 0x34;
oam_buf[spr].y = kDeath_SprY0[subsubmodule_index];
oam_buf[spr].charnum = kDeath_SprChar0[frame_counter >> 3 & 1];
oam_buf[spr].flags = 0x78;
}
void GameOver_InitializeRevivalFairy() { // 89f6a4
ConfigureRevivalAncillae();
link_hearts_filler = 56;
submodule_index += 1;