forked from snesrev/zelda3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dungeon.cpp
8786 lines (8034 loc) · 288 KB
/
dungeon.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 "zelda_rtl.h"
#include "variables.h"
#include "dungeon.h"
#include "snes_regs.h"
#include "nmi.h"
#include "hud.h"
#include "load_gfx.h"
#include "overworld.h"
#include "sprite.h"
#include "ancilla.h"
#include "ending.h"
#include "player.h"
#include "misc.h"
#include "player_oam.h"
#include "tables/generated_dungeon_rooms.h"
#include "tagalong.h"
// todo: move to config
static const uint16 kBossRooms[] = {
200, 51, 7,
32,
6, 90, 41, 144, 222, 164, 172,
13
};
static const uint8 kDungeonExit_From[12] = {200, 51, 7, 32, 6, 90, 41, 144, 222, 164, 172, 13};
static const uint8 kDungeonExit_To[12] = {201, 99, 119, 32, 40, 74, 89, 152, 14, 214, 219, 13};
static const uint16 kObjectSubtype1Params[] = {
0x3d8, 0x2e8, 0x2f8, 0x328, 0x338, 0x400, 0x410, 0x388, 0x390, 0x420, 0x42a, 0x434, 0x43e, 0x448, 0x452, 0x45c,
0x466, 0x470, 0x47a, 0x484, 0x48e, 0x498, 0x4a2, 0x4ac, 0x4b6, 0x4c0, 0x4ca, 0x4d4, 0x4de, 0x4e8, 0x4f2, 0x4fc,
0x506, 0x598, 0x600, 0x63c, 0x63c, 0x63c, 0x63c, 0x63c, 0x642, 0x64c, 0x652, 0x658, 0x65e, 0x664, 0x66a, 0x688,
0x694, 0x6a8, 0x6a8, 0x6a8, 0x6c8, 0x0, 0x78a, 0x7aa, 0xe26, 0x84a, 0x86a, 0x882, 0x8ca, 0x85a, 0x8fa, 0x91a,
0x920, 0x92a, 0x930, 0x936, 0x93c, 0x942, 0x948, 0x94e, 0x96c, 0x97e, 0x98e, 0x902, 0x99e, 0x9d8, 0x9d8, 0x9d8,
0x9fa, 0x156c, 0x1590, 0x1d86, 0x0, 0xa14, 0xa24, 0xa54, 0xa54, 0xa84, 0xa84, 0x14dc, 0x1500, 0x61e, 0xe52, 0x600,
0x3d8, 0x2c8, 0x2d8, 0x308, 0x318, 0x3e0, 0x3f0, 0x378, 0x380, 0x5fa, 0x648, 0x64a, 0x670, 0x67c, 0x6a8, 0x6a8,
0x6a8, 0x6c8, 0x0, 0x7aa, 0x7ca, 0x84a, 0x89a, 0x8b2, 0x90a, 0x926, 0x928, 0x912, 0x9f8, 0x1d7e, 0x0, 0xa34,
0xa44, 0xa54, 0xa6c, 0xa84, 0xa9c, 0x1524, 0x1548, 0x85a, 0x606, 0xe52, 0x5fa, 0x6a0, 0x6a2, 0xb12, 0xb14, 0x9b0,
0xb46, 0xb56, 0x1f52, 0x1f5a, 0x288, 0xe82, 0x1df2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x3d8, 0x3d8, 0x3d8, 0x3d8, 0x5aa, 0x5b2, 0x5b2, 0x5b2, 0x5b2, 0xe0, 0xe0, 0xe0, 0xe0, 0x110, 0x0, 0x0,
0x6a4, 0x6a6, 0xae6, 0xb06, 0xb0c, 0xb16, 0xb26, 0xb36, 0x1f52, 0x1f5a, 0x288, 0xeba, 0xe82, 0x1df2, 0x0, 0x0,
0x3d8, 0x510, 0x5aa, 0x5aa, 0x0, 0x168, 0xe0, 0x158, 0x100, 0x110, 0x178, 0x72a, 0x72a, 0x72a, 0x75a, 0x670,
0x670, 0x130, 0x148, 0x72a, 0x72a, 0x72a, 0x75a, 0xe0, 0x110, 0xf0, 0x110, 0x0, 0xab4, 0x8da, 0xade, 0x188,
0x1a0, 0x1b0, 0x1c0, 0x1d0, 0x1e0, 0x1f0, 0x200, 0x120, 0x2a8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
};
static const uint16 kObjectSubtype2Params[] = {
0xb66, 0xb86, 0xba6, 0xbc6, 0xc66, 0xc86, 0xca6, 0xcc6, 0xbe6, 0xc06, 0xc26, 0xc46, 0xce6, 0xd06, 0xd26, 0xd46,
0xd66, 0xd7e, 0xd96, 0xdae, 0xdc6, 0xdde, 0xdf6, 0xe0e, 0x398, 0x3a0, 0x3a8, 0x3b0, 0xe32, 0xe26, 0xea2, 0xe9a,
0xeca, 0xed2, 0xede, 0xede, 0xf1e, 0xf3e, 0xf5e, 0xf6a, 0xef6, 0xf72, 0xf92, 0xfa2, 0xfa2, 0x1088, 0x10a8, 0x10a8,
0x10c8, 0x10c8, 0x10c8, 0x10c8, 0xe52, 0x1108, 0x1108, 0x12a8, 0x1148, 0x1160, 0x1178, 0x1190, 0x1458, 0x1488, 0x2062, 0x2086,
};
static const uint16 kObjectSubtype3Params[] = {
0x1614, 0x162c, 0x1654, 0xa0e, 0xa0c, 0x9fc, 0x9fe, 0xa00, 0xa02, 0xa04, 0xa06, 0xa08, 0xa0a, 0x0, 0xa10, 0xa12,
0x1dda, 0x1de2, 0x1dd6, 0x1dea, 0x15fc, 0x1dfa, 0x1df2, 0x1488, 0x1494, 0x149c, 0x14a4, 0x10e8, 0x10e8, 0x10e8, 0x11a8, 0x11c8,
0x11e8, 0x1208, 0x3b8, 0x3c0, 0x3c8, 0x3d0, 0x1228, 0x1248, 0x1268, 0x1288, 0x0, 0xe5a, 0xe62, 0x0, 0x0, 0xe82,
0xe8a, 0x14ac, 0x14c4, 0x10e8, 0x1614, 0x1614, 0x1614, 0x1614, 0x1614, 0x1614, 0x1cbe, 0x1cee, 0x1d1e, 0x1d4e, 0x1d8e, 0x1d96,
0x1d9e, 0x1da6, 0x1dae, 0x1db6, 0x1dbe, 0x1dc6, 0x1dce, 0x220, 0x260, 0x280, 0x1f3a, 0x1f62, 0x1f92, 0x1ff2, 0x2016, 0x1f42,
0xeaa, 0x1f4a, 0x1f52, 0x1f5a, 0x202e, 0x2062, 0x9b8, 0x9c0, 0x9c8, 0x9d0, 0xfa2, 0xfb2, 0xfc4, 0xff4, 0x1018, 0x1020,
0x15b4, 0x15d8, 0x20f6, 0xeba, 0x22e6, 0x22ee, 0x5da, 0x281e, 0x2ae0, 0x2d2a, 0x2f2a, 0x22f6, 0x2316, 0x232e, 0x2346, 0x235e,
0x2376, 0x23b6, 0x1e9a, 0x0, 0x2436, 0x149c, 0x24b6, 0x24e6, 0x2516, 0x1028, 0x1040, 0x1060, 0x1070, 0x1078, 0x1080, 0x0,
};
static const uint16 kDoorTypeSrcData[] = {
0x2716, 0x272e, 0x272e, 0x2746, 0x2746, 0x2746, 0x2746, 0x2746, 0x2746, 0x275e, 0x275e, 0x275e, 0x275e, 0x2776, 0x278e, 0x27a6,
0x27be, 0x27be, 0x27d6, 0x27d6, 0x27ee, 0x2806, 0x2806, 0x281e, 0x2836, 0x2836, 0x2836, 0x2836, 0x284e, 0x2866, 0x2866, 0x2866,
0x2866, 0x287e, 0x2896, 0x28ae, 0x28c6, 0x28de, 0x28f6, 0x28f6, 0x28f6, 0x290e, 0x2926, 0x2958, 0x2978, 0x2990, 0x2990, 0x2990,
0x2990, 0x29a8, 0x29c0, 0x29d8,
};
static const uint16 kDoorTypeSrcData2[] = {
0x29f0, 0x2a08, 0x2a08, 0x2a20, 0x2a20, 0x2a20, 0x2a20, 0x2a20, 0x2a20, 0x2a38, 0x2a38, 0x2a38, 0x2a38, 0x2a50, 0x2a68, 0x2a80,
0x2a98, 0x2a98, 0x2a98, 0x2a98, 0x2a98, 0x2ab0, 0x2ac8, 0x2ae0, 0x2af8, 0x2af8, 0x2af8, 0x2af8, 0x2b10, 0x2b28, 0x2b28, 0x2b28,
0x2b28, 0x2b40, 0x2b58, 0x2b70, 0x2b88, 0x2ba0, 0x2bb8, 0x2bb8, 0x2bb8, 0x2bd0, 0x2be8, 0x2c1a, 0x2c3a, 0x2c52, 0x2c6a, 0x2c6a,
};
static const uint16 kDoorTypeSrcData3[] = {
0x2c6a, 0x2c82, 0x2c82, 0x2c9a, 0x2c9a, 0x2c9a, 0x2c9a, 0x2c9a, 0x2c9a, 0x2cb2, 0x2cb2, 0x2cb2, 0x2cb2, 0x2cca, 0x2ce2, 0x2cfa,
0x2cfa, 0x2cfa, 0x2cfa, 0x2cfa, 0x2cfa, 0x2d12, 0x2d12, 0x2d2a, 0x2d42, 0x2d42, 0x2d42, 0x2d42, 0x2d5a, 0x2d72, 0x2d72, 0x2d72,
0x2d72, 0x2d8a, 0x2da2, 0x2dba, 0x2dd2, 0x2dea, 0x2e02, 0x2e02, 0x2e02, 0x2e1a, 0x2e32, 0x2e32, 0x2e52, 0x2e6a, 0x2e6a, 0x2e6a,
};
static const uint16 kDoorTypeSrcData4[] = {
0x2e6a, 0x2e82, 0x2e82, 0x2e9a, 0x2e9a, 0x2e9a, 0x2e9a, 0x2e9a, 0x2e9a, 0x2eb2, 0x2eb2, 0x2eb2, 0x2eb2, 0x2eca, 0x2ee2, 0x2efa,
0x2efa, 0x2efa, 0x2efa, 0x2efa, 0x2efa, 0x2f12, 0x2f12, 0x2f2a, 0x2f42, 0x2f42, 0x2f42, 0x2f42, 0x2f5a, 0x2f72, 0x2f72, 0x2f72,
0x2f72, 0x2f8a, 0x2fa2, 0x2fba, 0x2fd2, 0x2fea, 0x3002, 0x3002, 0x3002, 0x301a, 0x3032, 0x3032, 0x3052, 0x306a, 0x306a,
};
static const uint16 kDoorPositionToTilemapOffs_Up[] = { 0x21c, 0x23c, 0x25c, 0x39c, 0x3bc, 0x3dc, 0x121c, 0x123c, 0x125c, 0x139c, 0x13bc, 0x13dc };
static const uint16 kDoorPositionToTilemapOffs_Down[] = { 0xd1c, 0xd3c, 0xd5c, 0xb9c, 0xbbc, 0xbdc, 0x1d1c, 0x1d3c, 0x1d5c, 0x1b9c, 0x1bbc, 0x1bdc };
static const uint16 kDoorPositionToTilemapOffs_Left[] = { 0x784, 0xf84, 0x1784, 0x78a, 0xf8a, 0x178a, 0x7c4, 0xfc4, 0x17c4, 0x7ca, 0xfca, 0x17ca };
static const uint16 kDoorPositionToTilemapOffs_Right[] = { 0x7b4, 0xfb4, 0x17b4, 0x7ae, 0xfae, 0x17ae, 0x7f4, 0xff4, 0x17f4, 0x7ee, 0xfee, 0x17ee };
static const int8 kSpiralTab1[] = { 0, 1, 1, -1, 1, 1, 1, 1 };
static const int8 kTeleportPitLevel1[] = { 0, 1, 1 };
static const int8 kTeleportPitLevel2[] = { 0, 0, 1 };
static const uint8 kDoorTypeRemap[] = {
0, 2, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 80, 0, 80, 80,
96, 98, 100, 102, 82, 90, 80, 82, 84, 86, 0, 80, 80, 0, 0, 0,
64, 88, 88, 0, 88, 88, 0, 0,
};
static const int8 kStaircaseTab2[] = {
12, 32, 48, 56, 72, -44, -40, -64, -64, -88, 12, 24, 40, 48, 64, -28,
-40, -56, -64, -80,
};
static const int8 kStaircaseTab3[] = { 4, -4, 4, -4 };
static const int8 kStaircaseTab4[] = { 52, 52, 59, 58 };
static const int8 kStaircaseTab5[] = { 32, -64, 32, -32 };
static const uint8 kMovingWall_Sizes0[4] = { 5, 7, 11, 15 };
static const uint8 kMovingWall_Sizes1[4] = { 8, 16, 24, 32 };
static const uint8 kWatergateLayout[17] = {
0x1b, 0xa1, 0xc9,
0x51, 0xa1, 0xc9,
0x92, 0xa1, 0xc9,
0xa1, 0x33, 0xc9,
0xa1, 0x72, 0xc9,
0xff, 0xff,
};
static const uint16 kChestOpenMasks[] = { 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000 };
const uint8 kLayoutQuadrantFlags[] = { 0xF, 0xF, 0xF, 0xF, 0xB, 0xB, 7, 7, 0xF, 0xB, 0xF, 7, 0xB, 0xF, 7, 0xF, 0xE, 0xD, 0xE, 0xD, 0xF, 0xF, 0xE, 0xD, 0xE, 0xD, 0xF, 0xF, 0xA, 9, 6, 5 };
static const uint8 kQuadrantVisitingFlags[] = { 8, 4, 2, 1, 0xC, 0xC, 3, 3, 0xA, 5, 0xA, 5, 0xF, 0xF, 0xF, 0xF };
#define XY(x, y) ((y)*64+(x))
static const uint8 kDungeon_MinigameChestPrizes1[8] = {
0x40, 0x41, 0x34, 0x42, 0x43, 0x44, 0x27, 0x17
};
static const uint8 kDungeon_RupeeChestMinigamePrizes[32] = {
0x47, 0x34, 0x46, 0x34, 0x46, 0x46, 0x34, 0x47, 0x46, 0x47, 0x34, 0x46, 0x47, 0x34, 0x46, 0x47,
0x34, 0x47, 0x41, 0x47, 0x41, 0x41, 0x47, 0x34, 0x41, 0x34, 0x47, 0x41, 0x34, 0x47, 0x41, 0x34,
};
static const int8 kDungeon_QueryIfTileLiftable_x[4] = { 7, 7, -3, 16 };
static const int8 kDungeon_QueryIfTileLiftable_y[4] = { 3, 24, 14, 14 };
static const uint16 kDungeon_QueryIfTileLiftable_rv[16] = { 0x5252, 0x5050, 0x5454, 0x0, 0x2323 };
static const uint16 kDoor_BlastWallUp_Dsts[] = { 0xd8a, 0xdaa, 0xdca, 0x2b6, 0xab6, 0x12b6 };
#define adjacent_doors_flags (*(uint16*)(g_ram+0x1100))
#define adjacent_doors ((uint16*)(g_ram+0x1110))
static const DungPalInfo kDungPalinfos[41] = {
{ 0, 0, 3, 1},
{ 2, 0, 3, 1},
{ 4, 0, 10, 1},
{ 6, 0, 1, 7},
{10, 2, 2, 7},
{ 4, 4, 3, 10},
{12, 5, 8, 20},
{14, 0, 3, 10},
{ 2, 0, 15, 20},
{10, 2, 0, 7},
{ 2, 0, 15, 12},
{ 6, 0, 6, 7},
{ 0, 0, 14, 18},
{18, 5, 5, 11},
{18, 0, 2, 12},
{16, 5, 10, 7},
{16, 0, 16, 12},
{22, 7, 2, 7},
{22, 0, 7, 15},
{ 8, 0, 4, 12},
{ 8, 0, 4, 9},
{ 4, 0, 3, 1},
{20, 0, 4, 4},
{20, 0, 20, 12},
{24, 5, 7, 11},
{24, 6, 16, 12},
{26, 5, 8, 20},
{26, 2, 0, 7},
{ 6, 0, 3, 10},
{28, 0, 3, 1},
{30, 0, 11, 17},
{ 4, 0, 11, 17},
{14, 0, 0, 2},
{32, 8, 19, 13},
{10, 0, 3, 10},
{20, 0, 4, 4},
{26, 2, 2, 7},
{26, 10, 0, 0},
{ 0, 0, 3, 2},
{14, 0, 3, 7},
{26, 5, 5, 11},
};
// these are not used by the code, but needed for the comparison with the real rom to work.
static const uint8 kDungeon_DrawObjectOffsets_BG1[33] = {
0, 0x20, 0x7e, 2, 0x20, 0x7e, 4, 0x20, 0x7e, 6, 0x20, 0x7e, 0x80, 0x20, 0x7e, 0x82,
0x20, 0x7e, 0x84, 0x20, 0x7e, 0x86, 0x20, 0x7e, 0, 0x21, 0x7e, 0x80, 0x21, 0x7e, 0, 0x22,
0x7e,
};
static const uint8 kDungeon_DrawObjectOffsets_BG2[33] = {
0, 0x40, 0x7e, 2, 0x40, 0x7e, 4, 0x40, 0x7e, 6, 0x40, 0x7e, 0x80, 0x40, 0x7e, 0x82,
0x40, 0x7e, 0x84, 0x40, 0x7e, 0x86, 0x40, 0x7e, 0, 0x41, 0x7e, 0x80, 0x41, 0x7e, 0, 0x42,
0x7e,
};
static const uint16 kUploadBgSrcs[] = { 0x0, 0x1000, 0x0, 0x40, 0x40, 0x1040, 0x1000, 0x1040, 0x1000, 0x0, 0x40, 0x0, 0x1040, 0x40, 0x1040, 0x1000 };
static const uint8 kUploadBgDsts[] = { 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 };
static const uint16 kTileAttrsByDoor[] = {
0x8080, 0x8484, 0x0, 0x101, 0x8484, 0x8e8e, 0x0, 0x0, 0x8888, 0x8e8e, 0x8080, 0x8080, 0x8282, 0x8080, 0x8080, 0x8080,
0x8080, 0x8080, 0x8080, 0x8080, 0x8282, 0x8e8e, 0x8080, 0x8282, 0x8080, 0x8080, 0x8080, 0x8282, 0x8282, 0x8080, 0x8080, 0x8080,
0x8484, 0x8484, 0x8686, 0x8888, 0x8686, 0x8686, 0x8080, 0x8080,
};
static PlayerHandlerFunc *const kDungeon_Effect_Handler[28] = {
&LayerEffect_Nothing,
&LayerEffect_Nothing,
&LayerEffect_Scroll,
&LayerEffect_WaterRapids,
&LayerEffect_Trinexx,
&LayerEffect_Agahnim2,
&LayerEffect_InvisibleFloor,
&LayerEffect_Ganon,
};
static const int16 kPushBlockMoveDistances[] = { -0x100, 0x100, -0x4, 0x4 };
static HandlerFuncK *const kDungTagroutines[] = {
&Dung_TagRoutine_0x00,
&RoomTag_NorthWestTrigger,
&Dung_TagRoutine_0x2A,
&Dung_TagRoutine_0x2B,
&Dung_TagRoutine_0x2C,
&Dung_TagRoutine_0x2D,
&Dung_TagRoutine_0x2E,
&Dung_TagRoutine_0x2F,
&Dung_TagRoutine_0x30,
&RoomTag_QuadrantTrigger,
&RoomTag_RoomTrigger,
&RoomTag_NorthWestTrigger,
&Dung_TagRoutine_0x2A,
&Dung_TagRoutine_0x2B,
&Dung_TagRoutine_0x2C,
&Dung_TagRoutine_0x2D,
&Dung_TagRoutine_0x2E,
&Dung_TagRoutine_0x2F,
&Dung_TagRoutine_0x30,
&RoomTag_QuadrantTrigger,
&RoomTag_RoomTrigger_BlockDoor,
&RoomTag_PrizeTriggerDoorDoor,
&RoomTag_SwitchTrigger_HoldDoor,
&RoomTag_SwitchTrigger_ToggleDoor,
&RoomTag_WaterOff,
&RoomTag_WaterOn,
&RoomTag_WaterGate,
&Dung_TagRoutine_0x1B,
&RoomTag_MovingWall_East,
&RoomTag_MovingWall_West,
&RoomTag_MovingWallTorchesCheck,
&RoomTag_MovingWallTorchesCheck,
&RoomTag_Switch_ExplodingWall,
&RoomTag_Holes0,
&RoomTag_ChestHoles0,
&Dung_TagRoutine_0x23,
&RoomTag_Holes2,
&RoomTag_GetHeartForPrize,
&RoomTag_KillRoomBlock,
&RoomTag_TriggerChest,
&RoomTag_PullSwitchExplodingWall,
&RoomTag_NorthWestTrigger,
&Dung_TagRoutine_0x2A,
&Dung_TagRoutine_0x2B,
&Dung_TagRoutine_0x2C,
&Dung_TagRoutine_0x2D,
&Dung_TagRoutine_0x2E,
&Dung_TagRoutine_0x2F,
&Dung_TagRoutine_0x30,
&RoomTag_QuadrantTrigger,
&RoomTag_RoomTrigger,
&RoomTag_TorchPuzzleDoor,
&Dung_TagRoutine_0x34,
&Dung_TagRoutine_0x35,
&Dung_TagRoutine_0x36,
&Dung_TagRoutine_0x37,
&RoomTag_Agahnim,
&Dung_TagRoutine_0x39,
&Dung_TagRoutine_0x3A,
&Dung_TagRoutine_0x3B,
&RoomTag_PushBlockForChest,
&RoomTag_GanonDoor,
&RoomTag_TorchPuzzleChest,
&RoomTag_RekillableBoss,
};
static const uint16 kDoorAnimUpSrc[] = { 0x306a, 0x306a, 0x3082, 0x309a, 0x30b2 };
static const uint16 kDoorAnimDownSrc[] = { 0x30b2, 0x30ca, 0x30e2, 0x30fa, 0x3112 };
static const uint16 kDoorAnimLeftSrc[] = { 0x3112, 0x312a, 0x3142, 0x315a, 0x3172 };
static const uint16 kDoorAnimRightSrc[] = { 0x3172, 0x318a, 0x31a2, 0x31ba, 0x31D2 };
static PlayerHandlerFunc *const kDungeon_IntraRoomTrans[8] = {
&DungeonTransition_Subtile_PrepTransition,
&DungeonTransition_Subtile_ApplyFilter,
&DungeonTransition_Subtile_ResetShutters,
&DungeonTransition_ScrollRoom,
&DungeonTransition_FindSubtileLanding,
&Dungeon_IntraRoomTrans_State5,
&DungeonTransition_Subtile_ApplyFilter,
&DungeonTransition_Subtile_TriggerShutters,
};
static PlayerHandlerFunc *const kDungeon_InterRoomTrans[16] = {
&Module07_02_00_InitializeTransition,
&Module07_02_01_LoadNextRoom,
&Module07_02_FadedFilter,
&Dungeon_InterRoomTrans_State3,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_State7,
&DungeonTransition_ScrollRoom,
&Dungeon_InterRoomTrans_State9,
&Dungeon_InterRoomTrans_State10,
&Dungeon_InterRoomTrans_State9,
&Dungeon_InterRoomTrans_State12,
&Dungeon_InterRoomTrans_State13,
&Module07_02_FadedFilter,
&Dungeon_InterRoomTrans_State15,
};
static PlayerHandlerFunc *const kDungeon_Submodule_7_DownFloorTrans[18] = {
&Module07_07_00_HandleMusicAndResetRoom,
&ApplyPaletteFilter_bounce,
&Dungeon_InitializeRoomFromSpecial,
&DungeonTransition_TriggerBGC34UpdateAndAdvance,
&DungeonTransition_TriggerBGC56UpdateAndAdvance,
&DungeonTransition_LoadSpriteGFX,
&Module07_07_06_SyncBG1and2,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_Staircase14,
&Module07_07_0F_FallingFadeIn,
&Module07_07_10_LandLinkFromFalling,
&Module07_07_11_CacheRoomAndSetMusic,
};
static PlayerHandlerFunc *const kWatergateFuncs[6] = {
&FloodDam_PrepTiles_init,
&Watergate_Main_State1,
&Watergate_Main_State1,
&Watergate_Main_State1,
&FloodDam_Expand,
&FloodDam_Fill,
};
static const int8 kSpiralStaircaseX[] = { -28, -28, 24, 24 };
static const int8 kSpiralStaircaseY[] = { 16, -10, -10, -32 };
static PlayerHandlerFunc *const kDungeon_SpiralStaircase[20] = {
&Module07_0E_00_InitPriorityAndScreens,
&Module07_0E_01_HandleMusicAndResetProps,
&Module07_0E_02_ApplyFilterIf,
&Dungeon_InitializeRoomFromSpecial,
&DungeonTransition_TriggerBGC34UpdateAndAdvance,
&DungeonTransition_TriggerBGC56UpdateAndAdvance,
&DungeonTransition_LoadSpriteGFX,
&Dungeon_SyncBackgroundsFromSpiralStairs,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_SpiralStaircase11,
&Dungeon_SpiralStaircase12,
&Dungeon_SpiralStaircase11,
&Dungeon_SpiralStaircase12,
&Dungeon_DoubleApplyAndIncrementGrayscale,
&Dungeon_AdvanceThenSetBossMusicUnorthodox,
&Dungeon_SpiralStaircase17,
&Dungeon_SpiralStaircase18,
&Module07_0E_13_SetRoomAndLayerAndCache,
};
static PlayerHandlerFunc *const kDungeon_Submodule_F[2] = {
&Module07_0F_00_InitSpotlight,
&Module07_0F_01_OperateSpotlight,
};
static PlayerHandlerFunc *const kDungeon_StraightStaircase[2] = {
&Module07_10_00_InitStairs,
&Module07_10_01_ClimbStairs,
};
static PlayerHandlerFunc *const kDungeon_StraightStaircaseDown[2] = {
&Module07_08_00_InitStairs,
&Module07_08_01_ClimbStairs,
};
static PlayerHandlerFunc *const kDungeon_StraightStairs[19] = {
&Module07_11_00_PrepAndReset,
&Module07_11_01_FadeOut,
&Module07_11_02_LoadAndPrepRoom,
&Module07_11_03_FilterAndLoadBGChars,
&Module07_11_04_FilterDoBGAndResetSprites,
&Dungeon_SpiralStaircase11,
&Dungeon_SpiralStaircase12,
&Dungeon_SpiralStaircase11,
&Dungeon_SpiralStaircase12,
&Module07_11_09_LoadSpriteGraphics,
&Module07_11_0A_ScrollCamera,
&Module07_11_0B_PrepDestination,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_DoubleApplyAndIncrementGrayscale,
&Module07_11_19_SetSongAndFilter,
&Module07_11_11_KeepSliding,
&ResetThenCacheRoomEntryProperties,
};
static PlayerHandlerFunc *const kDungeon_Teleport[15] = {
&ResetTransitionPropsAndAdvance_ResetInterface,
&Module07_15_01_ApplyMosaicAndFilter,
&Dungeon_InitializeRoomFromSpecial,
&DungeonTransition_LoadSpriteGFX,
&Module07_15_04_SyncRoomPropsAndBuildOverlay,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_InterRoomTrans_notDarkRoom,
&Dungeon_InterRoomTrans_State4,
&Dungeon_Staircase14,
&Module07_15_0E_FadeInFromWarp,
&Module07_15_0F_FinalizeAndCacheEntry,
};
static PlayerHandlerFunc *const kDungeonSubmodules[31] = {
&Module07_00_PlayerControl,
&Module07_01_SubtileTransition,
&Module07_02_SupertileTransition,
&Module07_03_OverlayChange,
&Module07_04_UnlockDoor,
&Module07_05_ControlShutters,
&Module07_06_FatInterRoomStairs,
&Module07_07_FallingTransition,
&Module07_08_NorthIntraRoomStairs,
&Module07_09_OpenCrackedDoor,
&Module07_0A_ChangeBrightness,
&Module07_0B_DrainSwampPool,
&Module07_0C_FloodSwampWater,
&Module07_0D_FloodDam,
&Module07_0E_SpiralStairs,
&Module07_0F_LandingWipe,
&Module07_10_SouthIntraRoomStairs,
&Module07_11_StraightInterroomStairs,
&Module07_11_StraightInterroomStairs,
&Module07_11_StraightInterroomStairs,
&Module07_14_RecoverFromFall,
&Module07_15_WarpPad,
&Module07_16_UpdatePegs,
&Module07_17_PressurePlate,
&Module07_18_RescuedMaiden,
&Module07_19_MirrorFade,
&Module07_1A_RoomDraw_OpenTriforceDoor_bounce,
};
const uint8 kDungAnimatedTiles[24] = {
0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5f, 0x5d, 0x5f, 0x5f, 0x5e, 0x5f, 0x5e, 0x5e, 0x5d,
0x5d, 0x5e, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d, 0x5d,
};
uint16 *DstoPtr(uint16 d) {
return (uint16 *)&(g_ram[dung_line_ptrs_row0 + d * 2]);
}
void Object_Fill_Nx1(int n, const uint16 *src, uint16 *dst) {
int t = src[0];
do *dst++ = t; while (--n);
}
void Object_Draw_5x4(const uint16 *src, uint16 *dst) {
int n = 5;
do {
dst[XY(0, 0)] = src[0];
dst[XY(1, 0)] = src[1];
dst[XY(2, 0)] = src[2];
dst[XY(3, 0)] = src[3];
dst += XY(0, 1), src += 4;
} while (--n);
}
void Object_Draw_4x2_BothBgs(const uint16 *src, uint16 dsto) {
dung_bg1[dsto + XY(0, 0)] = dung_bg2[dsto + XY(0, 0)] = src[0];
dung_bg1[dsto + XY(1, 0)] = dung_bg2[dsto + XY(1, 0)] = src[1];
dung_bg1[dsto + XY(2, 0)] = dung_bg2[dsto + XY(2, 0)] = src[2];
dung_bg1[dsto + XY(3, 0)] = dung_bg2[dsto + XY(3, 0)] = src[3];
dung_bg1[dsto + XY(0, 1)] = dung_bg2[dsto + XY(0, 1)] = src[4];
dung_bg1[dsto + XY(1, 1)] = dung_bg2[dsto + XY(1, 1)] = src[5];
dung_bg1[dsto + XY(2, 1)] = dung_bg2[dsto + XY(2, 1)] = src[6];
dung_bg1[dsto + XY(3, 1)] = dung_bg2[dsto + XY(3, 1)] = src[7];
}
void Object_ChestPlatform_Helper(const uint16 *src, int dsto) {
dung_bg2[dsto] = src[0];
int n = src[3];
for (int i = dung_draw_width_indicator; i--; dsto++)
dung_bg2[1 + dsto] = n;
dung_bg2[1 + dsto] = src[6];
dung_bg2[2 + dsto] = dung_bg2[3 + dsto] = dung_bg2[4 + dsto] = dung_bg2[5 + dsto] = src[9];
dung_bg2[6 + dsto] = src[12];
n = src[15];
for (int i = dung_draw_width_indicator; i--; dsto++)
dung_bg2[7 + dsto] = n;
dung_bg2[7 + dsto] = src[18];
}
void Object_Hole(const uint16 *src, uint16 *dst) {
Object_SizeAtoAplus15(4);
int w = dung_draw_width_indicator;
for (int i = 0; i < w; i++)
Object_Fill_Nx1(w, src, dst + XY(0, i));
// fill top/bottom
src = SrcPtr(0x63c);
dst[XY(0, 0)] = src[0];
Object_Fill_Nx1(w - 2, src + 1, dst + XY(1, 0));
dst[XY(w - 1, 0)] = src[2];
dst[XY(0, w - 1)] = src[3];
Object_Fill_Nx1(w - 2, src + 4, dst + XY(1, w - 1));
dst[XY(w - 1, w - 1)] = src[5];
// fill left/right edge
src = SrcPtr(0x648);
for (int i = 1; i < w - 1; i++) {
dst[XY(0, i)] = src[0];
dst[XY(w - 1, i)] = src[1];
}
}
// dsto is half the value of Y
void LoadType1ObjectSubtype1(uint8 idx, uint16 *dst, uint16 dsto) {
uint16 param1 = kObjectSubtype1Params[idx];
const uint16 *src = SrcPtr(param1);
int n;
switch (idx) {
case 0x0: // RoomDraw_Rightwards2x2_1to15or32 - Ceiling
case 0xb8: case 0xb9: // B8 - Blue Switch Block [L-R]
RoomDraw_GetObjectSize_1to15or32();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(2, 0);
} while (--dung_draw_width_indicator);
break;
case 0x1: case 0x2: // RoomDraw_Rightwards2x4_1to15or26 - [N]Wall Horz: [L-R]
case 0xb6: case 0xb7: // B6 - [N]Wall Decor: 1/2 [L-R]
RoomDraw_GetObjectSize_1to15or26();
do {
RoomDraw_Object_Nx4(2, src, dst), dst += XY(2, 0);
} while (--dung_draw_width_indicator);
break;
case 0x3: case 0x4: // RoomDraw_Rightwards2x4spaced4_1to16 - 03 - [N]Wall Horz: (LOW) [L-R]
RoomDraw_GetObjectSize_1to16();
do {
dung_bg1[dsto + XY(0, 0)] = dung_bg2[dsto + XY(0, 0)] = src[0];
dung_bg1[dsto + XY(0, 1)] = dung_bg2[dsto + XY(0, 1)] = src[1];
dung_bg1[dsto + XY(0, 2)] = dung_bg2[dsto + XY(0, 2)] = src[2];
dung_bg1[dsto + XY(0, 3)] = dung_bg2[dsto + XY(0, 3)] = src[3];
dung_bg1[dsto + XY(1, 0)] = dung_bg2[dsto + XY(1, 0)] = src[4];
dung_bg1[dsto + XY(1, 1)] = dung_bg2[dsto + XY(1, 1)] = src[5];
dung_bg1[dsto + XY(1, 2)] = dung_bg2[dsto + XY(1, 2)] = src[6];
dung_bg1[dsto + XY(1, 3)] = dung_bg2[dsto + XY(1, 3)] = src[7];
dsto += XY(2, 0);
} while (--dung_draw_width_indicator);
break;
case 0x5: case 0x6: // RoomDraw_Rightwards2x4spaced4_1to16_BothBG - 05 - [N]Wall Column [L-R]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Object_Nx4(2, src, dst), dst += XY(6, 0);
} while (--dung_draw_width_indicator);
break;
case 0x7: case 0x8: case 0x53: // RoomDraw_Rightwards2x2_1to16 - 07 - [N]Wall Pit [L-R]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(2, 0);
} while (--dung_draw_width_indicator);
break;
case 0x9: case 0x0c: case 0x0d: case 0x10: case 0x11: case 0x14: // 09 - / Wall Wood Bot (HIGH) [NW]
Object_SizeAtoAplus15(6);
do {
RoomDraw_DrawObject2x2and1(src, dst), dst += XY(1, -1);
} while (--dung_draw_width_indicator);
break;
case 0x0a: case 0x0b: case 0x0e: case 0x0f: case 0x12: case 0x13: // 12 - \ Wall Tile2 Bot (HIGH) [SW]
Object_SizeAtoAplus15(6);
do {
RoomDraw_DrawObject2x2and1(src, dst), dst += XY(1, 1);
} while (--dung_draw_width_indicator);
break;
case 0x15: case 0x18: case 0x19: case 0x1C: case 0x1D: case 0x20: // 15 - / Wall Tile Top (LOW)[NW]
Object_SizeAtoAplus15(6);
do {
dung_bg1[dsto + XY(0, 0)] = dung_bg2[dsto + XY(0, 0)] = src[0];
dung_bg1[dsto + XY(0, 1)] = dung_bg2[dsto + XY(0, 1)] = src[1];
dung_bg1[dsto + XY(0, 2)] = dung_bg2[dsto + XY(0, 2)] = src[2];
dung_bg1[dsto + XY(0, 3)] = dung_bg2[dsto + XY(0, 3)] = src[3];
dung_bg1[dsto + XY(0, 4)] = dung_bg2[dsto + XY(0, 4)] = src[4];
dsto -= 63;
} while (--dung_draw_width_indicator);
break;
case 0x16: case 0x17: case 0x1A: case 0x1B: case 0x1E: case 0x1F: // 16 - \ Wall Tile Top (LOW)[SW]
Object_SizeAtoAplus15(6);
do {
dung_bg1[dsto + XY(0, 0)] = dung_bg2[dsto + XY(0, 0)] = src[0];
dung_bg1[dsto + XY(0, 1)] = dung_bg2[dsto + XY(0, 1)] = src[1];
dung_bg1[dsto + XY(0, 2)] = dung_bg2[dsto + XY(0, 2)] = src[2];
dung_bg1[dsto + XY(0, 3)] = dung_bg2[dsto + XY(0, 3)] = src[3];
dung_bg1[dsto + XY(0, 4)] = dung_bg2[dsto + XY(0, 4)] = src[4];
dsto += 65;
} while (--dung_draw_width_indicator);
break;
case 0x21: // 21 - Mini Stairs [L-R]
dung_draw_width_indicator = (dung_draw_width_indicator << 2 | dung_draw_height_indicator) * 2 + 1;
RoomDraw_1x3_rightwards(2, src, dst), dst += XY(2, 0);
do {
RoomDraw_1x3_rightwards(1, src + 3, dst), dst += XY(1, 0);
} while (--dung_draw_width_indicator);
RoomDraw_1x3_rightwards(1, src + 6, dst);
break;
case 0x22: { // 22 - Horz: Rail Thin [L-R]
Object_SizeAtoAplus15(2);
if ((dst[0] & 0x3ff) != 0xe2)
dst[0] = src[0];
n = src[1];
do *++dst = n; while (--dung_draw_width_indicator);
dst[1] = src[2];
break;
}
case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: case 0x28:
case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: // 23 - Pit [N]Edge [L-R]
case 0x3f: case 0x40: case 0x41: case 0x42: case 0x43: case 0x44: // 3F - Water Edge [L-R]
case 0x45: case 0x46: case 0xb3: case 0xb4:
RoomDraw_GetObjectSize_1to16();
n = dst[0] & 0x3ff;
if (n != 0x1db && n != 0x1a6 && n != 0x1dd && n != 0x1fc)
dst[0] = src[0];
n = src[1];
do *++dst = n; while (--dung_draw_width_indicator);
dst[1] = src[2];
break;
case 0x2f: // 2F - Rail Wall [L-R]
Object_SizeAtoAplus15(10);
n = *src++;
if ((dst[0] & 0x3ff) != 0xe2) {
dst[XY(0, 0)] = src[0];
dst[XY(1, 0)] = src[1];
dst[XY(1, 1)] = dst[XY(0, 1)] = n;
dst += 2;
}
src += 2;
do {
dst[XY(0, 0)] = src[0];
dst[XY(0, 1)] = n;
} while (dst++, --dung_draw_width_indicator);
src++;
dst[XY(0, 0)] = src[0];
dst[XY(1, 0)] = src[1];
dst[XY(1, 1)] = dst[XY(0, 1)] = n;
break;
case 0x30: // 30 - Rail Wall [L-R]
Object_SizeAtoAplus15(10);
n = *src++;
if ((dst[XY(0, 1)] & 0x3ff) != 0xe2) {
dst[XY(0, 0)] = dst[XY(1, 0)] = n;
dst[XY(0, 1)] = src[0];
dst[XY(1, 1)] = src[1];
dst += 2;
}
src += 2;
do {
dst[XY(0, 0)] = n;
dst[XY(0, 1)] = src[0];
} while (dst++, --dung_draw_width_indicator);
src++;
dst[XY(0, 0)] = dst[XY(1, 0)] = n;
dst[XY(0, 1)] = src[0];
dst[XY(1, 1)] = src[1];
break;
case 0x31: case 0x32: // 31 - Unused -empty
case 0x35: case 0x54: case 0x57:case 0x58:case 0x59:case 0x5A:
break;
case 0x33: // 33 - Red Carpet Floor [L-R]
case 0xb2: case 0xba: // B2 - Floor? [L-R]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_4x4(src, dst), dst += XY(4, 0);
} while (--dung_draw_width_indicator);
break;
case 0x34: // 34 - Red Carpet Floor Trim [L-R]
Object_SizeAtoAplus15(4);
n = src[0];
do *dst++ = n; while (--dung_draw_width_indicator);
break;
case 0x36: case 0x37: // 36 - [N]Curtain [L-R]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_4x4(src, dst), dst += XY(6, 0);
} while (--dung_draw_width_indicator);
break;
case 0x38: // 38 - Statue [L-R]
src = (uint16 *)((uint8 *)src - param1 + 0xe26);
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_1x3_rightwards(2, src, dst), dst += XY(4, 0);
} while (--dung_draw_width_indicator);
break;
case 0x39: case 0x3d: // 39 - Column [L-R]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Object_Nx4(2, src, dst), dst += XY(6, 0);
} while (--dung_draw_width_indicator);
break;
case 0x3a: case 0x3b: // 3A - [N]Wall Decor: [L-R]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_1x3_rightwards(4, src, dst), dst += XY(8, 0);
} while (--dung_draw_width_indicator);
break;
case 0x3c: // 3C - Double Chair [L-R]
RoomDraw_GetObjectSize_1to16();
do {
const uint16 *src = SrcPtr(0x8ca);
RoomDraw_Rightwards2x2(src + 0, dst);
RoomDraw_Rightwards2x2(src + 4, dst + XY(0, 6));
dst += 4;
} while (--dung_draw_width_indicator);
break;
case 0x3e: case 0x4b: // 3E - [N]Wall Column [L-R]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(14, 0);
} while (--dung_draw_width_indicator);
break;
case 0x47: // 47 - Unused Waterfall [L-R]
RoomDraw_GetObjectSize_1to16();
dung_draw_width_indicator <<= 1;
dst = RoomDraw_DrawObject2x2and1(src, dst) + 1;
do {
RoomDraw_DrawObject2x2and1(src + 5, dst);
} while (dst++, --dung_draw_width_indicator);
RoomDraw_DrawObject2x2and1(src + 10, dst);
break;
case 0x48:
RoomDraw_GetObjectSize_1to16();
dung_draw_width_indicator <<= 1;
RoomDraw_1x3_rightwards(1, src, dst), dst += XY(1, 0);
do {
dst[XY(0, 0)] = src[3];
dst[XY(0, 1)] = src[4];
dst[XY(0, 2)] = src[5];
} while (dst++, --dung_draw_width_indicator);
RoomDraw_1x3_rightwards(1, src + 6, dst);
break;
case 0x49: case 0x4A: // RoomDraw_RightwardsFloorTile4x2_1to16 ; 49 - N/A
RoomDraw_GetObjectSize_1to16();
RoomDraw_Downwards4x2VariableSpacing(4, src, dst);
break;
case 0x4c: // 4C - Bar [L-R]
RoomDraw_GetObjectSize_1to16();
dung_draw_width_indicator <<= 1;
dst = RoomDraw_RightwardBarSegment(src, dst) + 1;
do {
dst = RoomDraw_RightwardBarSegment(src + 3, dst) + 1;
} while (--dung_draw_width_indicator);
dst = RoomDraw_RightwardBarSegment(src + 6, dst) + 1;
break;
case 0x4d: case 0x4e: case 0x4f: // 4C - Bar [L-R]
RoomDraw_GetObjectSize_1to16();
RoomDraw_Object_Nx4(1, src, dst), dst += XY(1, 0);
do {
RoomDraw_Object_Nx4(2, src + 4, dst), dst += XY(2, 0);
} while (--dung_draw_width_indicator);
RoomDraw_RightwardShelfEnd(src + 12, dst);
break;
case 0x50: // 50 - Cane Ride [L-R]
Object_SizeAtoAplus15(2);
n = src[0];
do *dst++ = n; while (--dung_draw_width_indicator);
break;
case 0x51: case 0x52: // 51 - [N]Canon Hole [L-R]
case 0x5B: case 0x5C:
RoomDraw_GetObjectSize_1to16();
RoomDraw_1x3_rightwards(2, src, dst), dst += XY(2, 0);
while (--dung_draw_width_indicator)
RoomDraw_1x3_rightwards(2, src + 6, dst), dst += XY(2, 0);
RoomDraw_1x3_rightwards(2, src + 12, dst);
break;
case 0x55: case 0x56: // 55 - [N]Wall Torches [L-R]
RoomDraw_GetObjectSize_1to16();
RoomDraw_Downwards4x2VariableSpacing(12, src, dst);
break;
case 0x5D: // 5D - Large Horz: Rail [L-R]
RoomDraw_GetObjectSize_1to16();
dung_draw_width_indicator++;
RoomDraw_1x3_rightwards(2, src, dst), dst += XY(2, 0);
do {
RoomDraw_RightwardBarSegment(src + 6, dst), dst += XY(1, 0);
} while (--dung_draw_width_indicator);
RoomDraw_1x3_rightwards(2, src + 9, dst);
break;
case 0x5E: // 5E - Block [L-R]
case 0xbb: // BB - N/A
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(4, 0);
} while (--dung_draw_width_indicator);
break;
case 0x5f: { // 5F - Long Horz: Rail [L-R]
Object_SizeAtoAplus15(21);
if ((dst[0] & 0x3ff) != 0xe2)
dst[0] = src[0];
n = src[1];
do *++dst = n; while (--dung_draw_width_indicator);
dst[1] = src[2];
break;
}
case 0x60: // 60 - Ceiling [U-D]
case 0x92: case 0x93: // 92 - Blue Peg Block [U-D]
RoomDraw_GetObjectSize_1to15or32();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(0, 2);
} while (--dung_draw_width_indicator);
break;
case 0x61: case 0x62: case 0x90: case 0x91: // 61 - [W]Wall Vert: [U-D]
RoomDraw_GetObjectSize_1to15or26();
RoomDraw_Downwards4x2VariableSpacing(2 * 64, src, dst);
break;
case 0x63:
case 0x64: // RoomDraw_Downwards4x2_1to16_BothBG - 63 - [W]Wall Vert: (LOW) [U-D]
RoomDraw_GetObjectSize_1to16();
do {
dung_bg1[dsto + XY(0, 0)] = dung_bg2[dsto + XY(0, 0)] = src[0];
dung_bg1[dsto + XY(1, 0)] = dung_bg2[dsto + XY(1, 0)] = src[1];
dung_bg1[dsto + XY(2, 0)] = dung_bg2[dsto + XY(2, 0)] = src[2];
dung_bg1[dsto + XY(3, 0)] = dung_bg2[dsto + XY(3, 0)] = src[3];
dung_bg1[dsto + XY(0, 1)] = dung_bg2[dsto + XY(0, 1)] = src[4];
dung_bg1[dsto + XY(1, 1)] = dung_bg2[dsto + XY(1, 1)] = src[5];
dung_bg1[dsto + XY(2, 1)] = dung_bg2[dsto + XY(2, 1)] = src[6];
dung_bg1[dsto + XY(3, 1)] = dung_bg2[dsto + XY(3, 1)] = src[7];
dsto += XY(0, 2);
} while (--dung_draw_width_indicator);
break;
case 0x65: case 0x66: // 65 - [W]Wall Column [U-D]
RoomDraw_GetObjectSize_1to16();
RoomDraw_Downwards4x2VariableSpacing(6 * 64, src, dst);
break;
case 0x67: case 0x68: // 67 - [W]Wall Pit [U-D]
case 0x7d: // 7D - Pipe Ride [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(0, 2);
} while (--dung_draw_width_indicator);
break;
case 0x69: // 69 - Vert: Rail Thin [U-D]
Object_SizeAtoAplus15(2);
if ((dst[0] & 0x3ff) != 0xe3)
dst[0] = src[0];
n = src[1];
do { dst += 64; *dst = n; } while (--dung_draw_width_indicator);
dst[64] = src[2];
break;
case 0x6a: case 0x6b: // 6A - [W]Pit Edge [U-D]
case 0x79: case 0x7a: // 79 - Water Edge [U-D]
case 0x8d: case 0x8e: // 8D - [W]Edge [U-D]
RoomDraw_GetObjectSize_1to16();
do {
dst[0] = src[0], dst += XY(0, 1);
} while (--dung_draw_width_indicator);
break;
case 0x6c: // 6C - [W]Rail Wall [U-D]
Object_SizeAtoAplus15(10);
n = *src++;
if ((dst[0] & 0x3ff) != 0xe3) {
dst[XY(0, 0)] = src[0];
dst[XY(0, 1)] = src[1];
dst[XY(1, 0)] = dst[XY(1, 1)] = n;
dst += XY(0, 2);
}
src += 2;
do {
dst[XY(0, 0)] = src[0];
dst[XY(1, 0)] = n;
dst += XY(0, 1);
} while (--dung_draw_width_indicator);
src += 1;
dst[XY(0, 0)] = src[0];
dst[XY(0, 1)] = src[1];
dst[XY(1, 0)] = dst[XY(1, 1)] = n;
break;
case 0x6d: // 6D - [E]Rail Wall [U-D]
Object_SizeAtoAplus15(10);
n = *src++;
if ((dst[XY(1, 0)] & 0x3ff) != 0xe3) {
dst[XY(0, 0)] = dst[XY(0, 1)] = n;
dst[XY(1, 0)] = src[0];
dst[XY(1, 1)] = src[1];
dst += XY(0, 2);
}
src += 2;
do {
dst[XY(0, 0)] = n;
dst[XY(1, 0)] = src[0];
dst += XY(0, 1);
} while (--dung_draw_width_indicator);
src += 1;
dst[XY(0, 0)] = dst[XY(0, 1)] = n;
dst[XY(1, 0)] = src[0];
dst[XY(1, 1)] = src[1];
break;
case 0x6e: case 0x6f: // unused
case 0x72: case 0x7e:
break;
case 0x70: case 0x94: // 70 - Red Floor/Wire Floor [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_4x4(src, dst), dst += XY(0, 4);
} while (--dung_draw_width_indicator);
break;
case 0x71: // 71 - Red Carpet Floor Trim [U-D]
Object_SizeAtoAplus15(4);
do {
*dst = src[0], dst += XY(0, 1);
} while (--dung_draw_width_indicator);
break;
case 0x73: case 0x74: // 73 - [W]Curtain [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_4x4(src, dst), dst += XY(0, 6);
} while (--dung_draw_width_indicator);
break;
case 0x75: case 0x87: // 75 - Column [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Object_Nx4(2, src, dst), dst += XY(0, 6);
} while (--dung_draw_width_indicator);
break;
case 0x76: case 0x77: // 76 - [W]Wall Decor: [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Object_Nx4(3, src, dst), dst += XY(0, 8);
} while (--dung_draw_width_indicator);
break;
case 0x78: case 0x7b: // 78 - [W]Wall Top Column [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(0, 14);
} while (--dung_draw_width_indicator);
break;
case 0x7c: // 7C - Cane Ride [U-D]
RoomDraw_GetObjectSize_1to16();
dung_draw_width_indicator += 1;
do {
dst[0] = src[0], dst += XY(0, 1);
} while (--dung_draw_width_indicator);
break;
case 0x7f: case 0x80: // 7F - [W]Wall Torches [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Object_Nx4(2, src, dst), dst += XY(0, 12);
} while (--dung_draw_width_indicator);
break;
case 0x81: case 0x82: case 0x83: case 0x84: // 81 - [W]Wall Decor: [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Object_Nx4(3, src, dst), dst += XY(0, 6);
} while (--dung_draw_width_indicator);
break;
case 0x85: case 0x86: // 85 - [W]Wall Canon Hole [U-D]
RoomDraw_GetObjectSize_1to16();
Object_Draw_3x2(src, dst), dst += XY(0, 2);
while (--dung_draw_width_indicator)
Object_Draw_3x2(src + 6, dst), dst += XY(0, 2);
Object_Draw_3x2(src + 12, dst);
break;
case 0x88: // 88 - Large Vert: Rail [U-D]
RoomDraw_GetObjectSize_1to16();
RoomDraw_Rightwards2x2(src, dst), dst += XY(0, 2), src += 4;
do {
dst[XY(0, 0)] = src[0];
dst[XY(1, 0)] = src[1];
dst += XY(0, 1);
} while (--dung_draw_width_indicator);
RoomDraw_1x3_rightwards(2, src + 2, dst);
break;
case 0x89: // 89 - Block Vert: [U-D]
RoomDraw_GetObjectSize_1to16();
do {
RoomDraw_Rightwards2x2(src, dst), dst += XY(0, 4);
} while (--dung_draw_width_indicator);
break;
case 0x8a: // 8A - Long Vert: Rail [U-D]
Object_SizeAtoAplus15(21);
if ((dst[0] & 0x3ff) != 0xe3)
dst[0] = src[0];
n = src[1];
do { dst += XY(0, 1); *dst = n; } while (--dung_draw_width_indicator);
dst[XY(0, 1)] = src[2];
break;
case 0x8b: case 0x8c: // 8B - [W]Vert: Jump Edge [U-D]
Object_SizeAtoAplus15(8);
do {
dst[0] = src[0], dst += XY(0, 1);
} while (--dung_draw_width_indicator);