-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBank08.asm
3281 lines (2164 loc) · 80.6 KB
/
Bank08.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
; ==============================================================================
; \unused 1. Don't think ambient sound effects do panning, and 2. this
; is probably unused because ... probably no ancillae cause
; ambient sound effects to play.
; $40000-$40006 LOCAL
Ancilla_DoSfx1_NearPlayer:
{
JSR Ancilla_SetSfxPan_NearPlayer : STA $012D
RTS
}
; ==============================================================================
; *$40007-$4000D LOCAL
Ancilla_DoSfx2_NearPlayer:
{
JSR Ancilla_SetSfxPan_NearPlayer : STA $012E
RTS
}
; ==============================================================================
; *$4000E-$40014 LOCAL
Ancilla_DoSfx3_NearPlayer:
{
JSR Ancilla_SetSfxPan_NearPlayer : STA $012F
RTS
}
; ==============================================================================
; *$40015-$4001F LOCAL
Ancilla_SetSfxPan_NearPlayer:
{
STA $0CF8
JSL Sound_SetSfxPanWithPlayerCoords : ORA $0CF8
RTS
}
; ==============================================================================
; \unused
; $40020-$40026 LOCAL
Ancilla_DoSfx1:
{
JSR Ancilla_SetSfxPan : STA $012D
RTS
}
; ==============================================================================
; *$40027-$4002D LOCAL
Ancilla_DoSfx2:
{
JSR Ancilla_SetSfxPan : STA $012E
RTS
}
; ==============================================================================
; *$4002E-$40034 LOCAL
Ancilla_DoSfx3:
{
JSR Ancilla_SetSfxPan : STA $012F
RTS
}
; ==============================================================================
; *$40035-$4003F LOCAL
Ancilla_SetSfxPan:
{
STA $0CF8
JSL Sound_SfxPanObjectCoords : ORA $0CF8
RTS
}
; ==============================================================================
; $40040-$4006E Data Table
{
db 0, 0, -8, 16
db 0, 0, -1, 0
db -8, 16, 3, 3
db -1, 0, 0, 0
db 0, 0, -40, 40, 0, 0, -48, 48, 0, 0, -64, 64
db -40, 40, 0, 0, -48, 48, 0, 0, -64, 64, 0, 0
db 0, 0, -64, 64
db -64, 64, 0, 0
; $40070 ($4006F + 1)
db 8, 12, 16, 16, 4, 16, 24, 8, 8, 8, 0, 20, 0, 16, 40, 24
db
}
; ==============================================================================
; $4006F-$400B2 Data
{
db 0, 8, 12, 16, 16, 4, 16, 24
db 8, 8, 8, 0, 20, 0, 16, 40
db 24, 16, 16, 16, 16, 12, 8, 8
db 80, 0, 16, 8, 64, 0, 12, 36
db 16, 12, 8, 16, 16, 4, 12, 28
db 0, 16, 20, 20, 16, 8, 32, 16
db 16, 16, 4, 0, 128, 16, 4, 48
db 20, 16, 0, 16, 0, 0, 8, 0
db 16, 8, 120, 128
}
; ==============================================================================
; *$400B3-$4019E LONG
AddFireRodShot:
{
LDY.b #$01
STA $00
JSL Ancilla_CheckForAvailableSlot : BPL .slot_available
; \tcrf Astounding! While it's not that silly when you think about it,
; it would appear that at some point they were considering using the
; Somarian blasts as the projectile for the fire rod. Why else put
; special logic in here for it? This function is only called when
; creating a Fire Rod shot.
LDA $00 : CMP.b #$01 : BEQ .no_mp_add_back
; Add back the mp cost for this class of item (rod)
; Oddly enough it avoids this for the Somarian blasts, for whatever
; reason. But, this is only in the event that there are no open slots
; for the object.... eh. whatever.
LDX.b #$00 : JSL LinkItem_ReturnUnusedMagic
.no_mp_add_back
BRL .return
.slot_available
PHB : PHK : PLB
PHX
; Again, the bizarro fire rod shot gets sore treatment. It's like it
; doesn't even exist! (which it doesn't, kind of).
LDA $00 : CMP.b #$01 : BEQ .dont_play_sound_effect
PHY
LDA.b #$0E : JSR Ancilla_DoSfx2_NearPlayer
PLY
.dont_play_sound_effect
LDA $00 : STA $0C4A, Y : TAX
LDA $806F, X : STA $0C90, Y
LDA.b #$03 : STA $0C68, Y
LDA.b #$00 : STA $0C54, Y : STA $0C5E, Y : STA $0280, Y : STA $028A, Y
LDA $2F : LSR A : STA $0C72, Y : TAX
PHY : PHX : TYX
; Appears to check multiple spots around Link to see if the item can
; spawn there. If it can't spawn in any of those locations, I guess
; we have a problem? Not sure yet.
JSL Ancilla_CheckInitialTileCollision_Class_1
PLX : PLY
BCS .initialize_in_spread_state
LDA $0022 : ADD $8040, X : STA $0C04, Y
LDA $0023 : ADC $8044, X : STA $0C18, Y
LDA $0020 : ADD $8048, X : STA $0BFA, Y
LDA $0021 : ADC $804C, X : STA $0C0E, Y
LDA $0C4A, Y : CMP.b #$01 : BEQ .sword_determines_speed
LDA $8068, X : STA $0C2C, Y
LDA $806C, X
BRA .speed_has_been_determined
.sword_determines_speed
; Does this mean we should only be here if we have the Master Sword
; or better? This makes somaria shots move at different speeds depending
; on which sword we have. But it seems unused for some reason?
LDA $7EF359 : DEC #2 : ASL #2 : STA $0F
TXA : ADD $0F : TAX
LDA $8050, X : STA $0C2C, Y
LDA $805C, X
.speed_has_been_determined
STA $0C22, Y
; Floor matches that of the player.
LDA $00EE : STA $0C7C, Y
; Pseudo floor matches that of the player.
LDA $0476 : STA $03CA, Y
PLX
PLB
.return
RTL
.initialize_in_spread_state
LDA $0C4A, Y : CMP.b #$01 : BNE .not_somarian_blast
; Again, the somarian blast gets shafted in the sound effect department.
LDA.b #$04 : STA $0C4A, Y
LDA.b #$07 : STA $0C68, Y
LDA.b #$10 : STA $0C90, Y
BRA .return_2
.not_somarian_blast
LDA.b #$01 : STA $0C54, Y
LDA.b #$1F : STA $0C68, Y
LDA.b #$08 : STA $0C90, Y
LDA.b #$2A : JSR Ancilla_DoSfx2
.return_2
PLX
PLB
RTL
}
; ==============================================================================
; $4019F-$401A6 DATA
pool SomarianBlast_SpawnCentrifugalQuad:
{
.x_offsets
db -8, -8, -9, -4
.y_offsets
db -15, -4, -8, -8
}
; ==============================================================================
; *$401A7-$40241 LOCAL
SomarianBlast_SpawnCentrifugalQuad:
{
LDA.b #$03 : STA $0FB5
LDA $029E, X : CMP.b #$FF : BNE .altitude_okay
LDA.b #$00
.altitude_okay
STA $05
LDA $0C04, X : STA $00
LDA $0C18, X : STA $01
LDA $0BFA, X : SUB $05 : STA $02
LDA $0C0E, X : SBC.b #$00 : STA $03
; Attempt to spawn four somarian blasts all moving in directions
; away from a central point (the location of the former somarian block).
LDA $0C7C, X : STA $04
.attempt_next_spawn
LDY.b #$04
LDA.b #$01
JSL Ancilla_CheckForAvailableSlot : BMI .spawn_failed
PHX
LDA.b #$01 : STA $0C4A, Y : TAX
LDA $806F, X : STA $0C90, Y
LDA.b #$04 : STA $0C54, Y
LDA.b #$00 : STA $0C5E, Y : STA $0280, Y
LDX $0FB5 : TXA : STA $0C72, Y
LDA $00 : ADD .x_offsets, X : STA $0C04, Y
LDA $01 : ADC.b #$FF : STA $0C18, Y
LDA $02 : ADD .y_offsets, X : STA $0BFA, Y
LDA $03 : ADC.b #$FF : STA $0C0E, Y
JSL Ancilla_TerminateIfOffscreen
LDA $8050, X : STA $0C2C, Y
LDA $805C, X : STA $0C22, Y
LDA $04 : STA $0C7C, Y
LDA $0476 : STA $03CA, Y
PLX
.spawn_failed
DEC $0FB5 : BPL .attempt_next_spawn
RTS
}
; ==============================================================================
; *$40242-$4024C LONG
Ancilla_Main:
{
PHB : PHK : PLB
JSR Ancilla_RepulseSpark
JSR Ancilla_ExecuteObjects
PLB
RTL
}
; ==============================================================================
; *$4024D-$40286 LOCAL
Bomb_ProjectReflexiveSpeedOntoSprite:
{
; This routine subs in an object's coordinates for the
; player's and uses a player routine to calculate a collision or some
; such.
LDA $0022 : PHA
LDA $0023 : PHA
LDA $0020 : PHA
LDA $0021 : PHA
LDA $04 : STA $0022
LDA $05 : STA $0023
LDA $06 : STA $0020
LDA $07 : STA $0021
TYA
JSL Bomb_ProjectReflexiveSpeedOntoSpriteLong
PLA : STA $0021
PLA : STA $0020
PLA : STA $0023
PLA : STA $0022
RTS
}
; ==============================================================================
; *$40287-$4032A LOCAL
Bomb_CheckSpriteDamage:
{
; collision detection used for telling if sprites need some ass whoopin'
; (i.e. if they are damaged by the bomb)
LDY.b #$0F
.check_sprite_damage_loop
TYA : EOR $1A : AND.b #$03
ORA $0EF0, Y : ORA $0BA0, Y : BEQ .proceed_with_damage_check
.different_floors
JMP .sprite_undamaged
.proceed_with_damage_check
LDA $0F20, Y : CMP $0C7C, X : BNE .different_floors
; won't work if the sprite is not "alive"
LDA $0DD0, Y : CMP.b #$09 : BCC .sprite_undamaged
; setting up variables for use with collision detection
LDA $0C04, X : SUB.b #$18 : STA $00
LDA $0C18, X : SBC.b #$00 : STA $08
LDA $0BFA, X : SUB.b #$18
PHP
SUB $029E, X : STA $01
LDA $0C0E, X : SBC.b #$00
PLP
SBC.b #$00 : STA $09
LDA.b #$30 : STA $02 : STA $03
PHX : TYX
JSL Sprite_SetupHitBoxLong
PLX
JSL Utility_CheckIfHitBoxesOverlapLong : BCC .sprite_undamaged
LDA $0E20, Y : CMP.b #$92 : BNE .not_helmasaur_king
; Only certain parts of the HK are vulnerable.
LDA $0DB0, Y : CMP.b #$03 : BCS .sprite_undamaged
.not_helmasaur_king
LDA $0C04, X : STA $04
LDA $0C18, X : STA $05
LDA $0BFA, X : STA $06
LDA $0C0E, X : STA $07
PHX : PHY
LDA $0C4A, X
TYX
JSL Ancilla_CheckSpriteDamage
; How far the sprite gets pushed back.
LDY.b #$40 : JSR Bomb_ProjectReflexiveSpeedOntoSprite
PLY : PLX
; Reverse those speeds so that we are projecting the speed away from
; the Ancilla. In other words, we are causing the sprite to recoil from
; some damage.
LDA $00 : EOR.b #$FF : INC A : STA $0F30, Y
LDA $01 : EOR.b #$FF : INC A : STA $0F40, Y
.sprite_undamaged
DEY : BMI .checked_all_sprites
JMP .check_sprite_damage_loop
.checked_all_sprites
RTS
}
; ==============================================================================
; *$4032B-$4033B LOCAL
Ancilla_ExecuteObjects:
{
LDX.b #$09
.next_object
STX $0FA0
; The type of effect in play. 0 designates no effect.
LDA $0C4A, X : BEQ .inactive_object
JSR Ancilla_ExecuteObject
.inactive_object
DEX : BPL .next_object
RTS
}
; ==============================================================================
; *$4033C-$40404 LOCAL
Ancilla_ExecuteObject:
{
; Push the ancilla's number to the stack.
PHA
; If X >= 6, then...
CPX.b #$06 : BCS .ignore_oam_allocation
; This is the number of sprites allocated for the s.o. at init.
LDA $0C90, X
; If "sort sprites" is in effect, things are slightly different.
LDY $0FB3 : BEQ .sort_sprites
; If the special effect is on a different floor use a different section of the OAM buffer (probably also changes priority)
LDY $0C7C, X : BNE .on_bg1
; floor 1 sprites...
JSL OAM_AllocateFromRegionD
BRA .record_starting_oam_position
.on_bg1
; floor 2 sprites...
JSL OAM_AllocateFromRegionF
BRA .record_starting_oam_position
.sortSprites
JSL OAM_AllocateFromRegionA
.record_starting_oam_position
; The starting place in the OAM Buffer for the special effect
TYA : STA $0C86, X
.ignore_oam_allocation
; We're not in the standard submodule.
LDY $11 : BNE .dont_tick_timer
; I'm not seeing this as terribly useful
LDY $0C68, X : BEQ .timer_at_rest
DEC $0C68, X
.timer_at_rest
.dont_tick_timer
; Note the subtraction before ASL
; Load a subroutine based on the anillary object's index.
PLA : DEC A : ASL A : TAY
LDA .object_routines+0, Y : STA $00
LDA .object_routines+1, Y : STA $01
JMP ($0000)
.object_routines
; NOTE: PARAMETER A IS ACTUALLY object type - 1, SINCE 0 WOULD INDICATE
; NO EFFECT ; SOURCE : $0C4A, X
dw Ancilla_SomarianBlast ; 0x01 - Both the pieces of somarian block splitting and the fireballs)
dw Ancilla_FireShot ; 0x02 - Fire Rod flame (both flying and after hitting something)
dw Ancilla_Unused_03 ; 0x03 - Unimplemented object type. Won't crash the game but won't ever self terminate.
dw Ancilla_BeamHit ; 0x04 - Effect that represents a beam splitting up after it hits something.
dw Ancilla_Boomerang ; 0x05 - Boomerang
dw Ancilla_WallHit ; 0x06 - Spark-like effect that occurs when you hit a wall with a boomerang or hookshot
dw Ancilla_Bomb ; 0x07 - Blue player bomb
dw Ancilla_DoorDebris ; 0x08 - Rock fall effect (from bombing a cave)
dw Ancilla_Arrow ; 0x09 - Flying arrow
dw Ancilla_HaltedArrow ; 0x0A - Arrow stuck in something (wall or sprite)
dw Ancilla_IceShot ; 0x0B - Ice Rod shot
dw Ancilla_SwordBeam ; 0x0C - Master sword beam
dw Ancilla_SwordFullChargeSpark ; 0x0D - The sparkle at the tip of your sword when you power up the spin attack
dw Ancilla_Unused_0E ; 0x0E - Unimplemented object type that points to the same location as the blast wall
dw Ancilla_Unused_0F ; 0x0F - Unimplemented object type that points to the same location as the blast wall
dw Ancilla_Unused_0E ; 0x10 - Unimplemented object type that points to the same location as the blast wall
dw Ancilla_IceShotSpread ; 0x11 - Ice rod shot dissipating after hitting a nontransitive tile.
dw Ancilla_Unused_0E ; 0x12 - Unimplemented object type that points to the same location as the blast wall
dw Ancilla_IceShotSparkle ; 0x13 - Ice Shot Sparkles (the only actual visible parts of the ice shot)
dw Ancilla_Unused_14 ; 0x14 - Unimplemented object type. Don't use as it will crash the game.
dw Ancilla_JumpSplash ; 0x15 - Splash from jumping into or out of deep water
dw Ancilla_HitStars ; 0x16 - The Hammer's Stars / Stars from hitting hard ground with the shovel
dw Ancilla_ShovelDirt ; 0x17 - Dirt from digging a hole with the shovel
dw Ancilla_EtherSpell ; 0x18 - The Ether Effect
dw Ancilla_BombosSpell ; 0x19 - The Bombos Effect
dw Ancilla_MagicPowder ; 0x1A - Magic powder
dw Ancilla_SwordWallHit ; 0x1B - Sparks from tapping a wall with your sword
dw Ancilla_QuakeSpell ; 0x1C - The Quake Effect
dw Ancilla_DashTremor ; 0x1D - Jarring effect from hitting a wall while dashing
dw Ancilla_DashDust ; 0x1E - Pegasus boots dust flying
dw Ancilla_Hookshot ; 0x1F - Hookshot
dw Ancilla_BedSpread ; 0x20 - Player's Bed Spread
dw Ancilla_SleepIcon ; 0x21 - Link's Zzzz's from sleeping
dw Ancilla_ReceiveItem ; 0x22 - Received Item Sprite
dw Ancilla_MorphPoof ; 0x23 - Bunny / Cape transformation poof
dw Ancilla_Gravestone ; 0x24 - Gravestone sprite when in motion
dw Ancilla_Unused_25 ; 0x25 - Unimplemented object type. Don't use as it will crash the game
dw Ancilla_SwordSwingSparkle ; 0x26 - Sparkles when swinging lvl 2 or higher sword
dw Ancilla_TravelBird ; 0x27 - the bird (when called by flute)
dw Ancilla_WishPondItem ; 0x28 - item sprite that you throw into magic faerie ponds.
dw Ancilla_MilestoneItem ; 0x29 - Pendants, crystals, medallions
dw Ancilla_InitialSpinSpark ; 0x2A - Start of spin attack sparkle
dw Ancilla_SpinSpark ; 0x2B - During Spin attack sparkles
dw Ancilla_SomarianBlock ; 0x2C - Cane of Somaria blocks
dw Ancilla_SomarianBlockFizzle ; 0x2D - Suspected of being in cahoots with the somaria objects
dw Ancilla_SomarianBlockDivide ; 0x2E - Suspected of being in cahoots with the somaria objects
dw Ancilla_LampFlame ; 0x2F - Torch's flame
dw Ancilla_InitialCaneSpark ; 0x30 - Initial spark for the Cane of Byrna activating
dw Ancilla_CaneSpark ; 0x31 - Cane of Byrna spinning sparkle
dw Ancilla_BlastWallFireball ; 0x32 - Flame blob, which is an ancillary effect from the blast wall
dw Ancilla_BlastWall ; 0x33 - Series of explosions from blowing up a wall (after pulling a switch)
dw Ancilla_SkullWoodsFire ; 0x34 - Burning effect used to open up the entrance to skull woods.
dw Ancilla_SwordCeremony ; 0x35 - Master Sword ceremony.... not sure if it's the whole thing or a part of it
dw Ancilla_Flute ; 0x36 - Flute that pops out of the ground in the haunted grove.
dw Ancilla_WeathervaneExplosion ; 0x37 - Appears to trigger the weathervane explosion.
dw Ancilla_TravelBirdIntro ; 0x38 - Appears to give Link the bird enabled flute.
dw Ancilla_SomarianPlatformPoof ; 0x39 - Cane of Somaria blast which creates platforms (sprite 0xED)
dw Ancilla_SuperBombExplosion ; 0x3A - super bomb explosion (also does things normal bombs can)
dw Ancilla_VictorySparkle ; 0x3B - Victory sparkle on sword
dw Ancilla_SwordChargeSpark ; 0x3C - Sparkles from holding the sword out charging for a spin attack.
dw Ancilla_ObjectSplash ; 0x3D - splash effect when things fall into the water
dw Ancilla_RisingCrystal ; 0x3E - 3D crystal effect (or transition into 3D crystal?)
dw Ancilla_BushPoof ; 0x3F - Disintegrating bush poof (due to magic powder)
dw Ancilla_DwarfPoof ; 0x40 - Dwarf transformation cloud
dw Ancilla_WaterfallSplash ; 0x41 - Water splash from player standing under waterfalls (doorways, basically)
dw Ancilla_HappinessPondRupees ; 0x42 - Rupees that you throw in to the Pond of Wishing
dw Ancilla_BreakTowerSeal ; 0x43 - Ganon's Tower seal being broken. (not opened up though!)
}
; ==============================================================================
incsrc "ancilla_ice_shot_sparkle.asm"
incsrc "ancilla_somarian_blast.asm"
incsrc "ancilla_fire_shot.asm"
; ==============================================================================
; $40853-$4097A DATA
pool Ancilla_CheckTileCollisionStaggered:
{
.collision_table
db 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0
db 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 3, 3, 3
db 0, 0, 0, 0, 0, 0, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4
db 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 3
db 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4
db 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0
db 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1
db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
db 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.y_offsets
db 0, 16, 5, 5, 0, 16, 4, 4, 4, 12
db 5, 5, 4, 12, 12, 12, 0, 0, 0, 0
.x_offsets
db 8, 8, 0, 16, 4, 4, 0, 16, 4, 4
db 4, 12, 12, 12, 4, 12, 0, 0, 0, 0
}
; ==============================================================================
; *$4097B-$40ABE LOCAL
Ancilla_CheckTileCollisionStaggered:
{
TXA : EOR $1A : LSR A : BCC .skip_even_frames
; *$40981 ALTERNATE ENTRY POINT
shared Ancilla_CheckTileCollision:
; If indoors branch here
LDA $1B : BNE .indoors
LDA $0280, X : BEQ .base_priority
STZ $03E4, X
.skip_even_frames
; indicate failure
CLC
RTS
.indoors
.base_priority
; Check collision properties of the room
; default collision with one BG ("one" in HM)
LDA $046C : BEQ .check_basic_collision
CMP.b #$03 : REP #$20 : BCC .difference_between_bg_scrolls
STZ $00
STZ $02
BRA .two_bg_collision_detection
.difference_between_bg_scrolls
LDA $E0 : SUB $E2 : STA $00
LDA $E6 : SUB $E8 : STA $02
.two_bg_collision_detection
SEP #$20
LDA $0C04, X : PHA : ADD $00 : STA $0C04, X
LDA $0C18, X : PHA : ADC $01 : STA $0C18, X
LDA $0BFA, X : PHA : ADD $02 : STA $0BFA, X
LDA $0C0E, X : PHA : ADC $03 : STA $0C0E, X
LDA.b #$01 : STA $0C7C, X
JSR .check_basic_collision
STZ $0C7C, X
PLA : STA $0C0E, X
PLA : STA $0BFA, X
PLA : STA $0C18, X
PLA : STA $0C04, X
LDY.b #$01
BCC .no_bg1_collision
INY
.no_bg1_collision
PHY
; store the state of the carry flag (if set it means there was a collision on BG0)
PHP
JSR .check_basic_collision
; takes the previous carry flag state, rolls in the current carry flag state
; (Has to detect on BG0 for the carry to be set)
PLA : AND.b #$01 : ROL A : CMP.b #$01
PLY
RTS
.check_basic_collision
; Normal Collision checking for just one BG
LDY $0C72, X
LDA $0BFA, X : ADD .y_offsets, Y : STA $00
LDA $0C0E, X : ADC.b #$00 : STA $01
LDA $0C04, X : ADD .x_offsets, Y : STA $02
LDA $0C18, X : ADC.b #$00 : STA $03
; *$40A26 ALTERNATE ENTRY POINT
shared Ancilla_CheckTargetedTileCollision:
REP #$20 : LDA $00 : SUB $E8
CMP.w #$00E0 : SEP #$20 : BCS .ignore_off_screen_collision_y
REP #$20 : LDA $02 : SUB $E2
; This one is also due to ignoring off screen collision, but in the
; x coordinate.
CMP.w #$0100 : SEP #$20 : BCS .no_collision
LDA $1B : BNE .check_indoor_collision
REP #$20
LSR $02 : LSR $02 : LSR $02
PHX
JSL Overworld_GetTileAttrAtLocation
PLX
BRA .store_tile_interaction_result
.check_indoor_collision
; Floor selector for special effects apparently :)
LDA $0C7C, X
; Retrieves tile type that the bomb is sitting on.
JSL Entity_GetTileAttr
.store_tile_interaction_result
STA $03E4, X : TAY
LDA .collision_table, Y : STA $0F
; Checks the special effect type
LDA $0C4A, X : CMP #$02 : BNE .not_fire_rod_shot
; Perhaps looking for a door type tile?
TYA : AND.b #$F0 : CMP.b #$C0 : BNE .not_torch_collision
; Make a note of which torch it touched.
STA $0F
.not_fire_rod_shot
.not_torch_collision
LDA $0280, X : BNE .forced_high_priority
LDA $0F : BEQ .tile_type_not_collision_candidate
CMP.b #$01 : BEQ .collided
CMP.b #$02 : BNE .not_sloped_tile
JSL Entity_CheckSlopedTileCollisionLong
RTS
.not_sloped_tile
CMP.b #$03 : BNE .not_attr_3
LDY $03CA, X : BNE .collided
.ignore_off_screen_collision_y
BRA .no_collision
.not_attr_3
.forced_high_priority
; Educated guess: This looks like an attempt to get the object out
; of high priority status that resulted from hitting certain tiles
; in earlier frames, like ledges.
DEC $028A, X : BPL .no_collision
STZ $028A, X
LDA $0F : CMP.b #$04 : BNE .no_collision
LDA.b #$06 : STA $028A, X
LDA $0280, X : EOR.b #$01 : STA $0280, X
BRA .no_collision
.tile_type_not_collision_candidate
.no_collision
CLC
RTS
.collided
LDY.b #$00
SEC
; *$40AB9 ALTERNATE ENTRY POINT
shared Ancilla_AlertSprites:
; This seems to activate enemies that "listen" for sounds
LDA.b #$03 : STA $0FDC
RTS
}
; ==============================================================================
; $40ABF-$40BCE DATA
pool Ancilla_CheckTileCollision_Class2:
{
; Similar to the other collision routine's behavior table, this one
; opts to not interact with torches or chests, but interacts more
; generally with doors and screen transition tiles. This may have
; something to do with
.collision_table
db 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0
db 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 0, 3, 3, 3
db 0, 0, 0, 0, 0, 0, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4
db 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 3
db 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1
db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
db 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
.y_offsets_low
db -8, 8, 0, 0
.y_offsets_high
db -1, 0, 0, 0
.x_offsets_low
db 0, 0, -8, 8
.x_offsets_high
db 0, 0, -1, 0
}
; ==============================================================================
; *$40BCF-$40CD8 LOCAL
Ancilla_CheckTileCollision_Class2:
{
; Does collision detection for a number of entities, bombs being one of them
; "Collision" in Hyrule Magic. Do only collision on BG2
LDA $046C : BEQ .check_basic_collision
; Is it the "moving floor" collision type?
; if it's collision with 2 BGs then branch
CMP.b #$03 : REP #$20 : BCC .difference_between_bg_scrolls
STZ $00
STZ $02
BRA .two_bg_collision_detection
.difference_between_bg_scrolls
; Calculate the differences in the scroll values between the two main BGs
; This is for rooms that have a hidden wall (there's only like 3 of them in the original)
; $00 = BG1HOFS - BG0HOFS
LDA $E0 : SUB $E2 : STA $00
; $02 = BG1VOFS - BG0VOFS
LDA $E6 : SUB $E8 : STA $02
.two_bg_collision_detection
SEP #$20
LDA $0C04, X : PHA : ADD $00 : STA $0C04, X
LDA $0C18, X : PHA : ADC $01 : STA $0C18, X
LDA $0BFA, X : PHA : ADD $02 : STA $0BFA, X
LDA $0C0E, X : PHA : ADC $03 : STA $0C0E, X
LDA.b #$01 : STA $0C7C, X
JSR .check_basic_collision
STZ $0C7C, X