-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBank $88.asm
9211 lines (8064 loc) · 431 KB
/
Bank $88.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
;;; $8000..8287: Layer blending ;;;
{
; General comments
{
; Summary of `[$1986] != 0` branch
; |_[$1986]_____|_Main screen layers__|_Subscreen layers____|_Colour math_|_Colour math layers___________|_Y_|_Misc.________________________________
; | 2/Eh/20h | BG1/BG2/ sprites | BG3 | Additive | BG1/BG2 /sprites/backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 4 | BG1 / sprites | BG3 | Additive | BG1/BG2 /sprites/backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 6 | BG1/BG2/ sprites | BG3/sprites | Additive | BG1/BG2/BG3 /backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 8 | BG1/BG2/ sprites | BG3/sprites | Additive | BG2 /backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | Ah | BG1/BG2/ sprites | BG3 | Additive | BG2 /sprites/backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | Ch | BG1/BG2/ sprites | BG3 | Subtractive | BG2 /backdrop | 0 | Disable colour math subscreen layers, disable window masking, enable all layers in window area
; | 10h/12h | BG1/BG2/ sprites | BG3 | Additive | BG1/BG2 /sprites/backdrop | 0 | Enable colour math subscreen layers, enable BG3 / colour math window 1 inclusive mask, disable BG3 in window area subscreen
; | 14h/22h | BG1/BG2/ sprites | BG3 | Subtractive | BG2 /sprites/backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 16h | BG1 / sprites | BG2/BG3 | Subtractive | BG1 /sprites/backdrop | 4 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 18h/1Eh/30h | BG3 | BG1/BG2 /sprites | Additive | BG3 /backdrop | 2 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 1Ah | BG1 /BG3/sprites | BG2 | Additive | BG1 /BG3/sprites/backdrop | 4 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 1Ch | BG1 /BG3/sprites | BG2 | Halved | BG1 /BG3/sprites | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 24h | BG1/BG2/ sprites | BG3 | Additive | BG1/BG2 /sprites/backdrop | 0 | Restrict colour math to inside window, disable BG1/BG2 window 1/2 masking, enable BG3/colour math window 1 inclusive mask, disable BG1/BG2/sprites in window area main screen, disable BG3 in window area subscreen
; | 26h | BG1/BG2/ sprites | BG3 | Halved | BG1/BG2/BG3/sprites/backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 28h | BG1/BG2/ sprites | BG3 | Subtractive | BG2 /sprites/backdrop | 0 | Disable colour math subscreen layers, disable window masking, enable all layers in window area, if [$1987] & 80h = 0: colour math subscreen backdrop colour = (5, 0, 0) (red)
; | 2Ah | BG1/BG2/ sprites | BG3 | Subtractive | BG2 /sprites/backdrop | 0 | Disable colour math subscreen layers, disable window masking, enable all layers in window area, if [$1987] & 80h = 0: colour math subscreen backdrop colour = (6, 2, 0) (orange)
; | 2Ch | BG1/BG2/ sprites | BG3 | Additive | BG1/BG2 /sprites/backdrop | 0 | Disable colour math subscreen layers, disable window masking, enable all layers in window area
; | 2Eh | BG1/BG2/ sprites | BG3 | Subtractive | BG1/BG2 /sprites/backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 32h | BG1/BG2/ sprites | BG3 | Subtractive | BG2 /sprites/backdrop | 0 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; | 34h | BG1/BG2/ sprites | BG3 | Additive | BG1/BG2 /sprites/backdrop | 6 | Enable colour math subscreen layers, disable window masking, enable all layers in window area
; Attempted explanation of each value:
{
; Normal: BG1/BG2/sprites are drawn with BG3 added on top
; 2/Eh/20h: Normal
; 4: Normal, but BG2 is disabled
; Used by Phantoon intro
; 6: Normal, but sprites aren't affected by BG3 and sprites are added to BG1/BG2 (instead of hidden)
; Unused
; 8: Normal, but BG1/sprites aren't affected by BG3 and sprites are added to BG2 (instead of hidden)
; Used in some power off Wrecked Ship rooms
; Ah: Normal, but BG1 isn't affected by BG3
; Used with FX type = spores
; Ch: Normal, but BG3 is disabled and colour math is subtractive
; Used with FX type = fireflea
; 10h/12h: Normal, but BG3 is disabled inside window 1
; Used by morph ball eye and varia/gravity suit pickup
; 14h/22h: Normal, but BG1 isn't affected by BG3 and colour math is subtractive
; Sometimes use with FX type = water
; 16h: BG1/sprites are drawn after the result of drawing BG2/BG3 is subtracted and Y = 4
; Sometimes use with FX type = water
; 18h/1Eh/30h: BG3 is drawn with the result of drawing BG1/BG2/sprites added on top and Y = 2
; Used with FX type = lava / acid / fog / Tourian entrance statue, sometimes use with FX type = water
; This is equivalent to normal, right? Apparently bypasses sprite colour math limitation(?)
; 1Ah: Normal, but BG2 and BG3 have reversed roles and Y = 4
; Used by Phantoon when semi-transparent
; 1Ch: Normal, but BG2 and BG3 have reversed roles, colour addition is halved and backdrop is disabled
; Unused
; 24h: BG1/BG2/sprites are drawn the backdrop is added on top inside window 1
; Used by Mother Brain
; 26h: Normal, but colour addition is halved
; Unused
; 28h: Normal, but BG3 is disabled, colour math is subtractive, and the backdrop subtracts red if there is no power bomb explosion
; Used in some default state Crateria rooms, some power off Wrecked Ship rooms, pre plasma beam rooms
; 2Ah: Normal, but BG3 is disabled, colour math is subtractive, and the backdrop subtracts orange if there is no power bomb explosion
; Used in blue Brinstar rooms, Kraid's lair entrance, n00b tube side rooms, plasma beam room, some sand falls rooms
; 2Ch: Normal, but BG3 is disabled
; Used by FX type = haze and torizos
; 2Eh: Normal, but colour math is subtractive
; Unused
; 32h: Normal, but BG1 isn't affected by BG3 and colour math is subtractive
; Unused
; 34h: Normal, but Y = 6
; Used by Mother Brain phase 2
}
; The Y values, power bomb configuration:
{
; Normal: BG1/BG2/sprites are drawn with BG3 drawn on top, BG3 is disabled inside window 2
; Y = 0/2: Normal
; Y = 4: BG1/sprites are drawn with the result of drawing BG2/BG3 added on top, BG2/BG3 is disabled inside window 2
; Y = 6: Normal, but BG2 isn't affected by BG3
}
; $1986: Layer blending configuration
{
; Set to [FX A] at the start of the HDMA object handler. See "FX per room.asm"
; Set to [FX B] by:
; $B3B0 ; HDMA object $C3E1, FX layer 3 lava and acid
; $C48E ; HDMA object $D847 / $D856, FX layer 3 water / Tourian entrance statue
; $D9A1 ; HDMA object $D96C, FX layer 3 rain
; $DA47 ; HDMA object $DA2D, FX layer 3 spores
; $DB36 ; HDMA object $DB19, FX layer 3 fog
; Set to 4/1Ah by $E449, Phantoon
; Set to Ch by $B0BC, HDMA object $B0AC, FX layer 3 fireflea
; Set to 10h by $E917, $E9E6, $EA3C, $EACB, HDMA object $E8EC, morph ball eye
; Set to 12h by:
; $E026, HDMA object $D5A2, varia suit pickup
; $E05C, HDMA object $D67A, gravity suit pickup
; Set to 24h by $E767, $E7BC, HDMA object $E751, Mother Brain
; Set to 2Ch by:
; $DE18/96, HDMA object $DEEB, FX layer 3 haze
; $DD43, HDMA object $DD4A, torizos
}
; The following is a list of what FX B values are used with each FX type (only FX B is used with FX layer 3)
{
; FX type = fireflea/both Ceres: FX B = 2
; FX type = spores: FX B = Ah
; FX type = rain: FX B = Eh
; FX type = water: FX B = 14h/16h/18h
; FX type = lava/acid: FX B = 1Eh
; FX type = fog: FX B = 30h
; FX type = Tourian entrance statue: FX B = 18h
}
}
;;; $8000: Layer blending handler ;;;
{
$88:8000 08 PHP
$88:8001 E2 30 SEP #$30
$88:8003 A0 00 LDY #$00 ; Layer blending power bomb configuration = 0
$88:8005 AE 86 19 LDX $1986 [$7E:1986] ;\
$88:8008 F0 06 BEQ $06 [$8010] ;} If [layer blending configuration] != 0:
$88:800A 20 75 80 JSR $8075 [$88:8075] ; Initialise layer blending
$88:800D FC 3E 80 JSR ($803E,x)[$88:8074]; Execute [$803E + [layer blending configuration]] (may change Y)
$88:8010 2C 87 19 BIT $1987 [$7E:1987] ;\
$88:8013 10 05 BPL $05 [$801A] ;} If [layer blending window 2 configuration] & 80h:
$88:8015 20 FE 81 JSR $81FE [$88:81FE] ; Handle layer blending power bomb (uses Y)
$88:8018 80 22 BRA $22 [$803C] ; Return
$88:801A 2C 87 19 BIT $1987 [$7E:1987] ;\
$88:801D 50 05 BVC $05 [$8024] ;} If [layer blending window 2 configuration] & 40h:
$88:801F 20 7B 81 JSR $817B [$88:817B] ; Handle layer blending x-ray - can show blocks
$88:8022 80 18 BRA $18 [$803C] ; Return
$88:8024 AD 87 19 LDA $1987 [$7E:1987] ;\
$88:8027 89 20 BIT #$20 ;} If [layer blending window 2 configuration] & 20h:
$88:8029 F0 05 BEQ $05 [$8030] ;/
$88:802B 20 A4 81 JSR $81A4 [$88:81A4] ; Handle layer blending x-ray - can't show blocks
$88:802E 80 0C BRA $0C [$803C] ; Return
$88:8030 AD 87 19 LDA $1987 [$7E:1987] ;\
$88:8033 89 10 BIT #$10 ;} If [layer blending window 2 configuration] & 10h:
$88:8035 F0 05 BEQ $05 [$803C] ;/
$88:8037 20 DB 81 JSR $81DB [$88:81DB] ; Handle layer blending x-ray - fireflea room
$88:803A 80 00 BRA $00 [$803C] ; >_<
$88:803C 28 PLP
$88:803D 60 RTS
$88:803E dw 8074, 8074, 8090, 8099, 80A2, 80AB, 80B0, 80B7, 80B8, 80B8, 80C5, 80CA, 80F5, 80D9, 80E8, 80F5,
810C, 80C5, 8156, 810D, 8112, 812A, 8142, 8145, 80F5, 814A, 8153
}
;;; $8074: RTS. Layer blending configuration 0/2 ;;;
{
$88:8074 60 RTS
}
;;; $8075: Initialise layer blending ;;;
{
$88:8075 64 60 STZ $60 [$7E:0060] ;\
$88:8077 64 61 STZ $61 [$7E:0061] ;} Disable window masking
$88:8079 64 62 STZ $62 [$7E:0062] ;/
$88:807B A9 13 LDA #$13 ;\
$88:807D 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:807F A9 04 LDA #$04 ;\
$88:8081 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3
$88:8083 64 6C STZ $6C [$7E:006C] ;\
$88:8085 64 6D STZ $6D [$7E:006D] ;} Enable all layers in window area
$88:8087 A9 02 LDA #$02 ;\
$88:8089 85 6E STA $6E [$7E:006E] ;} Enable colour math subscreen layers
$88:808B A9 33 LDA #$33 ;\
$88:808D 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG1/BG2/sprites/backdrop
$88:808F 60 RTS
}
;;; $8090: Layer blending configuration 4 ;;;
{
; Used by Phantoon
$88:8090 A9 11 LDA #$11 ;\
$88:8092 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/sprites
$88:8094 A9 04 LDA #$04 ;\
$88:8096 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3
$88:8098 60 RTS
}
;;; $8099: Unused. Layer blending configuration 6 ;;;
{
$88:8099 A9 14 LDA #$14 ;\
$88:809B 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3/sprites
$88:809D A9 27 LDA #$27 ;\
$88:809F 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG1/BG2/BG3/backdrop
$88:80A1 60 RTS
}
;;; $80A2: Layer blending configuration 8 ;;;
{
; Used in:
; Room CA52, state $CA64 ; Wrecked Ship attic, power off
; Room CAF6, state $CB08 ; Wrecked Ship mainstreet, power off
; Room CCCB, state $CCDD ; Wrecked Ship map station, power off
$88:80A2 A9 14 LDA #$14 ;\
$88:80A4 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3/sprites
$88:80A6 A9 22 LDA #$22 ;\
$88:80A8 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG2/backdrop
$88:80AA 60 RTS
}
;;; $80AB: Layer blending configuration Ah ;;;
{
; Used with spores
$88:80AB A9 32 LDA #$32 ;\
$88:80AD 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG2/sprites/backdrop
$88:80AF 60 RTS
}
;;; $80B0: Layer blending configuration Ch ;;;
{
; Used with FX type = fireflea
$88:80B0 64 6E STZ $6E [$7E:006E] ; Disable colour math subscreen layers
$88:80B2 A9 A2 LDA #$A2 ;\
$88:80B4 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG2/backdrop
$88:80B6 60 RTS
}
;;; $80B7: RTS. Layer blending configuration Eh ;;;
{
; Used with FX type = rain
$88:80B7 60 RTS
}
;;; $80B8: Layer blending configuration 10h/12h ;;;
{
; 10h is used by morph ball eye
; 12h is used by varia/gravity suit pickup
$88:80B8 A9 02 LDA #$02 ;\
$88:80BA 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 1 inclusive mask
$88:80BC A9 20 LDA #$20 ;\
$88:80BE 85 62 STA $62 [$7E:0062] ;} Enable colour math window 1 inclusive mask
$88:80C0 A9 04 LDA #$04 ;\
$88:80C2 85 6D STA $6D [$7E:006D] ;} Disable BG3 in window area subscreen
$88:80C4 60 RTS
}
;;; $80C5: Layer blending configuration 14h/22h ;;;
{
; 14h is sometimes used with FX type = water
$88:80C5 A9 B3 LDA #$B3 ;\
$88:80C7 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG2/sprites/backdrop
$88:80C9 60 RTS
}
;;; $80CA: Layer blending configuration 16h ;;;
{
; Sometimes used with FX type = water
$88:80CA A0 04 LDY #$04 ; Y = 4
$88:80CC A9 11 LDA #$11 ;\
$88:80CE 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/sprites
$88:80D0 A9 06 LDA #$06 ;\
$88:80D2 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG2/BG3
$88:80D4 A9 B1 LDA #$B1 ;\
$88:80D6 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG1/sprites/backdrop
$88:80D8 60 RTS
}
;;; $80D9: Layer blending configuration 1Ah ;;;
{
; Used by Phantoon
$88:80D9 A0 04 LDY #$04 ; Y = 4
$88:80DB A9 15 LDA #$15 ;\
$88:80DD 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG3/sprites
$88:80DF A9 02 LDA #$02 ;\
$88:80E1 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG2
$88:80E3 A9 35 LDA #$35 ;\
$88:80E5 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG1/BG3/sprites/backdrop
$88:80E7 60 RTS
}
;;; $80E8: Layer blending configuration 1Ch ;;;
{
$88:80E8 A9 15 LDA #$15 ;\
$88:80EA 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG3/sprites
$88:80EC A9 02 LDA #$02 ;\
$88:80EE 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG2
$88:80F0 A9 55 LDA #$55 ;\
$88:80F2 85 71 STA $71 [$7E:0071] ;} Enable halved colour math on BG1/BG3/sprites
$88:80F4 60 RTS
}
;;; $80F5: Layer blending configuration 18h/1Eh/30h ;;;
{
; 18h is sometimes used with FX type = water
; 18h might be used with FX type = tourian entrance statue?
; 1Eh is used with FX type = lava/acid
; 30h is used with FX type = fog
$88:80F5 A0 02 LDY #$02 ; Y = 2
$88:80F7 A5 84 LDA $84 [$7E:0084] ;\
$88:80F9 29 30 AND #$30 ;|
$88:80FB 49 30 EOR #$30 ;} If IRQ mode != v-count/h-count: return
$88:80FD D0 0C BNE $0C [$810B] ;/
$88:80FF A9 24 LDA #$24 ;\
$88:8101 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG3/backdrop
$88:8103 A9 13 LDA #$13 ;\
$88:8105 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG1/BG2/sprites
$88:8107 A9 04 LDA #$04 ;\
$88:8109 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG3
$88:810B 60 RTS
}
;;; $810C: RTS. Layer blending configuration 20h ;;;
{
$88:810C 60 RTS
}
;;; $810D: Layer blending configuration 26h ;;;
{
$88:810D A9 77 LDA #$77 ;\
$88:810F 85 71 STA $71 [$7E:0071] ;} Enable halved colour math on BG1/BG2/BG3/sprites/backdrop
$88:8111 60 RTS
}
;;; $8112: Layer blending configuration 28h ;;;
{
; Used in:
; Room 92FD, state $9314 ; Crateria mainstreet, default state
; Room 9A44, state $9A56 ; Crateria bomb block hall, default state
; Room 9A90, state $9AA2 ; Crateria chozo missile, default state
; Room C98E, state $C9A0 ; Wrecked Ship spike floor hall, power off
; Room CC6F, state $CC81 ; Pre Phantoon hall, power off
; Room D27E ; Plasma beam puyo room
; Room D387 ; Pre plasma beam shaft
$88:8112 64 6E STZ $6E [$7E:006E] ; Disable colour math subscreen layers
$88:8114 A9 B3 LDA #$B3 ;\
$88:8116 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG2/sprites/backdrop
$88:8118 2C 87 19 BIT $1987 [$7E:1987] ;\
$88:811B 30 0C BMI $0C [$8129] ;} If power bomb explosion active: return
$88:811D A9 25 LDA #$25 ;\
$88:811F 85 74 STA $74 [$7E:0074] ;|
$88:8121 A9 40 LDA #$40 ;|
$88:8123 85 75 STA $75 [$7E:0075] ;} Colour math subscreen backdrop colour = (5, 0, 0) (red)
$88:8125 A9 80 LDA #$80 ;|
$88:8127 85 76 STA $76 [$7E:0076] ;/
$88:8129 60 RTS
}
;;; $812A: Layer blending configuration 2Ah ;;;
{
; Used in:
; Room 97B5, state $97C6 ; Crateria -> Blue Brinstar elevator, default state
; Room 9E9F, state $9EB1 ; Morph ball room, default state
; Room 9F11, state $9F23 ; Old Kraid entrance, default state
; Room 9F64, state $9F76 ; Blue Brinstar ceiling e-tank hall, default state
; Room A6A1 ; Kraid's lair entrance
; Room CF54 ; n00b tube west
; Room CF80 ; n00b tube east
; Room D2AA ; Plasma beam room
; Room D54D ; Pre Maridia reserve tank room sand fall room
; Room D57A ; Pre PB #66 room sand fall room
; Room D86E ; Sandy Maridia sand falls room
; Room D898 ; Sand falls
$88:812A 64 6E STZ $6E [$7E:006E] ; Disable colour math subscreen layers
$88:812C A9 B3 LDA #$B3 ;\
$88:812E 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG2/sprites/backdrop
$88:8130 2C 87 19 BIT $1987 [$7E:1987] ;\
$88:8133 30 0C BMI $0C [$8141] ;} If power bomb explosion active: return
$88:8135 A9 26 LDA #$26 ;\
$88:8137 85 74 STA $74 [$7E:0074] ;|
$88:8139 A9 42 LDA #$42 ;|
$88:813B 85 75 STA $75 [$7E:0075] ;} Colour math subscreen backdrop colour = (6, 2, 0) (orange)
$88:813D A9 80 LDA #$80 ;|
$88:813F 85 76 STA $76 [$7E:0076] ;/
$88:8141 60 RTS
}
;;; $8142: Layer blending configuration 2Ch ;;;
{
; Use by FX type = haze and torizos
$88:8142 64 6E STZ $6E [$7E:006E] ; Disable colour math subscreen layers
$88:8144 60 RTS
}
;;; $8145: Layer blending configuration 2Eh ;;;
{
$88:8145 A9 B3 LDA #$B3 ;\
$88:8147 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG1/BG2/sprites/backdrop
$88:8149 60 RTS
}
;;; $814A: Layer blending configuration 32h ;;;
{
$88:814A A9 44 LDA #$44 ;\
$88:814C 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3 (and sets an unused bit)
$88:814E A9 B2 LDA #$B2 ;\
$88:8150 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG2/sprites/backdrop
$88:8152 60 RTS
}
;;; $8153: Layer blending configuration 34h ;;;
{
$88:8153 A0 06 LDY #$06 ; Y = 6
$88:8155 60 RTS
}
;;; $8156: Layer blending configuration 24h ;;;
{
; Used by Mother Brain
$88:8156 A9 00 LDA #$00 ;\
$88:8158 85 60 STA $60 [$7E:0060] ;} Disable BG1/BG2 window 1/2 masking
$88:815A A9 02 LDA #$02 ;\
$88:815C 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 1 inclusive mask
$88:815E A9 20 LDA #$20 ;\
$88:8160 85 62 STA $62 [$7E:0062] ;} Enable colour math window 1 inclusive mask
$88:8162 A9 13 LDA #$13 ;\
$88:8164 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:8166 A9 04 LDA #$04 ;\
$88:8168 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3
$88:816A A9 13 LDA #$13 ;\
$88:816C 85 6C STA $6C [$7E:006C] ;} Disable BG1/BG2/sprites in window area main screen
$88:816E A9 04 LDA #$04 ;\
$88:8170 85 6D STA $6D [$7E:006D] ;} Disable BG3 in window area subscreen
$88:8172 A9 10 LDA #$10 ;\
$88:8174 85 6E STA $6E [$7E:006E] ;} Disable subscreen layers and restrict colour math to inside window
$88:8176 A9 33 LDA #$33 ;\
$88:8178 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG1/BG2/sprites/backdrop
$88:817A 60 RTS
}
;;; $817B: Handle layer blending x-ray - can show blocks ;;;
{
$88:817B A9 C8 LDA #$C8 ;\
$88:817D 85 60 STA $60 [$7E:0060] ;} Enable BG1 window 2 inclusive mask and BG2 window 2 exclusive mask
$88:817F A9 08 LDA #$08 ;\
$88:8181 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 2 inclusive mask
$88:8183 A9 80 LDA #$80 ;\
$88:8185 85 62 STA $62 [$7E:0062] ;} Enable colour math window 2 inclusive mask
$88:8187 A9 13 LDA #$13 ;\
$88:8189 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:818B A9 04 LDA #$04 ;\
$88:818D 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3
$88:818F A9 03 LDA #$03 ;\
$88:8191 85 6C STA $6C [$7E:006C] ;} Disable BG1/BG2 in window area main screen
$88:8193 A9 04 LDA #$04 ;\
$88:8195 85 6D STA $6D [$7E:006D] ;} Disable BG3 in window area subscreen
$88:8197 A9 22 LDA #$22 ;\
$88:8199 85 6E STA $6E [$7E:006E] ;} Enable subscreen layers and restrict colour math to outside window
$88:819B A5 71 LDA $71 [$7E:0071] ;\
$88:819D 29 80 AND #$80 ;|
$88:819F 09 73 ORA #$73 ;} Enable halved colour math on BG1/BG2/sprites/backdrop
$88:81A1 85 71 STA $71 [$7E:0071] ;/
$88:81A3 60 RTS
}
;;; $81A4: Handle layer blending x-ray - can't show blocks ;;;
{
$88:81A4 64 60 STZ $60 [$7E:0060] ; Disable BG1/2 window masks
$88:81A6 A9 08 LDA #$08 ;\
$88:81A8 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 2 inclusive mask
$88:81AA A9 80 LDA #$80 ;\
$88:81AC 85 62 STA $62 [$7E:0062] ;} Enable colour math window 2 inclusive mask
$88:81AE A9 13 LDA #$13 ;\
$88:81B0 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:81B2 A9 04 LDA #$04 ;\
$88:81B4 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3
$88:81B6 A9 03 LDA #$03 ;\
$88:81B8 85 6C STA $6C [$7E:006C] ;} Disable BG1/BG2 in window area main screen
$88:81BA A9 04 LDA #$04 ;\
$88:81BC 85 6D STA $6D [$7E:006D] ;} Disable BG3 in window area subscreen
$88:81BE A9 22 LDA #$22 ;\
$88:81C0 85 6E STA $6E [$7E:006E] ;} Enable subscreen layers and restrict colour math to outside window
$88:81C2 A5 71 LDA $71 [$7E:0071] ;\
$88:81C4 29 80 AND #$80 ;|
$88:81C6 09 61 ORA #$61 ;} Enable halved colour math on BG1/backdrop
$88:81C8 85 71 STA $71 [$7E:0071] ;/
$88:81CA C2 20 REP #$20 ;\
$88:81CC AD 9B 07 LDA $079B [$7E:079B] ;|
$88:81CF C9 FB CE CMP #$CEFB ;} If [room pointer] = $CEFB (n00b tube):
$88:81D2 E2 20 SEP #$20 ;|
$88:81D4 D0 04 BNE $04 [$81DA] ;/
$88:81D6 A9 11 LDA #$11 ;\
$88:81D8 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/sprites
$88:81DA 60 RTS
}
;;; $81DB: Handle layer blending x-ray - fireflea room ;;;
{
$88:81DB 64 60 STZ $60 [$7E:0060] ; Disable BG1/2 window masks
$88:81DD A9 08 LDA #$08 ;\
$88:81DF 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 2 inclusive mask
$88:81E1 A9 80 LDA #$80 ;\
$88:81E3 85 62 STA $62 [$7E:0062] ;} Enable colour math window 2 inclusive mask
$88:81E5 A9 13 LDA #$13 ;\
$88:81E7 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:81E9 A9 04 LDA #$04 ; >_<;
$88:81EB 64 6B STZ $6B [$7E:006B] ; Disable all subscreen layers
$88:81ED A9 03 LDA #$03 ;\
$88:81EF 85 6C STA $6C [$7E:006C] ;} Disable BG1/BG2 in window area main screen
$88:81F1 A9 04 LDA #$04 ;\
$88:81F3 85 6D STA $6D [$7E:006D] ;} Disable BG3 in window area subscreen
$88:81F5 A9 20 LDA #$20 ;\
$88:81F7 85 6E STA $6E [$7E:006E] ;} Disable subscreen layers and restrict colour math to outside window
$88:81F9 A9 B3 LDA #$B3 ;\
$88:81FB 85 71 STA $71 [$7E:0071] ;} Enable subtractive colour math on BG1/BG2/sprites/backdrop
$88:81FD 60 RTS
}
;;; $81FE: Handle layer blending power bomb ;;;
{
$88:81FE C2 30 REP #$30 ;\
$88:8200 AD 9B 07 LDA $079B [$7E:079B] ;|
$88:8203 C9 6A A6 CMP #$A66A ;} If room is Tourian entrance:
$88:8206 E2 30 SEP #$30 ;|
$88:8208 D0 02 BNE $02 [$820C] ;/
$88:820A A0 06 LDY #$06 ; Y = 6
$88:820C BB TYX ;\
$88:820D FC 11 82 JSR ($8211,x)[$88:8219];} Execute [$8211 + [Y]]
$88:8210 60 RTS
$88:8211 dw 8219, 8219, 823E, 8263
}
;;; $8219: Handle layer blending power bomb configuration 0/2 ;;;
{
$88:8219 A9 00 LDA #$00 ;\
$88:821B 85 60 STA $60 [$7E:0060] ;} Disable BG1/BG2 window 1/2 masking
$88:821D A9 08 LDA #$08 ;\
$88:821F 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 2 inclusive mask
$88:8221 A9 80 LDA #$80 ;\
$88:8223 85 62 STA $62 [$7E:0062] ;} Enable colour math window 2 inclusive mask
$88:8225 A9 02 LDA #$02 ;\
$88:8227 85 6E STA $6E [$7E:006E] ;} Enable colour math subscreen layers
$88:8229 A9 37 LDA #$37 ;\
$88:822B 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG1/BG2/BG3/sprites/backdrop
$88:822D A9 00 LDA #$00 ;\
$88:822F 85 6C STA $6C [$7E:006C] ;} Enable all layers in window area main screen
$88:8231 A9 04 LDA #$04 ;\
$88:8233 85 6D STA $6D [$7E:006D] ;} Disable BG3 in window area subscreen
$88:8235 A9 13 LDA #$13 ;\
$88:8237 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:8239 A9 04 LDA #$04 ;\
$88:823B 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3
$88:823D 60 RTS
}
;;; $823E: Handle layer blending power bomb configuration 4 ;;;
{
$88:823E A9 80 LDA #$80 ;\
$88:8240 85 60 STA $60 [$7E:0060] ;} Enable BG2 window 2 inclusive mask
$88:8242 A9 08 LDA #$08 ;\
$88:8244 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 2 inclusive mask
$88:8246 A9 80 LDA #$80 ;\
$88:8248 85 62 STA $62 [$7E:0062] ;} Enable colour math window 2 inclusive mask
$88:824A A9 02 LDA #$02 ;\
$88:824C 85 6E STA $6E [$7E:006E] ;} Enable colour math subscreen layers
$88:824E A9 37 LDA #$37 ;\
$88:8250 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG1/BG2/BG3/sprites/backdrop
$88:8252 A9 00 LDA #$00 ;\
$88:8254 85 6C STA $6C [$7E:006C] ;} Enable all layers in window area main screen
$88:8256 A9 06 LDA #$06 ;\
$88:8258 85 6D STA $6D [$7E:006D] ;} Disable BG2/BG3 in window area subscreen
$88:825A A9 11 LDA #$11 ;\
$88:825C 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/sprites
$88:825E A9 06 LDA #$06 ;\
$88:8260 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG2/BG3
$88:8262 60 RTS
}
;;; $8263: Handle layer blending power bomb configuration 6 ;;;
{
; Compared with config 0/2, this one disables colour math on BG2/BG3
$88:8263 A9 00 LDA #$00 ;\
$88:8265 85 60 STA $60 [$7E:0060] ;} Disable BG1/BG2 window 1/2 masking
$88:8267 A9 08 LDA #$08 ;\
$88:8269 85 61 STA $61 [$7E:0061] ;} Enable BG3 window 2 inclusive mask
$88:826B A9 80 LDA #$80 ;\
$88:826D 85 62 STA $62 [$7E:0062] ;} Enable colour math window 2 inclusive mask
$88:826F A9 02 LDA #$02 ;\
$88:8271 85 6E STA $6E [$7E:006E] ;} Enable colour math subscreen layers
$88:8273 A9 31 LDA #$31 ;\
$88:8275 85 71 STA $71 [$7E:0071] ;} Enable colour math on BG1/sprites/backdrop
$88:8277 A9 00 LDA #$00 ;\
$88:8279 85 6C STA $6C [$7E:006C] ;} Enable all layers in window area main screen
$88:827B A9 04 LDA #$04 ;\
$88:827D 85 6D STA $6D [$7E:006D] ;} Disable BG3 in window area subscreen
$88:827F A9 13 LDA #$13 ;\
$88:8281 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:8283 A9 04 LDA #$04 ;\
$88:8285 85 6B STA $6B [$7E:006B] ;} Subscreen layers = BG3
$88:8287 60 RTS
}
}
;;; $8288: Enable HDMA objects ;;;
{
$88:8288 08 PHP
$88:8289 C2 20 REP #$20
$88:828B A9 00 80 LDA #$8000
$88:828E 0C B0 18 TSB $18B0 [$7E:18B0]
$88:8291 28 PLP
$88:8292 6B RTL
}
;;; $8293: Disable HDMA objects ;;;
{
; Power bombs still work
$88:8293 08 PHP
$88:8294 C2 20 REP #$20
$88:8296 A9 00 80 LDA #$8000
$88:8299 1C B0 18 TRB $18B0 [$7E:18B0]
$88:829C 28 PLP
$88:829D 6B RTL
}
;;; $829E: Wait until the end of a v-blank and clear (H)DMA enable flags ;;;
{
$88:829E 08 PHP
$88:829F E2 20 SEP #$20
$88:82A1 22 C5 82 80 JSL $8082C5[$80:82C5] ; Wait until the end of a v-blank
$88:82A5 9C 0B 42 STZ $420B ;\
$88:82A8 9C 0C 42 STZ $420C ;} Clear (H)DMA enable flags
$88:82AB 28 PLP
}
;;; $82AC: Delete HDMA objects ;;;
{
$88:82AC 08 PHP
$88:82AD E2 20 SEP #$20 ;\
$88:82AF 64 85 STZ $85 [$7E:0085] ;} Clear HDMA channels to enable
$88:82B1 C2 30 REP #$30 ;/
$88:82B3 DA PHX ;\
$88:82B4 A2 0A 00 LDX #$000A ;|
;|
$88:82B7 9E B4 18 STZ $18B4,x[$7E:18BE] ;|
$88:82BA CA DEX ;} Delete HDMA objects
$88:82BB CA DEX ;|
$88:82BC 10 F9 BPL $F9 [$82B7] ;|
$88:82BE FA PLX ;/
$88:82BF 28 PLP
$88:82C0 6B RTL
}
;;; $82C1: Initialise special effects for new room ;;;
{
; This initial bit regarding earthquake sound effects is strictly for rising acid/lava rooms
$88:82C1 08 PHP
$88:82C2 C2 20 REP #$20
$88:82C4 9C 07 06 STZ $0607 [$7E:0607] ; Earthquake sound effect index = 0
$88:82C7 9C 09 06 STZ $0609 [$7E:0609] ; Earthquake sound effect timer = 0 (enable)
$88:82CA AD 9B 07 LDA $079B [$7E:079B] ;\
$88:82CD C9 04 98 CMP #$9804 ;} If [room pointer] = $9804 (Bomb Torizo): go to BRANCH_NO_EARTHQUAKE_SFX
$88:82D0 F0 1B BEQ $1B [$82ED] ;/
$88:82D2 C9 BA 96 CMP #$96BA ;\
$88:82D5 F0 16 BEQ $16 [$82ED] ;} If [room pointer] = $96BA (old Tourian escape shaft): go to BRANCH_NO_EARTHQUAKE_SFX
$88:82D7 C9 2E B3 CMP #$B32E ;\
$88:82DA F0 11 BEQ $11 [$82ED] ;} If [room pointer] = $B32E (Ridley): go to BRANCH_NO_EARTHQUAKE_SFX
$88:82DC C9 57 B4 CMP #$B457 ;\
$88:82DF F0 0C BEQ $0C [$82ED] ;} If [room pointer] = $B457 (Lower Norfair breakable pillars hall): go to BRANCH_NO_EARTHQUAKE_SFX
$88:82E1 C9 58 DD CMP #$DD58 ;\
$88:82E4 F0 07 BEQ $07 [$82ED] ;} If [room pointer] = $DD58 (Mother Brain): go to BRANCH_NO_EARTHQUAKE_SFX
$88:82E6 C9 DE DE CMP #$DEDE ;\
$88:82E9 F0 02 BEQ $02 [$82ED] ;} If [room pointer] = $DEDE (escape room 4): go to BRANCH_NO_EARTHQUAKE_SFX
$88:82EB 80 06 BRA $06 [$82F3] ; Go to BRANCH_EARTHQUAKE_SFX
; BRANCH_NO_EARTHQUAKE_SFX
$88:82ED A9 FF FF LDA #$FFFF ;\
$88:82F0 8D 09 06 STA $0609 [$7E:0609] ;} Earthquake sound effect timer = FFFFh (disable)
; BRANCH_EARTHQUAKE_SFX
$88:82F3 9C F7 05 STZ $05F7 [$7E:05F7] ; Enable mini-map
$88:82F6 E2 30 SEP #$30
$88:82F8 A2 20 LDX #$20 ;\
;|
$88:82FA 9E 00 43 STZ $4300,x ;|
$88:82FD A9 13 LDA #$13 ;|
$88:82FF 9D 01 43 STA $4301,x ;|
$88:8302 9E 02 43 STZ $4302,x ;|
$88:8305 9E 03 43 STZ $4303,x ;|
$88:8308 9E 04 43 STZ $4304,x ;|
$88:830B 9E 05 43 STZ $4305,x ;|
$88:830E 9E 06 43 STZ $4306,x ;} Clear (H)DMA registers. Sets PPU addresses to $2113 (BG4 X scroll) for no particular reason
$88:8311 9E 08 43 STZ $4308,x ;|
$88:8314 9E 09 43 STZ $4309,x ;|
$88:8317 8A TXA ;|
$88:8318 18 CLC ;|
$88:8319 69 10 ADC #$10 ;|
$88:831B AA TAX ;|
$88:831C E0 80 CPX #$80 ;|
$88:831E D0 DA BNE $DA [$82FA] ;/
$88:8320 C2 30 REP #$30
$88:8322 A9 FF FF LDA #$FFFF
$88:8325 9C 5C 19 STZ $195C [$7E:195C] ; FX Y subposition = 0
$88:8328 8D 5E 19 STA $195E [$7E:195E] ; FX Y position = FFFFh (disabled)
$88:832B 9C 60 19 STZ $1960 [$7E:1960] ; Lava/acid Y subposition = 0
$88:832E 8D 62 19 STA $1962 [$7E:1962] ; Lava/acid Y position = FFFFh (disabled)
$88:8331 A9 00 00 LDA #$0000 ;\
$88:8334 8F D8 CA 7E STA $7ECAD8[$7E:CAD8] ;} HUD BG3 X position = 0
$88:8338 8F DA CA 7E STA $7ECADA[$7E:CADA] ; HUD BG3 Y position = 0
$88:833C 8F DC CA 7E STA $7ECADC[$7E:CADC] ; BG3 X position = 0
$88:8340 8F DE CA 7E STA $7ECADE[$7E:CADE] ; BG3 Y position = 0
$88:8344 9C 83 07 STZ $0783 [$7E:0783] ; Mode 7 flag = 0
$88:8347 9C 41 09 STZ $0941 [$7E:0941] ; Camera distance index = normal
$88:834A 9C 6F 1E STZ $1E6F [$7E:1E6F] ; Tourian entrance statue animation state = 0
$88:834D 9C 6D 1E STZ $1E6D [$7E:1E6D] ; Tourian entrance statue finished processing flag = 0
$88:8350 9C 40 18 STZ $1840 [$7E:1840] ; Earthquake timer = 0
$88:8353 9C 88 19 STZ $1988 [$7E:1988] ; Phantoon semi-transparency flag = 0
$88:8356 9C 92 05 STZ $0592 [$7E:0592] ; Power bomb explosion status = 0
$88:8359 9C EE 0C STZ $0CEE [$7E:0CEE] ; Power bomb flag = 0
$88:835C 9C EA 0C STZ $0CEA [$7E:0CEA] ; Power bomb radius = 0
$88:835F 9C 64 19 STZ $1964 [$7E:1964] ; FX tilemap address = 0
$88:8362 9C 6E 19 STZ $196E [$7E:196E] ; FX type = none
$88:8365 A9 00 80 LDA #$8000 ;\
$88:8368 8D 76 19 STA $1976 [$7E:1976] ;} FX base Y position = 0.8000h
$88:836B 9C 78 19 STZ $1978 [$7E:1978] ;/
$88:836E 9C 7A 19 STZ $197A [$7E:197A] ; FX target Y position = 0
$88:8371 9C 7C 19 STZ $197C [$7E:197C] ; FX Y velocity = 0
$88:8374 9C 7E 19 STZ $197E [$7E:197E] ; FX liquid options = 0
$88:8377 9C 80 19 STZ $1980 [$7E:1980] ; FX timer = 0
$88:837A 9C 74 19 STZ $1974 [$7E:1974] ; Tide phase = 0
$88:837D 9C 70 19 STZ $1970 [$7E:1970] ;\
$88:8380 9C 72 19 STZ $1972 [$7E:1972] ;} FX Y offset = 0.0
$88:8383 A9 02 00 LDA #$0002 ;\
$88:8386 8D 82 19 STA $1982 [$7E:1982] ;} Default layer blending configuration = 2 (normal)
$88:8389 64 B9 STZ $B9 [$7E:00B9] ; BG3 X scroll = 0
$88:838B 64 BB STZ $BB [$7E:00BB] ; BG3 Y scroll = 0
$88:838D 9C 17 09 STZ $0917 [$7E:0917] ; Layer 2 X position = 0
$88:8390 9C 19 09 STZ $0919 [$7E:0919] ; Layer 2 Y position = 0
$88:8393 64 A9 STZ $A9 [$7E:00A9] ; Room loading interrupt command = 0
$88:8395 A9 00 88 LDA #$8800 ;\
$88:8398 8D 02 06 STA $0602 [$7E:0602] ;|
$88:839B 8D 05 06 STA $0605 [$7E:0605] ;|
$88:839E A9 E1 83 LDA #$83E1 ;} Pause hook = unpause hook = $88:83E1 (RTL)
$88:83A1 8D 01 06 STA $0601 [$7E:0601] ;|
$88:83A4 8D 04 06 STA $0604 [$7E:0604] ;/
$88:83A7 E2 20 SEP #$20 ;\
$88:83A9 A9 F0 LDA #$F0 ;|
$88:83AB 8D 81 21 STA $2181 ;|
$88:83AE A9 FF LDA #$FF ;} WRAM address = $7F:FFF0 (for no particular reason)
$88:83B0 8D 82 21 STA $2182 ;|
$88:83B3 A9 01 LDA #$01 ;|
$88:83B5 8D 83 21 STA $2183 ;/
$88:83B8 64 85 STZ $85 [$7E:0085] ; HDMA channels to enable = 0
$88:83BA A9 20 LDA #$20 ;\
$88:83BC 85 74 STA $74 [$7E:0074] ;|
$88:83BE A9 40 LDA #$40 ;|
$88:83C0 85 75 STA $75 [$7E:0075] ;} Colour math subscreen backdrop colour = (0, 0, 0)
$88:83C2 A9 80 LDA #$80 ;|
$88:83C4 85 76 STA $76 [$7E:0076] ;/
$88:83C6 64 57 STZ $57 [$7E:0057] ; Disable mosaic
$88:83C8 A9 13 LDA #$13 ;\
$88:83CA 85 69 STA $69 [$7E:0069] ;} Main screen layers = BG1/BG2/sprites
$88:83CC 64 6F STZ $6F [$7E:006F] ; Colour math control register A = 0
$88:83CE 64 72 STZ $72 [$7E:0072] ; Colour math control register B = 0
$88:83D0 64 5D STZ $5D [$7E:005D] ; BG1/BG2 tiles base address = $0000
$88:83D2 A9 04 LDA #$04 ;\
$88:83D4 85 5E STA $5E [$7E:005E] ;} BG3 tiles base address = $4000
$88:83D6 A9 49 LDA #$49 ;\
$88:83D8 85 59 STA $59 [$7E:0059] ;} BG2 tilemap base address = $4800, size = 64x32
$88:83DA A9 5A LDA #$5A ;\
$88:83DC 85 5A STA $5A [$7E:005A] ;} BG3 tilemap base address = $5800, size = 32x64
$88:83DE 85 5B STA $5B [$7E:005B] ;/
$88:83E0 28 PLP
$88:83E1 6B RTL
}
;;; $83E2: Unused. Spawn HDMA object to slot 0 - HDMA object channel = 4, HDMA object channel index = 20h ;;;
{
$88:83E2 08 PHP
$88:83E3 8B PHB
$88:83E4 C2 20 REP #$20
$88:83E6 A9 00 04 LDA #$0400
$88:83E9 85 12 STA $12 [$7E:0012]
$88:83EB A9 20 00 LDA #$0020
$88:83EE 85 14 STA $14 [$7E:0014]
$88:83F0 A2 00 00 LDX #$0000
$88:83F3 4C 1B 84 JMP $841B [$88:841B]
}
;;; $83F6: Unused. Spawn HDMA object to slot 8 - HDMA object channel = 40h, HDMA object channel index = 60h ;;;
{
$88:83F6 08 PHP
$88:83F7 8B PHB
$88:83F8 C2 20 REP #$20
$88:83FA A9 00 40 LDA #$4000
$88:83FD 85 12 STA $12 [$7E:0012]
$88:83FF A9 60 00 LDA #$0060
$88:8402 85 14 STA $14 [$7E:0014]
$88:8404 A2 08 00 LDX #$0008
$88:8407 4C 1B 84 JMP $841B [$88:841B]
}
;;; $840A: Spawn HDMA object to slot Ah - HDMA object channel = 80h, HDMA object channel index = 70h ;;;
{
; Called by:
; $D865: Spawn BG3 scroll HDMA object
$88:840A 08 PHP
$88:840B 8B PHB
$88:840C C2 20 REP #$20
$88:840E A9 00 80 LDA #$8000
$88:8411 85 12 STA $12 [$7E:0012]
$88:8413 A9 70 00 LDA #$0070
$88:8416 85 14 STA $14 [$7E:0014]
$88:8418 A2 0A 00 LDX #$000A
}
;;; $841B: Spawn HDMA object to slot [X] (hardcoded parameters) ;;;
{
;; Parameters:
;; [[S] + 1] + 3: HDMA control
;; [[S] + 1] + 4: HDMA target
;; [[S] + 1] + 5: HDMA object instruction list pointer
; Must have DB and P pushed
$88:841B E2 20 SEP #$20
$88:841D A3 05 LDA $05,s [$7E:1FF5] ;\
$88:841F 48 PHA ;} DB = caller bank
$88:8420 AB PLB ;/
$88:8421 EB XBA ;\
$88:8422 A9 00 LDA #$00 ;|
$88:8424 C2 30 REP #$30 ;} $19 = [DB]
$88:8426 85 18 STA $18 [$7E:0018] ;/
$88:8428 A3 03 LDA $03,s [$7E:1FF3] ;\
$88:842A A8 TAY ;} Y = (return address) + 1
$88:842B C8 INY ;/
$88:842C 18 CLC ;\
$88:842D 69 04 00 ADC #$0004 ;} Adjust return address
$88:8430 83 03 STA $03,s [$7E:1FF3] ;/
$88:8432 4C 77 84 JMP $8477 [$88:8477] ; Go to spawn HDMA object to slot [X]
}
;;; $8435: Spawn HDMA object ;;;
{
;; Parameters:
;; [[S] + 1] + 1: HDMA control
;; v = ri000ttt
;; r: Read data
;; i: Indirect HDMA table
;; t: Transfer type
;; 0: 8-bit
;; 1: 16-bit / two 8-bit units
;; 2: 16-bit for write-twice registers / two 8-bit units to same register
;; 3: Two 16-bit units for two write-twice registers
;; 4: Two 16-bit units / four 8-bit units
;; [[S] + 1] + 2: HDMA target. Common targets:
;; $0D: BG1 X scroll (16-bit, write-twice)
;; $0E: BG1 Y scroll (16-bit, write-twice)
;; $0F: BG2 X scroll (16-bit, write-twice)
;; $10: BG2 Y scroll (16-bit, write-twice)
;; $11: BG3 X scroll (16-bit, write-twice)
;; $12: BG3 Y scroll (16-bit, write-twice)
;; $26: Window 1 left position (8-bit)
;; $27: Window 1 right position (8-bit)
;; $28: Window 2 left position (8-bit)
;; $29: Window 2 right position (8-bit)
;; $32: Colour math subscreen backdrop colour (8-bit, sometimes used with write-twice)
;; [[S] + 1] + 3: HDMA object instruction list pointer
;; Returns:
;; Carry: Clear if HDMA object was spawned. Set if HDMA array full
;; A: HDMA object index (80h if HDMA array full)
$88:8435 08 PHP
$88:8436 8B PHB
$88:8437 E2 20 SEP #$20
$88:8439 A3 05 LDA $05,s [$7E:1FEB] ;\
$88:843B 48 PHA ;} DB = caller bank
$88:843C AB PLB ;/
$88:843D EB XBA ;\
$88:843E A9 00 LDA #$00 ;|
$88:8440 C2 30 REP #$30 ;} $19 = [DB]
$88:8442 85 18 STA $18 [$7E:0018] ;/
$88:8444 A3 03 LDA $03,s [$7E:1FE9] ;\
$88:8446 A8 TAY ;} Y = (return address) + 1
$88:8447 C8 INY ;/
$88:8448 18 CLC ;\
$88:8449 69 04 00 ADC #$0004 ;} Adjust return address
$88:844C 83 03 STA $03,s [$7E:1FE9] ;/
$88:844E A9 00 04 LDA #$0400 ;\
$88:8451 85 12 STA $12 [$7E:0012] ;} $13 = 4 (HDMA channel)
$88:8453 A9 20 00 LDA #$0020 ;\
$88:8456 85 14 STA $14 [$7E:0014] ;} $14 = 20h (HDMA index)
$88:8458 A2 00 00 LDX #$0000 ; X = 0 (HDMA object index)
; LOOP
$88:845B BD B4 18 LDA $18B4,x[$7E:18B4] ;\
$88:845E F0 17 BEQ $17 [$8477] ;} If [HDMA object channel] = 0: go to spawn HDMA object to slot [X]
$88:8460 06 12 ASL $12 [$7E:0012] ; $13 <<= 1
$88:8462 B0 0F BCS $0F [$8473] ; If $13 MSb was clear:
$88:8464 A5 14 LDA $14 [$7E:0014] ;\
$88:8466 18 CLC ;|
$88:8467 69 10 00 ADC #$0010 ;} $14 += 10h
$88:846A 85 14 STA $14 [$7E:0014] ;/
$88:846C E8 INX ;\
$88:846D E8 INX ;} X += 2 (next HDMA object)
$88:846E E0 0C 00 CPX #$000C ;\
$88:8471 D0 E8 BNE $E8 [$845B] ;} If [X] != Ch: go to LOOP
$88:8473 AB PLB
$88:8474 28 PLP
$88:8475 38 SEC ;\
$88:8476 6B RTL ;} Return carry set
}
;;; $8477: Spawn HDMA object to slot [X] (variable parameters) ;;;
{
;; Parameters:
;; X: HDMA object index
;; Y: Return address + 1
;; [Y] + 0: HDMA control
;; [Y] + 1: HDMA target
;; [Y] + 2: HDMA object instruction list pointer
;; $13: HDMA object channel
;; $14: HDMA object channel index
;; $19: HDMA object bank
;; Returns:
;; Carry: Clear
;; A: HDMA object index
; Must have DB and P pushed
$88:8477 A9 B8 84 LDA #$84B8 ;\
$88:847A 9D F0 18 STA $18F0,x[$7E:18F0] ;|
$88:847D A9 88 00 LDA #$0088 ;} HDMA object pre-instruction = RTL
$88:8480 9D FC 18 STA $18FC,x[$7E:18FC] ;/
$88:8483 B9 02 00 LDA $0002,y[$88:EB65] ;\
$88:8486 9D CC 18 STA $18CC,x[$7E:18CC] ;} HDMA object instruction list pointer = [(return address) + 3]
$88:8489 A9 01 00 LDA #$0001 ;\
$88:848C 9D E4 18 STA $18E4,x[$7E:18E4] ;} HDMA object instruction timer = 1
$88:848F 9E 08 19 STZ $1908,x[$7E:1908] ; HDMA object timer = 0
$88:8492 9E 14 19 STZ $1914,x[$7E:1914] ; HDMA object $1914 = 0
$88:8495 9E 20 19 STZ $1920,x[$7E:1920] ; HDMA object $1920 = 0
$88:8498 9E 2C 19 STZ $192C,x[$7E:192C] ; HDMA object $192C = 0
$88:849B 9E 38 19 STZ $1938,x[$7E:1938] ; HDMA object $1938 = 0
$88:849E A5 12 LDA $12 [$7E:0012] ;\
$88:84A0 EB XBA ;} HDMA object channel = [$13]
$88:84A1 9D B4 18 STA $18B4,x[$7E:18B4] ;/