-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmmmaincode.txt
20698 lines (18420 loc) · 635 KB
/
mmmaincode.txt
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
MEGAMAN 1 NES ROM TECH DOC
origin: http://worldofwarcraftbeta.0catch.com/nes/megm1rom.txt
UPDATED BY Joel Yliluoma
AT http://bisqwit.iki.fi/jutut/megamansource/
; MEGAMAN 1 ROM MAP
; $420 = MD?L?tRT
;
; M = 1 if moving, 0 if still
; D = direction (0 = facing left, 1 = facing right)
; ? = ?
; L = on ladder
; ?A = set when Megaman is getting off ladder at top
; t = set when throwing something while standing
; R = set to make Megaman get stunned by Gutsman's eart-shaking jump
; T = set to make Megaman transform
;
; R+T both set = megaman getting hit
;
; for enemies it works as follows
;
; $420,X = HDIT?BMC (ObjectFlags)
;
; H = object getting hit by Megaman's bullet
; D = direction (0 = facing left, 1 = facing right)
; I = set if invisible
; T = Temporary object that disappears after some time (bonus items etc)
; ? = ?
; B = set if object can collide with Megaman's bullets (ghostlike otherwise)
; M = set if object can collide with Megaman (ghostlike otherwise)
; C = set if object collides with BG
;
; freezing $640 for enemies freezes them in a certain state...
; freezing $440 for enemies freezes them in a certain frame...
;
; MegamanSpriteNum ($400):
;
; These are sprite frames.
; These values correspond to what Megaman does.
; If you set it to a weird value like $1A, it will appear as a shot instead.
; Examples of these weird values are shown in MegamanWeaponFireData.
; It is the same for ObjectSpriteNum and MegamanSpriteNum.
;
; #$00 = 00000000 = standing
; #$01 = 00000001 = firing megablaster (while standing)
; #$02 = 00000010 = standing while carrying gutsman rock
; #$03 = 00000011 = moving slowly (also causes slow movement!)
; #$04 = 00000100 = firing megablaster (while standing)
; #$05 = 00000101 = moving slowly while carrying gutsman rock
; #$06 = 00000110 = running
; #$07 = 00000111 = running while firing megablaster
; #$08 = 00000100 = running while carrying gutsman rock
; #$09 = 00001001 = jumping/falling
; #$0A = 00001010 = firing megablaster while jumping
; #$0B = 00001011 = jumping while carrying gutsman rock
; #$0C = 00001100 = slowing down after running (also causes movement)
; #$0F = 00001111 = hitting ground
; #$10 = 00010000 = walking with gun
; #$12 = 00010010 = getting hit by enemy
; #$13 = 00010011 = Getting stun by Gutsman's earth-shaking jump
; #$14 = 00010100 = transforming (when entering stage or after pause)
; #$15 = 00010101 = On ladder
; #$16 = 00010110 = Firing while on ladder
; #$17 = 00010111 = Getting off at top of ladder
; #$18 = 00011000 = Also firing on the ladder?
; #$19 = 00011001 = Getting damage (sweatdrops)
; #$31 = 00110001 = "READY"
; #$6E = 01101110 = Throwing something
; #$6F = 01101111 = Throwing something while jumping/falling
; #$70 = 01110000 = Throwing something while on ladder
;
;
;#$C0 = "P"
;#$C1 = Cutman
;#$C2 = Iceman
;#$C3 = Bombman
;#$C4 = Fireman(?)
;#$C5 = Elecman
;#$C6 = Gutsman (rock either carried by megaman or airborne)
;#$C7 = Magnet beam
;
; $41 = #1 if game paused with SELECT, #0 otherwise
; New weapon capsule uses $61F
MiscCounter1 = $3C ;Counter used for various purposes
; RLDUSsBA (s = select, S = START)
; Keys held down on this frame
JoyPads = $14
Joypad0 = Joypads
Joypad1 = Joypads+1
JoyPadsOld = $16
Joypad0old = JoypadsOld
Joypad1old = JoypadsOld+1
ForcedInputFlag = $68
ForcedInputData = $69
; Keys pressed on this frame
JoyD = $18
JoyD0 = JoyD
JoyD1 = JoyD+1
ScrollPosX = $1A
ScrollPosScreen = $1B
ScrollPosY = $1E
; $0D is used for plenty of purposes. Here's one.
SpriteCounter = $0D
NMI_GfxUpdateDone = $1F ;in Rockman2, at $1D
FrameCounter = $23 ;In Rockman2, at $1C
RefObjectNum = $2F
NumberOfFramesSinceShooting = $61
WritePaletteParam = $34
PaletteUpdateDelay = $37
LastRestartPointType = $AB ;0=level beginning, #$0C = point A, #$18 = point B
PreviousEnemyIndex = $8B
CurrentEnemyIndex = $8C
ZigZagFireStatus = $8F
AutoSpawnObjectFFcounter = $92 ;unknown
CurrentBeginScreen = $27 ;In Rockman2, $14
; ^The screen that begins the current strip. Only updated in transitions.
CurrentEndScreen = $28 ;In Rockman2, $15
; ^The screen where the current strip ends. Only updated in transitions.
CurrentOrderNum = $29 ;In Rockman2, $38
; ^Pointer to the order table. Only updated in transitions.
ObjectReceivedHitType = $53
UseTempScrollX = $B4
TempScrollPosX = $B2
TempScrollPosScreen = $B3
ScreenMovedFlag = $8D
;Bit 0: (&01) = New enemies may need to be loaded (screen has moved)
;Bit 6: (&40) = Movement forward? 0=backward
ActivesLowerIndex = $8E
;ActivesLowerIndex points to the first Active that may need to be cared of.
;Actives before that index are of no concern.
RoomActiveTable = $720
IgnoreStageSelection = $BC
SoundCodeParameter = $A7
CurrentRoomMonsterGraphicsIndex = $7A
BonusPearlCount = $AE ; Max: 99
RandomSeed = $46 ; In Rockman2, at $4A
LevelClearScoreInThousands = $3D
CurrentBank = $42
ExtraLives = $A6
DrawScoreAndMetersFlag = $BB
WeaponsOwned = $5D ; (MFCIGEB0)
WeaponSelect = $5F
Meters = $6A ; (from 0-28)
; 0 = "P" (just the old megablaster)
; 1 = Cutman
; 2 = Iceman
; 3 = Bombman
; 4 = Fireman
; 5 = Elecman
; 6 = Gutsman
; 7 = Magnet beam
MetersFraction = $9E ; (index 1 not used)
WeaponFiring = $60
; $60 = non-zero if any of Megaman's weapons are at the screen
; &7 = weapon number
; |$40 = phase A
; |$80 = phase B
; Usually both phases are used at same time, but Gutsblock has two phases.
TotalObjects = $54
ObjectSpriteNum = $400
ObjectFlags = $420 ;also used for boss moves in stage select
ObjectUnknown440 = $440 ; low 4 bits: >0 if taken damage this frame
; high 4 bits: possibly invulnerability timer?
ObjectPosScreen = $460 ; aka. screen ID
ObjectPosX = $480
ObjectPosXfraction = $4A0 ;Xpos fractional part
ObjectXSpeed = $4C0
ObjectXSpeedFraction = $4E0
ObjectPosY = $600
ObjectPosYfraction = $620
ObjectFireDelay = $640 ;uncertain!! but delays objects somehow
ObjectYSpeedFraction = $660
ObjectYSpeed = $680
ObjectLifeCycleCounter = $6A0
ObjectLifeMeter = $6C0
ObjectType = $6E0 ; enemy ID
LiftIndex = $9A ;number of active lifts
LiftUnknown9B = $9B ;not table
LiftXSpeedFraction= $9C ;not table
LiftXSpeed = $9D ;not table
LiftUnknown9E = $9E ;not table
LiftPosScreen = $700 ;table
LiftPosX = $708 ;table
LiftPosY = $710 ;table
LiftDirection = $718 ;table
LiftXMovement = $06 ;(temporary meaning..)
LiftXScreenMovement = $07
MagnetBeamLength = $5A0
MagnetBeamAge = $5B0 ;0=not active, $9C = initial age
MagnetBeamPosX = $5C0
MagnetBeamPosScreen = $5D0
MagnetBeamCyclePos = $5E0
MagnetBeamPosY = $5F0
IssuedSoundsList = $580
NumIssuedSounds = $45
MegamanBlinkState = $55 ; Timer: 0 = not blinking. #$6F = max
BossBlinkState = $56
SpriteTable = $0200
CurrentSpriteData = SpriteTable+4 (array of 4-byte records)
; Structure:
; 0 = Y coordinate
; 1 = Tile number
; 2 = Sprite attributes
; 3 = X coordinate
RawPPUtransferSize = $5E
RawPPUtransferAddress = $0380
RawPPUtransferBuf = $0382
TSAPPUtransferSize = $1C
TSAPPUtransfer0NTaddress = $0300
TSAPPUtransfer0NTdata = $0302
TSAPPUtransfer0AttrAddress = $0312
TSAPPUtransfer0AttrData = $0314
TSAPPUtransfer0AttrAndMask = $0314
TSAPPUtransfer0AttrOrMask = $0315
PPU2000value = $FF
PPU2001value = $FE
SpritePalettes = $03E0
BGPalettes = $03D0
UnknownPalettes = $03F0
GutsmanStompCounter = $47
MegamanWalkTimer = $94 ;perhaps this meaning.
MegamanStallTimer = $95 ;perhaps this meaning.
CurrentTileState = $30
;CurrentTileState bits are:
; #$10: (bit 4) - Rockman is climbing up
; #$08: (bit 3) - Ladder above that
; #$04: (bit 2) - Ladder above
; #$02: (bit 1) - Ladder here
; #$01: (bit 0) - there is a ladder below this tile
;
; If both bits 2,3 are clear, this is a ladder top (or not ladder)
; If the value is #$01, it's a ladder top
CurrentStage = $31
BossCurrentStrategy = $3E ;doubles as the boss number
BossVariable3F = $3F ;unknown meaning
BossVariable43 = $43 ; unknown meaning, indicates strategy somehow
BossVariable44 = $44 ; counter of some kind
FightingBossNum = $AC
; $AC = boss we're fighting (value gets set at boss fight, invalid otherwise)
; 0 = Cutman
; 1 = Iceman
; 2 = Bombman
; 3 = Fireman
; 4 = Elecman(?)
; 5 = Gutsman
; 6 = Stone giant
CurrentRoomPointer = $06 ;two 16-bit pointers, occupying 06 07 08 09
CurrentStripeEndType = $26
; &3:
; 0=right
; 1=up
; 2=left
; 3=down
CapsuleObtained = $AD
TeleportEnteredFlag = $B0
GutsmanWeaponTargetActive = $52
; In weapon select menu (accessed by START button),
; $5F gets set as follows:
;
; 0 = "P"
; 1 = Bombman
; 2 = Elecman
; 3 = Gutsman
; 4 =
; 5 = Cutman
; 6 =
; 7 = Magnet beam
Score = $72
RoomBlockData = $8000
RoomBlockPals = $8300
RoomOrderTable = $8C00
RoomPointerTable = $8C30
RoomLayoutTable = $8C70
RoomSpritePalettes1 = $8CA0 ;normal stages
RoomSpritePalettes2 = $8CD0 ;wily stages
RoomTileTable1 = $8D00 ;normal stages
RoomTileTable2 = $8D20 ;wily stages
RoomMonsterIndex = $8D40 ;something common to both
RoomMonsterGraphics = $8D80 ;something common to both
RoomActives1 = $8E00 ;normal stages
RoomActives2 = $8EA0 ;wily stages
RoomShutterBlockData = $8F40
RoomShutterBlockPals = $8F70
RoomShutterInfo = $8F80
;;;;;;;;;;;; BANK 7 BEGIN ;;;;;;;;;;;;;;;;;;
Bank 7:
1C000-112k loaded into memory $C000(always)
|
- all the CODE of the game
0001C000: .byte 0,1,2,3,4,5,6,7 ;This table must be present in ROM for bankswitching to work properly
Reset:
0001C008: 78 sei
0001C009: A9 01 lda #$01
0001C00B: 8D 00 20 sta $2000
0001C00E: A9 06 lda #$06
0001C010: 8D 01 20 sta $2001
0001C013: A9 05 lda #$05
0001C015: 8D 05 C0 sta $C005
0001C018: 4C 00 90 jmp Reset2 ; $9000
;
; if MegamanStallTimer != 0 then don't get joypad input in this frame
;
; if ForcedInputFlag != 0 then Joypad0 = ForcedInputData
;
NextFrame
0001C01B: A5 95 lda MegamanStallTimer
0001C01D: D0 08 bne + ; $C027
0001C01F: A5 14 lda JoyPad0
0001C021: 85 16 sta JoyPad0old
0001C023: A5 15 lda JoyPad1
0001C025: 85 17 sta JoyPad1old
+
; Wait until our NMI's done what an NMI's gotta do...
0001C027: A9 00 lda #$00
0001C029: 85 1F sta NMI_GfxUpdateDone
-
0001C02B: A5 1F lda NMI_GfxUpdateDone
0001C02D: F0 FC beq - ; $0001C02B
0001C02F: A5 68 lda ForcedInputFlag
0001C031: F0 07 beq + ; $0001C03A
0001C033: A5 69 lda ForcedInputData
0001C035: 85 14 sta JoyPad0
0001C037: 4C 4B C0 jmp ++ ; $C04B
+
0001C03A: A5 95 lda MegamanStallTimer
0001C03C: D0 1B bne +++ ; $0001C059
0001C03E: 98 tya
0001C03F: 48 pha
0001C040: 8A txa
0001C041: 48 pha
0001C042: 20 8D D5 jsr ReadJoypads ; $D58D
0001C045: 68 pla
0001C046: AA tax
0001C047: 68 pla
0001C048: A8 tay
0001C049: A5 14 lda JoyPad0
++
0001C04B: 45 16 eor JoyPad0old
0001C04D: 25 14 and JoyPad0
0001C04F: 85 18 sta JoyD0
0001C051: A5 15 lda Joypad1
0001C053: 45 17 eor JoyPad1old
0001C055: 25 15 and Joypad1
0001C057: 85 19 sta JoyD1
+++
0001C059: 60 rts
StageClear
; What happens in regular stages.
;1. Play item sound
;2. Play stage clear music
;3. Load levelend gfx
;4. Remove all objects except Megaman
;5. Delay 383 frames
;6. Hide energy bars
;7. Draw first patch of text
;8. Halt Megaman
;9. Calculate score, 1000 points per frame
;10. Delay 64 frames
;11. Draw second patch of text
;12. Calculate bonus pearls, one per frame (3000 points each)
;13. Delay 383 frames
;14. Reboot game without clearing game status
;
0001C05A: A9 00 lda #$00
0001C05C: 85 3E sta BossCurrentStrategy
0001C05E: A9 FE lda #$FE
0001C060: 20 77 C4 jsr IssueSound ; $C477
0001C063: A5 AC lda FightingBossNum
0001C065: C9 0A cmp #$0A
0001C067: D0 08 bne PlayStageClearMusic ; $0001C071
0001C069: A9 00 lda #$00
0001C06B: 20 77 C4 jsr IssueSound ; $C477
0001C06E: 4C 79 C0 jmp ++ ; $C079
; Play stage clear melody
PlayStageClearMusic
0001C071: A9 04 lda #$04
0001C073: 20 77 C4 jsr IssueSound ; $C477
0001C076: 20 04 C2 jsr ClearAllObjectsExceptMegaman ; $C204
++
0001C079: A9 00 lda #$00
0001C07B: 85 5C sta $5C
0001C07D: A9 B7 lda #$B7
0001C07F: A2 0B ldx #$0B
0001C081: A0 08 ldy #$08
0001C083: 20 BE F0 jsr DoPPUtransferRoutineF0BE
0001C086: A5 AC lda FightingBossNum
0001C088: C9 0A cmp #$0A
0001C08A: D0 0A bne + ; $C096
; Whole game cleared?
0001C08C: A9 FF lda #$FF
0001C08E: 20 16 D1 jsr TimeDelayWithAllObjectsHalted
0001C091: A9 FF lda #$FF
0001C093: 20 16 D1 jsr TimeDelayWithAllObjectsHalted
+ ;Nope
0001C096: A9 80 lda #$80
0001C098: 20 16 D1 jsr TimeDelayWithAllObjectsHalted
0001C09B: A9 FF lda #$FF
0001C09D: 20 16 D1 jsr TimeDelayWithAllObjectsHalted
0001C0A0: A5 AC lda FightingBossNum
0001C0A2: C9 0A cmp #$0A
0001C0A4: D0 08 bne + ; $C0AE
0001C0A6: 20 04 C2 jsr ClearAllObjectsExceptMegaman ; $C204
0001C0A9: A9 F8 lda #$F8 ; Disable Megaman object
0001C0AB: 8D 00 06 sta ObjectPosY+0 ; $0600
+
0001C0AE: E6 BB inc DrawScoreAndMetersFlag
0001C0B0: A9 00 lda #$00
0001C0B2: 85 2F sta RefObjectNumber
0001C0B4: A2 02 ldx #$02 ;into the given slot
0001C0B6: 20 63 C1 jsr SetNObjects
0001C0B9: A2 05 ldx #$05
-
0001C0BB: 95 B5 sta $B5,x
0001C0BD: CA dex
0001C0BE: 10 FB bpl - ; $C0BB
0001C0C0: EE A0 06 inc ObjectLifeCycleCounter+0
-
0001C0C3: A2 00 ldx #$00
0001C0C5: 20 81 C1 jsr LevelEndAddThousandPoints
0001C0C8: 20 AC C1 jsr $C1AC
0001C0CB: 20 1B C0 jsr NextFrame ; $C01B
0001C0CE: C6 3D dec LevelClearScoreInThousands
0001C0D0: D0 F1 bne - ; $C0C3
; wait 1 second
0001C0D2: A9 40 lda #$40
0001C0D4: 20 0F C2 jsr TimeDelayNoMove ; $C20F
0001C0D7: A9 00 lda #$00
0001C0D9: 85 2F sta RefObjectNumber
0001C0DB: A2 05 ldx #$05
0001C0DD: 20 63 C1 jsr SetNObjects
0001C0E0: EE A0 06 inc ObjectLifeCycleCounter+0
0001C0E3: A5 AE lda BonusPearlCount
0001C0E5: F0 12 beq + ; $C0F9
-
0001C0E7: A2 03 ldx #$03
0001C0E9: 20 81 C1 jsr LevelEndAddThousandPoints
0001C0EC: 20 AC C1 jsr $C1AC
0001C0EF: 20 BE C1 jsr $C1BE
0001C0F2: 20 1B C0 jsr NextFrame ; $C01B
0001C0F5: C6 AE dec BonusPearlCount
0001C0F7: D0 EE bne - ; $C0E7
+
0001C0F9: 20 31 D1 jsr UpdateGraphics ; $D131
0001C0FC: 20 AC C1 jsr $C1AC
0001C0FF: 20 BE C1 jsr $C1BE
; Wait 6-7 seconds
0001C102: A9 FF lda #$FF
0001C104: 20 0F C2 jsr TimeDelayNoMove ; $C20F
0001C107: A9 80 lda #$80
0001C109: 20 0F C2 jsr TimeDelayNoMove ; $C20F
0001C10C: 20 95 D4 jsr DisableNMI&PPU ; $D495
0001C10F: C6 BB dec DrawScoreAndMetersFlag
0001C111: A2 FF ldx #$FF
0001C113: 9A txs
0001C114: A9 05 lda #$05
0001C116: 8D 05 C0 sta $C005
0001C119: 85 42 sta CurrentBank
0001C11B: A6 31 ldx CurrentStage
0001C11D: E0 09 cpx #$09
0001C11F: F0 16 beq + ; $0001C137
0001C121: E0 06 cpx #$06
0001C123: B0 16 bcs ++ ; $0001C13B
; Add new weapon/set boss defeated flag
0001C125: A5 5D lda WeaponsOwned
0001C127: 1D 48 C1 ora WeaponsOwnedTab,x
0001C12A: 85 5D sta WeaponsOwned
0001C12C: A9 00 lda #$00
0001C12E: 85 BC sta IgnoreStageSelection
0001C130: 85 55 sta MegamanBlinkState
0001C132: 85 68 sta ForcedInputFlag
0001C134: 4C 5A 90 jmp $905A
; Prepare for ending
+
0001C137: E6 31 inc CurrentStage
0001C139: C6 BB dec DrawScoreAndMetersFlag
; Prepare for Wilystage
++
0001C13B: A9 00 lda #$00
0001C13D: 85 B4 sta UseTempScrollX
0001C13F: 85 AB sta LastRestartPointType
0001C141: 85 68 sta ForcedInputFlag
0001C143: E6 31 inc CurrentStage
0001C145: 4C 6A 90 jmp $906A
;C148 C I B F E G
WeaponsOwnedTab .byte $20, $10, $02, $40, $04, $08 ;See also: Lbl_b50d
;C14E
IndexIntoTheActiveThatPreventsEscapingRematch
.byte 0*6, 5*6, 3*6, 4*6, 1*6, 6*6 ;indexes into RoomActiveTable
; Objects in order:
; 0: HP bar
; 1: Score
XPosTable1 .db $24, $80, $A0, $80, $88
YPosTable1 .db $A0, $40, $58, $68, $80
SpriteNumTable1 .db $80, $87, $89, $88, $8A, $89 ;
SetNObjects
0001C163: 20 7B F6 jsr InitActor
0001C166: BD 53 C1 lda XPosTable1,x
0001C169: 9D 80 04 sta ObjectPosX,x
0001C16C: BD 58 C1 lda YPosTable1,x
0001C16F: 9D 00 06 sta ObjectPosY,x
0001C172: BD 5D C1 lda SpriteNumTable1,x
0001C175: 9D 00 04 sta ObjectSpriteNum,x
0001C178: A9 00 lda #$00
0001C17A: 9D 20 04 sta ObjectFlags,x
0001C17D: CA dex
0001C17E: D0 E3 bne SetNObjects
0001C180: 60 rts
; X = index to the digits
LevelEndAddThousandPoints
0001C181: A0 03 ldy #$03
0001C183: 18 clc
0001C184: A9 01 lda #$01
-
0001C186: 75 B5 adc $B5,x
0001C188: C9 0A cmp #$0A
0001C18A: 90 02 bcc + ; $0001C18E
0001C18C: E9 0A sbc #$0A
+
0001C18E: 95 B5 sta $B5,x
0001C190: A9 00 lda #$00
0001C192: E8 inx
0001C193: 88 dey
0001C194: D0 F0 bne - ; $0001C186
0001C196: A9 10 lda #$10 ; Add 1,000 points to score
0001C198: 85 05 sta $05
0001C19A: 20 40 D4 jsr IncreaseScore ; $D440
0001C19D: 20 31 D1 jsr UpdateGraphics ; $D131
0001C1A0: A5 23 lda FrameCounter
0001C1A2: 29 03 and #$03
0001C1A4: D0 05 bne + ; $C1AB
0001C1A6: A9 21 lda #$21 ; SFX for points
0001C1A8: 20 77 C4 jsr IssueSound ; $C477
+
0001C1AB: 60 rts
0001C1AC: A2 02 ldx #$02 ; 3 sprites
0001C1AE: 86 0E stx $0E
0001C1B0: A0 C0 ldy #$C0 ; spritepage index = #$C4
0001C1B2: A9 68 lda #$68 ; X position = #$68
0001C1B4: 85 0C sta $0C
0001C1B6: A9 50 lda #$50 ; Y position = #$50
0001C1B8: 85 0D sta $0D
0001C1BA: 20 DD C1 jsr ProcessSprites ; $C1DD
0001C1BD: 60 rts
;
;
;
0001C1BE: A2 04 ldx #$04
0001C1C0: A9 01 lda #$01 ; 2 sprites
0001C1C2: 85 0E sta $0E
0001C1C4: A9 78 lda #$78
0001C1C6: 85 0D sta $0D
0001C1C8: A9 70 lda #$70
0001C1CA: 85 0C sta $0C
0001C1CC: 20 DD C1 jsr ProcessSprites ; $C1DD
0001C1CF: A2 04 ldx #$04
0001C1D1: A9 01 lda #$01
0001C1D3: 85 0E sta $0E
0001C1D5: A9 60 lda #$60
0001C1D7: 85 0D sta $0D
0001C1D9: A9 90 lda #$90
0001C1DB: 85 0C sta $0C
;continues to ProcessSprites
;
;
; Process sprite information (write to spritepage)
;
; $0C = X position
; $0D = Y position
;
; $0E = Number of sprites - 1
;
; Palette # = 1
;
; X = index into $B5
;
ProcessSprites
-
0001C1DD: B5 B5 lda $B5,x ; Get tile number
0001C1DF: 09 F0 ora #$F0
0001C1E1: 99 05 02 sta CurrentSpriteData+1,y
0001C1E4: A5 0C lda $0C
0001C1E6: 99 07 02 sta CurrentSpriteData+3,y
0001C1E9: A5 0D lda $0D
0001C1EB: 99 04 02 sta CurrentSpriteData+0,y
0001C1EE: A9 01 lda #$01
0001C1F0: 99 06 02 sta CurrentSpriteData+2,y
0001C1F3: C8 iny
0001C1F4: C8 iny
0001C1F5: C8 iny
0001C1F6: C8 iny
0001C1F7: CA dex
0001C1F8: 18 clc
0001C1F9: A5 0C lda $0C ; X position += 8
0001C1FB: 69 08 adc #$08
0001C1FD: 85 0C sta $0C
0001C1FF: C6 0E dec $0E
0001C201: 10 DA bpl - ; $C1DD
0001C203: 60 rts
; Clears all objects except Megaman
ClearAllObjectsExceptMegaman
0001C204: A9 F8 lda #$F8
0001C206: A2 1F ldx #$1F
-
0001C208: 9D 00 06 sta ObjectPosY,x
0001C20B: CA dex
0001C20C: D0 FA bne - ; $0001C208
0001C20E: 60 rts
;
; A = number of frames to freeze gameplay for
;
TimeDelayNoMove
0001C20F: 85 3C sta MiscCounter1
-
0001C211: 20 1B C0 jsr NextFrame ; $C01B
0001C214: C6 3C dec MiscCounter1
0001C216: D0 F9 bne - ; $C211
0001C218: 60 rts
MegaManKilled
0001C219: A9 FE lda #$FE
0001C21B: 20 77 C4 jsr IssueSound ; $C477
0001C21E: A9 FF lda #$FF
0001C220: 20 77 C4 jsr IssueSound ; $C477
0001C223: A9 20 lda #$20
0001C225: 20 16 D1 jsr TimeDelayWithAllObjectsHalted
0001C228: A9 31 lda #$31 ; Mega Man exploding
0001C22A: 20 77 C4 jsr IssueSound ; $C477
0001C22D: A9 00 lda #$00
0001C22F: 85 59 sta $59
0001C231: A9 7D lda #$7D
0001C233: 85 5A sta $5A
0001C235: 20 2A C3 jsr AtomicExplodeActor
0001C238: A9 00 lda #$00
0001C23A: 85 45 sta NumIssuedSounds
0001C23C: A9 F8 lda #$F8 ; Hide Megaman
0001C23E: 8D 00 06 sta ObjectPosY+0 ; $0600
0001C241: A9 C0 lda #$C0
0001C243: 85 3C sta MiscCounter1
-
0001C245: 20 17 C3 jsr TimeDelayC317
0001C248: D0 FB bne - ; $0001C245
0001C24A: 20 95 D4 jsr DisableNMI&PPU ; $D495
0001C24D: A9 00 lda #$00
0001C24F: 85 47 sta GutsmanStompCounter
0001C251: 85 B4 sta UseTempScrollX
0001C253: 85 55 sta MegamanBlinkState
0001C255: 85 94 sta MegamanWalkTimer
0001C257: 85 95 sta MegamanStallTimer
0001C259: C6 A6 dec ExtraLives
0001C25B: A5 A6 lda ExtraLives ; Branch if no lives left
0001C25D: 30 72 bmi +++ ; $C2D1
0001C25F: 20 5B C7 jsr WriteChr ; $C75B
0001C262: A9 00 lda #$00
0001C264: 85 AB sta LastRestartPointType
0001C266: 85 59 sta $59
0001C268: AD 60 04 lda ObjectPosScreen+0 ; $0460
0001C26B: A6 31 ldx CurrentStage
0001C26D: DD D4 C2 cmp StageCheckPointA,x
0001C270: 90 35 bcc ++ ; $C2A7
0001C272: A0 0C ldy #$0C
0001C274: DD E0 C2 cmp StageCheckPointB,x
0001C277: 90 02 bcc + ; $C27B
0001C279: A0 18 ldy #$18
+
0001C27B: 98 tya
0001C27C: 85 AB sta LastRestartPointType
0001C27E: 18 clc
0001C27F: 65 31 adc CurrentStage
0001C281: AA tax
0001C282: BD EB C2 lda FirstScreenScreenTable,x
0001C285: 8D 60 04 sta ObjectPosScreen+0 ; $0460
0001C288: 20 58 C6 jsr SetupEnemyGraphicsPointer
-
0001C28B: 20 C4 C6 jsr LoadEnemyGraphics
0001C28E: 20 AF D5 jsr DoRawPPUtransfer
0001C291: A5 59 lda $59
0001C293: C9 28 cmp #$28
0001C295: D0 F4 bne - ; $C28B
0001C297: 20 C4 C6 jsr LoadEnemyGraphics
0001C29A: A9 2C lda #$2C
0001C29C: 8D E1 03 sta SpritePalettes + $1
0001C29F: A9 11 lda #$11
0001C2A1: 8D E2 03 sta SpritePalettes + $2
0001C2A4: 20 0A D6 jsr UpdatePalettes ; $D60A
++
0001C2A7: A9 00 lda #$00
0001C2A9: 85 19 sta JoyD1
0001C2AB: A2 FF ldx #$FF
0001C2AD: 9A txs
0001C2AE: A9 05 lda #$05
0001C2B0: 85 42 sta CurrentBank
0001C2B2: 8D 05 C0 sta $C005
0001C2B5: A5 AB lda LastRestartPointType
0001C2B7: C9 0C cmp #$0C
0001C2B9: B0 03 bcs + ; $C2BE
-
0001C2BB: 4C 7E 90 jmp StageBegin
+
0001C2BE: A5 31 lda CurrentStage
0001C2C0: C9 07 cmp #$07
0001C2C2: F0 04 beq + ; $0001C2C8
0001C2C4: C9 09 cmp #$09
0001C2C6: D0 06 bne ++ ; $0001C2CE
+
0001C2C8: A5 AB lda LastRestartPointType
0001C2CA: C9 0D cmp #$0D
0001C2CC: B0 ED bcs - ; $0001C2BB
++
0001C2CE: 4C 81 90 jmp StageBeginFromDeath
;Game over
+++
0001C2D1: 4C 38 90 jmp GameOver
; Table that says what screen# Megaman's current screen# must be above or
; equal to in order for him to restart from it...
; Cutman #0
; Iceman #1
; Bombman #2
; Fireman #3
; Elecman #4
; Gutsman #5
StageCheckPointA ;at C2D4
.byte $0A,$0A,$0E,$08,$07,$0A
.byte $22,$24,$2F,$1D,$1D,$1D
StageCheckPointB
.byte $14,$14,$14,$10,$14,$0F
.byte $27,$29,$2F,$21,$1C
FirstScreenScreenTable ;at C2EB
; Initial screen start?
.byte $00,$00,$00,$00,$00,$00
.byte $18,$18,$18,$14,$18,$1E ;Stored into ObjectPosScreen+0 or CurrentBeginScreen
; Restart point A
.byte $0A,$0A,$0E,$08,$07,$0A
.byte $22,$24,$2E,$1D,$1D,$1D
; Restart point B
.byte $14,$14,$14,$10,$14,$0F
.byte $26,$28,$2E,$21,$20
C30E_table:
.byte $FB,$05,$00 ;X increment of some kind
C311_table:
.byte $FF,$00,$00 ;screen increment of some kind
C314_table:
.byte $F8,$F4,$06 ;Y increment of some kind
TimeDelayC317
0001C317: A5 lda RefObjectNumber
0001C319: D0 03 bne + ; $C31E
0001C31B: 20 8C DB jsr RunBossAI
+
0001C31E: 20 EA 98 jsr RunEnemyAI ; $98EA
0001C321: 20 31 D1 jsr UpdateGraphics ; $D131
0001C324: 20 1B C0 jsr NextFrame ; $C01B
0001C327: C6 3C dec MiscCounter1
0001C329: 60 rts
AtomicExplodeActor: ;Ah, explosions probably!
0001C32A: A9 0C lda #$0C ;How many atoms to create?
0001C32C: 85 3C sta MiscCounter1
-
0001C32E: A5 3C lda MiscCounter1
0001C330: 29 03 and #$03
0001C332: D0 43 bne + ; $C377
0001C334: A5 59 lda $59
0001C336: 85 2F sta RefObjectNumber
0001C338: A2 02 ldx #$02
0001C33A: 20 76 C5 jsr FindFreeObject ; $C576
0001C33D: B0 38 bcs + ; $C377
0001C33F: 20 7B F6 jsr InitActor
0001C342: A5 5A lda $5A
0001C344: 9D 00 04 sta ObjectSpriteNum,x
0001C347: A9 08 lda #$08
0001C349: 9D 20 04 sta ObjectFlags,x
0001C34C: A9 10 lda #$10
0001C34E: 9D 40 04 sta ObjectUnknown440,x
0001C351: A5 3C lda MiscCounter1
0001C353: 4A lsr a
0001C354: 4A lsr a
0001C355: A8 tay
0001C356: BD 80 04 lda ObjectPosX,x
0001C359: 79 0D C3 adc C30E_table-1,y
0001C35C: 9D 80 04 sta ObjectPosX,x
0001C35F: BD 60 04 lda ObjectPosScreen,x
0001C362: 79 10 C3 adc C311_table-1,y
0001C365: 9D 60 04 sta ObjectPosScreen,x
0001C368: 18 clc
0001C369: BD 00 06 lda ObjectPosY,x
0001C36C: 79 13 C3 adc C314_table-1,y
0001C36F: 9D 00 06 sta ObjectPosY,x
0001C372: A0 08 ldy #$08
0001C374: 20 33 F5 jsr InitObjectDefaultSpeed
+
0001C377: 20 17 C3 jsr TimeDelayC317
0001C37A: D0 B2 bne - ; $C32E
0001C37C: A9 0B lda #$0B
0001C37E: 85 0C sta $0C
0001C380: A5 5A lda $5A
0001C382: 85 0D sta $0D
0001C384: A9 00 lda #$00
0001C386: 85 0E sta $0E
-
0001C388: A4 59 ldy $59
0001C38A: A2 02 ldx #$02
0001C38C: 20 76 C5 jsr FindFreeObject ; FindFreeObject
0001C38F: B0 05 bcs $0001C396
0001C391: 20 41 F8 jsr CreateExplosionObject
0001C394: 10 F2 bpl -
0001C396: A9 12 lda #$12 ; Explosion
0001C398: 20 77 C4 jsr IssueSound ; $C477
0001C39B: 60 rts
;
;
;
SwitchBankStage ;doesn't modify P,A. Modifies X.
0001C39C: 08 php
0001C39D: 48 pha
0001C39E: 8A txa
0001C39F: 48 pha
0001C3A0: A5 31 lda CurrentStage