-
Notifications
You must be signed in to change notification settings - Fork 15
/
bank_03.asm
11895 lines (10930 loc) · 268 KB
/
bank_03.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
ORG $038000
StompSFX3:
db !SFX_STOMP1
db !SFX_STOMP2
db !SFX_STOMP3
db !SFX_STOMP4
db !SFX_STOMP5
db !SFX_STOMP6
db !SFX_STOMP7
DATA_038007:
db $F0,$F8,$FC,$00,$04,$08,$10
DATA_03800E:
db $A0,$D0,$C0,$D0
Football:
JSL GenericSprGfxRt2
LDA.B SpriteLock
BNE Return038086
JSR SubOffscreen0Bnk3
JSL SprSpr_MarioSprRts
LDA.W SpriteMisc1540,X
BEQ CODE_03802D
DEC A
BNE +
JSL CODE_01AB6F
CODE_03802D:
JSL UpdateSpritePos
+ LDA.W SpriteBlockedDirs,X ; \ Branch if not touching object
AND.B #$03 ; |
BEQ + ; /
LDA.B SpriteXSpeed,X
EOR.B #$FF
INC A
STA.B SpriteXSpeed,X
+ LDA.W SpriteBlockedDirs,X
AND.B #$08
BEQ +
STZ.B SpriteYSpeed,X ; Sprite Y Speed = 0
+ LDA.W SpriteBlockedDirs,X ; \ Branch if not on ground
AND.B #$04 ; |
BEQ Return038086 ; /
LDA.W SpriteMisc1540,X
BNE Return038086
LDA.W SpriteOBJAttribute,X
EOR.B #$40
STA.W SpriteOBJAttribute,X
JSL GetRand
AND.B #$03
TAY
LDA.W DATA_03800E,Y
STA.B SpriteYSpeed,X
LDY.W SpriteSlope,X
INY
INY
INY
LDA.W DATA_038007,Y
CLC
ADC.B SpriteXSpeed,X
BPL CODE_03807E
CMP.B #$E0
BCS +
LDA.B #$E0
BRA +
CODE_03807E:
CMP.B #$20
BCC +
LDA.B #$20
+ STA.B SpriteXSpeed,X
Return038086:
RTS
BigBooBoss:
JSL CODE_038398
JSL CODE_038239
LDA.W SpriteStatus,X
BNE +
INC.W CutsceneID
LDA.B #$FF
STA.W EndLevelTimer
LDA.B #!BGM_BOSSCLEAR
STA.W SPCIO2 ; / Change music
RTS
+ CMP.B #$08
BNE +
LDA.B SpriteLock
BNE +
LDA.B SpriteTableC2,X
JSL ExecutePtr
dw CODE_0380BE
dw CODE_0380D5
dw CODE_038119
dw CODE_03818B
dw CODE_0381BC
dw CODE_038106
dw CODE_0381D3
CODE_0380BE:
LDA.B #$03
STA.W SpriteMisc1602,X
INC.W SpriteMisc1570,X
LDA.W SpriteMisc1570,X
CMP.B #$90
BNE +
LDA.B #$08
STA.W SpriteMisc1540,X
INC.B SpriteTableC2,X
+ RTS
CODE_0380D5:
LDA.W SpriteMisc1540,X
BNE Return0380F9
LDA.B #$08
STA.W SpriteMisc1540,X
INC.W BooTransparency
LDA.W BooTransparency
CMP.B #$02
BNE +
LDY.B #!SFX_MAGIC ; \ Play sound effect
STY.W SPCIO0 ; /
+ CMP.B #$07
BNE Return0380F9
INC.B SpriteTableC2,X
LDA.B #$40
STA.W SpriteMisc1540,X
Return0380F9:
RTS
DATA_0380FA:
db $FF,$01
DATA_0380FC:
db $F0,$10
DATA_0380FE:
db $0C,$F4
DATA_038100:
db $01,$FF
DATA_038102:
db $01,$02,$02,$01
CODE_038106:
LDA.W SpriteMisc1540,X
BNE +
STZ.B SpriteTableC2,X
LDA.B #$40
STA.W SpriteMisc1570,X
+ LDA.B #$03
STA.W SpriteMisc1602,X
BRA +
CODE_038119:
STZ.W SpriteMisc1602,X
JSR CODE_0381E4
+ LDA.W SpriteMisc15AC,X
BNE CODE_038132
JSR SubHorzPosBnk3
TYA
CMP.W SpriteMisc157C,X
BEQ CODE_03814A
LDA.B #$1F
STA.W SpriteMisc15AC,X
CODE_038132:
CMP.B #$10
BNE +
PHA
LDA.W SpriteMisc157C,X
EOR.B #$01
STA.W SpriteMisc157C,X
PLA
+ LSR A
LSR A
LSR A
TAY
LDA.W DATA_038102,Y
STA.W SpriteMisc1602,X
CODE_03814A:
LDA.B EffFrame
AND.B #$07
BNE +
LDA.W SpriteMisc151C,X
AND.B #$01
TAY
LDA.B SpriteXSpeed,X
CLC
ADC.W DATA_0380FA,Y
STA.B SpriteXSpeed,X
CMP.W DATA_0380FC,Y
BNE +
INC.W SpriteMisc151C,X
+ LDA.B EffFrame
AND.B #$07
BNE +
LDA.W SpriteMisc1528,X
AND.B #$01
TAY
LDA.B SpriteYSpeed,X
CLC
ADC.W DATA_038100,Y
STA.B SpriteYSpeed,X
CMP.W DATA_0380FE,Y
BNE +
INC.W SpriteMisc1528,X
+ JSL UpdateXPosNoGvtyW
JSL UpdateYPosNoGvtyW
RTS
CODE_03818B:
LDA.W SpriteMisc1540,X
BNE CODE_0381AE
INC.B SpriteTableC2,X
LDA.B #$08
STA.W SpriteMisc1540,X
JSL LoadSpriteTables
INC.W SpriteMisc1534,X
LDA.W SpriteMisc1534,X
CMP.B #$03
BNE +
LDA.B #$06
STA.B SpriteTableC2,X
JSL KillMostSprites
+ RTS
CODE_0381AE:
AND.B #$0E
EOR.W SpriteOBJAttribute,X
STA.W SpriteOBJAttribute,X
LDA.B #$03
STA.W SpriteMisc1602,X
RTS
CODE_0381BC:
LDA.W SpriteMisc1540,X
BNE +
LDA.B #$08
STA.W SpriteMisc1540,X
DEC.W BooTransparency
BNE +
INC.B SpriteTableC2,X
LDA.B #$C0
STA.W SpriteMisc1540,X
+ RTS
CODE_0381D3:
LDA.B #$02 ; \ Sprite status = Killed
STA.W SpriteStatus,X ; /
STZ.B SpriteXSpeed,X ; Sprite X Speed = 0
LDA.B #$D0
STA.B SpriteYSpeed,X
LDA.B #!SFX_FALL ; \ Play sound effect
STA.W SPCIO0 ; /
RTS
CODE_0381E4:
LDY.B #$0B
CODE_0381E6:
LDA.W SpriteStatus,Y
CMP.B #$09
BEQ CODE_0381F5
CMP.B #$0A
BEQ CODE_0381F5
CODE_0381F1:
DEY
BPL CODE_0381E6
RTS
CODE_0381F5:
PHX
TYX
JSL GetSpriteClippingB
PLX
JSL GetSpriteClippingA
JSL CheckForContact
BCC CODE_0381F1
LDA.B #$03
STA.B SpriteTableC2,X
LDA.B #$40
STA.W SpriteMisc1540,X
PHX
TYX
STZ.W SpriteStatus,X
LDA.B SpriteXPosLow,X
STA.B TouchBlockXPos
LDA.W SpriteXPosHigh,X
STA.B TouchBlockXPos+1
LDA.B SpriteYPosLow,X
STA.B TouchBlockYPos
LDA.W SpriteYPosHigh,X
STA.B TouchBlockYPos+1
PHB
LDA.B #$02
PHA
PLB
LDA.B #$FF
JSL ShatterBlock
PLB
PLX
LDA.B #!SFX_ENEMYHURT ; \ Play sound effect
STA.W SPCIO3 ; /
RTS
CODE_038239:
LDY.B #$24
STY.B ColorSettings
LDA.W BooTransparency
CMP.B #$08
DEC A
BCS +
LDY.B #$34
STY.B ColorSettings
INC A
+ ASL A
ASL A
ASL A
ASL A
TAX
STZ.B _0
LDY.W DynPaletteIndex
- LDA.L BooBossPals,X
STA.W DynPaletteTable+2,Y
INY
INX
INC.B _0
LDA.B _0
CMP.B #$10
BNE -
LDX.W DynPaletteIndex
LDA.B #$10
STA.W DynPaletteTable,X
LDA.B #$F0
STA.W DynPaletteTable+1,X
STZ.W DynPaletteTable+$12,X
TXA
CLC
ADC.B #$12
STA.W DynPaletteIndex
LDX.W CurSpriteProcess ; X = Sprite index
RTL
BigBooDispX:
db $08,$08,$20,$00,$00,$00,$00,$10
db $10,$10,$10,$20,$20,$20,$20,$30
db $30,$30,$30,$FD,$0C,$0C,$27,$00
db $00,$00,$00,$10,$10,$10,$10,$1F
db $20,$20,$1F,$2E,$2E,$2C,$2C,$FB
db $12,$12,$30,$00,$00,$00,$00,$10
db $10,$10,$10,$1F,$20,$20,$1F,$2E
db $2E,$2E,$2E,$F8,$11,$FF,$08,$08
db $00,$00,$00,$00,$10,$10,$10,$10
db $20,$20,$20,$20,$30,$30,$30,$30
BigBooDispY:
db $12,$22,$18,$00,$10,$20,$30,$00
db $10,$20,$30,$00,$10,$20,$30,$00
db $10,$20,$30,$18,$16,$16,$12,$22
db $00,$10,$20,$30,$00,$10,$20,$30
db $00,$10,$20,$30,$00,$10,$20,$30
BigBooTiles:
db $C0,$E0,$E8,$80,$A0,$A0,$80,$82
db $A2,$A2,$82,$84,$A4,$C4,$E4,$86
db $A6,$C6,$E6,$E8,$C0,$E0,$E8,$80
db $A0,$A0,$80,$82,$A2,$A2,$82,$84
db $A4,$C4,$E4,$86,$A6,$C6,$E6,$E8
db $C0,$E0,$E8,$80,$A0,$A0,$80,$82
db $A2,$A2,$82,$84,$A4,$A4,$84,$86
db $A6,$A6,$86,$E8,$E8,$E8,$C2,$E2
db $80,$A0,$A0,$80,$82,$A2,$A2,$82
db $84,$A4,$C4,$E4,$86,$A6,$C6,$E6
BigBooGfxProp:
db $00,$00,$40,$00,$00,$80,$80,$00
db $00,$80,$80,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$40,$00
db $00,$80,$80,$00,$00,$80,$80,$00
db $00,$00,$00,$00,$00,$00,$00,$00
db $00,$00,$40,$00,$00,$80,$80,$00
db $00,$80,$80,$00,$00,$80,$80,$00
db $00,$80,$80,$00,$00,$40,$00,$00
db $00,$00,$80,$80,$00,$00,$80,$80
db $00,$00,$00,$00,$00,$00,$00,$00
CODE_038398:
PHB ; Wrapper
PHK
PLB
JSR CODE_0383A0
PLB
RTL
CODE_0383A0:
LDA.B SpriteNumber,X
CMP.B #$37
BNE CODE_0383C2
LDA.B #$00
LDY.B SpriteTableC2,X
BEQ +
LDA.B #$06
LDY.W SpriteMisc1558,X
BEQ +
TYA
AND.B #$04
LSR A
LSR A
ADC.B #$02
+ STA.W SpriteMisc1602,X
JSL GenericSprGfxRt2
RTS
CODE_0383C2:
JSR GetDrawInfoBnk3
LDA.W SpriteMisc1602,X
STA.B _6
ASL A
ASL A
STA.B _3
ASL A
ASL A
ADC.B _3
STA.B _2
LDA.W SpriteMisc157C,X
STA.B _4
LDA.W SpriteOBJAttribute,X
STA.B _5
LDX.B #$00
CODE_0383E0:
PHX
LDX.B _2
LDA.W BigBooTiles,X
STA.W OAMTileNo+$100,Y
LDA.B _4
LSR A
LDA.W BigBooGfxProp,X
ORA.B _5
BCS +
EOR.B #$40
+ ORA.B SpriteProperties
STA.W OAMTileAttr+$100,Y
LDA.W BigBooDispX,X
BCS +
EOR.B #$FF
INC A
CLC
ADC.B #$28
+ CLC
ADC.B _0
STA.W OAMTileXPos+$100,Y
PLX
PHX
LDA.B _6
CMP.B #$03
BCC +
TXA
CLC
ADC.B #$14
TAX
+ LDA.B _1
CLC
ADC.W BigBooDispY,X
STA.W OAMTileYPos+$100,Y
PLX
INY
INY
INY
INY
INC.B _2
INX
CPX.B #$14
BNE CODE_0383E0
LDX.W CurSpriteProcess ; X = Sprite index
LDA.W SpriteMisc1602,X
CMP.B #$03
BNE +
LDA.W SpriteMisc1558,X
BEQ +
LDY.W SpriteOAMIndex,X ; Y = Index into sprite OAM
LDA.W OAMTileYPos+$100,Y
CLC
ADC.B #$05
STA.W OAMTileYPos+$100,Y
STA.W OAMTileYPos+$104,Y
+ LDA.B #$13
LDY.B #$02
JSL FinishOAMWrite
RTS
GreyFallingPlat:
JSR CODE_038492
LDA.B SpriteLock
BNE Return038489
JSR SubOffscreen0Bnk3
LDA.B SpriteYSpeed,X
BEQ CODE_038476
LDA.W SpriteMisc1540,X
BNE +
LDA.B SpriteYSpeed,X
CMP.B #$40
BPL +
CLC
ADC.B #$02
STA.B SpriteYSpeed,X
+ JSL UpdateYPosNoGvtyW
CODE_038476:
JSL InvisBlkMainRt
BCC Return038489
LDA.B SpriteYSpeed,X
BNE Return038489
LDA.B #$03
STA.B SpriteYSpeed,X
LDA.B #$18
STA.W SpriteMisc1540,X
Return038489:
RTS
FallingPlatDispX:
db $00,$10,$20,$30
FallingPlatTiles:
db $60,$61,$61,$62
CODE_038492:
JSR GetDrawInfoBnk3
PHX
LDX.B #$03
- LDA.B _0
CLC
ADC.W FallingPlatDispX,X
STA.W OAMTileXPos+$100,Y
LDA.B _1
STA.W OAMTileYPos+$100,Y
LDA.W FallingPlatTiles,X
STA.W OAMTileNo+$100,Y
LDA.B #$03
ORA.B SpriteProperties
STA.W OAMTileAttr+$100,Y
INY
INY
INY
INY
DEX
BPL -
PLX
LDY.B #$02
LDA.B #$03
JSL FinishOAMWrite
RTS
BlurpMaxSpeedY:
db $04,$FC
BlurpSpeedX:
db $08,$F8
BlurpAccelY:
db $01,$FF
Blurp:
JSL GenericSprGfxRt2
LDY.W SpriteOAMIndex,X ; Y = Index into sprite OAM
LDA.W EffFrame
LSR A
LSR A
LSR A
CLC
ADC.W CurSpriteProcess
LSR A
LDA.B #$A2
BCC +
LDA.B #$EC
+ STA.W OAMTileNo+$100,Y
LDA.W SpriteStatus,X
CMP.B #$08
BEQ +
CODE_0384EC:
LDA.W OAMTileAttr+$100,Y
ORA.B #$80
STA.W OAMTileAttr+$100,Y
RTS
+ LDA.B SpriteLock
BNE Return03852A
JSR SubOffscreen0Bnk3
LDA.B EffFrame
AND.B #$03
BNE +
LDA.B SpriteTableC2,X
AND.B #$01
TAY
LDA.B SpriteYSpeed,X
CLC
ADC.W BlurpAccelY,Y
STA.B SpriteYSpeed,X
CMP.W BlurpMaxSpeedY,Y
BNE +
INC.B SpriteTableC2,X
+ LDY.W SpriteMisc157C,X
LDA.W BlurpSpeedX,Y
STA.B SpriteXSpeed,X
JSL UpdateXPosNoGvtyW
JSL UpdateYPosNoGvtyW
JSL SprSpr_MarioSprRts
Return03852A:
RTS
PorcuPuffAccel:
db $01,$FF
PorcuPuffMaxSpeed:
db $10,$F0
PorcuPuffer:
JSR CODE_0385A3
LDA.B SpriteLock
BNE Return038586
LDA.W SpriteStatus,X
CMP.B #$08
BNE Return038586
JSR SubOffscreen0Bnk3
JSL SprSpr_MarioSprRts
JSR SubHorzPosBnk3
TYA
STA.W SpriteMisc157C,X
LDA.B EffFrame
AND.B #$03
BNE +
LDA.B SpriteXSpeed,X ; \ Branch if at max speed
CMP.W PorcuPuffMaxSpeed,Y ; |
BEQ + ; /
CLC ; \ Otherwise, accelerate
ADC.W PorcuPuffAccel,Y ; |
STA.B SpriteXSpeed,X ; /
+ LDA.B SpriteXSpeed,X
PHA
LDA.W Layer1DXPos
ASL A
ASL A
ASL A
CLC
ADC.B SpriteXSpeed,X
STA.B SpriteXSpeed,X
JSL UpdateXPosNoGvtyW
PLA
STA.B SpriteXSpeed,X
JSL CODE_019138
LDY.B #$04
LDA.W SpriteInLiquid,X
BEQ +
LDY.B #$FC
+ STY.B SpriteYSpeed,X
JSL UpdateYPosNoGvtyW
Return038586:
RTS
PocruPufferDispX:
db $F8,$08,$F8,$08,$08,$F8,$08,$F8
PocruPufferDispY:
db $F8,$F8,$08,$08
PocruPufferTiles:
db $86,$C0,$A6,$C2,$86,$C0,$A6,$8A
PocruPufferGfxProp:
db $0D,$0D,$0D,$0D,$4D,$4D,$4D,$4D
CODE_0385A3:
JSR GetDrawInfoBnk3
LDA.B EffFrame
AND.B #$04
STA.B _3
LDA.W SpriteMisc157C,X
STA.B _2
PHX
LDX.B #$03
CODE_0385B4:
LDA.B _1
CLC
ADC.W PocruPufferDispY,X
STA.W OAMTileYPos+$100,Y
PHX
LDA.B _2
BNE +
TXA
ORA.B #$04
TAX
+ LDA.B _0
CLC
ADC.W PocruPufferDispX,X
STA.W OAMTileXPos+$100,Y
LDA.W PocruPufferGfxProp,X
ORA.B SpriteProperties
STA.W OAMTileAttr+$100,Y
PLA
PHA
ORA.B _3
TAX
LDA.W PocruPufferTiles,X
STA.W OAMTileNo+$100,Y
PLX
INY
INY
INY
INY
DEX
BPL CODE_0385B4
PLX
LDY.B #$02
LDA.B #$03
JSL FinishOAMWrite
RTS
FlyingBlockSpeedY:
db $08,$F8
FlyingTurnBlocks:
JSR CODE_0386A8
LDA.B SpriteLock
BNE Return038675
LDA.W BGFastScrollActive
BEQ CODE_038629
LDA.W SpriteMisc1534,X
INC.W SpriteMisc1534,X
AND.B #$01
BNE +
DEC.W SpriteMisc1602,X
LDA.W SpriteMisc1602,X
CMP.B #$FF
BNE +
LDA.B #$FF
STA.W SpriteMisc1602,X
INC.W SpriteMisc157C,X
+ LDA.W SpriteMisc157C,X
AND.B #$01
TAY
LDA.W FlyingBlockSpeedY,Y
STA.B SpriteYSpeed,X
CODE_038629:
LDA.B SpriteYSpeed,X
PHA
LDY.W SpriteMisc151C,X
BNE +
EOR.B #$FF
INC A
STA.B SpriteYSpeed,X
+ JSL UpdateYPosNoGvtyW
PLA
STA.B SpriteYSpeed,X
LDA.W BGFastScrollActive
STA.B SpriteXSpeed,X
JSL UpdateXPosNoGvtyW
STA.W SpriteMisc1528,X
JSL InvisBlkMainRt
BCC Return038675
LDA.W BGFastScrollActive
BNE Return038675
LDA.B #$08
STA.W BGFastScrollActive
LDA.B #$7F
STA.W SpriteMisc1602,X
LDY.B #$09
CODE_038660:
CPY.W CurSpriteProcess
BEQ CODE_03866C
LDA.W SpriteNumber,Y
CMP.B #$C1
BEQ CODE_038670
CODE_03866C:
DEY
BPL CODE_038660
INY
CODE_038670:
LDA.B #$7F
STA.W SpriteMisc1602,Y
Return038675:
RTS
ForestPlatDispX:
db $00,$10,$20,$F2,$2E,$00,$10,$20
db $FA,$2E
ForestPlatDispY:
db $00,$00,$00,$F6,$F6,$00,$00,$00
db $FE,$FE
ForestPlatTiles:
db $40,$40,$40,$C6,$C6,$40,$40,$40
db $5D,$5D
ForestPlatGfxProp:
db $32,$32,$32,$72,$32,$32,$32,$32
db $72,$32
ForestPlatTileSize:
db $02,$02,$02,$02,$02,$02,$02,$02
db $00,$00
CODE_0386A8:
JSR GetDrawInfoBnk3
LDY.W SpriteOAMIndex,X ; Y = Index into sprite OAM
LDA.B EffFrame
LSR A
AND.B #$04
BEQ +
INC A
+ STA.B _2
PHX
LDX.B #$04
- STX.B _6
TXA
CLC
ADC.B _2
TAX
LDA.B _0
CLC
ADC.W ForestPlatDispX,X
STA.W OAMTileXPos+$100,Y
LDA.B _1
CLC
ADC.W ForestPlatDispY,X
STA.W OAMTileYPos+$100,Y
LDA.W ForestPlatTiles,X
STA.W OAMTileNo+$100,Y
LDA.W ForestPlatGfxProp,X
STA.W OAMTileAttr+$100,Y
PHY
TYA
LSR A
LSR A
TAY
LDA.W ForestPlatTileSize,X
STA.W OAMTileSize+$40,Y
PLY
INY
INY
INY
INY
LDX.B _6
DEX
BPL -
PLX
LDY.B #$FF
LDA.B #$04
JSL FinishOAMWrite
RTS
GrayLavaPlatform:
JSR CODE_03873A
LDA.B SpriteLock
BNE Return038733
JSR SubOffscreen0Bnk3
LDA.W SpriteMisc1540,X
DEC A
BNE +
LDY.W SpriteLoadIndex,X ; \
LDA.B #$00 ; | Allow sprite to be reloaded by level loading routine
STA.W SpriteLoadStatus,Y ; /
STZ.W SpriteStatus,X
RTS
+ JSL UpdateYPosNoGvtyW
JSL InvisBlkMainRt
BCC Return038733
LDA.W SpriteMisc1540,X
BNE Return038733
LDA.B #$06
STA.B SpriteYSpeed,X
LDA.B #$40
STA.W SpriteMisc1540,X
Return038733:
RTS
LavaPlatTiles:
db $85,$86,$85
DATA_038737:
db $43,$03,$03
CODE_03873A:
JSR GetDrawInfoBnk3
PHX
LDX.B #$02
- LDA.B _0
STA.W OAMTileXPos+$100,Y
CLC
ADC.B #$10
STA.B _0
LDA.B _1
STA.W OAMTileYPos+$100,Y
LDA.W LavaPlatTiles,X
STA.W OAMTileNo+$100,Y
LDA.W DATA_038737,X
ORA.B SpriteProperties
STA.W OAMTileAttr+$100,Y
INY
INY
INY
INY
DEX
BPL -
PLX
LDY.B #$02
LDA.B #$02
JSL FinishOAMWrite
RTS
MegaMoleSpeed:
db $10,$F0
MegaMole:
JSR MegaMoleGfxRt ; Graphics routine
LDA.W SpriteStatus,X ; \
CMP.B #$08 ; | If status != 8, return
BNE Return038733 ; /
JSR SubOffscreen3Bnk3 ; Handle off screen situation
LDY.W SpriteMisc157C,X ; \ Set x speed based on direction
LDA.W MegaMoleSpeed,Y ; |
STA.B SpriteXSpeed,X ; /
LDA.B SpriteLock ; \ If sprites locked, return
BNE Return038733 ; /
LDA.W SpriteBlockedDirs,X
AND.B #$04
PHA
JSL UpdateSpritePos ; Update position based on speed values
JSL SprSprInteract ; Interact with other sprites
LDA.W SpriteBlockedDirs,X ; \ Branch if not on ground
AND.B #$04 ; |
BEQ MegaMoleInAir ; /
STZ.B SpriteYSpeed,X ; Sprite Y Speed = 0
PLA
BRA MegaMoleOnGround
MegaMoleInAir:
PLA
BEQ +
LDA.B #$0A
STA.W SpriteMisc1540,X
+ LDA.W SpriteMisc1540,X
BEQ MegaMoleOnGround
STZ.B SpriteYSpeed,X ; Sprite Y Speed = 0
MegaMoleOnGround:
LDY.W SpriteMisc15AC,X ; \
LDA.W SpriteBlockedDirs,X ; | If Mega Mole is in contact with an object...
AND.B #$03 ; |
BEQ CODE_0387CD ; |
CPY.B #$00 ; | ... and timer hasn't been set (time until flip == 0)...
BNE + ; |
LDA.B #$10 ; | ... set time until flip
STA.W SpriteMisc15AC,X ; /
+ LDA.W SpriteMisc157C,X ; \ Flip the temp direction status
EOR.B #$01 ; |
STA.W SpriteMisc157C,X ; /
CODE_0387CD:
CPY.B #$00 ; \ If time until flip == 0...
BNE + ; |
LDA.W SpriteMisc157C,X ; | ...update the direction status used by the gfx routine
STA.W SpriteMisc151C,X ; /
+ JSL MarioSprInteract ; Check for mario/Mega Mole contact
BCC Return03882A ; (Carry set = contact)
JSR SubVertPosBnk3
LDA.B _E
CMP.B #$D8
BPL MegaMoleContact
LDA.B PlayerYSpeed+1
BMI Return03882A
LDA.B #$01 ; \ Set "on sprite" flag
STA.W StandOnSolidSprite ; /
LDA.B #$06 ; \ Set riding Mega Mole
STA.W SpriteMisc154C,X ; /
STZ.B PlayerYSpeed+1 ; Y speed = 0
LDA.B #$D6 ; \
LDY.W PlayerRidingYoshi ; | Mario's y position += C6 or D6 depending if on yoshi
BEQ + ; |
LDA.B #$C6 ; |
+ CLC ; |
ADC.B SpriteYPosLow,X ; |
STA.B PlayerYPosNext ; |
LDA.W SpriteYPosHigh,X ; |
ADC.B #$FF ; |
STA.B PlayerYPosNext+1 ; /
LDY.B #$00 ; \
LDA.W SpriteXMovement ; | $1491 == 01 or FF, depending on direction
BPL + ; | Set mario's new x position
DEY ; |
+ CLC ; |
ADC.B PlayerXPosNext ; |
STA.B PlayerXPosNext ; |
TYA ; |
ADC.B PlayerXPosNext+1 ; |