-
Notifications
You must be signed in to change notification settings - Fork 15
/
bank_02.asm
16983 lines (15807 loc) · 346 KB
/
bank_02.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 $028000
DATA_028000:
db $80,$40,$20,$10,$08,$04,$02,$01
CODE_028008:
PHX
LDA.W PlayerItembox
BEQ CODE_028070
STZ.W PlayerItembox
PHA
LDA.B #!SFX_ITEMDEPLOYED ; \ Play sound effect
STA.W SPCIO3 ; /
LDX.B #$0B
CODE_028019:
LDA.W SpriteStatus,X
BEQ CODE_028042
DEX
BPL CODE_028019
DEC.W SpriteToOverwrite
BPL +
LDA.B #$01
STA.W SpriteToOverwrite
+ LDA.W SpriteToOverwrite
CLC
ADC.B #$0A
TAX
LDA.B SpriteNumber,X
CMP.B #$7D
BNE CODE_028042
LDA.W SpriteStatus,X
CMP.B #$0B
BNE CODE_028042
STZ.W PBalloonInflating
CODE_028042:
LDA.B #$08 ; \ Sprite status = Normal
STA.W SpriteStatus,X ; /
PLA
CLC
ADC.B #$73
STA.B SpriteNumber,X
JSL InitSpriteTables
LDA.B #$78
CLC
ADC.B Layer1XPos
STA.B SpriteXPosLow,X
LDA.B Layer1XPos+1
ADC.B #$00
STA.W SpriteXPosHigh,X
LDA.B #$20
CLC
ADC.B Layer1YPos
STA.B SpriteYPosLow,X
LDA.B Layer1YPos+1
ADC.B #$00
STA.W SpriteYPosHigh,X
INC.W SpriteMisc1534,X
CODE_028070:
PLX
RTL
BombExplosionX:
db $00,$08,$06,$FA,$F8,$06,$08,$00
db $F8,$FA
BombExplosionY:
db $F8,$FE,$06,$06,$FE,$FA,$02,$08
db $02,$FA
ExplodeBombRt:
JSR ExplodeBombSubRt ;BOMB
RTL
ExplodeBombSubRt:
STZ.W SpriteTweakerA,X ; Make sprite unstompable
LDA.B #$11 ; \ Set new clipping area for explosion
STA.W SpriteTweakerB,X ; /
JSR GetDrawInfo2
LDA.B SpriteLock ; \ Increase frame count if sprites not locked
BNE + ; |
INC.W SpriteMisc1570,X ; /
+ LDA.W SpriteMisc1540,X ; \ When timer is up free up sprite slot
BNE + ; |
STZ.W SpriteStatus,X ; /
RTS
+ LDA.W SpriteMisc1540,X
LSR A
AND.B #$03
CMP.B #$03
BNE +
JSR ExplodeSprites
LDA.W SpriteMisc1540,X
SEC
SBC.B #$10
CMP.B #$20
BCS +
JSL MarioSprInteract
+ LDY.B #$04
STY.B _F
CODE_0280C4:
LDA.W SpriteMisc1540,X
LSR A
PHA
AND.B #$03
STA.B _2
LDA.B SpriteXPosLow,X
SEC
SBC.B Layer1XPos
CLC
ADC.B #$04
STA.B _0
LDA.B SpriteYPosLow,X
SEC
SBC.B Layer1YPos
CLC
ADC.B #$04
STA.B _1
LDY.B _F
PLA
AND.B #$04
BEQ CODE_0280ED
TYA
CLC
ADC.B #$05
TAY
CODE_0280ED:
LDA.B _0
CLC
ADC.W BombExplosionX,Y
STA.B _0
LDA.B _1
CLC
ADC.W BombExplosionY,Y
STA.B _1
DEC.B _2
BPL CODE_0280ED
LDA.B _F
ASL A
ASL A
ADC.W SpriteOAMIndex,X
TAY
LDA.B _0
STA.W OAMTileXPos+$100,Y
LDA.B _1
STA.W OAMTileYPos+$100,Y
LDA.B #$BC
STA.W OAMTileNo+$100,Y
LDA.B TrueFrame
LSR A
LSR A
AND.B #$03
SEC
ROL A
ORA.B SpriteProperties
STA.W OAMTileAttr+$100,Y
TYA
LSR A
LSR A
TAY
LDA.B #$00
STA.W OAMTileSize+$40,Y
DEC.B _F
BPL CODE_0280C4
LDY.B #$00
LDA.B #$04
JMP CODE_02B7A7
ExplodeSprites:
LDY.B #$09 ; \ Loop over sprites:
ExplodeLoopStart:
CPY.W CurSpriteProcess ; | Don't attempt to kill self
BEQ CODE_02814C ; |
PHY ; |
LDA.W SpriteStatus,Y ; | Skip sprite if it's already dying/dead
CMP.B #$08 ; |
BCC + ; |
JSR ExplodeKillSpr ; | Check for contact
+ PLY ; |
CODE_02814C:
DEY ; | Next
BPL ExplodeLoopStart ; /
RTS
ExplodeKillSpr:
PHX
TYX ; \ Return if no sprite contact
JSL GetSpriteClippingB ; |
PLX ; |
JSL GetSpriteClippingA ; |
JSL CheckForContact ; |
BCC + ; /
LDA.W SpriteTweakerD,Y ; \ Return if sprite is invincible
AND.B #$02 ; | to explosions
BNE + ; /
LDA.B #$02 ; \ Sprite status = Killed
STA.W SpriteStatus,Y ; /
LDA.B #$C0 ; \ Sprite Y speed = #$C0
STA.W SpriteYSpeed,Y ; /
LDA.B #$00 ; \ Sprite X speed = #$00
STA.W SpriteXSpeed,Y ; /
+ RTS
DATA_028178:
db $F8,$38,$78,$B8,$00,$10,$20,$D0
db $E0,$10,$40,$80,$C0,$10,$10,$20
db $B0,$20,$50,$60,$C0,$F0,$80,$B0
db $20,$60,$A0,$E0,$70,$F0,$70,$B0
db $F0,$10,$20,$50,$60,$90,$A0,$D0
db $E0,$10,$20,$50,$60,$90,$A0,$D0
db $E0,$10,$20,$50,$60,$90,$A0,$D0
db $E0,$50,$60,$C0,$D0,$30,$40,$70
db $80,$B0,$C0,$30,$40,$70,$80,$B0
db $C0,$40,$50,$80,$90,$C8,$D8,$30
db $40,$A0,$B0,$58,$68,$B0,$C0
DATA_0281CF:
db $70,$70,$70,$70,$20,$20,$20,$20
db $20,$30,$30,$30,$30,$70,$80,$80
db $80,$90,$90,$90,$A0,$50,$60,$60
db $70,$70,$70,$70,$60,$60,$70,$70
db $70,$40,$40,$40,$40,$40,$40,$40
db $40,$50,$50,$50,$50,$50,$50,$50
db $50,$60,$60,$60,$60,$60,$60,$60
db $60,$30,$30,$30,$30,$48,$48,$48
db $48,$48,$48,$58,$58,$58,$58,$58
db $58,$70,$70,$78,$78,$70,$70,$80
db $80,$88,$88,$A0,$A0,$A0,$A0
DATA_028226:
db $E8,$E8,$E8,$E8,$E4,$E4,$E4,$E4
db $E4,$E4,$E4,$E4,$E4,$E4,$E4,$E4
db $E4,$E4,$E4,$E4,$E4,$E4,$E4,$E4
db $E4,$E4,$E4,$E4,$EE,$EE,$EE,$EE
db $EE,$C0,$C2,$C0,$C2,$C0,$C2,$C0
db $C2,$E0,$E2,$E0,$E2,$E0,$E2,$E0
db $E2,$C4,$A4,$C4,$A4,$C4,$A4,$C4
db $A4,$CC,$CE,$CC,$CE,$C8,$CA,$C8
db $CA,$C8,$CA,$CA,$C8,$CA,$C8,$CA
db $C8,$CC,$CE,$CC,$CE,$CC,$CE,$CC
db $CE,$CC,$CE,$CC,$CE,$CC,$CE
ProcM7BossObjBG:
LDA.B Layer1XPos
STA.W BossBGSpriteXCalc
EOR.B #$FF
INC A
STA.B _5
LDA.B Layer1XPos+1
LSR A
ROR.W BossBGSpriteXCalc
PHA
LDA.W BossBGSpriteXCalc
EOR.B #$FF
INC A
STA.B _6
PLA
LSR A
ROR.W BossBGSpriteXCalc
LDA.W BossBGSpriteXCalc
EOR.B #$FF
INC A
STA.W BossBGSpriteXCalc
REP #$10 ; XY->16
LDY.W #$0164
LDA.B #$66
STY.B _3
LDA.B #$F0
- STA.W OAMTileYPos+$0C,Y
INY
INY
INY
INY
CPY.W #$018C
BCC -
LDX.W #$0000
STX.B _C
LDX.W #$0038
LDY.W #$00E0
LDA.W SpriteMisc187B+9
CMP.B #$01
BNE CODE_0282D8
LDX.W #$0039
STX.B _C
LDX.W #$001D
LDY.W #$00FC
CODE_0282D8:
STX.B _0
REP #$20 ; A->16
TXA
CLC
ADC.B _C
STA.B _A
SEP #$20 ; A->8
LDA.B _6
CLC
LDX.B _A
ADC.L DATA_028178,X
STA.W OAMTileXPos+$0C,Y
STA.B _2
LDA.W ScreenShakeYOffset
STA.B _7
ASL A
ROR.B _7
LDA.L DATA_0281CF,X
DEC A
SEC
SBC.B _7
STA.W OAMTileYPos+$0C,Y
LDX.B _A
LDA.W BossBGSpriteUpdate
BNE +
LDA.L DATA_028226,X
STA.W OAMTileNo+$0C,Y
LDA.B #$0D
STA.W OAMTileAttr+$0C,Y
+ REP #$20 ; A->16
PHY
TYA
LSR A
LSR A
TAY
SEP #$20 ; A->8
LDA.B #$02
STA.W OAMTileSize+3,Y
LDA.B _2
CMP.B #$F0
BCC +
LDA.W SpriteMisc187B+9
CMP.B #$01
BEQ +
PLY
PHY
LDX.B _3
LDA.W OAMTileXPos+$0C,Y
STA.W OAMTileXPos+$0C,X
LDA.W OAMTileYPos+$0C,Y
STA.W OAMTileYPos+$0C,X
LDA.W OAMTileNo+$0C,Y
STA.W OAMTileNo+$0C,X
LDA.W OAMTileAttr+$0C,Y
STA.W OAMTileAttr+$0C,X
REP #$20 ; A->16
TXA
LSR A
LSR A
TAY
SEP #$20 ; A->8
LDA.B #$03
STA.W OAMTileSize+3,Y
LDA.B _3
CLC
ADC.B #$04
STA.B _3
BCC +
INC.B _4
+ PLY
LDX.B _0
DEY
DEY
DEY
DEY
DEX
BMI +
JMP CODE_0282D8
+ SEP #$10 ; XY->8
LDA.B #$01
STA.W BossBGSpriteUpdate
LDA.W SpriteMisc187B+9
CMP.B #$01
BNE CODE_028398
LDA.B #$CD
STA.W OAMTileAttr+$BC
STA.W OAMTileAttr+$C0
STA.W OAMTileAttr+$C4
STA.W OAMTileAttr+$C8
STA.W OAMTileAttr+$CC
STA.W OAMTileAttr+$D0
BRA CODE_0283C4
CODE_028398:
LDA.B EffFrame
AND.B #$03
BNE CODE_0283C4
STZ.B _0
CODE_0283A0:
LDX.B _0
LDA.L DATA_0283C8,X
TAY
JSL GetRand
AND.B #$01
BNE +
LDA.W OAMTileNo+$0C,Y
EOR.B #$02
STA.W OAMTileNo+$0C,Y
+ LDA.B #$09
STA.W OAMTileAttr+$0C,Y
INC.B _0
LDA.B _0
CMP.B #$04
BNE CODE_0283A0
CODE_0283C4:
JSR CODE_0283CE
RTL
DATA_0283C8:
db $00,$04,$08,$0C
DATA_0283CC:
db $0C,$30
CODE_0283CE:
LDA.W SpriteMisc1534+9
SEC
SBC.B #$1E
STA.B _C
LDA.W SpriteMisc160E+9
CLC
ADC.B #$10
STA.B _D
LDX.B #$01
CODE_0283E0:
STX.B _F
LDA.W BossPillarFalling,X
BEQ CODE_0283F4
BMI +
STA.W PlayerIsFrozen
STA.B SpriteLock
JSR CODE_0283F8
+ JSR CODE_028439
CODE_0283F4:
DEX
BPL CODE_0283E0
RTS
CODE_0283F8:
LDA.W BossPillarYPos,X
LSR A
LSR A
LSR A
LSR A
LSR A
SEC
ADC.W BossPillarYPos,X
CMP.B #$B0
BCC CODE_028435
ASL.W BossPillarFalling,X
SEC
ROR.W BossPillarFalling,X
LDA.B #$30 ; \ Set ground shake timer
STA.W ScreenShakeTimer ; /
LDA.B #!SFX_KAPOW ; \ Play sound effect
STA.W SPCIO3 ; /
CPX.B #$00
BNE CODE_02842A
LDA.W BossPillarFalling+1
BNE CODE_02842A
INC.W BossPillarFalling+1
STZ.W BossPillarYPos+1
BRA +
CODE_02842A:
CPX.B #$01
BNE +
STZ.B SpriteLock
STZ.W PlayerIsFrozen
+ LDA.B #$B0
CODE_028435:
STA.W BossPillarYPos,X
RTS
CODE_028439:
LDA.L DATA_0283CC,X
TAY
STZ.B _0
CODE_028440:
LDA.B #$F0
STA.W OAMTileYPos,Y
LDA.W BossPillarYPos,X
SEC
SBC.B Layer1YPos
SEC
SBC.W ScreenShakeYOffset
SEC
SBC.B _0
CMP.B #$20
BCC Return02848C
CMP.B #$A4
BCS +
STA.W OAMTileYPos,Y
+ LDA.B _C,X
STA.W OAMTileXPos,Y
LDA.B #$E6
LDX.B _0
BEQ +
LDA.B #$08
+ STA.W OAMTileNo,Y
LDA.B #$0D
STA.W OAMTileAttr,Y
TYA
LSR A
LSR A
TAX
LDA.B #$02
STA.W OAMTileSize,X
LDX.B _F
INY
INY
INY
INY
LDA.B _0
CLC
ADC.B #$10
STA.B _0
CMP.B #$90
BCC CODE_028440
Return02848C:
RTS
SubHorzPosBnk2:
LDY.B #$00
LDA.B PlayerXPosNext
SEC
SBC.B SpriteXPosLow,X
STA.B _F
LDA.B PlayerXPosNext+1
SBC.W SpriteXPosHigh,X
BPL +
INY
+ RTS
IsOffScreenBnk2:
LDA.W SpriteOffscreenX,X
ORA.W SpriteOffscreenVert,X
RTS
CODE_0284A6:
STA.B _3
LDA.B #$02
STA.B _1
- JSL CODE_0284D8
LDA.B _2
CLC
ADC.B _3
STA.B _2
DEC.B _1
BPL -
RTL
CODE_0284BC:
LDA.B #$12
BRA +
CODE_0284C0:
LDA.B #$00
+ STA.B _0
STZ.B _2
LDA.B SpriteNumber,X
CMP.B #$41
BEQ CODE_0284D0
CMP.B #$42
BNE CODE_0284D8
CODE_0284D0:
LDA.B SpriteYSpeed,X
BPL Return0284E7
LDA.B #$0A
BRA CODE_0284A6
CODE_0284D8:
JSR IsOffScreenBnk2
BNE Return0284E7
LDY.B #$0B
CODE_0284DF:
LDA.W MinExtSpriteNumber,Y
BEQ CODE_0284E8
DEY
BPL CODE_0284DF
Return0284E7:
RTL
CODE_0284E8:
LDA.B SpriteYPosLow,X
CLC
ADC.B #$00
AND.B #$F0
CLC
ADC.B #$03
STA.W MinExtSpriteYPosLow,Y
LDA.B SpriteXPosLow,X
CLC
ADC.B _2
STA.W MinExtSpriteXPosLow,Y
LDA.W SpriteXPosHigh,X
ADC.B #$00
STA.W MinExtSpriteXPosHigh,Y
LDA.B #$07
STA.W MinExtSpriteNumber,Y
LDA.B _0
STA.W MinExtSpriteTimer,Y
RTL
DATA_028510:
db $04,$FC,$06,$FA,$08,$F8,$0A,$F6
DATA_028518:
db $E0,$E1,$E2,$E3,$E4,$E6,$E8,$EA
DATA_028520:
db $1F,$13,$10,$1C,$17,$1A,$0F,$1E
CODE_028528:
JSR IsOffScreenBnk2
LDA.W SpriteOffscreenVert,X
BNE Return0284E7
LDA.B #$04
STA.B _0
LDY.B #$07 ; \ Find a free extended sprite slot
CODE_028536:
LDA.W ExtSpriteNumber,Y ; |
BEQ CODE_02853F ; |
DEY ; |
BPL CODE_028536 ; |
RTL ; / Return if no free slots
CODE_02853F:
LDA.B #$07 ; \ Extended sprite = Lava splash
STA.W ExtSpriteNumber,Y ; /
LDA.B SpriteYPosLow,X
STA.W ExtSpriteYPosLow,Y
LDA.W SpriteYPosHigh,X
STA.W ExtSpriteYPosHigh,Y
LDA.B SpriteXPosLow,X
CLC
ADC.B #$04
STA.W ExtSpriteXPosLow,Y
LDA.W SpriteXPosHigh,X
ADC.B #$00
STA.W ExtSpriteXPosHigh,Y
JSL GetRand
PHX
AND.B #$07
TAX
LDA.L DATA_028510,X
STA.W ExtSpriteXSpeed,Y
LDA.W RandomNumber+1
AND.B #$07
TAX
LDA.L DATA_028518,X
STA.W ExtSpriteYSpeed,Y
JSL GetRand
AND.B #$07
TAX
LDA.L DATA_028520,X
STA.W ExtSpriteMisc176F,Y
PLX
DEC.B _0
BPL CODE_028536
RTL
CODE_02858F:
LDY.B #$1F ; \ If Big Mario:
LDX.B #$00 ; | Y = #$1F
LDA.B Powerup ; | X = #$00
BNE + ; | Small Mario:
LDY.B #$0F ; | Y = #$0F
LDX.B #$10 ; / X = #$10
+ STX.B _1
JSL GetRand
TYA
AND.W RandomNumber
CLC
ADC.B _1
CLC
ADC.B PlayerYPosNext
STA.B _0
LDA.W RandomNumber+1
AND.B #$0F
CLC
ADC.B #$FE
CLC
ADC.B PlayerXPosNext
STA.B _2
CODE_0285BA:
LDY.B #$0B
CODE_0285BC:
LDA.W MinExtSpriteNumber,Y
BEQ CODE_0285C5
DEY
BPL CODE_0285BC
RTL
CODE_0285C5:
LDA.B #$05
STA.W MinExtSpriteNumber,Y
LDA.B #$00
STA.W MinExtSpriteYSpeed,Y
LDA.B _0
STA.W MinExtSpriteYPosLow,Y
LDA.B _2
STA.W MinExtSpriteXPosLow,Y
LDA.B #$17
STA.W MinExtSpriteTimer,Y
RTL
CODE_0285DF:
JSR IsOffScreenBnk2
BNE Return0285EE
LDY.B #$0B
CODE_0285E6:
LDA.W MinExtSpriteNumber,Y
BEQ CODE_0285EF
DEY
BPL CODE_0285E6
Return0285EE:
RTL
CODE_0285EF:
JSL GetRand
LDA.B #$04
STA.W MinExtSpriteNumber,Y
LDA.B #$00
STA.W MinExtSpriteYSpeed,Y
LDA.W RandomNumber
AND.B #$0F
SEC
SBC.B #$03
CLC
ADC.B SpriteXPosLow,X
STA.W MinExtSpriteXPosLow,Y
LDA.W SpriteXPosHigh,X
ADC.B #$00
STA.W MinExtSpriteXPosHigh,Y
LDA.W RandomNumber+1
AND.B #$07
CLC
ADC.B #$07
CLC
ADC.B SpriteYPosLow,X
STA.W MinExtSpriteYPosLow,Y
LDA.W SpriteYPosHigh,X
ADC.B #$00
STA.W MinExtSpriteYPosHigh,Y
LDA.B #$17
STA.W MinExtSpriteTimer,Y
RTL
CODE_02862F:
JSL FindFreeSprSlot ; \ Return if no free slots
BMI + ; /
TYX
LDA.B #$0B ; \ Sprite status = Being carried
STA.W SpriteStatus,X ; /
LDA.B PlayerYPosNext
STA.B SpriteYPosLow,X
LDA.B PlayerYPosNext+1
STA.W SpriteYPosHigh,X
LDA.B PlayerXPosNext
STA.B SpriteXPosLow,X
LDA.B PlayerXPosNext+1,X
STA.W SpriteXPosHigh,X
LDA.B #$53 ; \ Sprite = Throw Block
STA.B SpriteNumber,X ; /
JSL InitSpriteTables
LDA.B #$FF
STA.W SpriteMisc1540,X
LDA.B #$08
STA.W PickUpItemTimer
STA.W IsCarryingItem
+ RTL
ShatterBlock:
PHX
STA.B _0
LDY.B #$03
LDX.B #$0B
CODE_02866A:
LDA.W MinExtSpriteNumber,X
BEQ CODE_02867F
CODE_02866F:
DEX
BPL CODE_02866A
DEC.W MinExtSpriteSlotIdx
BPL +
LDA.B #$0B
STA.W MinExtSpriteSlotIdx
+ LDX.W MinExtSpriteSlotIdx
CODE_02867F:
LDA.B #!SFX_SHATTER ; \
STA.W SPCIO3 ; / Play sound effect
LDA.B #$01
STA.W MinExtSpriteNumber,X
LDA.B TouchBlockXPos
CLC
ADC.W DATA_028746,Y
STA.W MinExtSpriteXPosLow,X
LDA.B TouchBlockXPos+1
ADC.B #$00
STA.W MinExtSpriteXPosHigh,X
LDA.B TouchBlockYPos
CLC
ADC.W DATA_028742,Y
STA.W MinExtSpriteYPosLow,X
LDA.B TouchBlockYPos+1
ADC.B #$00
STA.W MinExtSpriteYPosHigh,X
LDA.W DATA_02874A,Y
STA.W MinExtSpriteYSpeed,X
LDA.W DATA_02874E,Y
STA.W MinExtSpriteXSpeed,X
LDA.B _0
STA.W MinExtSpriteTimer,X
DEY
BPL CODE_02866F
PLX
RTL
YoshiStompRoutine:
LDA.W SpriteStompCounter
BNE +
PHB
PHK
PLB
JSR SprBlkInteract
LDA.B #$02
STA.W QuakeSpriteNumber,Y
LDA.B PlayerXPosNext
STA.W QuakeSpriteXPosLow,Y
LDA.B PlayerXPosNext+1
STA.W QuakeSpriteYPosHigh,Y
LDA.B PlayerYPosNext
CLC
ADC.B #$20
STA.W QuakeSpriteYPosLow,Y
LDA.B PlayerYPosNext+1
ADC.B #$00
STA.W QuakeSpriteYPosHigh,Y
JSR CODE_029BE4
PLB
+ RTL
SprBlkInteract:
LDY.B #$03
CODE_0286EF:
LDA.W QuakeSpriteNumber,Y
BEQ CODE_0286F8
DEY
BPL CODE_0286EF
INY
CODE_0286F8:
LDA.B TouchBlockXPos
STA.W QuakeSpriteXPosLow,Y
LDA.B TouchBlockXPos+1
STA.W QuakeSpriteXPosHigh,Y
LDA.B TouchBlockYPos
STA.W QuakeSpriteYPosLow,Y
LDA.B TouchBlockYPos+1
STA.W QuakeSpriteYPosHigh,Y
LDA.W LayerProcessing
BEQ +
LDA.B TouchBlockXPos
SEC
SBC.B Layer23XRelPos
STA.W QuakeSpriteXPosLow,Y
LDA.B TouchBlockXPos+1
SBC.B Layer23XRelPos+1
STA.W QuakeSpriteXPosHigh,Y
LDA.B TouchBlockYPos
SEC
SBC.B Layer23YRelPos
STA.W QuakeSpriteYPosLow,Y
LDA.B TouchBlockYPos+1
SBC.B Layer23YRelPos+1
STA.W QuakeSpriteYPosHigh,Y
+ LDA.B #$01
STA.W QuakeSpriteNumber,Y
LDA.B #$06
STA.W BounceSpriteIntTimer,Y
RTS
BlockBounceSpeedY:
db $C0,$00,$00,$40
BlockBounceSpeedX:
db $00,$40,$C0,$00
DATA_028742:
db $00,$00,$08,$08
DATA_028746:
db $00,$08,$00,$08
DATA_02874A:
db $FB,$FB,$FD,$FD
DATA_02874E:
db $FF,$01,$FF,$01
CODE_028752:
LDA.B _4
CMP.B #$07
BNE NotBreakable
LDA.W PlayerTurnLvl ; \ Increase points
ASL A ; |
ADC.W PlayerTurnLvl ; |
TAX ; |
LDA.W PlayerScore,X ; |
CLC ; |
ADC.B #$05 ; |
STA.W PlayerScore,X ; |
BCC + ; |
INC.W PlayerScore+1,X ; |
BNE + ; |
INC.W PlayerScore+2,X ; /
+ LDA.B #$D0 ; Deflect Mario downward
STA.B PlayerYSpeed+1 ; /
LDA.B #$00 ; for shatter routine?
JSL ShatterBlock ; Actually break the block
JSR SprBlkInteract ; Handle sprite/block interaction
CODE_028780:
LDA.B #$02 ; \ Replace block with "nothing" tile
STA.B Map16TileGenerate ; |
JSL GenerateTile ; /
RTL
BlockBounce:
db $00,$03,$00,$00,$01,$07,$00,$04
db $0A
NotBreakable:
LDY.B #$03 ; \ Reset turning block
FindTurningBlkSlot:
LDA.W BounceSpriteNumber,Y ; |
BEQ CODE_028807 ; |
DEY ; |
BPL FindTurningBlkSlot ; /
DEC.W BounceSpriteSlotIdx
BPL +
LDA.B #$03
STA.W BounceSpriteSlotIdx
+ LDY.W BounceSpriteSlotIdx
LDA.W BounceSpriteNumber,Y ; \ Branch if not a turn block
CMP.B #$07 ; |
BNE + ; /
LDA.B TouchBlockXPos ; \ Save [$98-$9A]
PHA ; |
LDA.B TouchBlockXPos+1 ; |
PHA ; |
LDA.B TouchBlockYPos ; |
PHA ; |
LDA.B TouchBlockYPos+1 ; |
PHA ; /
LDA.W BounceSpriteXPosLow,Y ; \ Block Y position = Bounce Y sprite position
STA.B TouchBlockXPos ; |
LDA.W BounceSpriteXPosHigh,Y ; |
STA.B TouchBlockXPos+1 ; /
LDA.W BounceSpriteYPosLow,Y ; \ Block X position = Bounce X sprite position
CLC ; |
ADC.B #$0C ; | (Round to nearest #$10)
AND.B #$F0 ; |
STA.B TouchBlockYPos ; |
LDA.W BounceSpriteYPosHigh,Y ; |
ADC.B #$00 ; |
STA.B TouchBlockYPos+1 ; /
LDA.W BounceSpriteTile,Y ; \ Block to generate = Bounce sprite block
STA.B Map16TileGenerate ; /
LDA.B _4 ; \ Save [$04-$07]
PHA ; |
LDA.B _5 ; |
PHA ; |
LDA.B _6 ; |
PHA ; |
LDA.B _7 ; |
PHA ; /
JSL GenerateTile
PLA ; \ Restore [$04-$07]
STA.B _7 ; |
PLA ; |
STA.B _6 ; |
PLA ; |
STA.B _5 ; |
PLA ; |
STA.B _4 ; /
PLA ; \ Restore [$98-$9A]
STA.B TouchBlockYPos+1 ; |
PLA ; |
STA.B TouchBlockYPos ; |
PLA ; |
STA.B TouchBlockXPos+1 ; |
PLA ; |
STA.B TouchBlockXPos ; /
+ LDY.W BounceSpriteSlotIdx
CODE_028807:
LDA.B _4
CMP.B #$10
BCC CODE_028818