-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBank $91.asm
14888 lines (13031 loc) · 661 KB
/
Bank $91.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
;;; $8000..834D: Normal Samus pose input handler ;;;
{
;;; $8000: Normal Samus pose input handler ;;;
{
; Called by Samus pose input handlers other than x-ray (which uses $91:FCAF instead)
$91:8000 08 PHP
$91:8001 8B PHB
$91:8002 4B PHK ;\
$91:8003 AB PLB ;} DB = $91
$91:8004 C2 30 REP #$30
$91:8006 AD 1F 0A LDA $0A1F [$7E:0A1F] ;\
$91:8009 29 FF 00 AND #$00FF ;|
$91:800C 0A ASL A ;} Execute [$8014 + [Samus movement type] * 2]
$91:800D AA TAX ;|
$91:800E FC 14 80 JSR ($8014,x)[$91:804D];/
$91:8011 AB PLB
$91:8012 28 PLP
$91:8013 6B RTL
$91:8014 dw 804D, ; 0: Standing
8066, ; 1: Running
806E, ; 2: Normal jumping
8076, ; 3: Spin jumping
807E, ; 4: Morph ball - on ground
8087, ; 5: Crouching
80B6, ; 6: Falling
8086, ; 7: Unused
810A, ; 8: Morph ball - falling
8112, ; 9: Unused
8113, ; Ah: Knockback / crystal flash ending
812D, ; Bh: Unused
8132, ; Ch: Unused
813A, ; Dh: Unused
8142, ; Eh: Turning around - on ground
8146, ; Fh: Crouching/standing/morphing/unmorphing transition
8147, ; 10h: Moonwalking
814F, ; 11h: Spring ball - on ground
8157, ; 12h: Spring ball - in air
815F, ; 13h: Spring ball - falling
8167, ; 14h: Wall jumping
816F, ; 15h: Ran into a wall
8181, ; 16h: Grappling
8189, ; 17h: Turning around - jumping
818D, ; 18h: Turning around - falling
8191, ; 19h: Damage boost
8199, ; 1Ah: Grabbed by Draygon
81A1 ; 1Bh: Shinespark / crystal flash / drained by metroid / damaged by MB's attacks
}
;;; $804C: RTS ;;;
{
$91:804C 60 RTS
}
;;; $804D: Normal Samus pose input handler - [Samus movement type] = standing ;;;
{
$91:804D 08 PHP
$91:804E C2 30 REP #$30
$91:8050 AD 1C 0A LDA $0A1C [$7E:0A1C] ;\
$91:8053 F0 07 BEQ $07 [$805C] ;|
$91:8055 C9 9B 00 CMP #$009B ;} If not facing forward:
$91:8058 F0 02 BEQ $02 [$805C] ;/
$91:805A 80 05 BRA $05 [$8061] ; Go to NOT_FACING_FORWARD
$91:805C AD 18 0E LDA $0E18 [$7E:0E18] ;\
$91:805F D0 03 BNE $03 [$8064] ;} If [elevator status] != inactive: return
; NOT_FACING_FORWARD
$91:8061 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8064 28 PLP
$91:8065 60 RTS
}
;;; $8066: Normal Samus pose input handler - [Samus movement type] = running ;;;
{
$91:8066 08 PHP
$91:8067 C2 30 REP #$30
$91:8069 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:806C 28 PLP
$91:806D 60 RTS
}
;;; $806E: Normal Samus pose input handler - [Samus movement type] = normal jumping ;;;
{
$91:806E 08 PHP
$91:806F C2 30 REP #$30
$91:8071 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8074 28 PLP
$91:8075 60 RTS
}
;;; $8076: Normal Samus pose input handler - [Samus movement type] = spin jumping ;;;
{
$91:8076 08 PHP
$91:8077 C2 30 REP #$30
$91:8079 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:807C 28 PLP
$91:807D 60 RTS
}
;;; $807E: Normal Samus pose input handler - [Samus movement type] = morph ball - on ground ;;;
{
$91:807E 08 PHP
$91:807F C2 30 REP #$30
$91:8081 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8084 28 PLP
$91:8085 60 RTS
}
;;; $8086: RTS. Normal Samus pose input handler - [Samus movement type] = 7 ;;;
{
$91:8086 60 RTS
}
;;; $8087: Normal Samus pose input handler - [Samus movement type] = crouching ;;;
{
; Note that this routine is not called when time is frozen ([$0A42] = $E713 during reserve tanks, [$0A60] = $E918 during x-ray),
; so the call to $91:FCAF (x-ray) is dead code.
; I also don't think there's any way to transition directly from crouching to standing, (actually: check x-ray stand up)
; so the Y position adjustment is dead code too.
$91:8087 08 PHP
$91:8088 C2 30 REP #$30
$91:808A AD 78 0A LDA $0A78 [$7E:0A78] ;\
$91:808D D0 21 BNE $21 [$80B0] ;} If time is not frozen:
$91:808F 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8092 AD 1F 0A LDA $0A1F [$7E:0A1F] ;\
$91:8095 29 FF 00 AND #$00FF ;} If [Samus movement type] != standing: return
$91:8098 D0 1A BNE $1A [$80B4] ;/
$91:809A AD FA 0A LDA $0AFA [$7E:0AFA] ;\
$91:809D 38 SEC ;|
$91:809E E9 05 00 SBC #$0005 ;} Samus Y position -= 5
$91:80A1 8D FA 0A STA $0AFA [$7E:0AFA] ;/
$91:80A4 AD 14 0B LDA $0B14 [$7E:0B14] ;\
$91:80A7 38 SEC ;|
$91:80A8 E9 05 00 SBC #$0005 ;} Samus previous Y position -= 5
$91:80AB 8D 14 0B STA $0B14 [$7E:0B14] ;/
$91:80AE 80 04 BRA $04 [$80B4]
; Else (time is frozen):
$91:80B0 22 AF FC 91 JSL $91FCAF[$91:FCAF] ; X-ray Samus pose input handler
$91:80B4 28 PLP
$91:80B5 60 RTS
}
;;; $80B6: Normal Samus pose input handler - [Samus movement type] = falling ;;;
{
$91:80B6 08 PHP
$91:80B7 C2 30 REP #$30
$91:80B9 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:80BC 28 PLP
$91:80BD 60 RTS
}
;;; $80BE: Unused ;;;
{
; Tries to make Samus jump if pressing jump and she's falling straight down but has zero Y speed and she wasn't crouching before she fell...?
; Perhaps an earlier attempt at auto-jump
$91:80BE AD 1C 0A LDA $0A1C [$7E:0A1C] ;\
$91:80C1 C9 29 00 CMP #$0029 ;|
$91:80C4 F0 05 BEQ $05 [$80CB] ;} If [Samus pose] != falling (not aiming): return
$91:80C6 C9 2A 00 CMP #$002A ;|
$91:80C9 D0 3D BNE $3D [$8108] ;/
$91:80CB AD 27 0A LDA $0A27 [$7E:0A27] ;\
$91:80CE 29 FF 00 AND #$00FF ;|
$91:80D1 C9 05 00 CMP #$0005 ;} If [Samus last different pose movement type] = crouching: return
$91:80D4 F0 32 BEQ $32 [$8108] ;/
$91:80D6 A5 8B LDA $8B [$7E:008B] ;\
$91:80D8 89 00 03 BIT #$0300 ;} If pressing left or right: return
$91:80DB D0 2B BNE $2B [$8108] ;/
$91:80DD AD 2E 0B LDA $0B2E [$7E:0B2E] ;\
$91:80E0 D0 26 BNE $26 [$8108] ;} If [Samus Y speed] != 0: return
$91:80E2 A5 8F LDA $8F [$7E:008F] ;\
$91:80E4 2C B4 09 BIT $09B4 [$7E:09B4] ;} If not newly pressing jump: return
$91:80E7 F0 1F BEQ $1F [$8108] ;/
$91:80E9 AD 1E 0A LDA $0A1E [$7E:0A1E] ;\
$91:80EC 29 FF 00 AND #$00FF ;|
$91:80EF C9 04 00 CMP #$0004 ;} If facing right:
$91:80F2 F0 08 BEQ $08 [$80FC] ;/
$91:80F4 A9 4D 00 LDA #$004D ;\
$91:80F7 8D 2A 0A STA $0A2A [$7E:0A2A] ;} Special prospective pose = facing right - normal jump - not aiming - not moving - gun not extended
$91:80FA 80 06 BRA $06 [$8102]
$91:80FC A9 4E 00 LDA #$004E ;\
$91:80FF 8D 2A 0A STA $0A2A [$7E:0A2A] ;} Special prospective pose = facing left - normal jump - not aiming - not moving - gun not extended
$91:8102 A9 04 00 LDA #$0004 ;\
$91:8105 8D 30 0A STA $0A30 [$7E:0A30] ;} Special prospective pose change command = 4
$91:8108 28 PLP
$91:8109 60 RTS
}
;;; $810A: Normal Samus pose input handler - [Samus movement type] = morph ball - falling ;;;
{
$91:810A 08 PHP
$91:810B C2 30 REP #$30
$91:810D 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8110 28 PLP
$91:8111 60 RTS
}
;;; $8112: RTS. Normal Samus pose input handler - [Samus movement type] = 9 ;;;
{
$91:8112 60 RTS
}
;;; $8113: Normal Samus pose input handler - [Samus movement type] = knockback / crystal flash ending ;;;
{
; Only processes knockback in practice as [$0A60] = RTS during crystal flash, so this function never gets called.
; Samus movement type cannot be changed via $81A9... but if it did then Samus would jump(?!).
$91:8113 08 PHP
$91:8114 C2 30 REP #$30
$91:8116 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8119 AD 1F 0A LDA $0A1F [$7E:0A1F] ;\
$91:811C 29 FF 00 AND #$00FF ;|
$91:811F C9 0A 00 CMP #$000A ;} If [Samus movement type] != knockback / crystal flash ending:
$91:8122 F0 07 BEQ $07 [$812B] ;/
$91:8124 22 BC 98 90 JSL $9098BC[$90:98BC] ; Make Samus jump
$91:8128 9C AA 18 STZ $18AA [$7E:18AA] ; Samus knockback timer = 0
$91:812B 28 PLP
$91:812C 60 RTS
}
;;; $812D: RTS. Normal Samus pose input handler - [Samus movement type] = Bh ;;;
{
$91:812D 08 PHP
$91:812E C2 30 REP #$30
$91:8130 28 PLP
$91:8131 60 RTS
}
;;; $8132: Normal Samus pose input handler - [Samus movement type] = Ch ;;;
{
$91:8132 08 PHP
$91:8133 C2 30 REP #$30
$91:8135 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8138 28 PLP
$91:8139 60 RTS
}
;;; $813A: Normal Samus pose input handler - [Samus movement type] = Dh ;;;
{
$91:813A 08 PHP
$91:813B C2 30 REP #$30
$91:813D 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8140 28 PLP
$91:8141 60 RTS
}
;;; $8142: Normal Samus pose input handler - [Samus movement type] = turning around - on ground ;;;
{
$91:8142 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8145 60 RTS
}
;;; $8146: RTS. Normal Samus pose input handler - [Samus movement type] = crouching/standing/morphing/unmorphing transition ;;;
{
;
$91:8146 60 RTS
}
;;; $8147: Normal Samus pose input handler - [Samus movement type] = moonwalking ;;;
{
$91:8147 08 PHP
$91:8148 C2 30 REP #$30
$91:814A 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:814D 28 PLP
$91:814E 60 RTS
}
;;; $814F: Normal Samus pose input handler - [Samus movement type] = spring ball - on ground ;;;
{
$91:814F 08 PHP
$91:8150 C2 30 REP #$30
$91:8152 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8155 28 PLP
$91:8156 60 RTS
}
;;; $8157: Normal Samus pose input handler - [Samus movement type] = spring ball - in air ;;;
{
$91:8157 08 PHP
$91:8158 C2 30 REP #$30
$91:815A 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:815D 28 PLP
$91:815E 60 RTS
}
;;; $815F: Normal Samus pose input handler - [Samus movement type] = spring ball - falling ;;;
{
$91:815F 08 PHP
$91:8160 C2 30 REP #$30
$91:8162 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8165 28 PLP
$91:8166 60 RTS
}
;;; $8167: Normal Samus pose input handler - [Samus movement type] = wall jumping ;;;
{
$91:8167 08 PHP
$91:8168 C2 30 REP #$30
$91:816A 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:816D 28 PLP
$91:816E 60 RTS
}
;;; $816F: Normal Samus pose input handler - [Samus movement type] = ran into a wall ;;;
{
; Note that this routine is not called when time is frozen ([$0A42] = $E713 during reserve tanks, [$0A60] = $E918 during x-ray),
; so the broken call to $91:FCAF (x-ray) is dead code.
$91:816F 08 PHP
$91:8170 C2 30 REP #$30
$91:8172 AD 78 0A LDA $0A78 [$7E:0A78] ;\
$91:8175 D0 05 BNE $05 [$817C] ;} If time is not frozen:
$91:8177 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:817A 80 03 BRA $03 [$817F]
; Else (time is frozen):
$91:817C 20 AF FC JSR $FCAF [$91:FCAF] ; Execute $FCAF (bug, should be JSL)
$91:817F 28 PLP
$91:8180 60 RTS
}
;;; $8181: Normal Samus pose input handler - [Samus movement type] = grappling ;;;
{
$91:8181 08 PHP
$91:8182 C2 30 REP #$30
$91:8184 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8187 28 PLP
$91:8188 60 RTS
}
;;; $8189: Normal Samus pose input handler - [Samus movement type] = turning around - jumping ;;;
{
$91:8189 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:818C 60 RTS
}
;;; $818D: Normal Samus pose input handler - [Samus movement type] = turning around - falling ;;;
{
$91:818D 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8190 60 RTS
}
;;; $8191: Normal Samus pose input handler - [Samus movement type] = damage boost ;;;
{
$91:8191 08 PHP
$91:8192 C2 30 REP #$30
$91:8194 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:8197 28 PLP
$91:8198 60 RTS
}
;;; $8199: Normal Samus pose input handler - [Samus movement type] = grabbed by Draygon ;;;
{
$91:8199 08 PHP
$91:819A C2 30 REP #$30
$91:819C 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:819F 28 PLP
$91:81A0 60 RTS
}
;;; $81A1: Normal Samus pose input handler - [Samus movement type] = shinespark / crystal flash / drained by metroid / damaged by MB's attacks ;;;
{
$91:81A1 08 PHP
$91:81A2 C2 30 REP #$30
$91:81A4 20 A9 81 JSR $81A9 [$91:81A9] ; Determine prospective pose from transition table
$91:81A7 28 PLP
$91:81A8 60 RTS
}
;;; $81A9: Determine prospective pose from transition table ;;;
{
;; Returns:
;; Carry: Set if pose was found, clear otherwise
; Transition table entries have the format:
; nnnn cccc pppp
; nnnn cccc pppp
; ...
; FFFF
; where:
; n is the required newly pressed input, n = FFFF terminates the table entry
; c is the required held input
; p is the pose to transition to (if not currently already in that pose)
; Iterate through transition table entry for current pose, if transition found with the required inputs being pressed:
; If transition pose is the current pose, return carry clear
; Else, set prospective pose and return carry set
; If not pressing nothing and transition table entry is empty, return carry clear
; Else, execute $91:82D9 and return carry clear
; $12: The controller 1 input bits *not* newly pressed (not including start/select)
; $14: The controller 1 input bits *not* pressed (not including start/select)
; [[Y]]: Required newly pressed input
; [[Y] + 2]: Required input
; If [[Y]] & [$12/14] != 0 then there were some buttons specified in [[Y]] that are not being pressed
$91:81A9 A5 8B LDA $8B [$7E:008B] ;\
$91:81AB F0 2E BEQ $2E [$81DB] ;} If pressing nothing: go to BRANCH_NO_INPUT
$91:81AD 20 F4 81 JSR $81F4 [$91:81F4] ; Translate custom controller bindings to default bindings
$91:81B0 AD 1C 0A LDA $0A1C [$7E:0A1C] ;\
$91:81B3 0A ASL A ;|
$91:81B4 AA TAX ;} Y = [$9EE2 + [Samus pose] * 2] (transition table entry pointer)
$91:81B5 BD E2 9E LDA $9EE2,x[$91:9EE6] ;|
$91:81B8 A8 TAY ;/
$91:81B9 B9 00 00 LDA $0000,y[$91:A172] ;\
$91:81BC 1A INC A ;} If [[Y]] = FFFFh: return carry clear
$91:81BD F0 23 BEQ $23 [$81E2] ;/
; LOOP
$91:81BF 3A DEC A ;\
$91:81C0 F0 04 BEQ $04 [$81C6] ;} If [[Y]] != 0 (required newly pressed input):
$91:81C2 25 12 AND $12 [$7E:0012] ;\
$91:81C4 D0 09 BNE $09 [$81CF] ;} If [[Y]] & [$12] != 0: go to BRANCH_NEXT
$91:81C6 B9 02 00 LDA $0002,y[$91:A1A4] ;\
$91:81C9 F0 19 BEQ $19 [$81E4] ;} If [[Y] + 2] = 0 (required input): go to BRANCH_FOUND_TRANSITION
$91:81CB 25 14 AND $14 [$7E:0014] ;\
$91:81CD F0 15 BEQ $15 [$81E4] ;} If [[Y] + 2] & [$14] = 0: go to BRANCH_FOUND_TRANSITION
; BRANCH_NEXT
$91:81CF 98 TYA ;\
$91:81D0 18 CLC ;|
$91:81D1 69 06 00 ADC #$0006 ;} Y += 6
$91:81D4 A8 TAY ;/
$91:81D5 B9 00 00 LDA $0000,y[$91:A178] ;\
$91:81D8 1A INC A ;} If [[Y]] != FFFFh: go to LOOP
$91:81D9 D0 E4 BNE $E4 [$81BF] ;/
; BRANCH_NO_INPUT
$91:81DB 9C 18 0A STZ $0A18 [$7E:0A18] ; $0A18 = 0 (never read)
$91:81DE 22 D9 82 91 JSL $9182D9[$91:82D9] ; Handle transition table lookup failure
$91:81E2 18 CLC ;\
$91:81E3 60 RTS ;} Return carry clear
; BRANCH_FOUND_TRANSITION
$91:81E4 B9 04 00 LDA $0004,y[$91:A1F4] ;\
$91:81E7 CD 1C 0A CMP $0A1C [$7E:0A1C] ;} If [[Y] + 4] = [Samus pose]: return carry clear
$91:81EA F0 F6 BEQ $F6 [$81E2] ;/
$91:81EC 8D 28 0A STA $0A28 [$7E:0A28] ; Prospective pose = [[Y] + 4]
$91:81EF 9C 56 0A STZ $0A56 [$7E:0A56] ; Bomb jump direction = 0
$91:81F2 38 SEC ;\
$91:81F3 60 RTS ;} Return carry set
}
;;; $81F4: Translate custom controller bindings to default bindings ;;;
{
;; Returns:
;; $12: The controller 1 input bits *not* newly pressed (not including start/select)
;; $14: The controller 1 input bits *not* pressed (not including start/select)
; This contains the evil code that disallows aiming to not be L and R
; $82:F587 handles the graphical part of the controller settings menu
$91:81F4 A5 8F LDA $8F [$7E:008F] ;\
$91:81F6 29 00 0F AND #$0F00 ;} $12 = newly pressed d-pad input
$91:81F9 85 12 STA $12 [$7E:0012] ;/
$91:81FB A5 8B LDA $8B [$7E:008B] ;\
$91:81FD 29 00 0F AND #$0F00 ;} $14 = current d-pad input
$91:8200 85 14 STA $14 [$7E:0014] ;/
$91:8202 A5 8F LDA $8F [$7E:008F] ;\
$91:8204 2C B2 09 BIT $09B2 [$7E:09B2] ;} If newly pressed shoot:
$91:8207 F0 09 BEQ $09 [$8212] ;/
$91:8209 A5 12 LDA $12 [$7E:0012] ;\
$91:820B 09 40 00 ORA #$0040 ;|
$91:820E 85 12 STA $12 [$7E:0012] ;} $12 |= X
$91:8210 A5 8F LDA $8F [$7E:008F] ;/
$91:8212 2C B4 09 BIT $09B4 [$7E:09B4] ;\
$91:8215 F0 09 BEQ $09 [$8220] ;} If newly pressed jump:
$91:8217 A5 12 LDA $12 [$7E:0012] ;\
$91:8219 09 80 00 ORA #$0080 ;|
$91:821C 85 12 STA $12 [$7E:0012] ;} $12 |= A
$91:821E A5 8F LDA $8F [$7E:008F] ;/
$91:8220 2C B6 09 BIT $09B6 [$7E:09B6] ;\
$91:8223 F0 09 BEQ $09 [$822E] ;} If newly pressed run:
$91:8225 A5 12 LDA $12 [$7E:0012] ;\
$91:8227 09 00 80 ORA #$8000 ;|
$91:822A 85 12 STA $12 [$7E:0012] ;} $12 |= B
$91:822C A5 8F LDA $8F [$7E:008F] ;/
$91:822E 2C B8 09 BIT $09B8 [$7E:09B8] ;\
$91:8231 F0 09 BEQ $09 [$823C] ;} If newly pressed item cancel:
$91:8233 A5 12 LDA $12 [$7E:0012] ;\
$91:8235 09 00 40 ORA #$4000 ;|
$91:8238 85 12 STA $12 [$7E:0012] ;} $12 |= Y
$91:823A A5 8F LDA $8F [$7E:008F] ;/
$91:823C 2C BE 09 BIT $09BE [$7E:09BE] ;\
$91:823F F0 11 BEQ $11 [$8252] ;} If newly pressed aim up:
$91:8241 AD BE 09 LDA $09BE [$7E:09BE] ;\
$91:8244 89 30 00 BIT #$0030 ;} If aim up binding is L or R:
$91:8247 F0 07 BEQ $07 [$8250] ;/
$91:8249 A5 12 LDA $12 [$7E:0012] ;\
$91:824B 09 10 00 ORA #$0010 ;} $12 |= R
$91:824E 85 12 STA $12 [$7E:0012] ;/
$91:8250 A5 8F LDA $8F [$7E:008F]
$91:8252 2C BC 09 BIT $09BC [$7E:09BC] ;\
$91:8255 F0 0F BEQ $0F [$8266] ;} If newly pressed aim down:
$91:8257 AD BC 09 LDA $09BC [$7E:09BC] ;\
$91:825A 89 30 00 BIT #$0030 ;} If aim up binding is L or R:
$91:825D F0 07 BEQ $07 [$8266] ;/
$91:825F A5 12 LDA $12 [$7E:0012] ;\
$91:8261 09 20 00 ORA #$0020 ;} $12 |= L
$91:8264 85 12 STA $12 [$7E:0012] ;/
$91:8266 A5 12 LDA $12 [$7E:0012] ;\
$91:8268 49 FF FF EOR #$FFFF ;} $12 = ~[$12]
$91:826B 85 12 STA $12 [$7E:0012] ;/
$91:826D A5 8B LDA $8B [$7E:008B] ;\
$91:826F 2C B2 09 BIT $09B2 [$7E:09B2] ;} If pressing shoot:
$91:8272 F0 09 BEQ $09 [$827D] ;/
$91:8274 A5 14 LDA $14 [$7E:0014] ;\
$91:8276 09 40 00 ORA #$0040 ;|
$91:8279 85 14 STA $14 [$7E:0014] ;} $14 |= X
$91:827B A5 8B LDA $8B [$7E:008B] ;/
$91:827D 2C B4 09 BIT $09B4 [$7E:09B4] ;\
$91:8280 F0 09 BEQ $09 [$828B] ;} If pressing jump:
$91:8282 A5 14 LDA $14 [$7E:0014] ;\
$91:8284 09 80 00 ORA #$0080 ;|
$91:8287 85 14 STA $14 [$7E:0014] ;} $14 |= A
$91:8289 A5 8B LDA $8B [$7E:008B] ;/
$91:828B 2C B6 09 BIT $09B6 [$7E:09B6] ;\
$91:828E F0 09 BEQ $09 [$8299] ;} If pressing run:
$91:8290 A5 14 LDA $14 [$7E:0014] ;\
$91:8292 09 00 80 ORA #$8000 ;|
$91:8295 85 14 STA $14 [$7E:0014] ;} $14 |= B
$91:8297 A5 8B LDA $8B [$7E:008B] ;/
$91:8299 2C B8 09 BIT $09B8 [$7E:09B8] ;\
$91:829C F0 09 BEQ $09 [$82A7] ;} If pressing item cancel:
$91:829E A5 14 LDA $14 [$7E:0014] ;\
$91:82A0 09 00 40 ORA #$4000 ;|
$91:82A3 85 14 STA $14 [$7E:0014] ;} $14 |= Y
$91:82A5 A5 8B LDA $8B [$7E:008B] ;/
$91:82A7 2C BE 09 BIT $09BE [$7E:09BE] ;\
$91:82AA F0 11 BEQ $11 [$82BD] ;} If pressing aim up:
$91:82AC AD BE 09 LDA $09BE [$7E:09BE] ;\
$91:82AF 89 30 00 BIT #$0030 ;} If aim up binding is L or R:
$91:82B2 F0 07 BEQ $07 [$82BB] ;/
$91:82B4 A5 14 LDA $14 [$7E:0014] ;\
$91:82B6 09 10 00 ORA #$0010 ;} $14 |= R
$91:82B9 85 14 STA $14 [$7E:0014] ;/
$91:82BB A5 8B LDA $8B [$7E:008B]
$91:82BD 2C BC 09 BIT $09BC [$7E:09BC] ;\
$91:82C0 F0 0F BEQ $0F [$82D1] ;} If pressing aim down:
$91:82C2 AD BC 09 LDA $09BC [$7E:09BC] ;\
$91:82C5 89 30 00 BIT #$0030 ;} If aim up binding is L or R:
$91:82C8 F0 07 BEQ $07 [$82D1] ;/
$91:82CA A5 14 LDA $14 [$7E:0014] ;\
$91:82CC 09 20 00 ORA #$0020 ;} $14 |= L
$91:82CF 85 14 STA $14 [$7E:0014] ;/
$91:82D1 A5 14 LDA $14 [$7E:0014] ;\
$91:82D3 49 FF FF EOR #$FFFF ;} $14 = ~[$14]
$91:82D6 85 14 STA $14 [$7E:0014] ;/
$91:82D8 60 RTS
}
;;; $82D9: Handle transition table lookup failure ;;;
{
; Also called when grapple beam is disconnected
$91:82D9 08 PHP
$91:82DA 8B PHB
$91:82DB 4B PHK ;\
$91:82DC AB PLB ;} DB = $91
$91:82DD C2 30 REP #$30
$91:82DF 20 04 83 JSR $8304 [$91:8304] ; Set prospective pose change command
$91:82E2 90 08 BCC $08 [$82EC] ; If not retaining current pose: go to BRANCH_CONSULT_POSE_DEFINITION
; BRANCH_RETAIN_CURRENT_POSE
$91:82E4 AD 1C 0A LDA $0A1C [$7E:0A1C] ;\
$91:82E7 8D 28 0A STA $0A28 [$7E:0A28] ;} Prospective pose = [Samus pose]
$91:82EA 80 15 BRA $15 [$8301] ; Return
; BRANCH_CONSULT_POSE_DEFINITION
$91:82EC AD 1C 0A LDA $0A1C [$7E:0A1C] ;\
$91:82EF 0A ASL A ;|
$91:82F0 0A ASL A ;|
$91:82F1 0A ASL A ;} A = [$B62B + [Samus pose] * 8] (new pose if not affected by buttons)
$91:82F2 AA TAX ;|
$91:82F3 BD 2B B6 LDA $B62B,x[$91:B63B] ;|
$91:82F6 29 FF 00 AND #$00FF ;/
$91:82F9 C9 FF 00 CMP #$00FF ;\
$91:82FC F0 E6 BEQ $E6 [$82E4] ;} If [A] = FFh: go to BRANCH_RETAIN_CURRENT_POSE
$91:82FE 8D 28 0A STA $0A28 [$7E:0A28] ; Prospective pose = [A]
$91:8301 AB PLB
$91:8302 28 PLP
$91:8303 6B RTL
}
;;; $8304: Set prospective pose change command ;;;
{
;; Returns:
;; Carry: Set if retaining current pose (i.e. command = decelerate), clear otherwise
$91:8304 AD 1F 0A LDA $0A1F [$7E:0A1F] ;\
$91:8307 29 FF 00 AND #$00FF ;|
$91:830A AA TAX ;|
$91:830B BD 32 83 LDA $8332,x[$91:8332] ;} If [$8332 + [Samus movement type]] = 1: go to BRANCH_DECELERATE
$91:830E 29 FF 00 AND #$00FF ;|
$91:8311 C9 01 00 CMP #$0001 ;|
$91:8314 F0 05 BEQ $05 [$831B] ;/
$91:8316 8D 2E 0A STA $0A2E [$7E:0A2E] ; Prospective pose change command = [$8332 + [Samus movement type]]
$91:8319 18 CLC ;\
$91:831A 60 RTS ;} Return carry clear
; BRANCH_DECELERATE
$91:831B AD 46 0B LDA $0B46 [$7E:0B46] ;\
$91:831E D0 0A BNE $0A [$832A] ;|
$91:8320 AD 48 0B LDA $0B48 [$7E:0B48] ;} If [Samus X base speed] = 0.0:
$91:8323 D0 05 BNE $05 [$832A] ;/
$91:8325 A9 02 00 LDA #$0002 ; Prospective pose change command = stop
$91:8328 80 EC BRA $EC [$8316] ; Return carry clear
$91:832A A9 01 00 LDA #$0001 ;\
$91:832D 8D 2E 0A STA $0A2E [$7E:0A2E] ;} Prospective pose change command = decelerate
$91:8330 38 SEC ;\
$91:8331 60 RTS ;} Return carry set
; Value for prospective pose change command. If 1 and [Samus X base speed] = 0, use 2 instead
$91:8332 db 02, ; 0: Standing
01, ; 1: Running
01, ; 2: Normal jumping
00, ; 3: Spin jumping
06, ; 4: Morph ball - on ground
02, ; 5: Crouching
08, ; 6: Falling
02, ; 7: Unused
01, ; 8: Morph ball - falling
06, ; 9: Unused
02, ; Ah: Knockback / crystal flash ending
02, ; Bh: Unused
02, ; Ch: Unused
06, ; Dh: Unused
02, ; Eh: Turning around - on ground
02, ; Fh: Crouching/standing/morphing/unmorphing transition
02, ; 10h: Moonwalking
06, ; 11h: Spring ball - on ground
06, ; 12h: Spring ball - in air
06, ; 13h: Spring ball - falling
06, ; 14h: Wall jumping
02, ; 15h: Ran into a wall
06, ; 16h: Grappling
02, ; 17h: Turning around - jumping
02, ; 18h: Turning around - falling
02, ; 19h: Damage boost
02, ; 1Ah: Grabbed by Draygon
02 ; 1Bh: Shinespark / crystal flash / drained by metroid / damaged by MB's attacks
}
}
;;; $834E..9EE1: Demo ;;;
{
;;; $834E: Enable demo input ;;;
{
$91:834E 08 PHP
$91:834F C2 30 REP #$30
$91:8351 A9 1D E9 LDA #$E91D ;\
$91:8354 8D 60 0A STA $0A60 [$7E:0A60] ;} Samus pose input handler = $E91D (demo)
$91:8357 A9 00 80 LDA #$8000 ;\
$91:835A 0C 88 0A TSB $0A88 [$7E:0A88] ;} Enable demo input
$91:835D 28 PLP
$91:835E 6B RTL
}
;;; $835F: Disable demo input ;;;
{
$91:835F 08 PHP
$91:8360 C2 30 REP #$30
$91:8362 A9 13 E9 LDA #$E913 ;\
$91:8365 8D 60 0A STA $0A60 [$7E:0A60] ;} Samus pose input handler = $E913 (normal)
$91:8368 A9 00 80 LDA #$8000 ;\
$91:836B 1C 88 0A TRB $0A88 [$7E:0A88] ;} Disable demo input
$91:836E 28 PLP
$91:836F 6B RTL
}
;;; $8370: Clear demo input RAM ;;;
{
; Called before calling $834E
$91:8370 08 PHP
$91:8371 C2 30 REP #$30
$91:8373 DA PHX
$91:8374 9C 7A 0A STZ $0A7A [$7E:0A7A] ; Demo input pre-instruction = 0
$91:8377 9C 7C 0A STZ $0A7C [$7E:0A7C] ; Demo input instruction timer = 0
$91:837A 9C 7E 0A STZ $0A7E [$7E:0A7E] ; Demo input instruction list pointer = 0
$91:837D 9C 80 0A STZ $0A80 [$7E:0A80] ; Demo input timer = 0
$91:8380 9C 82 0A STZ $0A82 [$7E:0A82] ; Demo input initialisation parameter = 0
$91:8383 9C 84 0A STZ $0A84 [$7E:0A84] ; Demo input = 0
$91:8386 9C 86 0A STZ $0A86 [$7E:0A86] ; Demo newly pressed input = 0
$91:8389 9C 8C 0A STZ $0A8C [$7E:0A8C] ; Previous demo input = 0
$91:838C 9C 8E 0A STZ $0A8E [$7E:0A8E] ; Previous demo newly pressed input = 0
$91:838F 9C 88 0A STZ $0A88 [$7E:0A88] ; Disable demo input
$91:8392 FA PLX
$91:8393 28 PLP
$91:8394 6B RTL
}
;;; $8395: Load demo input object ;;;
{
;; Parameters:
;; A: Initialisation parameter
;; Y: Pointer to demo input object
$91:8395 08 PHP
$91:8396 8B PHB
$91:8397 4B PHK ;\
$91:8398 AB PLB ;} DB = $91
$91:8399 C2 30 REP #$30
$91:839B DA PHX
$91:839C 8D 82 0A STA $0A82 [$7E:0A82] ; $0A82 = [A]
$91:839F BB TYX ; X = [Y]
$91:83A0 BD 02 00 LDA $0002,x[$91:8786] ;\
$91:83A3 8D 7A 0A STA $0A7A [$7E:0A7A] ;} Demo input pre-instruction = [[X] + 2]
$91:83A6 BD 04 00 LDA $0004,x[$91:8788] ;\
$91:83A9 8D 7E 0A STA $0A7E [$7E:0A7E] ;} Demo input instruction list pointer = [[X] + 4] (instruction list pointer)
$91:83AC A9 01 00 LDA #$0001 ;\
$91:83AF 8D 7C 0A STA $0A7C [$7E:0A7C] ;} Demo input instruction timer = 1
$91:83B2 A9 00 00 LDA #$0000 ;\
$91:83B5 8D 80 0A STA $0A80 [$7E:0A80] ;} Demo input timer = 0
$91:83B8 FC 00 00 JSR ($0000,x)[$91:83BF]; Execute [[X]] (RTS)
$91:83BB FA PLX
$91:83BC AB PLB
$91:83BD 28 PLP
$91:83BE 6B RTL
}
;;; $83BF: RTS ;;;
{
$91:83BF 60 RTS
}
;;; $83C0: Demo input object handler ;;;
{
$91:83C0 08 PHP
$91:83C1 8B PHB
$91:83C2 4B PHK ;\
$91:83C3 AB PLB ;} DB = $91
$91:83C4 C2 30 REP #$30
$91:83C6 2C 88 0A BIT $0A88 [$7E:0A88] ;\
$91:83C9 10 24 BPL $24 [$83EF] ;} If demo input not enabled: return
$91:83CB AD 7E 0A LDA $0A7E [$7E:0A7E] ;\
$91:83CE F0 1F BEQ $1F [$83EF] ;} If [demo input instruction list pointer] = 0: return
$91:83D0 20 F2 83 JSR $83F2 [$91:83F2] ; Process demo input object
$91:83D3 AD 8C 0A LDA $0A8C [$7E:0A8C] ;\
$91:83D6 8D FE 0D STA $0DFE [$7E:0DFE] ;} Previous controller 1 input = [previous demo input]
$91:83D9 AD 8E 0A LDA $0A8E [$7E:0A8E] ;\
$91:83DC 8D 00 0E STA $0E00 [$7E:0E00] ;} Previous newly pressed controller 1 input = [previous demo newly pressed input]
$91:83DF AD 84 0A LDA $0A84 [$7E:0A84] ;\
$91:83E2 85 8B STA $8B [$7E:008B] ;} Controller 1 input = [demo input]
$91:83E4 8D 8C 0A STA $0A8C [$7E:0A8C] ; Previous demo input = [demo input]
$91:83E7 AD 86 0A LDA $0A86 [$7E:0A86] ;\
$91:83EA 85 8F STA $8F [$7E:008F] ;} Newly pressed controller 1 input = [demo newly pressed input]
$91:83EC 8D 8E 0A STA $0A8E [$7E:0A8E] ; Previous demo newly pressed input = [demo newly pressed input]
$91:83EF AB PLB
$91:83F0 28 PLP
$91:83F1 6B RTL
}
;;; $83F2: Process demo input object ;;;
{
$91:83F2 A2 00 00 LDX #$0000 ;\
$91:83F5 FC 7A 0A JSR ($0A7A,x)[$91:83BF];} Execute [demo input pre-instruction]
$91:83F8 CE 7C 0A DEC $0A7C [$7E:0A7C] ; Decrement demo input instruction timer
$91:83FB D0 29 BNE $29 [$8426] ; If [demo input instruction timer] != 0: return
$91:83FD AC 7E 0A LDY $0A7E [$7E:0A7E] ; Y = [demo input instruction list pointer]
; LOOP
$91:8400 B9 00 00 LDA $0000,y[$91:8694] ;\
$91:8403 10 0A BPL $0A [$840F] ;} If [[Y]] & 8000h != 0:
$91:8405 85 12 STA $12 [$7E:0012] ; $12 = [[Y]]
$91:8407 C8 INY ;\
$91:8408 C8 INY ;} Y += 2
$91:8409 F4 FF 83 PEA $83FF ; Return to LOOP
$91:840C 6C 12 00 JMP ($0012)[$91:8739] ; Go to [$12]
$91:840F 8D 7C 0A STA $0A7C [$7E:0A7C] ; Demo input instruction timer = [[Y]]
$91:8412 B9 02 00 LDA $0002,y[$91:8696] ;\
$91:8415 8D 84 0A STA $0A84 [$7E:0A84] ;} Demo input [[Y] + 2]
$91:8418 B9 04 00 LDA $0004,y[$91:8698] ;\
$91:841B 8D 86 0A STA $0A86 [$7E:0A86] ;} Demo newly pressed input [[Y] + 4]
$91:841E 98 TYA ;\
$91:841F 18 CLC ;|
$91:8420 69 06 00 ADC #$0006 ;} Demo input instruction list pointer = [Y] + 6
$91:8423 8D 7E 0A STA $0A7E [$7E:0A7E] ;/
$91:8426 60 RTS
}
;;; $8427: Instruction - delete ;;;
{
$91:8427 C2 30 REP #$30
$91:8429 9C 7E 0A STZ $0A7E [$7E:0A7E] ; Demo input instruction list pointer = 0
$91:842C 9C 84 0A STZ $0A84 [$7E:0A84] ; Demo input = 0
$91:842F 9C 86 0A STZ $0A86 [$7E:0A86] ; Demo newly pressed input = 0
$91:8432 68 PLA ; Terminate processing demo input object
$91:8433 60 RTS
}
;;; $8434: Instruction - pre-instruction = [[Y]] ;;;
{
$91:8434 C2 30 REP #$30
$91:8436 B9 00 00 LDA $0000,y
$91:8439 8D 7A 0A STA $0A7A [$7E:0A7A]
$91:843C C8 INY
$91:843D C8 INY
$91:843E 60 RTS
}
;;; $843F: Instruction - clear pre-instruction ;;;
{
$91:843F C2 30 REP #$30
$91:8441 A9 47 84 LDA #$8447
$91:8444 8D 7A 0A STA $0A7A [$7E:0A7A]
$91:8447 60 RTS
}
;;; $8448: Instruction - go to [[Y]] ;;;
{
$91:8448 C2 30 REP #$30
$91:844A B9 00 00 LDA $0000,y[$91:8621]
$91:844D A8 TAY
$91:844E 60 RTS
}
;;; $844F: Instruction - decrement timer and go to [[Y]] if non-zero ;;;
{
$91:844F C2 30 REP #$30
$91:8451 CE 80 0A DEC $0A80 [$7E:0A80]
$91:8454 D0 F2 BNE $F2 [$8448]
$91:8456 C8 INY
$91:8457 C8 INY
$91:8458 60 RTS
}
;;; $8459: Instruction - timer = [[Y]] ;;;
{
$91:8459 C2 30 REP #$30
$91:845B B9 00 00 LDA $0000,y
$91:845E 8D 80 0A STA $0A80 [$7E:0A80]
$91:8461 C8 INY
$91:8462 C8 INY
$91:8463 60 RTS
}
;;; $8464: Record demo input frame ;;;
{
; Controller 2 Y enables recording
$91:8464 08 PHP
$91:8465 8B PHB
$91:8466 4B PHK ;\
$91:8467 AB PLB ;} DB = $91
$91:8468 C2 30 REP #$30
$91:846A AD 8A 0A LDA $0A8A [$7E:0A8A] ;\
$91:846D 29 FF 7F AND #$7FFF ;} $0E24 = [recorded demo duration] & 7FFFh
$91:8470 8D 24 0E STA $0E24 [$7E:0E24] ;/
$91:8473 A9 E0 00 LDA #$00E0 ;\
$91:8476 8D 20 0E STA $0E20 [$7E:0E20] ;} $0E20 = E0h (X position)
$91:8479 A9 38 00 LDA #$0038 ;\
$91:847C 8D 22 0E STA $0E22 [$7E:0E22] ;} $0E22 = 38h (Y position)
$91:847F 20 2F 85 JSR $852F [$91:852F] ; Draw recorded demo duration
$91:8482 AD 8A 0A LDA $0A8A [$7E:0A8A] ;\
$91:8485 30 4B BMI $4B [$84D2] ;} If demo is not being recorded: return
$91:8487 D0 07 BNE $07 [$8490] ; If [recorded demo duration] = 0:
$91:8489 A5 91 LDA $91 [$7E:0091] ;\
$91:848B 89 00 40 BIT #$4000 ;} If controller 2 not newly pressed Y: return
$91:848E F0 42 BEQ $42 [$84D2] ;/
$91:8490 AD 8A 0A LDA $0A8A [$7E:0A8A] ;\
$91:8493 0A ASL A ;|
$91:8494 0A ASL A ;|
$91:8495 85 12 STA $12 [$7E:0012] ;} X = [recorded demo duration] * Ch
$91:8497 0A ASL A ;|
$91:8498 65 12 ADC $12 [$7E:0012] ;|
$91:849A AA TAX ;/
$91:849B A5 8B LDA $8B [$7E:008B] ;\
$91:849D 9F 00 80 B8 STA $B88000,x ;} $B8:8000 + [X] = [controller 1 input]
$91:84A1 A5 8F LDA $8F [$7E:008F] ;\
$91:84A3 9F 02 80 B8 STA $B88002,x ;} $B8:8000 + [X] + 2 = [newly pressed controller 1 input]
$91:84A7 AD 11 09 LDA $0911 [$7E:0911] ;\
$91:84AA 9F 04 80 B8 STA $B88004,x ;} $B8:8000 + [X] + 4 = [layer 1 X position]
$91:84AE AD 15 09 LDA $0915 [$7E:0915] ;\
$91:84B1 9F 06 80 B8 STA $B88006,x ;} $B8:8000 + [X] + 6 = [layer 1 Y position]
$91:84B5 AD F6 0A LDA $0AF6 [$7E:0AF6] ;\
$91:84B8 9F 08 80 B8 STA $B88008,x ;} $B8:8000 + [X] + 8 = [Samus X position]
$91:84BC AD FA 0A LDA $0AFA [$7E:0AFA] ;\
$91:84BF 9F 0A 80 B8 STA $B8800A,x ;} $B8:8000 + [X] + Ah = [Samus Y position]
$91:84C3 AD 8A 0A LDA $0A8A [$7E:0A8A] ;\
$91:84C6 1A INC A ;|
$91:84C7 C9 00 0A CMP #$0A00 ;|
$91:84CA D0 03 BNE $03 [$84CF] ;} Recorded demo duration = ([recorded demo duration] + 1) % A00h
$91:84CC A9 00 00 LDA #$0000 ;|
;|
$91:84CF 8D 8A 0A STA $0A8A [$7E:0A8A] ;/
$91:84D2 AB PLB
$91:84D3 28 PLP
$91:84D4 6B RTL
}
;;; $84D5: Pause/terminate/reset demo recorder ;;;
{
; Controller 2 X pauses/terminates demo recorder
; Controller 2 A resets demo recorder
$91:84D5 08 PHP
$91:84D6 8B PHB
$91:84D7 4B PHK ;\
$91:84D8 AB PLB ;} DB = $91
$91:84D9 C2 30 REP #$30
$91:84DB A5 91 LDA $91 [$7E:0091] ;\
$91:84DD 89 40 00 BIT #$0040 ;} If controller 2 newly pressed X:
$91:84E0 F0 3D BEQ $3D [$851F] ;/
$91:84E2 AD 8A 0A LDA $0A8A [$7E:0A8A] ;\
$91:84E5 0A ASL A ;|
$91:84E6 0A ASL A ;|
$91:84E7 85 12 STA $12 [$7E:0012] ;} X = [recorded demo duration] * Ch
$91:84E9 0A ASL A ;|
$91:84EA 65 12 ADC $12 [$7E:0012] ;|
$91:84EC AA TAX ;/
$91:84ED A9 FF FF LDA #$FFFF ;\
$91:84F0 9F 00 80 B8 STA $B88000,x ;|
$91:84F4 9F 02 80 B8 STA $B88002,x ;|
$91:84F8 9F 04 80 B8 STA $B88004,x ;} Write Ch bytes of FFFFh to $B8:8000 + [X]
$91:84FC 9F 06 80 B8 STA $B88006,x ;|
$91:8500 9F 08 80 B8 STA $B88008,x ;|
$91:8504 9F 0A 80 B8 STA $B8800A,x ;/
$91:8508 AD 8F 07 LDA $078F [$7E:078F] ;\
$91:850B 8F 00 FF B8 STA $B8FF00[$B8:FF00] ;} $B8:FF00 = [door BTS]
$91:850F AD 9F 07 LDA $079F [$7E:079F] ;\
$91:8512 8F 02 FF B8 STA $B8FF02[$B8:FF02] ;} $B8:FF02 = [area index]
$91:8516 AD 8A 0A LDA $0A8A [$7E:0A8A] ;\
$91:8519 09 00 80 ORA #$8000 ;} Set demo as not being recorded
$91:851C 8D 8A 0A STA $0A8A [$7E:0A8A] ;/
$91:851F A5 91 LDA $91 [$7E:0091] ;\
$91:8521 89 80 00 BIT #$0080 ;} If controller 2 newly pressed A: