-
Notifications
You must be signed in to change notification settings - Fork 3
/
Bank05.asm
3101 lines (1875 loc) · 67.3 KB
/
Bank05.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
; ==============================================================================
; $28000-$28007 DATA
pool Sprite_SpawnSparkleGarnish:
{
.low_offset
db $FC, $00, $04, $08
.high_offset
db $FF, $00, $00, $00
}
; ==============================================================================
; *$28008-$2807E LONG
Sprite_SpawnSparkleGarnish:
{
; Check if the frame counter is a multiple of 4
LDA $1A : AND.b #$03 : BNE .skip_frame
PHX
TXY
JSL GetRandomInt : AND.b #$03 : TAX
LDA.l .low_offset, X : STA $00
LDA.l .high_offset, X : STA $01
JSL GetRandomInt : AND.b #$03 : TAX
LDA.l .low_offset, X : STA $02
LDA.l .high_offset, X : STA $03
LDX.b #$1D
.next_slot
LDA $7FF800, X : BEQ .empty_slot
DEX : BPL .next_slot
; Even if we don't find an empty slot, we're still going to use slot 0
; anyway.
INX
.empty_slot
; sprite falling into a hole animation?
; (update: more likely to be setting up a sparkle animation, as this
; has so far only been linked to good bees and something that also seems
; to be a good bee).
LDA.b #$12 : STA $7FF800, X
STA $0FB4
LDA $0D10, Y : ADD $00 : STA $7FF83C, X
LDA $0D30, Y : ADC $01 : STA $7FF878, X
LDA $0D00, Y : ADD $02 : STA $7FF81E, X
LDA $0D20, Y : ADC $03 : STA $7FF85A, X
; Set the associated sprite index for the garnish sprite?
TYA : STA $7FF92C, X
LDA.b #$0F : STA $7FF90E, X
TXY
PLX
.skip_frame
RTL
}
; ==============================================================================
; *$2807F-$28083 JUMP LOCATION
Sprite_HelmasaurFireballTrampoline:
{
JSL Sprite_HelmasaurFireballLong
RTS
}
; ==============================================================================
incsrc "sprite_wall_cannon.asm"
incsrc "sprite_archery_game_guy.asm"
incsrc "sprite_debirando_pit.asm"
incsrc "sprite_beamos.asm"
incsrc "sprite_debirando.asm"
incsrc "sprite_master_sword.asm"
incsrc "sprite_spike_roller.asm"
incsrc "sprite_spark.asm"
incsrc "sprite_lost_woods_bird.asm"
incsrc "sprite_lost_woods_squirrel.asm"
incsrc "sprite_crab.asm"
incsrc "sprite_desert_barrier.asm"
incsrc "sprite_zora_and_fireball.asm"
incsrc "sprite_zora_king.asm"
incsrc "sprite_walking_zora.asm"
incsrc "sprite_armos_knight.asm"
incsrc "sprite_lanmola.asm"
incsrc "sprite_rat.asm"
incsrc "sprite_rope.asm"
incsrc "sprite_cannon_trooper.asm"
incsrc "sprite_warp_vortex.asm"
incsrc "sprite_flail_trooper.asm"
; ==============================================================================
; *$2B5C3-$2B5CA LONG
SpriteActive2_MainLong:
{
PHB : PHK : PLB
JSR SpriteActive2_Main
PLB
RTL
}
; ==============================================================================
; $2B5CB-$2B5D2 DATA
Soldier_DirectionLockSettings:
{
.directions
db $03, $02, $00, $01
.animation_states
db $08, $00, $0C, $05
}
; ==============================================================================
; *$2B5D3-$2B647 LOCAL
SpriteActive2_Main:
{
; This routine is meant to handle sprites with IDs 0x41 to 0x70.
LDA $0E20, X : SUB.b #$41 : REP #$30 : AND.w #$00FF : ASL A : TAY
LDA .sprite_routines, Y : DEC A : PHA
SEP #$30
RTS
.sprite_routines
; Sprite routines 3*
; Please note that the numbers in the comments to the right are the actual sprite numbers
; and have nothing to do with the orientation of the table, though they ;are in order.
dw Sprite_Soldier ; 0x41 - Green Soldier
dw Sprite_Soldier ; 0x42 - Blue Soldier
dw Sprite_Soldier ; 0x43 - Red Spear Soldier
dw Sprite_PsychoTrooper ; 0x44 - Crazy Blue Killer Soldiers
dw Sprite_PsychoSpearSoldier ; 0x45 - Crazed Spear Soldiers (Green or Red)
dw Sprite_ArcherSoldier ; 0x46 - Blue Archers
dw Sprite_BushArcherSoldier ; 0x47 - Green Archers (in bushes)
dw Sprite_JavelinTrooper ; 0x48 - Red Javelin Soldiers (in special armor)
dw Sprite_BushJavelinSoldier ; 0x49 - Red Javelin Soldiers (in bushes)
dw Sprite_BombTrooper ; 0x4A - Bomb Trooper / Enemy Bombs
dw Sprite_Recruit ; 0x4B - Recruit
dw Sprite_GerudoMan ; 0x4C - Gerudo Man
dw Sprite_Toppo ; 0x4D - Asshole bunnies (Toppo)
dw Sprite_Popo ; 0x4E - Snakebasket (Popo?)
dw Sprite_Bot ; 0x4F - Bot / Bit?
dw Sprite_MetalBall ; 0x50 - Metal Balls in Eastern Palace
dw Sprite_Armos ; 0x51 - Armos
dw Sprite_ZoraKing ; 0x52 - Giant Zora
dw Sprite_ArmosKnight ; 0x53 - Armos Knight Code
dw Sprite_Lanmola ; 0x54 - Lanmola
dw Sprite_ZoraAndFireball ; 0x55 - Zora (or Agahnim) fireball code.
dw Sprite_WalkingZora ; 0x56 - Walking Zora
dw Sprite_DesertBarrier ; 0x57 - Desert Palace Barrier
dw Sprite_Crab ; 0x58 - Crab
dw Sprite_LostWoodsBird ; 0x59 - Birds (master sword grove)
dw Sprite_LostWoodsSquirrel ; 0x5A - Squirrel (master sword grove?)
dw Sprite_Spark ; 0x5B - Spark (clockwise on convex, counterclockwise on concave)
dw Sprite_Spark ; 0x5C - Spark (counterclockwise on convex, clockwise on concave)
dw Sprite_SpikeRoller ; 0x5D - Roller (????)
dw Sprite_SpikeRoller ; 0x5E - Roller (????)
dw Sprite_SpikeRoller ; 0x5F - Roller (????)
dw Sprite_SpikeRoller ; 0x60 - Roller (????)
dw Sprite_Beamos ; 0x61 - Beamos (aka Statue Sentry)
dw Sprite_MasterSword ; 0x62 - Master Sword (in the grove)
dw Sprite_DebirandoPit ; 0x63 - Sand lion pit
dw Sprite_Debirando ; 0x64 - Sand lion
dw Sprite_ArcheryGameGuy ; 0x65 - Shooting gallery guy
dw Sprite_WallCannon ; 0x66 - Moving cannon ball shooters
dw Sprite_WallCannon ; 0x67 - Moving cannon ball shooters
dw Sprite_WallCannon ; 0x68 - Moving cannon ball shooters
dw Sprite_WallCannon ; 0x69 - Moving cannon ball shooters
dw Sprite_ChainBallTrooper ; 0x6A - Ball n' Chain Trooper
dw Sprite_CannonTrooper ; 0x6B - Cannon Ball Shooting Trooper (unused in game)
dw Sprite_WarpVortex ; 0x6C - Warp Vortex (from Magic mirror in light world)
dw Sprite_Rat ; 0x6D - Rat / Bazu
dw Sprite_Rope ; 0x6E - Rope / Skullrope
dw Sprite_Keese ; 0x6F - Keese
dw Sprite_HelmasaurFireballTrampoline ; 0x70 - Helmasaur King fireballs
}
; ==============================================================================
incsrc "sprite_metal_ball.asm"
incsrc "sprite_armos.asm"
incsrc "sprite_bot.asm"
incsrc "sprite_gerudo_man.asm"
incsrc "sprite_toppo.asm"
incsrc "sprite_recruit.asm"
; ==============================================================================
; *$2C155-$2C226 JUMP LOCATION LOCAL
Sprite_Soldier:
{
LDA $0DB0, X : BNE .is_probe
JMP Soldier_Main
.is_probe
; \note Label here for informational purposes.
shared Sprite_Probe:
LDY.b #$00
; Is the sprite moving right? Yes, so skip the decrement of Y
LDA $0D50, X : BPL .moving_right
; Sprite is moving left, so we have to make sure subtraction is done smoothly
DEY
.moving_right
; This code moves the soldier left or right, depending on $0D50, X
ADD $0D10, X : STA $0D10, X
TYA : ADC $0D30, X : STA $0D30, X
LDY.b #$00
; Same as above but for Y coordinate of the soldier
LDA $0D40, X : BPL .moving_down
DEY
.moving_down
ADD $0D00, X : STA $0D00, X
TYA : ADC $0D00, X : STA $0D20, X
; Usually 0. Otherwise the soldiers invisible.
LDY $0DB0, X
; Is this soldier (Link locator) belonging to Blind?
LDA $0E1F, Y : CMP.b #$CE : BNE .parent_not_blind_the_thief
REP #$20
LDA $0FD8 : SUB $22 : ADD.w #$0010
CMP.w #$0020 : SEP #$20 : BCS .player_not_close
REP #$20
LDA $20 : SUB $0FDA : ADD.w #$0018
CMP.w #$0020 : SEP #$20 : BCS .player_not_close
JMP $C1F6 ; $2C1F6 IN ROM
.player_not_close
JMP $C21A ; $2C21A IN ROM
.parent_not_blind_the_thief
; Check the tile attr that the sprite is interacting with
JSL Probe_CheckTileSolidity : BCC .zeta
LDA $0FA5 : CMP.b #$09 : BNE .theta
.zeta
; Is Link invisible and invincible? (magic cape)
LDA $0055 : BNE .theta
REP #$20
LDA $0FD8 : SUB $22 : CMP.w #$0010 : SEP #$20 : BCS .iota
REP #$20
LDA $0FDA : SUB $20 : CMP.w #$0010 : SEP #$20 : BCS .iota
; Are Link and the soldier on the same floor?
LDA $0F20, X : CMP $EE : BNE .iota
; *$2C1F6 ALTERNATE ENTRY POINT
LDA $0DB0, X : DEC A
PHX
TAX
LDA $0D80, X : CMP.b #$03 : BEQ .kappa
LDA.b #$03 : STA $0D80, X
; Is the sprite Blind the Thief?
LDA $0E20, X : CMP.b #$CE : BEQ .kappa ; Yes...
LDA.b #$10 : STA $0DF0, X
STZ $0E80, X
.kappa
PLX
BRA .theta
; *$2C21A ALTERNATE ENTRY POINT
.iota
JSR Sprite2_PrepOamCoord
LDA $01 : ORA $03 : BEQ .return
.theta
STZ $0DD0, X
.return
RTS
}
; ==============================================================================
; *$2C227-$2C2CF JUMP LOCATION
Soldier_Main:
{
LDA $0DC0, X : PHA
LDY $0DE0, X : PHY
; This is actually used.
LDA $0E00, X : BEQ .direction_lock_inactive
LDA Soldier_DirectionLockSettings.directions, Y : STA $0DE0, X
LDA Soldier_DirectionLockSettings.animation_states, Y : STA $0DC0, X
.direction_lock_inactive
; Looks like a "draw soldier" function...
JSR $C680 ; $2C680 IN ROM
PLA : STA $0DE0, X
PLA : STA $0DC0, X
LDA $0DD0, X : CMP.b #$05 : BNE .not_falling_in_hole
LDA $11 : BNE Sprite_Soldier.return
; ticking animation clock and state...
JSR $C535 ; $2C535 IN ROM
JMP $C535 ; $2C535 IN ROM
.not_falling_in_hole
JSR Sprite2_CheckIfActive
JSL $06EB5E ; $36B5E IN ROM ; push sprite back from sword hit?
JSL Sprite_CheckDamageToPlayerLong : BCS .gamma
LDA $0FDC : BEQ .delta
.gamma
LDA $0D80, X : CMP.b #$03 : BCS .delta
LDA.b #$03 : STA $0D80, X
LDA.b #$20
BRA .epsilon
.delta
LDA $0EA0, X : BEQ .zeta
CMP.b #$04 : BCC .zeta
LDA.b #$04 : STA $0D80, X
LDA.b #$80
.epsilon
JSR $C4D7 ; $2C4D7 IN ROM
.zeta
JSR Sprite2_CheckIfRecoiling
LDA $0E30, X : AND.b #$07 : CMP.b #$05 : BCS .theta
LDA $0E70, X : BNE .iota
JSR $F9EB ; $2F9EB IN ROM
.iota
JSR Sprite2_CheckTileCollision
BRA .kappa
.theta
JSR Sprite2_Move
.kappa
LDA $0D80, X : CMP.b #$04 : BEQ .nu
STZ $0ED0, X
.nu
REP #$30 : AND.w #$00FF : ASL A : TAY
; Hidden table! gah!!!
LDA .states, Y : DEC A : PHA
SEP #$30
RTS
.states
dw $C2D4 ; = $2C2D4*
dw $C403 ; = $2C403*
dw $C490 ; = $2C490*
dw $C4C1 ; = $2C4C1*
dw $C4E8 ; = $2C4E8*
}
; ==============================================================================
; $2C2D0-$2C2D3 DATA
{
db $60, $C0, $FF, $40
}
; ==============================================================================
; $2C2D4-$2C330 JUMP LOCATION
{
JSR Sprite2_ZeroVelocity
LDA $0DF0, X : BNE .delay
INC $0D80, X
LDA $0E30, X : BEQ .beta
AND.b #$07 : CMP.b #$05 : BCS .beta
LDA $0E30, X : LSR #3 : AND.b #$03 : TAY
LDA $C2D0, Y : STA $0DF0, X
LDA $0DE0, X : EOR.b #$01 : STA $0DE0, X
STZ $0E80, X
BRA .gamma
.beta
JSL GetRandomInt : AND.b #$3F : ADC.b #$28 : STA $0DF0, X
LDA $0DE0, X : PHA
JSL GetRandomInt : AND.b #$03 : STA $0DE0, X
PLA : CMP $0DE0, X : BEQ .alpha
EOR $0DE0, X : AND.b #$02 : BNE .alpha
; *$2C32B ALTERNATE ENTRY POINT
shared Soldier_EnableDirectionLock:
.gamma
LDA.b #$0C : STA $0E00, X
.alpha
.delay
RTS
}
; $2C331-$2C3A0 DATA
pool Probe:
parallel pool Soldier:
{
.x_speeds
db $08, $F8, $00, $00
.y_speeds
db $00, $00, $08, $F8
; $2C339
.animation_states
db $0B, $0C, $0D, $0C, $04, $05, $06, $05
db $00, $01, $02, $03, $07, $08, $09, $0A
db $11, $12, $11, $12, $07, $08, $07, $08
db $03, $04, $03, $04, $0D, $0E, $0D, $0E
; $2C359
.x_checked_directions
db 1, 1, -1, -1
db -1, -1, 1, 1
; $2C361
.y_checked_directions
db -1, 1, 1, -1
db -1, 1, 1, -1
; $2C369
.chase_x_speeds
db $08, $00, $F8, $00
db $F8, $00, $08, $00
.chase_y_speeds
db $00, $08, $00, $F8
db $00, $08, $00, $F8
; $2C379
db 0, 2, 1, 3
db 1, 2, 0, 3
.collinear_directions
db $01, $04, $02, $08
db $02, $04, $01, $08
; $2C389
.orthogonal_directions
db $08, $01, $04, $02
db $08, $02, $04, $01
.collinear_next_direction
db 1, 2, 3, 0
db 5, 6, 7, 4
; $2C399
.orthogonal_next_direction
db 3, 0, 1, 2
db 7, 4, 5, 6
}
; *$2C3A1-$2C402 JUMP LOCATION
{
LDY $0DA0, X
LDA $C359, Y : STA $0D50, X
LDA $C361, Y : STA $0D40, X
JSR Sprite2_CheckTileCollision
LDA $0E10, X : BEQ .alpha
CMP.b #$2C : BNE .beta
LDY $0DA0, X
LDA $C399, Y : STA $0DA0, X
BRA .beta
.alpha
LDY $0DA0, X
LDA $0E70, Y : AND $C389, Y : BNE .beta
LDA.b #$58 : STA $0E10, X
.beta
LDY $0DA0, X
LDA $0E70, Y : AND $C381, Y : BEQ .gamma
LDA $C391, Y : STA $0DA0, X
.gamma
LDY $0DA0, X
LDA Soldier.chase_x_speeds, Y : STA $0D50, X
LDA Soldier.chase_y_speeds, Y : STA $0D40, X
LDA $C379, Y : STA $0DE0, X : STA $0EB0, X
JMP $C454 ; $2C454 IN ROM
}
; *$2C403-$2C46F JUMP LOCATION
{
JSR Sprite_SpawnProbeStaggered
LDA $0E30, X : AND.b #$07 : CMP.b #$05 : BCC .alpha
JMP $C3A1 ; $2C3A1 IN ROM
.alpha
LDA $0DF0, X : BNE .beta
; *$2C417 ALTERNATE ENTRY POINT
JSR Sprite2_ZeroVelocity
LDA.b #$02 : STA $0D80, X
LDA.b #$A0 : STA $0DF0, X
RTS
.beta
LDA $0E80, X : AND.b #$01 : BNE .gamma
INC $0DF0, X
.gamma
LDA $0E70, X : AND.b #$0F : BEQ .delta
LDA $0DE0, X : EOR.b #$01 : STA $0DE0, X
JSR Soldier_EnableDirectionLock
.delta
LDY $0DE0, X
LDA Soldier.x_speeds, Y : STA $0D50, X
LDA Soldier.y_speeds, Y : STA $0D40, X
TYA : STA $0EB0, X
INC $0E80, X
; *$2C454-$2C46F ALTERNATE ENTRY POINT
INC $0E80, X
LDA $0E80, X : LSR #3 : AND.b #$03 : STA $00
LDA $0DE0, X : ASL #2 : ADC $00 : TAY
LDA Soldier.animation_states, Y : STA $0DC0, X
RTS
}
; ==============================================================================
; $2C470-$2C48F DATA
pool Soldier:
{
.head_looking_states
db $00, $02, $02, $02, $00, $03, $03, $03
db $01, $03, $03, $03, $01, $02, $02, $02
db $02, $00, $00, $00, $02, $01, $01, $01
db $03, $01, $01, $01, $03, $00, $00, $00
}
; ==============================================================================
; $2C490-$2C4C0 JUMP LOCATION
{
JSR Sprite2_ZeroVelocity
JSR Sprite_SpawnProbeStaggered
LDA $0DF0, X : BNE .alpha
LDA.b #$20 : STA $0DF0, X
LDA.b #$00 : STA $0D80, X
RTS
.alpha
CMP.b #$80 : BCS .beta
LSR #3 : AND.b #$07 : STA $00
LDA $0DE0, X : ASL #3 : ORA $00 : TAY
LDA Soldier.head_looking_states, Y : STA $0EB0, X
.beta
RTS
}
; *$2C4C1-$2C4E7 JUMP LOCATION
{
; Green soldier submode 3
JSR Sprite2_ZeroVelocity
JSR Sprite2_DirectionToFacePlayer : TYA : STA $0EB0, X
LDA $0DF0, X : BNE .alpha
LDA.b #$04 : STA $0D80, X
LDA.b #$FF
; *$2C4D7 ALTERNATE ENTRY POINT
STA $0DF0, X
STZ $0E30, X
LDA $0B6B, X : AND.b #$0F : ORA.b #$60 : STA $0B6B, X
.alpha
RTS
}
; $2C4E8-$2C4F8 JUMP LOCATION
{
LDA $0DF0, X : BNE BRANCH_$2C500
LDY $0DE0, X
LDA JavelinTrooper_Attack.scan_anbles, X : STA $0EC0, X
BRL BRANCH_2C417
}
; ==============================================================================
; *$2C4F9-$2C4FF LOCAL
Sprite2_ZeroVelocity:
{
; Stop horizontal and vertical velocities
STZ $0D50, X
STZ $0D40, X
RTS
}
; ==============================================================================
; $2C500-$2C53B LOCAL
{
TYA : EOR $1A : AND.b #$1F : BNE .alpha
LDA $0ED0, X : BNE .beta
LDA.b #$04 : JSL Sound_SetSfx3PanLong
INC $0ED0, X
.beta
TXA : AND.b #$03 : TAY
LDA $0E20, X : CMP.b #$42 : BEQ .gamma
.gamma
LDA $C566, X : JSL Sprite_ApplySpeedTowardsPlayerLong
JSR Sprite2_DirectionToFacePlayer : TYA : STA $0DE0, X : STA $0EB0, X
.alpha
JSL Probe_SetDirectionTowardsPlayer
; *$2C535 ALTERNATE ENTRY POINT
INC $0E80, X
JSR $C454 ; $2C454 IN ROM
RTS
}
; ==============================================================================
; $2C53C-$2C541 DATA
pool Probe_SetDirectionTowardsPlayer:
parallel pool Sprite_PsychoSpearSoldier:
parallel pool Sprite_PsychoTrooper:
{
.x_speeds length 4
db $0E, $F2
.y_speeds
db $00, $00, $0E, $F2
}
; ==============================================================================
; $2C542-$2C565 LONG
Probe_SetDirectionTowardsPlayer:
{
PHB : PHK : PLB
LDA $0E70, X : BEQ .no_tile_collision
AND.b #$03 : BEQ .no_horiz_collision
JSR Sprite2_IsBelowPlayer : INY #2 : BRA .moving_on
.no_horiz_collision
JSR Sprite2_IsToRightOfPlayer
.moving_on
LDA .x_speeds, Y : STA $0D50, X
LDA .y_speeds, Y : STA $0D40, X
.no_tile_collision
PLB
RTL
}
; ==============================================================================
; $2C566-$2C5F1 DATA
{
db $10, $10, $10, $10
; $2C56A
db $12, $12, $12, $12
; $2C56E
db $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0
db $F0, $F2, $F4, $F6, $F8, $FA, $FC, $FE
db $00, $02, $04, $06, $08, $0A, $0C, $0E
db $10, $10, $10, $10, $10, $10, $10, $10
db $10, $10, $10, $10, $10, $10, $10, $10
db $0E, $0C, $0A, $08, $06, $04, $02, $00
db $FE, $FC, $FA, $F8, $F6, $F4, $F2, $F0
db $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0
; $2C5AE
db $00, $02, $04, $06, $08, $0A, $0C, $0E
db $10, $10, $10, $10, $10, $10, $10, $10
db $10, $10, $10, $10, $10, $10, $10, $10
db $0E, $0C, $0A, $08, $06, $04, $02, $00
db $FE, $FC, $FA, $F8, $F6, $F4, $F2, $F0
db $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0
db $F0, $F0, $F0, $F0, $F0, $F0, $F0, $F0
db $F2, $F4, $F6, $F8, $FA, $FC, $FE, $00
; $2C5EE
db $10, $30, $00, $20
}
; ==============================================================================
; *$2C5F2-$2C66D LOCAL
Sprite_SpawnProbeStaggered:
{
; Soldiers and Archers seem to be the only two types that call this.
; Beamos and Blind call the alternate entry point...
; Is there some point to this store that I'm not seeing? It's
; overwritten later before even being used.
TXA : ADD $1A : STA $0F
AND.b #$03 : ORA $0F00, X : BNE .spawn_failed
LDA $0EC0, X : INC $0EC0, X
LDY $0DE0, X
CLC : AND.b #$1F : ADC $C5EE, Y : AND.b #$3F : STA $0F
; *$2C612 ALTERNATIVE ENTRY POINT
shared Sprite_SpawnProbeAlways:
LDA.b #$41 ; If any of our sprites are dead, change it to a soldier
LDY.b #$0A ; Well be checking sprites in slots 0x00 through 0x0A
JSL Sprite_SpawnDynamically.arbitrary : BMI .spawn_failed
LDA $00 : ADD.b #$08 : STA $0D10, Y
LDA $01 : ADC.b #$00 : STA $0D30, Y
LDA $02 : ADD.b #$04 : STA $0D00, Y
LDA $03 : ADC.b #$00 : STA $0D20, Y
PHX
; The direction the statue sentry eye is facing determines the direction
; that the feeler will travel in.
LDX $0F
TXA : STA $0DE0, Y
LDA $C56E, X : STA $0D50, Y
LDA $C5AE, X : STA $0D40, Y
LDA $0E40, Y : AND.b #$F0 : ORA.b #$A0 : STA $0E40, Y
PLX
TXA : INC A : STA $0DB0, Y
STA $0BA0, Y
LDA.b #$40 : STA $0F60, Y
STA $0E60, Y
LDA.b #$02 : STA $0CAA, Y
.spawn_failed
RTS
}
; ==============================================================================
; *$2C66E-$2C675 LONG
Sprite_SpawnProbeAlwaysLong:
{
PHB : PHK : PLB
JSR Sprite_SpawnProbeAlways
PLB
RTL
}
; ==============================================================================
; *$2C676-$2C67F LONG
Soldier_AnimateMarionetteTempLong:
{
PHB : PHK : PLB
PHX
JSR $C680 ; $2C680 IN ROM
PLX
PLB
RTL
}
; *$2C680-$2C6A2 LOCAL
{