-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZSCustomOverworld.asm
2488 lines (1831 loc) · 68 KB
/
ZSCustomOverworld.asm
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
; ==============================================================================
; Hooks
; ==============================================================================
AnimatedTileGFXSet = $0FC0
org $008913
Sound_LoadLightWorldSongBank:
org $00D394
DecompOwAnimatedTiles:
org $00D4DB
GetAnimatedSpriteTile:
org $00D4ED
GetAnimatedSpriteTile_variable:
org $00DF4F
Do3To4High16Bit:
org $00E19B
InitTilesets:
org $00E556
CopyFontToVram:
org $02ABBE
Overworld_FinishTransGfx_firstHalf:
org $02AF19
Overworld_LoadSubscreenAndSilenceSFX1:
org $02FD0D
LoadSubscreenOverlay:
org $099EFC
Tagalong_Init:
org $09AF89
Sprite_ReinitWarpVortex:
org $09C44E
Sprite_ResetAll:
org $09C499
Sprite_OverworldReloadAll:
org $0ED5A8
Overworld_LoadPalettes:
org $0ED618
Palette_SetOwBgColor_Long:
org $0ED6DD
LoadGearPalettes_bunny:
org $1BEC77
Palette_SpriteAux3:
org $1BEC9E
Palette_MainSpr:
org $1BECC5
Palette_SpriteAux1:
org $1BECE4
Palette_SpriteAux2:
org $1BED03
Palette_Sword:
org $1BED29
Palette_Shield:
org $1BED6E
Palette_MiscSpr:
org $1BEDF9
Palette_ArmorAndGloves:
org $1BEE52
Palette_Hud:
org $1BEEC7
Palette_OverworldBgMain:
; ==============================================================================
; Fixing old hooks:
; ==============================================================================
; Loads the transparent color under some load conditions
org $0BFEB6
STA.l $7EC500
; Main Palette loading routine.
org $0ED5E7
JSL $1BEEA8 ;Palette_OverworldBgAux3
; After leaving special areas like Zora's and the Master Sword area.
org $02E94A
JSL $0ED5A8 ; Overworld_LoadPalettes
; ==============================================================================
; Custom Functions and Data
; ==============================================================================
; Reserved ZS space.
; Avoid moving this at all costs. If you do, you will have to change where ZS
; saves this data as well and previous data will be lost or corrupted.
org $288000 ; $140000
Pool:
{
.BGColorTable ; 0x140
; Valid values:
; 555 color value $0000 to $7FFF.
; LW
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
dw $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E, $1D8E
; DW
dw $0000, $2107, $2107, $2107, $2107, $2107, $2107, $2107
dw $2107, $2107, $2107, $2107, $2107, $2107, $2107, $2107
dw $2107, $2107, $2107, $2107, $2107, $2107, $2107, $2107
dw $2107, $2107, $2107, $2107, $2107, $2107, $2107, $2107
dw $2107, $2107, $2107, $2107, $2107, $2107, $2107, $2107
dw $2107, $2107, $2107, $2107, $2107, $2107, $2107, $2107
dw $2107, $2107, $2107, $2107, $2107, $2107, $2107, $2107
dw $2107, $2107, $2107, $2107, $2107, $2107, $2107, $2107
; SW
dw $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6
dw $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6
dw $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6
dw $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6, $19C6
warnpc $288140
; ZS is weird with SW areas, so we are marking the bridge one specifically so we can find it later.
org $288128
.BGColorTable_Bridge
org $288140 ; $140140
.EnableTable ; 0x20
; Valid values:
; $00 - Disabled
; $FF - Enabled
org $288140 ; $140140
.EnableBGColor
db $01
org $288141 ; $140141
.EnableMainPalette
db $01
org $288142 ; $140142
.EnableMosaic ; Unused for now.
db $FF
org $288143 ; $140143
.EnableAnimated
db $01
org $288144 ; $140144
.EnableSubScreenOverlay
db $FF
; This is a reserved value that ZS will write to when it has applied the ASM.
; That way the next time ZS loads the ROM it knows to read the custom values
; instead of using the default ones.
org $288145 ; $140145
.ZSAppliedASM
db $FF
; When non 0 this will cause rain to appear on all areas in the beginning phase.
; Default is $FF
org $288146 ; $140146
.EnableBeginningRain
db $00
; When non 0 this will disable the ambiant sound that plays in the mire area after the event is triggered.
; Default is $FF
org $288147 ; $140147
.EnableRainMireEvent
db $00
; The rest of these are extra bytes that can be used for anything else later on.
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
warnpc $288160
org $288160 ; $140160
.MainPaletteTable ; 0xA0
; Valid values:
; Main overworld palette index $00 to $05.
; $00 is the normal light world palette.
; $01 is the normal dark world palette.
; $02 is the normal light world death mountain palette.
; $03 is the normal dark world death mountain palette.
; $04 is the Triforce room palette.
; $05 is the title screen palette?
; LW
db $00, $00, $00, $02, $00, $02, $00, $02
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
; DW
db $01, $01, $01, $03, $01, $03, $01, $03
db $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01
db $01, $01, $01, $01, $01, $01, $01, $01
; SW
db $00, $00, $00, $00, $00, $00, $00, $00
db $04, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
warnpc $288200
org $288200 ; $140200
.MosaicTable ; 0xA0
; Valid values:
; $01 to enable mosaic, $00 to disable.
; LW
db $01, $00, $00, $01, $00, $00, $00, $00
db $00, $00, $00, $01, $00, $00, $01, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $01, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $01, $01, $01, $01, $01, $00, $00
db $00, $00, $00, $00, $01, $01, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
; DW
db $01, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
; SW
db $01, $01, $00, $00, $00, $00, $00, $00
db $01, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00
warnpc $2882A0
org $2882A0 ; $1402A0
.AnimatedTable ; 0xA0
; Valid values:
; GFX index $00 to $FF.
; In vanilla, $59 are the clouds and $5B are the regular water tiles.
; LW
db $5B, $5B, $5B, $59, $5B, $59, $5B, $59
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
; DW
db $5B, $5B, $5B, $59, $5B, $59, $5B, $59
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
; SW
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
db $5B, $5B, $5B, $5B, $5B, $5B, $5B, $5B
warnpc $288340
org $288340 ; $140340
.OverlayTable ; 0x140
; Valid values:
; Can be any value $00 to $FF but is stored as 2 bytes instead of one to help the code out below.
; $FF is for no overlay area.
; Hopefully no crazy person decides to expand their overworld to $FF areas.
; $0093 is the triforce room curtain overlay.
; $0094 is the under the bridge overlay.
; $0095 is the sky background overlay.
; $0096 is the pyramid background overlay.
; $0097 is the first fog overlay.
; $009C is the lava background overlay.
; $009D is the second fog overlay.
; $009E is the tree canopy overlay.
; $009F is the rain overlay.
;LW
dw $009E, $00FF, $00FF, $009F, $009F, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $009F, $009F, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $009F, $009F, $009D, $009D, $009D, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $009D, $009D, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $009D, $00FF, $00FF, $00FF
;DW
dw $0096, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
;SP
dw $0097, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $0093, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
dw $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF, $00FF
warnpc $288480
}
; Debug addresses
; $00D8D5 ; W7 Animated tiles on warp.
!Func00D8D5 = $01
; $00DA63 ; W8 Enable/Disable subscreen.
!Func00DA63 = $01
; $00EEBB ; Zeros out the BG color when mirror warping to the pyramid area.
!Func00EEBB = $01
; $00FF7C ; W9 BG scrolling for HC and the pyramid area.
!Func00FF7C = $01
; $028027
; $029C0C
; $029D1E
; $029F82
; $0283EE ; E2 ; Changes the function that loads overworld properties when exiting a dungeon. Includes removing asm that plays music in certain areas and changing how animated tiles are loaded.
!Func0283EE = $01
; $028632 ; Changes a function that loads animated tiles under certain conditions.
!Func028632 = $01
; $029AA6 ; E1 ; Changes part of a function that changes the special BG color when leaving dungeons? not sure.
!Func029AA6 = $01
; $02AF58 ; T2 S2 W2 Main subscreen loading function.
!Func02AF58 = $01
; $02B2D4 ; W1 turns on subscreen for pyramid.
!Func02B2D4 = $01
; $02B3A1 ; W6 Activate subscreen durring pyramid warp.
!Func02B3A1 = $01
; $02BC44 ; Controls overworld vertical subscreen movement for the pyramid BG.
!Func02BC44 = $01
; $02C02D ; T4 Changes how the pyramid BG scrolls durring transition.
!Func02C02D = $01
; $02C692 ; W3 Main palette loading routine.
!Func02C692 = $01
; $02A4CD ; Rain animation code.
!Func02A4CD = $01
; $02AADB ; T1 Mosaic
!Func02AADB = $01
; $02ABB8 ; T3 transition animated and main palette.
!Func02ABB8 = $01
; $0ABC5A ; Loads the animated tiles after the overworld map is closed.
!Func0ABC5A = $01
; $0AB8F5 ; Loads different animated tiles when returning from bird travel.
!Func0AB8F5 = $01
; $0BFEC6 ; W5 Load overlay, fixed color, and BG color.
!Func0BFEC6 = $01
; $0ED627 ; S1 W4 Transparent color durring warp and during special area enter.
!Func0ED627 = $01
; $0ED8AE ; Resets the area special color after the screen flashes.
!Func0ED8AE = $01
; Start of expanded space.
org $288480 ; $140480
pushpc
; ==============================================================================
if !Func00D8D5 = 1
; Replaces a function that decompresses animated tiles in certain mirror warp conditions.
org $00D8D5 ; $0058D5
Func00D8D5:
{
PHX
; Load the animated tiles the area needs.
LDX.b $8A
; Do a 00 check just in case the data isn't present we don't get at crash.
LDA.l Pool_AnimatedTable, X : BNE .notZero
; $5B is the defualt flower/water animated tiles value.
LDA.b #$5B
.notZero
; The decompression function increases it by 1 so subtract 1 here.
DEC : TAY
PLX
JSL DecompOwAnimatedTiles
RTL
}
warnpc $00D8EE
else
; Undo the function above:
org $00D8D5 ; $0058D5
db $A0, $58, $A5, $8A, $29, $BF, $C9, $03
db $F0, $0A, $C9, $05, $F0, $06, $C9, $07
db $F0, $02, $A0, $5A, $22, $94, $D3, $00
db $6B
endif
; ==============================================================================
if !Func00DA63 = 1
; Sets the $1D Sub Screen Designation to either enable or disable BG for screens with special overlays.
org $00DA63 ; $005A63
Func00DA63:
{
JSL ActivateSubScreen
; From this point on it is the vanilla function.
PHB : PHK : PLB
LDA.l $00D8F4, X : TAY
LDA.w $D1B1, Y : STA.b $00
LDA.w $D0D2, Y : STA.b $01
LDA.w $CFF3, Y : STA.b $02
STA.b $05
PLB
REP #$31 ; Set A, X, and Y in 16bit mode. +1 no idea
; Source address is determined above, number of tiles is 0x0040, base target address is $7F0000
LDX.w #$0000
LDY.w #$0040
LDA.b $00
JSR Do3To4High16Bit
SEP #$30 ; Set A, X, and Y in 8bit mode.
RTL
}
warnpc $00DABB
else
; Undo the function above:
org $00DA63 ; $005A63
db $64, $1D, $A5, $8A, $F0, $24, $C9, $70
db $F0, $20, $C9, $40, $F0, $1C, $C9, $5B
db $F0, $18, $C9, $03, $F0, $14, $C9, $05
db $F0, $10, $C9, $07, $F0, $0C, $C9, $43
db $F0, $08, $C9, $45, $F0, $04, $C9, $47
db $D0, $04, $A9, $01, $85, $1D, $8B, $4B
db $AB, $BF, $F4, $D8, $00, $A8, $B9, $B1
db $D1, $85, $00, $B9, $D2, $D0, $85, $01
db $B9, $F3, $CF, $85, $02, $85, $05, $AB
db $C2, $31, $A2, $00, $00, $A0, $40, $00
db $A5, $00, $20, $4F, $DF, $E2, $30, $6B
endif
pullpc
ActivateSubScreen:
{
STZ.b $1D
PHX
REP #$20 ; Set A in 16bit mode
LDA.b $8A : BNE .notForest
; Check if we have the master sword.
LDA.l $7EF300 : AND.w #$0040 : BEQ .notForest
; The forest canopy overlay
BRA .turnOn
.notForest
; Check if we need to disable the rain in the misery mire.
LDA.l Pool_EnableRainMireEvent : BEQ .notMire
LDA.b $8A : CMP.w #$0070 : BNE .notMire
; Has Misery Mire been triggered yet?
LDA.l $7EF2F0 : AND.w #$0020 : BNE .notMire
BRA .turnOn
.notMire
; Check if we are in the beginning phase, if not, no rain.
; If $7EF3C5 >= 0x02
LDA.l $7EF3C5 : AND.w #$00FF : CMP.w #$0002 : BCS .noRain
BRA .turnOn
.noRain
; Get the overlay value for this overworld area
LDA.b $8A : ASL : TAX
LDA.l Pool_OverlayTable, X : CMP.w #$00FF : BEQ .normal
; If not $FF, assume we want an overlay.
.turnOn
SEP #$20 ; Set A in 8bit mode
; Turn on BG1.
LDA.b #$01 : STA.b $1D
.normal
SEP #$20 ; Set A in 8bit mode
PLX
RTL
}
pushpc
; ==============================================================================
if !Func00EEBB = 1
; Zeros out the BG color when mirror warping to the pyramid area.
org $00EEBB ; $006EBB
Func00EEBB:
{
; TODO: Probably not needed.
; Check if we are warping to an area with the pyramid BG.
LDA.b $8A : ASL : TAX
LDA.l Pool_OverlayTable, X : CMP.w #$0096 : BNE .notHyruleCastle
; This is annoying but I just needed a little bit of extra space.
JSL EraseBGColors
.notHyruleCastle
SEP #$20 ; Set A in 8bit mode
LDA.b #$08 : STA.w $06BB
STZ.w $06BA
RTL
}
warnpc $00EEE0
else
; Undo the function above:
org $00EEBB ; $006EBB
db $A5, $8A, $C9, $1B, $00, $D0, $13, $A9
db $00, $00, $8F, $00, $C3, $7E, $8F, $40
db $C3, $7E, $8F, $00, $C5, $7E, $8F, $40
db $C5, $7E, $E2, $20, $A9, $08, $8D, $BB
db $06, $9C, $BA, $06, $6B
endif
pullpc
EraseBGColors:
{
LDA.w #$0000 : STA.l $7EC300 : STA.l $7EC340 : STA.l $7EC500 : STA.l $7EC540
RTL
}
pushpc
; ==============================================================================
if !Func00FF7C = 1
; Controls the BG scrolling for HC and the pyramid area.
org $00FF7C ; $007F7C
Func00FF7C:
{
LDA.w $1C80 : ORA.w $1C90 : ORA.w $1CA0 : ORA.w $1CB0 : CMP.b $E2 : BNE .BRANCH_DELTA
SEP #$30 ; Set A, X, and Y in 8bit mode.
STZ.b $9B
INC.b $B0
JSL $0BFE70 ; $05FE70 IN ROM
REP #$30 ; Set A, X, and Y in 16bit mode.
; Check if we are warping to an area with the pyramid BG.
LDA.b $8A : ASL : TAX
LDA.l Pool_OverlayTable, X : CMP.w #$0096 : BEQ .dont_align_bgs
LDA.b $E2 : STA.b $E0 : STA.w $0120 : STA.w $011E
LDA.b $E8 : STA.b $E6 : STA.w $0122 : STA.w $0124
.dont_align_bgs
.BRANCH_DELTA
SEP #$30 ; Set A, X, and Y in 8bit mode.
RTL
}
warnpc $00FFC0 ; This end point also uses up a null block at the end of the function.
else
; Undo the function above:
org $00FF7C ; $007F7C
db $AD, $80, $1C, $0D, $90, $1C, $0D, $A0
db $1C, $0D, $B0, $1C, $C5, $E2, $D0, $28
db $E2, $20, $64, $9B, $E6, $B0, $22, $70
db $FE, $0B, $A5, $8A, $29, $3F, $C9, $1B
db $F0, $16, $C2, $20, $A5, $E2, $85, $E0
db $8D, $20, $01, $8D, $1E, $01, $A5, $E8
db $85, $E6, $8D, $22, $01, $8D, $24, $01
db $E2, $30, $6B, $FF, $FF, $FF, $FF, $FF
db $FF, $FF, $FF, $FF
endif
; ==============================================================================
if !Func0283EE = 1
; Replaces a bunch of calls to a shared function.
; Intro_SetupScreen:
org $028027 ; $010027
JSR PreOverworld_LoadProperties_LoadMain_LoadMusicIfNeeded
warnpc $02802A
; Dungeon_LoadSongBankIfNeeded:
org $029C0C ; $011C0C
JMP PreOverworld_LoadProperties_LoadMain_LoadMusicIfNeeded
warnpc $029C0F
; Mirror_LoadMusic:
org $029D1E ; $011D1E
JSR PreOverworld_LoadProperties_LoadMain_LoadMusicIfNeeded
warnpc $029D21
; GanonEmerges_LOadPyramidArea:
org $029F82 ; $011F82
JSR PreOverworld_LoadProperties_LoadMain_LoadMusicIfNeeded
warnpc $029F85
; Changes the function that loads overworld properties when exiting a dungeon.
; Includes removing asm that plays music in certain areas and changing how animated tiles are loaded.
; TODO: May need to add other funtionality here as well.
org $0283EE ; $0103EE
PreOverworld_LoadProperties_LoadMain:
{
LDX.b #$F3
; If the volume was set to half, set it back to full.
LDA.w $0132 : CMP.b #$F2 : BEQ .setToFull
; If we're in the dark world
; If area number is < 0x40 or >= 80 we are not in the dark world.
LDA.b $8A : CMP.b #$40 : BCC .setNormalSong
CMP.b #$80 : BCS .setNormalSong
; Does Link have a moon pearl?
LDA.l $7EF357 : BNE .setNormalSong
; If not, play the music that plays when you're a bunny in the Dark World.
LDX.b #$04
BRA .setToFull
.setNormalSong
LDX.b $8A
LDA.l $7F5B00, X : AND.b #$0F : TAX
.setToFull
; The value written here will take effect during NMI.
STX.w $0132
; Set the ambient sound.
;LDX.b $8A
;LDA.l $7F5B00, X : LSR #4 : STA.w $012D
; Load the animated tiles the area needs.
LDX.b $8A
; Do a 00 check just in case the data isn't present we don't get at crash.
LDA.l Pool_AnimatedTable, X : BNE .notZero
; $5B is the defualt flower/water animated tiles value.
LDA.b #$5B
.notZero
; The decompression function increases it by 1 so subtract 1 here.
DEC : TAY
JSL DecompOwAnimatedTiles ; $5394 IN ROM
JSL InitTilesets ; $619B IN ROM; Decompress all other graphics
JSR Overworld_LoadAreaPalettes ; $014692 IN ROM; Load palettes for overworld
LDX.b $8A
LDA.l $7EFD40, X : STA.b $00
LDA.l $00FD1C, X
JSL Overworld_LoadPalettes ; $0755A8 IN ROM; Load some other palettes
JSL Palette_SetOwBgColor_Long ; $075618 IN ROM; Sets the background color (changes depending on area)
LDA.b $10 : CMP.b #$08 : BNE .specialArea2
; $01465F IN ROM; Copies $7EC300[0x200] to $7EC500[0x200]
JSR $C65F
BRA .normalArea2
.specialArea2
; apparently special overworld handles palettes a bit differently?
JSR $C6EB ; $0146EB IN ROM
.normalArea2
JSL $0BFE70 ; $05FE70 IN ROM; Sets fixed colors and scroll values
; Something fixed color related
LDA.b #$00 : STA.l $7EC017
; Sets up properties in the event a tagalong shows up
JSL Tagalong_Init
; TODO: investigate this.
LDA.b $8A : AND.b #$3F : BNE .notForestArea
LDA.b #$1E
JSL GetAnimatedSpriteTile_variable
.notForestArea
LDA.b #$09 : STA.w $010C
JSL Sprite_OverworldReloadAll ;09C499
; Are we in the dark world? If so, there's no warp vortex there.
LDA.b $8A : AND.b #$40 : BNE .noWarpVortex
JSL Sprite_ReinitWarpVortex ; $04AF89 IN ROM
.noWarpVortex
; Check if Blind disguised as a crystal maiden was following us when
; we left the dungeon area
LDA.l $7EF3CC : CMP.b #$06 : BNE .notBlindGirl
; If it is Blind, kill her!
LDA.b #$00 : STA.l $7EF3CC
.notBlindGirl
STZ.b $6C
STZ.b $3A
STZ.b $3C
STZ.b $50
STZ.b $5E
STZ.w $0351
; Reinitialize many of Link's gameplay variables
JSR $8B0C ; $010B0C IN ROM
LDA.l $7EF357 : BNE .notBunny
LDA.l $7EF3CA : BEQ .notBunny
LDA.b #$01 : STA.w $02E0 : STA.b $56
LDA.b #$17 : STA.b $5D
JSL LoadGearPalettes_bunny
.notBunny
; Set screen to mode 1 with BG3 priority.
LDA.b #$09 : STA.b $94
LDA.b #$00 : STA.l $7EC005
STZ.w $046C
STZ.b $EE
STZ.w $0476
INC.b $11
INC.b $16
STZ.w $0402 : STZ.w $0403
; Alternate entry point.
.LoadMusicIfNeeded
LDA.w $0136 : BEQ .no_music_load_needed
SEI
; Shut down NMI until music loads
STZ.w $4200
; Stop all HDMA
STZ.w $420C
STZ.w $0136
LDA.b #$FF : STA.w $2140
JSL Sound_LoadLightWorldSongBank
; Re-enable NMI and joypad
LDA.b #$81 : STA.w $4200
.no_music_load_needed
; PLACE CUSTOM GFX LOAD HERE!
JSL CheckForChangeGraphicsNormalLoadCastle
RTS
}
warnpc $02856A ; $01056A
else
; Undo the function above:
org $028027 ; $010027
db $20, $4C, $85
org $029C0C ; $011C0C
db $4C, $4C, $85
org $029D1E ; $011D1E
db $20, $4C, $85
org $029F82 ; $011F82
db $20, $4C, $85
org $0283EE ; $0103EE
db $A0, $58, $A2, $02, $A5, $8A, $C9, $03
db $F0, $6F, $C9, $05, $F0, $6B, $C9, $07
db $F0, $67, $A2, $09, $A5, $8A, $C9, $43
db $F0, $5F, $C9, $45, $F0, $5B, $C9, $47
db $F0, $57, $A0, $5A, $A5, $8A, $C9, $40
db $B0, $3A, $A2, $07, $AF, $C5, $F3, $7E
db $C9, $03, $90, $02, $A2, $02, $A5, $A0
db $C9, $E3, $F0, $3D, $C9, $18, $F0, $39
db $C9, $2F, $F0, $35, $A5, $A0, $C9, $1F
db $D0, $06, $A5, $8A, $C9, $18, $F0, $29
db $A2, $05, $AF, $00, $F3, $7E, $29, $40
db $F0, $02, $A2, $02, $A5, $A0, $F0, $19
db $C9, $E1, $F0, $15, $A2, $F3, $AD, $32
db $01, $C9, $F2, $F0, $30, $A2, $02, $AF
db $C5, $F3, $7E, $C9, $02, $B0, $02, $A2
db $03, $AF, $CA, $F3, $7E, $F0, $1E, $A2
db $0D, $A5, $8A, $C9, $40, $F0, $0E, $C9
db $43, $F0, $0A, $C9, $45, $F0, $06, $C9
db $47, $F0, $02, $A2, $09, $AF, $57, $F3
db $7E, $D0, $02, $A2, $04, $8E, $32, $01
db $22, $94, $D3, $00, $22, $9B, $E1, $00
db $20, $92, $C6, $A6, $8A, $BF, $40, $FD
db $7E, $85, $00, $BF, $1C, $FD, $00, $22
db $A8, $D5, $0E, $22, $18, $D6, $0E, $A5
db $10, $C9, $08, $D0, $05, $20, $5F, $C6
db $80, $03, $20, $EB, $C6, $22, $70, $FE
db $0B, $A9, $00, $8F, $17, $C0, $7E, $22
db $FC, $9E, $09, $A5, $8A, $29, $3F, $D0
db $06, $A9, $1E, $22, $ED, $D4, $00, $A9
db $09, $8D, $0C, $01, $22, $99, $C4, $09
db $A5, $8A, $29, $40, $D0, $04, $22, $89
db $AF, $09, $A2, $05, $AF, $C5, $F3, $7E
db $C9, $02, $B0, $02, $A2, $01, $8E, $2D
db $01, $AF, $CC, $F3, $7E, $C9, $06, $D0
db $06, $A9, $00, $8F, $CC, $F3, $7E, $64
db $6C, $64, $3A, $64, $3C, $64, $50, $64
db $5E, $9C, $51, $03, $20, $0C, $8B, $AF
db $57, $F3, $7E, $D0, $15, $AF, $CA, $F3
db $7E, $F0, $0F, $A9, $01, $8D, $E0, $02
db $85, $56, $A9, $17, $85, $5D, $22, $DD
db $D6, $0E, $A9, $09, $85, $94, $A9, $00
db $8F, $05, $C0, $7E, $9C, $6C, $04, $64
db $EE, $9C, $76, $04, $E6, $11, $E6, $16
db $9C, $02, $04, $9C, $03, $04, $AD, $36
db $01, $F0, $18, $78, $9C, $00, $42, $9C
db $0C, $42, $9C, $36, $01, $A9, $FF, $8D
db $40, $21, $22, $13, $89, $00, $A9, $81
db $8D, $00, $42, $60
endif
; ==============================================================================
if !Func028632 = 1
; Changes a function that loads animated tiles under certain conditions.
org $028632 ; $010632
Func028632:
{
; Load the animated tiles the area needs.
LDX.b $8A
; Do a 00 check just in case the data isn't present we don't get at crash.
LDA.l Pool_AnimatedTable, X : BNE .notZero
; $5B is the defualt flower/water animated tiles value.
LDA.b #$5B
.notZero
; The decompression function increases it by 1 so subtract 1 here.
DEC : TAY
JSL DecompOwAnimatedTiles ; $5394 IN ROM
LDA.b $11 : LSR A : TAX
LDA.l $0285E2, X : STA.w $0AA3
LDA.l $0285F3, X : PHA
JSL InitTilesets ; $619B IN ROM
JSR Overworld_LoadAreaPalettes ; $014692 IN ROM ; Load Palettes
PLA : STA.b $00
LDX.b $8A
LDA.l $00FD1C, X
JSL Overworld_LoadPalettes ; $0755A8 IN ROM
LDA.b #$01 : STA.w $0AB2
JSL Palette_Hud ; $0DEE52 IN ROM
LDA.l $11 : BNE .BRANCH_4
JSL CopyFontToVram ; $006556 IN ROM
.BRANCH_4
JSR $C65F ; $01465F IN ROM
JSL $0BFE70 ; $05FE70 IN ROM
LDA.l $8A : CMP.b #$80 : BCC .BRANCH_5
JSL Palette_SetOwBgColor_Long ; $075618 IN ROM
.BRANCH_5
LDA.b #$09 : STA.b $94
INC.b $B0
RTS
}
warnpc $028697
else
; Undo the function above:
org $028632 ; $010632
db $A0, $58, $A5, $8A, $29, $BF, $C9, $03
db $F0, $0A, $C9, $05, $F0, $06, $C9, $07
db $F0, $02, $A0, $5A, $22, $94, $D3, $00
db $A5, $11, $4A, $AA, $BF, $E2, $85, $02
db $8D, $A3, $0A, $BF, $F3, $85, $02, $48
db $22, $9B, $E1, $00, $20, $92, $C6, $68
db $85, $00, $A6, $8A, $BF, $1C, $FD, $00
db $22, $A8, $D5, $0E, $A9, $01, $8D, $B2
db $0A, $22, $52, $EE, $1B, $A5, $11, $D0
db $04, $22, $56, $E5, $00, $20, $5F, $C6
db $22, $70, $FE, $0B, $A5, $8A, $C9, $80
db $90, $04, $22, $18, $D6, $0E, $A9, $09
db $85, $94, $E6, $B0, $60
endif