-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMMX3_Events_Zero.asm
3067 lines (2584 loc) · 77.4 KB
/
MMX3_Events_Zero.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
;==================================================================================
; Mega Man X3 (Base Mod Project)
; By xJustin3009x (Shishisenkou) (Justin3009)
;==================================================================================
; This file is used to import the code changes that separate all characters from one
; another so they can have individual stats instead of group stats.
;==================================================================================
; NOTE: The ROM MUST be expanded to 4MB first WITHOUT a header!
;==================================================================================
;***************************
;Blank data
;***************************
;B9:C1BC - $B9:FFFF
;***************************
;***************************
; ROM Addresses
;***************************
!ZeroMainEvents = $E08080
;***************************
header : lorom
incsrc MMX3_NewCode_Locations.asm
incsrc MMX3_VariousAddresses.asm
;***************************
;***************************
; Pointers to Zero Events
;***************************
org !ZeroMainEvents
LDX $01
JMP (ZeroMainEventPointers,x)
ZeroMainEventPointers:
dw ZeroEvent00SpyCopterBase
dw ZeroEvent02XGetsCapturedBase
dw ZeroEvent04RescueXBase
dw ZeroEvent06ZeroMaohGiantBase
dw ZeroEvent08ZeroPowerCellDamagedBase ;UNUSED AND COMPLETELY BLANK
dw ZeroEvent0ADrCainFindLabBase
dw ZeroEvent0CREX2000Base
dw ZeroEvent0EMosquitusBase
dw ZeroEvent10ZSaberWallBase
dw ZeroEvent12SigmaVirusBase
dw ZeroEvent14CliffSceneBase
dw ZeroEvent16CreditsBase
dw $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
dw $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
dw $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
dw $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
dw $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
dw $FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF,$FFFF
;***************************
;***************************
; Event #00: Spycopter
;***************************
{
ZeroEvent00SpyCopterBase:
LDX !PCNPC_EventID_02
JMP (ZeroEvent00SpyCopterEvents,x)
ZeroEvent00SpyCopterEvents:
dw ZeroSpyCopter00
dw ZeroSpyCopter02
dw ZeroSpyCopter04
dw ZeroSpyCopter06
dw ZeroSpyCopter08
dw ZeroSpyCopter0A
dw ZeroSpyCopter0C
dw ZeroSpyCopter0E
dw ZeroSpyCopter10
dw ZeroSpyCopter12
dw ZeroSpyCopter14
dw ZeroSpyCopter16
db $FF,$FF
;***************************
; Sub-event #00: Sets Zero's sprite data up & palette, Z-Saber palette, Zero's jump velocity, distance and hitbox.
;***************************
ZeroSpyCopter00:
INC !PCNPC_EventID_02 ;Increase Zero Introduction Event to 02
INC !PCNPC_EventID_02 ;Increase Zero Introduction Event to 02
LDA #$2C ;Set PC NPC's palette RAM location [ABSOLUTELY REQUIRED BEFORE JSLING TO SPRITES FIRST TIME]
STA !PCNPC_PaletteDirection_11
JSL ZeroSetup ;Load Zero's sprite settings
LDA #$52 ;Zero Jump Animation
JSL !AnimationOneFrame
JSL NewVRAMRoutine
REP #$10
LDX #$0070 ;Load RAM location to store palette
LDA !RideChipsOrigin_7E1FD7
AND #$F0
CMP #$F0
BEQ LoadZeroPurpleSaber
LDY #$00D2 ;Load Z-Saber palette
BRA LoadZeroBusterPaletteEnd
LoadZeroPurpleSaber:
LDY #$0206 ;Load Z-Saber Purple palette
LoadZeroBusterPaletteEnd:
JSL !Palette
REP #$20
LDA !ScreenXCoordinate_1E5D
CLC
ADC #$0100
STA !PCNPC_XCoordinate_05
LDA !ScreenYCoordinate_1E60
CLC
ADC #$00E0
STA !PCNPC_YCoordinate_08
LDA #$0710 ;Load velocity of Zero
STA !PCNPC_Velocity_1C
LDA #$FE80 ;Load distance/speed of Zero
STA !PCNPC_SpeedDistance_1A
LDA #$0040 ;Load hitbox of Zero
STA !PCNPC_JumpHeight_1E
SEP #$30
RTL
;***************************
; Sub-event #02: Zero flying up to land on Spycopter
;***************************
ZeroSpyCopter02:
JSL !CheckForGround
BIT $1D
BPL SpyCopter02Loop
REP #$20
LDA $08 ;Y coordinate of NPC
CMP #$0178 ;Check for value
SEP #$20
BMI SpyCopter02Loop ;If <= #$0178, BMI to $03/A8D2 to ignore event increase and loop event
INC !PCNPC_EventID_02 ;Increase Zero Introduction Spycopter Event to 04
INC !PCNPC_EventID_02 ;Increase Zero Introduction Spycopter Event to 04
LDA #$6F ;Load animation for Zero landing on Spycopter
JML !VRAMRoutineConsistent
SpyCopter02Loop:
JML !AnimationConsistent
;***************************
; Sub-event #04: Zero landing on Spycopter
;***************************
ZeroSpyCopter04:
REP #$30
LDX $1F57 ;Load base RAM for Spycopter
LDA $0005,x ;X coordinates of Spycopter
CLC
ADC #$0018
STA !PCNPC_XCoordinate_05 ;Store to NPC RAM X coordinates
LDA $0008,x
STA !PCNPC_YCoordinate_08 ;Store to NPC RAM Y coordinates
LDA !ScreenXCoordinate_1E5D
CMP #$09D0
BPL ZeroSpyCopter04Increase
SEP #$30
JML !AnimationConsistent
ZeroSpyCopter04Increase:
LDA #$0600 ;Load speed/stance of NPC
STA !PCNPC_SpeedDistance_1A
LDA #$0380 ;Load velocity of NPC
STA !PCNPC_Velocity_1C
SEP #$30
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 06
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 06
LDA #$72 ;Load Zero kicking off wall animation
JML !VRAMRoutineConsistent
;***************************
; Sub-event #06: Check for ??? then load Zero's Z-Saber sprite assembly data and animation
;***************************
ZeroSpyCopter06:
JSL !CheckForGround
LDA $0F
BMI ZeroSpyCopter06Increase
JML !AnimationConsistent
ZeroSpyCopter06Increase:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 08
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 08
REP #$20
STZ !PCNPC_SpeedDistance_1A ;Store 00 to PC NPC RAM at $7E:0CE2 (PC NPC jump speed/distance low byte)
SEP #$20
JSL ZeroZSaberSetup
LDA #$0E ;Load Zero using Z-Saber animation
JML !VRAMRoutineConsistent
;***************************
; Sub-event #08: Draw Z-Saber object
;***************************
ZeroSpyCopter08:
JSL !CheckForGround
REP #$20
LDA #$FA80
CMP !PCNPC_Velocity_1C
BMI ZeroSpyCopter08IgnoreStorage
STA !PCNPC_Velocity_1C
ZeroSpyCopter08IgnoreStorage:
SEP #$20
BIT !PCNPC_IsAnimating_0F
BMI ZeroSpyCopter08Increase
BVC ZeroSpyCopter08Animation
;Z-Saber setup
JSL ZSaberZeroSetup
ZeroSpyCopter08Animation:
SEP #$30
JML !AnimationConsistent
ZeroSpyCopter08Increase:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 0A
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 0A
JSL ZeroSetup
LDA #$57 ;Load Zero falling animation
JML !VRAMRoutineConsistent
;***************************
; Sub-event #0A: Spycopter breaking with NPC Zero falling/landing
;***************************
ZeroSpyCopter0A:
REP #$20
LDA #$FA80
CMP !PCNPC_Velocity_1C
BMI ZeroSpyCopter0AIgnoreStorage
STA !PCNPC_Velocity_1C
ZeroSpyCopter0AIgnoreStorage:
SEP #$20
JSL !CheckForGround
JSL !LandOnGround
LDA !PCNPC_OnGround_2B ;Load byte to determine if NPC is on ground or in air
BIT #$04 ;BIT #$04 (On ground)
BNE ZeroSpyCopter0AIncrease
JML !AnimationConsistent
ZeroSpyCopter0AIncrease:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 0C
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 0C
LDA #$3C ;Load delay timer before dialogue box can load up
STA !PCNPC_DelayTimer_3C ;Store to NPC RAM at $7E:0D04
LDA #$50 ;Load animation for Zero landing on ground
JML !VRAMRoutineConsistent
;***************************
; Sub-event #0C: Initiate data to draw dialogue box
;***************************
ZeroSpyCopter0C:
DEC !PCNPC_DelayTimer_3C ;Decrease delay timer from $7E:0D04
BEQ ZeroSpyCopter0CSkipAnimation
JSL !VRAMRoutineAlt ;Load alternate force VRAM update? (Can be changed to 04:BCA2 and it works just fine still?)
JML !EventLoop
ZeroSpyCopter0CSkipAnimation:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 0E
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 0E
LDA #$3C ;Load delay timer before Zero teleports out after dialogue
STA !PCNPC_DelayTimer_3C
REP #$20
LDA !CurrentPCAction_09DA
STA !PCNPC_TempStorage_33
LDA #$0866
STA !CurrentPCAction_09DA
SEP #$20
LDA #$30 ;Load which dialogue to use
JSL !DialogueBoxNormal
LDA #$50 ;Load frame to use after Zero NPC is done talking
STA !PCNPC_AnimationFrameDoneTalk_43
LDA #$87 ;Load frame for Zero Talking
JML !VRAMRoutineConsistent
;***************************
; Sub-event #0E: Initiate data to draw dialogue box
;***************************
ZeroSpyCopter0E:
LDA $1F3F ;Check for 'Event lock'
BPL ZeroSpyCopter0EIncrease
LDA $1F51 ;Load NPC talk animation bit
BNE ZeroSpyCopter0ECheckVRAM
LDA $1F50 ;Check for NPC allowed to talk animation bit
CMP #$01
BEQ ZeroSpyCopter0EVRAMUpdate
ZeroSpyCopter0ECheckVRAM:
LDA !PCNPC_IsAnimating_0F ;Load flag to check if NPC needs to update their VRAM data
BEQ ZeroSpyCopter0EEventLoop
ZeroSpyCopter0EVRAMUpdate:
JSL !VRAMRoutineAlt
ZeroSpyCopter0EEventLoop:
JML !EventLoop
ZeroSpyCopter0EIncrease:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 10
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 10
REP #$20
LDA !PCNPC_TempStorage_33
STA !CurrentPCAction_09DA
SEP #$20
LDA #$80 ;Load idle
STA $09EF ;Current PC Frame
LDA !PCNPC_AnimationFrameDoneTalk_43 ;Load frame to load after talking
JML !VRAMRoutineConsistent
;***************************
; Sub-event #10: Initiate data to draw dialogue box
;***************************
ZeroSpyCopter10:
DEC !PCNPC_DelayTimer_3C ;Decrease delay timer from $7E:0D04
BEQ ZeroSpyCopter10Increase
JSL !VRAMRoutineAlt
JML !EventLoop
ZeroSpyCopter10Increase:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 12
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 12
LDA #$11 ;Load teleport out SFX
JSL !PlaySFX
LDA #$7F ;Load Zero begin teleporting out animation
JML !VRAMRoutineConsistent
;***************************
; Sub-event #12: Common event for NPC begin teleport out
;***************************
ZeroSpyCopter12:
LDA !PCNPC_IsAnimating_0F ;Load flag to check if NPC needs to update their VRAM data
BMI ZeroSpyCopter12Increase
JML !AnimationConsistent
ZeroSpyCopter12Increase:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 14
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 14
REP #$20
LDA #$0AA6 ;Load velocity of Zero
STA !PCNPC_Velocity_1C
SEP #$20
LDA #$10 ;Load teleport out SFX #2
JSL !PlaySFX
LDA #$7D ;Load Zero teleport out animation
JML !VRAMRoutineConsistent
;***************************
; Sub-event #14: Zero teleporting out
;***************************
ZeroSpyCopter14:
JSL !MoveObjectUp
LDA !PCNPC_Animate_0E ;Load whether NPC is animating or not
BEQ ZeroSpyCopter14Increase
JML !EventLoop
ZeroSpyCopter14Increase:
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 16
INC !PCNPC_EventID_02 ;Increase Introduction Spycopter Event to 16
RTL
;***************************
; Sub-event #16: End Introduction event
;***************************
ZeroSpyCopter16:
STZ !PCNPC_Active_00 ;Store 00 to NPC RAM at $7E:0CC8 so NPC is removed from screen
RTL
}
;-----------------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------------
;***************************
; Event #02: X Gets Captured
;***************************
ZeroEvent02XGetsCapturedBase:
LDX !PCNPC_EventID_02
JMP (ZeroEvent02XGetsCapturedEvents,x)
ZeroEvent02XGetsCapturedEvents:
dw ZeroEvent02XGetsCaptured00
dw ZeroEvent02XGetsCaptured02
dw ZeroEvent02XGetsCaptured04
dw ZeroEvent02XGetsCaptured06
dw ZeroEvent02XGetsCaptured08
dw ZeroEvent02XGetsCaptured0A
dw ZeroEvent02XGetsCaptured0C
dw ZeroEvent02XGetsCaptured0E
dw ZeroEvent02XGetsCaptured10
dw ZeroEvent02XGetsCaptured12
dw ZeroEvent02XGetsCaptured14
dw ZeroEvent02XGetsCaptured12
dw ZeroEvent02XGetsCaptured18
dw ZeroEvent02XGetsCaptured1A
dw ZeroEvent02XGetsCaptured1C
dw ZeroEvent02XGetsCaptured12
dw ZeroEvent02XGetsCaptured20
dw $FF
;***************************
; Sub-event #00: Set X NPC sprites up
;***************************
ZeroEvent02XGetsCaptured00:
INC !PCNPC_EventID_02 ;Increase Zero Introduction Event to 02
INC !PCNPC_EventID_02 ;Increase Zero Introduction Event to 02
LDA #$04
STA !PCNPC_SpritePriority_12
LDA #$26
STA !PCNPC_PaletteDirection_11
LDA #$40 ;Manually set PC NPC direction
TSB !PCNPC_PaletteDirection_11
JSL XSetup
LDA #$30
STA !PCNPC_VRAMSlot_18
INC !DisableLRSubWeaponScroll_1F45
INC !DisableMenuOpening_1F4F
INC !PCGodMode_1F1D ;Might not be needed
STZ !CurrentPCSubWeapon_0A0B
STZ !PCVisibility_09E6
STZ !PCVisibility2_0A43 ;Might not be needed
INC !PCNPC_UNKNOWN_30 ;Might not be needed
LDA !PCPaletteDirection_09E9
STA !PCNPC_PaletteDirection_11
REP #$20
LDA !PCXCoordinate_09DD
STA !PCNPC_XCoordinate_05
LDA !PCYCoordinate_09E0
STA !PCNPC_YCoordinate_08
LDA !CurrentPCHitbox_09F8
STA !PCNPC_Hitbox_20
SEP #$20
LDA #$03
STA !PCNPC_AnimationFrameDoneTalk_43
LDA #$50
CLC
ADC $0A4B
JSL !AnimationOneFrame
;***************************
; Sub-event #02: Sets Zero breathing and collapsing. Clears out all charges.
;***************************
ZeroEvent02XGetsCaptured02:
REP #$10
LDX !PCNPC_TempStorage_0C
JSL !MissileHitObject
BCC ZeroEvent02JumptoAnimation02
LDA #$0D
JSL !PlaySFX
LDA #$04
STA $0001,x
JSL !ClearPCCharge
STZ $0A2F ;Clears current charge time
JSL !LoadPCWeaponPalette
INC !DisablePCCharging_0A54
LDX !PCNPC_TempStorage_0C
LDA #$04 ;Animation to play for missile
STA $0001,x
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA #$78 ;Set timer until dialogue box appears
STA !PCNPC_DelayTimer_3C
JSL XZSaberSetup
LDA #$1C ;Load animation for NPC X to use
JSL !AnimationOneFrame
INC $3D ;Enables object above PC
INC $3E ;Enables object above PC
JSL !CheckSpecialFXSlot
BNE ZeroEvent02JumptoAnimation02
INC $0000,x ;Loads code for missile objects
LDA #$10
STA $000A,x
LDA #$1E
STA $0002,x
LDA #$01
STA $0003,x
LDA #$1C
STA $000B,x
LDY !PCNPC_JumpHeight_1E ;Used as a temp. storage for where to get RAM on missile
LDA $0011,y
CLC
ADC #$02
STA $0011,x
REP #$20
LDA !PCNPC_XCoordinate_05
STA $0005,x
LDA !PCNPC_YCoordinate_08
STA $0008,x
LDA #$0D05
STA $000C,x
TXA
STA $3F
ZeroEvent02JumptoAnimation02:
JML !AnimationConsistent
;***************************
; Sub-event #04: Countdown timer to load next dialogue box/flickering
;***************************
ZeroEvent02XGetsCaptured04:
JSL MissileFlickering ;Sets flickering for object covering X
DEC !PCNPC_DelayTimer_3C
BNE ZeroEvent02JumptoAnimation04
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA #$31 ;Load dialogue to use
JSL !DialogueBoxNormal
ZeroEvent02JumptoAnimation04:
JML !AnimationConsistent
;***************************
; Sub-event #06: Sets event lock then loads object to pick NPC X up
;***************************
ZeroEvent02XGetsCaptured06:
JSL MissileFlickering
LDA !EnableEventLock_1F3F
BMI ZeroEvent02JumptoAnimation06
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
JSL !CheckSpecialFXSlot
BNE ZeroEvent02JumptoAnimation06
INC $0000,x
LDA #$10
STA $000A,x
LDA #$1E
STA $0002,x
STA $0003,x
LDA #$1A
STA $000B,x
LDA #$21
STA $0011,x
REP #$20
LDA !ScreenXCoordinate_1E5D
CLC
ADC #$0100
STA $0005,x
LDA !ScreenYCoordinate_1E60
CLC
ADC #$0040
STA $0008,x
LDA #$FC00
STA $001A,x
LDA #$FF00
STA $001C,x
LDA #$0D06
STA $000C,x
TXA
STA $41 ;Temp. Storage on PC NPC
ZeroEvent02JumptoAnimation06:
SEP #$30
JML !AnimationConsistent
;***************************
; Sub-event #08: Object checking for coordinates and picking up NPC X
;***************************
ZeroEvent02XGetsCaptured08:
JSL MissileFlickering
REP #$20
PHD
LDA $41 ;Temp. Storage on PC NPC
TCD
JSL !CheckForLanding
LDA $0CCD ;PC NPC X coordinates. This is HARD SET due to the missile using the main RAM
CMP !PCNPC_XCoordinate_05 ;Check object X coordinates using OBJECT RAM at $7E:185D
BMI ZeroEvent02IgnoreSTZ08
STZ !PCNPC_SpeedDistance_1A ;Store 00 to OBJECT RAM at $7E:1872
ZeroEvent02IgnoreSTZ08:
LDA !PCNPC_YCoordinate_08 ;Load OBJECT RAM Y coordinates
CMP #$068F
BPL ZeroEvent02IgnoreContinue08
PLD
JML !AnimationConsistent
ZeroEvent02IgnoreContinue08:
LDA #$068F
STA !PCNPC_YCoordinate_08 ;Store to OBJECT RAM X coordinates
PLD
SEP #$20
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA #$3C
STA !PCNPC_DelayTimer_3C
JML !AnimationConsistent
;***************************
; Sub-event #0A: Sets life to invisible and X gets picked up
; ;Altered so life bar doesn't get set to invisible
;***************************
ZeroEvent02XGetsCaptured0A:
JSL MissileFlickering
DEC !PCNPC_DelayTimer_3C
BNE ZeroEvent02JumptoAnimation0A
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
REP #$10
LDX $41
LDA #$80
STA $000B,x
REP #$20
LDA #$0078
STA !PCNPC_DelayTimer_3C
LDA #$0300
STA !PCNPC_SpeedDistance_1A ;OBJECT that drags X off screen
LDA #$0200
STA !PCNPC_Velocity_1C ;OBJECT that drags X off screen
ZeroEvent02JumptoAnimation0A:
JML !AnimationConsistent
;***************************
; Sub-event #0C: X gets picked up and dragged off screen
;***************************
ZeroEvent02XGetsCaptured0C:
JSL MissileFlickering
DEC !PCNPC_DelayTimer_3C
BEQ ZeroEvent02JumptoAnimation0C
JML !AnimationConsistent
ZeroEvent02JumptoAnimation0C:
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
JSL XSetup
LDA #$7B
JML !VRAMRoutineConsistent
;***************************
; Sub-event #0E: Moves object that has X up (Merges with next event)
;***************************
ZeroEvent02XGetsCaptured0E:
JSL MissileFlickering
REP #$30
LDA !PCNPC_YCoordinate_08
CMP #$0680
BPL ZeroEvent02MoveObjectUp0E
SEP #$20
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
ZeroEvent02MoveObjectUp0E:
JSL !MoveObjectUp
BRA ZeroEvent02SkipMoveObjectRight0E
;***************************
; Sub-event #10: Moves object that has X to the right and off screen
;***************************
ZeroEvent02XGetsCaptured10:
JSL !MoveObjectRight
ZeroEvent02SkipMoveObjectRight0E:
REP #$30
LDX $3F ;PC NPC temporary storage
LDY !PCNPC_TempStorage_41
LDA !PCNPC_XCoordinate_05
STA $0005,x
STA $0005,y
LDA !PCNPC_YCoordinate_08
STA $0008,x
CLC
ADC #$FFE0
STA $0008,y
JSL !AnimationConsistent
REP #$10
LDA !PCNPC_Animate_0E
BNE ZeroEvent02SkipMacIncrease10
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
STZ $3E ;PC NPC temp storage
LDA #$B4
STA !PCNPC_DelayTimer_3C
LDX !PCNPC_JumpHeight_1E ;Used as temp. storage for Mac's RAM
INC $0002,x ;Increase Mac's event
INC $0002,x ;Increase Mac's event
ZeroEvent02SkipMacIncrease10:
RTL
;***************************
; Sub-event #12: Common Event used for strictly count downs to get to the next event
;***************************
ZeroEvent02XGetsCaptured12:
DEC !PCNPC_DelayTimer_3C
BNE ZeroEvent02IgnoreCounter12
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
ZeroEvent02IgnoreCounter12:
RTL
;***************************
; Sub-event #14: Ceiling shake/Fall
;***************************
ZeroEvent02XGetsCaptured14:
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA #$C0
STA !PCNPC_DelayTimer_3C
JSL !CheckEnemyRoom
BNE ZeroEvent02NoOpenEnemy14
;Sets data up for falling ceiling tile
INC $0000,x
LDA #$20
STA $000A,x
LDA #$01
STA $000B,x
REP #$20
LDA #$1170
STA $0005,x
LDA #$0606
STA $0008,x
ZeroEvent02NoOpenEnemy14:
RTL
;***************************
; Sub-event #16: Event used for strictly count downs to get to the next event (Same as #12)
;***************************
;JMP ZeroEvent02XGetsCaptured12
;***************************
; Sub-event #18: Load Zero falling from ceiling & sets health
;***************************
ZeroEvent02XGetsCaptured18:
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDY #$5C ;Loads music fade and PC icon
JSL !LoadSubWeaponIcon
SEP #$30
LDA #$3C
STA !PCNPC_DelayTimer_3C
STZ !PCGodMode_1F1D ;Might not be needed
INC !PCVisibility_09E6
LDA #$02
STA !CurrentPC_0A8E
STA !CurrentPCCheck_1FFF
JSL HeartTank
LDA #$FF
STA !CurrentHealth_09FF
LDA #$01
STA !JumpDashFlag_7EF4E7
JSL SetJumpValues
JSL PCGeneralPalettes
REP #$20
LDA #$1170
STA !PCXCoordinate_09DD
LDA #$05E0
STA !PCYCoordinate_09E0
LDA #$0EB4
STA !CurrentPCHitbox_09F8
SEP #$20
LDA #$04
TRB $0A03
JSL !PalettePCBuster ;Sets PC's weapon palette
LDA #$31
JSL !PlayMusic
JSL $84D1CA ;Prevents Zero from being damaged when falling
STZ !PCHealthBar_1F22
STZ !PCSubWeaponAmmoBar_1F23
STZ !DisablePCCharging_0A54
DEC !DisableMenuOpening_1F4F
RTL
;***************************
; Sub-event #1A: ???
;***************************
ZeroEvent02XGetsCaptured1A:
LDA $1F18
STA !PCNPC_AnimationFrameDoneTalk_43 ;Temp. storage
LDA #$0F
STA $1F18
JSL $80B1DC
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
RTL
;***************************
; Sub-event #1C: Zero falling
;***************************
ZeroEvent02XGetsCaptured1C:
LDA $0040
BNE ZeroEvent02IgnoreSubEvent1C
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA #$01
STA $1F19
JSL $80B5A5
ZeroEvent02IgnoreSubEvent1C:
RTL
;***************************
; Sub-event #1E: Event used for strictly count downs to get to the next event (Same as #12)
;***************************
;***************************
; Sub-event #20: Zero lands
;***************************
ZeroEvent02XGetsCaptured20:
LDA $0A03 ;Load PC NPC to check if on ground or air
BIT #$04
BEQ ZeroEvent02PCNPC_isNotOnGround20
DEC !DisableLRSubWeaponScroll_1F45
DEC !DisableMenuOpening_1F4F
LDA !PCNPC_AnimationFrameDoneTalk_43 ;Load temp. storage
STA $1F18
STZ $1F19
JSL $84D1EF
STZ $00 ;Disables PC NPC event
ZeroEvent02PCNPC_isNotOnGround20:
RTL
;-----------------------------------------------------------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------------------------------------------------------
;***************************
; Event #04: Rescue X from Mac
;***************************
ZeroEvent04RescueXBase:
LDX !PCNPC_EventID_02
JMP (ZeroEvent04RescueXEvents,x)
ZeroEvent04RescueXEvents:
dw ZeroEvent04RescueX00
dw ZeroEvent04RescueX02
dw ZeroEvent04RescueX04
dw ZeroEvent04RescueX06
dw ZeroEvent04RescueX08
dw ZeroEvent04RescueX0A
dw ZeroEvent04RescueX0C
dw ZeroEvent04RescueX0E
dw ZeroEvent04RescueX10
dw $FF
;***************************
; Sub-event #00: Set X hanging from object
;***************************
ZeroEvent04RescueX00:
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA !PCPaletteDirection_09E9
AND #$30
ORA #$01
ORA !PCNPC_PaletteDirection_11
STA !PCNPC_PaletteDirection_11
JSL ZeroSetup
LDA #$20
STA !PCNPC_VRAMSlot_18
REP #$20
STZ !PCNPC_SpeedDistance_1A
STZ !PCNPC_Velocity_1C
LDA #$0040
STA !PCNPC_JumpHeight_1E
LDA #$B40E
STA !PCNPC_Hitbox_20
SEP #$20
LDA #$7B ;Load frame of X being held
JSL !AnimationOneFrame
JSL !VRAMRoutineAllowMissiles
JML !EventLoop
;***************************
; Sub-event #02: Repeat animation
;***************************
ZeroEvent04RescueX02:
LDA !PCNPC_Animate_0E
BMI ZeroEvent04RescueX02SkipAnimate
JSL !VRAMRoutineAlt
JSL !VRAMRoutineAllowMissiles
ZeroEvent04RescueX02SkipAnimate:
LDA $157A
CMP #$10
BNE ZeroEvent04RescueX02IncreaseEvent
LDA $0D58 ;Check object holding X to see if active
BNE ZeroEvent04RescueX02IncreaseEvent
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
INC !DisableLRSubWeaponScroll_1F45
INC !DisableMenuOpening_1F4F
LDA #$04
STA !PCHealthBar_1F22
STA !PCSubWeaponAmmoBar_1F23
ZeroEvent04RescueX02IncreaseEvent:
JML !EventLoop
;***************************
; Sub-event #04: Initiate X falling
;***************************
ZeroEvent04RescueX04:
REP #$20
LDA !ScreenXCoordinate_1E5D
CLC
ADC #$0050
JSL $84D24B ;Sets PC NPC coordinates to walk
SEP #$20
JSL $848E81 ;???
JSL $84B6D0 ;???
INC !DisablePCCharging_0A54 ;??? [Doesn't seem like it's needed]
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA #$57
JSL !AnimationOneFrame
JSL !VRAMRoutineAllowMissiles
JML !EventLoop
;***************************
; Sub-event #06: X falling/check for landing
;***************************
ZeroEvent04RescueX06:
JSL !CheckForGround
JSL FallingVelocity
JSL !LandOnGround
LDA !PCNPC_OnGround_2B
BIT #$04
BNE ZeroEvent04RescueX06OnGround
JML !EventLoop
ZeroEvent04RescueX06OnGround:
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
LDA #$50
JSL !AnimationOneFrame
JSL !VRAMRoutineAllowMissiles
JML !EventLoop
;***************************
; Sub-event #08: X landed
;***************************
ZeroEvent04RescueX08:
LDA !CurrentPCSubAction_09DB
CMP #$08
BNE ZeroEvent04RescueX08IgnoreEventIncrease
INC !PCNPC_EventID_02
INC !PCNPC_EventID_02
ZeroEvent04RescueX08IgnoreEventIncrease:
JML !EventLoop
;***************************
; Sub-event #0A: Sets PC back to X and loads dialogue
;***************************
ZeroEvent04RescueX0A:
REP #$30
LDA !PCXCoordinate_09DD
LDX !PCNPC_XCoordinate_05
STA !PCNPC_XCoordinate_05
STX !PCXCoordinate_09DD
LDA !PCYCoordinate_09E0
LDX !PCNPC_YCoordinate_08
STA !PCNPC_YCoordinate_08
STX !PCYCoordinate_09E0
SEP #$20
PHD
PEA $09D8
PLD
LDA #$02
STA !CurrentPC_0A8E
STA !CurrentPCCheck_1FFF