-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.s
3158 lines (2932 loc) · 36.5 KB
/
1.s
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
;freespace: MACRO
; rept (\1 / $4000 + 1) * $4000 - \1
; db -1
; endr
;ENDM
freespace: MACRO
incbin "base1.gb",\1,(\1 / $4000 + 1) * $4000 - \1
ENDM
bankswitch: MACRO
ld [$DF99],a
ld [$2100],a
ENDM
SECTION "func0",ROM0[0]
ld hl,$FFFE
ld sp,hl
jp Function150
db 1
SECTION "func8",ROM0[8]
jp $2AD
SECTION "vblank",ROM0[$40]
jp $675
SECTION "lcdc",ROM0[$48]
jp $C0A4
SECTION "timer",ROM0[$50]
reti
SECTION "serial",ROM0[$58]
reti
SECTION "joypad",ROM0[$60]
reti
SECTION "header",ROM0[$100]
nop
jp Function150
SECTION "start",ROM0[$150]
Function150:
jp Function5FE
Function153:
jp $38A9
Function156:
jp $0F96
Function159:
jp $1758
Function15C:
jp $163C
Function15F:
jp $1968
Function162:
jp Function167E
Function165:
jp $18B3
Function168:
jp Function3C3
Function16B:
jp $1694
Function16E:
jp Function3CD
Function171:
jp $5A87
Function174:
jp $273B
Function177:
jp $274B
Function17A:
jp $2EDC
Function17D:
jp $2F0A
Function180:
jp $2CF0
Function183:
jp $1004
Function186:
jp $2CD6
Function189:
jp $1973
Function18C:
jp $19B5
Function18F:
jp $2245
Function192:
jp $227A
Function195:
jp $22A3
Function198:
jp $22CC
Function19B:
jp $1AFC
Function19E:
jp $1618
Function1A1:
jp $157D
Function1A4:
jp Function1F4
Function1A7:
jp $096F
Function1AA:
jp $3057
Function1AD:
jp $1093
Function1B0:
jp Function2C37
Function1B3:
jp Function1BD
Function1B6:
jp Function1F4
Data1B9: ; $1B9
dw $34D3
dw $3693
Function1BD: ; $1BD
ld a,6
bankswitch
ld de,$9000
ld hl,$363
call Function2516
call $18B3
ld de,$9800
ld hl,$365
call Function2521
call Function1E6
ld a,1
bankswitch
ret
Function1E6: ; $1E6
ld c,$12
.loop
push bc
ld bc,$0014
call $18B3
pop bc
dec c
jr nz,.loop
ret
Function1F4: ; $1F4
ld [$FF91],a
ld a,[$DF99]
push af
push hl
push de
ld a,[$FF91]
ld e,a
ld d,0
ld hl,.pointers
add hl,de
add hl,de
ld a,[hli]
ld [$C0D1],a
ld a,[hli]
ld [$C0D2],a
ld a,$C3 ; jump
ld [$C0D0],a
pop de
pop hl
ld a,1
bankswitch
call $C0D0
pop af
bankswitch
ret
.pointers
dw $0248
dw $5A87
dw $5943
dw $1AFC
dw $5939
dw $1A28
dw $1A3D
db $CF; $236
dw $4000
db $CF
dw $4003
db $CF
dw $4006
db $CF
dw $4009
db $CF
dw $400C
db $CF
dw $400F
db $CF
dw $4012
dw $4015
dw $4017
dw $4019
dw $401B
dw $401D
dw $401F
dw $4021
dw $4023
dw $4025
dw $4027
dw $4029
dw $402B
dw $402D
dw $402F
dw $4031
dw $4033
dw $4035
dw $4037
dw $4039
dw $403B
dw $403D
dw $403F
dw $4041
dw $4043
dw $4045
dw $4047
dw $4049
dw $404B
dw $404D
dw $404F
dw $4051
dw $4053
dw $4055
dw $4057
dw $4059
dw $405B
dw $405D
dw $405F
dw $4061
dw $4063
dw $4065
dw $4067
dw $4069
dw $406B
dw $406D
dw $406F
dw $4071
dw $4073
dw $4075
Function2AD: ; $2AD
ld [$FF8C],a
ld a,l
ld [$FF8D],a
ld a,h
ld [$FF8E],a
ld a,e
ld [$FF8F],a
ld a,d
ld [$FF90],a
ld a,[$DF9A]
bankswitch
pop hl
ld de,.Function2DC
push de
ld e,[hl]
inc hl
ld d,[hl]
push de
ld a,[$FF8D]
ld l,a
ld a,[$FF8E]
ld h,a
ld a,[$FF8F]
ld e,a
ld a,[$FF90]
ld d,a
ld a,[$FF8C]
ret
.Function2DC ; $2DC
push af
ld a,1
bankswitch
pop af
ret
__MegaManSpriteGFX:
dw _MegaManSpriteGFX
__ItemPickupSpriteGFX:
dw _ItemPickupSpriteGFX
__UnknownBulletGFX:
dw _UnknownBulletGFX
__RollingCutterGFX:
dw _RollingCutterGFX
__ThunderBeamGFX:
dw _ThunderBeamGFX
__IceSlasherGFX:
dw _IceSlasherGFX
__FireStormGFX:
dw _FireStormGFX
__CarryGFX:
dw _CarryGFX
__AtomicFireGFX:
dw _AtomicFireGFX
__TimeStopperGFX:
dw _TimeStopperGFX
__QuickBoomerangGFX:
dw _QuickBoomerangGFX
__BubbleLeadGFX:
dw _BubbleLeadGFX
__MirrorBusterGFX:
dw _MirrorBusterGFX
__HealthBarGFX:
dw _HealthBarGFX
__SevenSegmentGFX:
dw _SevenSegmentGFX
Pointer305:
dw Pointer1001E
Pointer307:
dw Pointer10020
Pointer309:
dw Pointer10022
Pointer30B:
dw Pointer10024
Pointer30D:
dw Pointer10026
Pointer30F:
dw Pointer10028
Pointer301:
dw Pointer1002A
Pointer313:
dw Pointer1002C
Pointer315:
dw Pointer1002E
Pointer317:
dw Pointer10030
Pointer319:
dw Pointer10032
Pointer31B:
dw Pointer10034
Pointer31D:
dw Pointer10036
Pointer31F:
dw Pointer10038
Pointer321:
dw Pointer1003A
Pointer323:
dw Pointer1003C
Pointer325:
dw Pointer1003E
Pointer327:
dw Pointer10040
Pointer329:
dw Pointer10042
Pointer32B:
dw Pointer10044
Pointer32D:
dw Pointer10046
Pointer32F:
dw Pointer10048
Pointer331:
dw Pointer1004A
Pointer333:
dw Pointer1004C
Pointer335:
dw Pointer1004E
Pointer337:
dw Pointer10050
Pointer339:
dw Pointer10052
Pointer33B:
dw CutManLevelDataPointer
Pointer33D:
dw IceManLevelDataPointer
Pointer33F:
dw FireManLevelDataPointer
Pointer341:
dw ElecManLevelDataPointer
Pointer343:
dw Pointer18000
Pointer345:
dw Pointer18002
Pointer347:
dw Pointer18004
Pointer349:
dw Pointer18006
Pointer34B:
dw Pointer18008
Pointer34D:
dw Pointer1800A
Pointer34F:
dw Pointer1800C
Pointer351:
dw Pointer1800E
Pointer353:
dw Pointer18010
Pointer355:
dw Pointer18012
Pointer357:
dw Pointer18014
Pointer359:
dw Pointer18016
Pointer35B:
dw Pointer18018
Pointer35D:
dw Pointer1801A
Pointer35F:
dw Pointer1801C
Pointer361:
dw Pointer1801E
Pointer363:
dw Pointer18020
Pointer365:
dw Pointer18022
Pointer367:
dw Pointer18024
Pointer369:
dw Pointer18026
Pointer36B:
dw Pointer18028
Pointer36D:
dw Pointer1C000
Pointer36F:
dw Pointer1C002
Pointer371:
dw Pointer1C004
Pointer373:
dw Pointer1C006
Pointer375:
dw Pointer1C008
Pointer377:
dw Pointer1C00A
Pointer379:
dw Pointer1C00C
Pointer37B:
dw Pointer1C00E
Pointer37D:
dw Pointer1C010
Pointer37F:
dw Pointer1C012
Pointer381:
dw Pointer1C014
Pointer383:
dw Pointer1C016
Pointer385:
dw Pointer1C018
Pointer387:
dw Pointer1C01A
Pointer389:
dw Pointer1C01C
Pointer38B:
dw Pointer1C01E
Pointer38D:
dw Pointer1C020
Pointer38F:
dw Pointer1C022
Pointer391:
dw Pointer1C024
Pointer393:
dw Pointer1C026
Pointer395:
dw Pointer1C028
Pointer397:
dw Pointer1C02A
Pointer399:
dw Pointer1C02C
Pointer39B:
dw Pointer1C02E
Pointer39D:
dw Pointer1C030
Pointer39F:
dw Pointer1C032
Pointer3A1:
dw Pointer1C034
Pointer3A3:
dw Pointer1C036
Pointer3A5:
dw Pointer1C038
Pointer3A7:
dw Pointer1C03A
Pointer3A9:
dw Pointer1C03C
Pointer3AB:
dw Pointer20000
Pointer3AD:
dw Pointer20002
Pointer3AF:
dw Pointer20004
Pointer3B1:
dw Pointer20006
Pointer3B3:
dw Pointer30000
Pointer3B5:
dw Pointer30002
Pointer3B7:
dw Pointer30004
Pointer3B9:
dw Pointer30006
Pointer3BB:
dw Pointer30008
Pointer3BD:
dw Pointer3000A
Pointer3BF:
dw Pointer3000C
Pointer3C1:
dw Pointer3000E
Function3C3: ; $3C3
ld hl,$41E
ld bc,$1E0
call $18B3
ret
Function3CD: ; $3CD
; play a song or sound effect
; a=02: enemy destroyed
; a=03: electric trap
; a=04: megaman fires buster
; a=05: sniper joe fires bullet
; a=06: megaman takes damage
; a=08: megaman lands on ground
; a=09: enemy takes damage
; a=0A: sniper joe deflects buster
; a=0B: move cursor
; a=0F: megaman dies
; a=10: megaman picks up extra life
; a=11: cutting wheel appears
; a=12: health refill
; a=1E: disappearing platform appears
; a=21: open menu
; a=24: chose a robot master
; a=26: robot master select screen
; a=2A: title screen
; a=2B: icicle falls
; a=2E: password screen
push hl
push de
ld d,a
ld hl,$D920
ld a,[hl]
cp $14
jr z,.next
inc [hl]
inc hl
add l
ld l,a
ld a,h
adc 0
ld h,a
ld [hl],d
.next
pop de
pop hl
ret
Function3E4: ; $3E4
push hl
push de
push bc
ld hl,$D920
ld a,[hl]
ld [hl],0
inc hl
add l
ld d,a
.loop
ld a,l
cp d
jr z,.next
ld a,[hli]
push hl
push de
call $7DD
pop de
pop hl
jr .loop
.next
call $826
pop bc
pop de
pop hl
ret
Function405: ; $405
ld a,[$DF99]
push af
ei
ld a,[$DF9A]
bankswitch
call $400F
pop af
bankswitch
ret
INCBIN "base1.gb",$41E,$5FE-$41E
Function5FE: ; $5FE
xor a
ld [$DFCF],a
ld [$DFD0],a
xor a
ld [$CCFC],a
ld [$DF8C],a
xor a
ld [$FF24],a
ld [$FF25],a
ld [$FF26],a
di
xor a
ld [$FF0F],a
ld [$FFFF],a
ld hl,$FFFE
ld sp,hl
call $15EA
ld hl,$8000
ld bc,$2000
xor a
call $1694
ld hl,$C000
ld bc,$2000
xor a
call $1694
ld hl,$FF8A
ld bc,$0072
xor a
call $1694
di
xor a
ld [$FF0F],a
ld [$FFFF],a
ld hl,$FFFE
ld sp,hl
ld a,1
bankswitch
call $157D
call $066A
call $15D2
ld a,0
ld [$FF47],a
ld [$FF48],a
ld [$FF49],a
ld [$DF9F],a
call $1654
jp $855
Function66A:
ld hl,$C0A4
ld bc,$5C
ld a,$C9
jp $1694
Function675:
push af
push hl
push de
push bc
ld a,[$df85]
inc a
ld [$df85],a
ld a,[$d85f]
ld [$ff43],a
ld a,[$d860]
ld [$ff42],a
ld a,[$df8a]
ld [$ff40],a
ld a,[$df9c]
ld [$ff47],a
ld a,[$df89]
or a
jr nZ,.next1
ld a,$01
ld [$df89],a
call $ff80
call $071c
call $076e
call $06e4
ld hl,$df83
inc [hl]
jr nZ,.next1
inc hl
inc [hl]
.next1
ld a,[$c131]
or a
jr nZ,.next2
dec a
ld [$c131],a
ld a,[$df99]
push af
ei
ld a,[$df9a]
bankswitch
call $400f
pop af
bankswitch
ei
xor a
ld [$c131],a
.next2
pop bc
pop de
pop hl
ld a,$01
ld [$df88],a
pop af
reti
Function6E4:
ld hl,$c102
ld a,[hl]
or a
ret Z
ld [hl],$00
inc l
ld e,[hl]
inc l
ld d,[hl]
inc l
ldi a,[hl]
ld h,[hl]
ld l,a
ld b,$02
.loop
push bc
push hl
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
ld hl,$001a
add hl,de
ld e,l
ld d,h
pop hl
ld bc,$0014
add hl,bc
pop bc
dec b
jr nZ,.loop
ret
Function71C:
ld hl,$d865
ld a,[hl]
or a
ret Z
ld [hl],$00
inc hl
ldi a,[hl]
ld h,[hl]
ld l,a
ld de,$ddd0
ld bc,$0020
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
add hl,bc
ld a,[de]
inc e
ld [hl],a
ret
Function76E:
ld hl,$d86b
ld a,[hl]
or a
ret Z
ld [hl],$00
ld hl,$dde0
ld a,[$d86c]
ld e,a
ld a,[$d86d]
ld d,a
ld a,e
and $e0
ld c,a
ld b,$1f
ld a,$03
.loop
push af
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
ld a,e
inc a
and b
or c
ld e,a
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
ld a,e
inc a
and b
or c
ld e,a
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
ld a,e
inc a
and b
or c
ld e,a
ldi a,[hl]
ld [de],a
inc e
ldi a,[hl]
ld [de],a
ld a,e
inc a
and b
or c
ld e,a
pop af
dec a
jr nZ,.loop
ret
Function7B7:
reti
Function7B8:
reti
Function7B9:
jp $157D
Function7BC:
push af
.loop1
ld a,[$ff41]
and $03
jr Z,.loop1
.loop2
ld a,[$ff41]
and $03
jr nZ,.loop2
xor a
ld [$ff43],a
ld a,[$df9e]
ld [$ff42],a
ld a,[$df9d]
ld [$ff40],a
ld a,[$df9f]
ld [$ff47],a
pop af
reti
Function7DD:
or a
ret Z
ld [$cc47],a
push de
push hl
ld a,[$cc47]
ld e,a
ld d,$00
ld hl,$4013
add hl,de
add hl,de
ld a,[$df9a]
bankswitch
ldi a,[hl]
ld h,[hl]
ld l,a
ld a,$01
bankswitch
push hl
inc hl
ld a,[hl]
ld e,a
ld a,[$d936]
ld l,a
ld a,[$d937]
ld h,a
or l
jr Z,.next1
inc hl
ld a,e
cp [hl]
jr nC,.next1
pop hl
jr .next2
.next1
pop hl
ld a,h
ld [$d937],a
ld a,l
ld [$d936],a
.next2
pop hl
pop de
ret
Function826:
ld a,[$D936]
ld l,a
ld a,[$D937]
ld h,a
or l
call nz,$23C
xor a
ld [$D936],a
ld [$D937],a
ret
Function83A:
ld a,[$DCBC]
ld b,a
ld c,1
.loop
ld a,c
cp b
push bc
ld [$CC4A],a
call nz,$239
pop bc
inc c
ld a,c
cp $A
jr c,.loop
xor a
ld [$D920],a