-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_03f.asm
executable file
·16192 lines (16122 loc) · 130 KB
/
bank_03f.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
; Disassembly of "DQM.gbc"
; This file was created with:
; mgbdis v1.4 - Game Boy ROM disassembler by Matt Currie and contributors.
; https://github.com/mattcurrie/mgbdis
SECTION "ROM Bank $03f", ROMX[$4000], BANK[$3f]
ccf
ld de, $2c40
ld b, b
ld a, c
ld b, b
or e
ld b, b
ld e, h
ld b, d
ret nc
ld b, d
inc b
ld b, e
jp nc, Jump_03f_4043
ld [bc], a
ld bc, $a001
rst $38
ld c, l
ld bc, $0f5f
ld c, l
ld bc, $0fbf
ld c, l
ld bc, $1f1f
ld c, l
ld bc, $1f7f
ld c, l
ld bc, $1fdf
ld c, l
ld b, b
ld [bc], a
ld [bc], a
ld bc, $0002
rrca
nop
ld [bc], a
db $f4
rst $38
ld c, l
ld [bc], a
inc [hl]
rrca
ld a, [hl+]
dec b
dec b
ld [bc], a
inc sp
add hl, bc
dec b
ld [bc], a
Jump_03f_4043:
ret nz
nop
ld [bc], a
and [hl]
add hl, bc
dec b
dec b
ld [bc], a
inc [hl]
add hl, bc
ld [bc], a
ret nz
ld bc, $e102
add hl, bc
ld [bc], a
inc sp
dec bc
ld b, $02
ld [bc], a
dec de
ld [bc], a
ld [hl-], a
inc c
rlca
ld [bc], a
ld [hl+], a
dec de
ld [bc], a
ld [de], a
rra
ld [bc], a
ld [bc], a
ld b, b
nop
rlca
rlca
ld [bc], a
ld hl, $0211
ld [hl-], a
rrca
ld c, l
ld [bc], a
sub d
rra
ld c, l
ld [bc], a
jp nc, $1b1f
ld b, b
ld [bc], a
nop
ld bc, $0000
rrca
nop
inc b
nop
inc d
rlca
nop
nop
rrca
ld c, l
nop
ld h, b
rrca
ld c, l
nop
and b
rrca
rrca
ld [bc], a
nop
ld [bc], a
dec de
nop
sub d
inc c
inc bc
nop
ld [hl+], a
dec de
nop
ld [de], a
rra
dec e
nop
sub b
ld [$8e00], sp
rrca
dec b
nop
ld h, [hl]
rra
dec c
nop
add [hl]
rrca
ld c, l
nop
add $1f
daa
add b
ld [bc], a
dec b
rst $38
ld h, b
rst $38
sub b
rst $08
adc b
rst $00
add h
db $e3
ld b, d
pop af
ld hl, $10f8
db $fc
ld [$0cff], sp
rst $38
ld [de], a
di
ld [hl+], a
db $e3
ld b, d
rst $00
add h
jr_03f_40d0:
adc a
ld [$101f], sp
ccf
jr_03f_40d5:
jr nz, jr_03f_40d5
inc b
dec b
jr nz, jr_03f_40e3
jr_03f_40db:
rst $38
inc bc
ld a, a
ld b, b
dec b
jr nc, @+$0a
rst $38
jr_03f_40e3:
add b
rst $38
rlca
rst $38
jr @-$06
jr nz, jr_03f_40db
jr nz, jr_03f_40d0
ld b, e
rst $20
ld b, h
dec b
ld c, d
nop
rst $38
ret nz
rst $38
jr nc, jr_03f_4107
ld [$080f], sp
add a
add h
dec b
ld c, d
ld [bc], a
dec b
ld c, d
ld [bc], a
db $e3
ld b, e
ldh a, [rNR41]
jr_03f_4107:
ld hl, sp+$20
rst $38
jr @+$01
rlca
dec b
ld c, d
ld [bc], a
add a
add h
dec b
ld d, h
nop
rst $38
jr nc, @+$01
ret nz
rst $38
jr c, @+$01
dec b
ld e, e
rlca
rst $20
ld b, h
dec b
add b
inc c
dec b
ld h, b
ld [$05fe], sp
ld l, l
dec bc
ccf
dec b
ld a, l
nop
ld h, b
rst $38
sub b
rst $18
dec b
jp $9102
rst $08
adc d
rst $28
ld c, d
rst $38
ld b, $ff
add hl, bc
db $fd
dec b
db $d3
ld [bc], a
adc c
ld sp, hl
ld d, c
ld a, e
ld d, d
rst $28
ld c, d
rst $28
ld c, d
and $44
ldh a, [rNR41]
pop af
ld hl, $22f3
rst $38
ld [hl+], a
rst $38
inc e
ld a, e
ld d, d
ld a, e
ld d, d
inc sp
ld [hl+], a
rlca
inc b
add a
add h
rst $00
ld b, h
rst $00
dec b
adc a
nop
inc bc
rst $38
dec b
ld hl, $800a
rst $38
dec b
ld sp, $0509
jr nz, @+$11
ld c, $3c
rst $38
ld b, d
db $e3
ld b, d
pop hl
ld b, c
pop hl
ld b, c
ldh [rLCDC], a
ldh [rLCDC], a
and $44
rst $38
ld c, $ff
ld de, $05f9
ld d, e
ld [de], a
sub c
ld sp, hl
sub c
ld a, c
ld d, c
and $44
rst $20
ld b, [hl]
rst $20
ld b, [hl]
rst $20
ld b, l
rst $20
ld b, l
dec b
adc h
ld [bc], a
ld a, c
ld d, c
add hl, sp
ld sp, $3139
sbc c
ld de, $0181
pop bc
add c
pop bc
add c
rst $38
ld a, [hl]
dec b
nop
dec e
ret nz
cp a
jr nz, jr_03f_41f5
dec b
sub e
rla
rst $38
ld [bc], a
rst $38
ld [bc], a
rst $38
ld bc, $00ff
rst $38
ld bc, $a005
ld [de], a
dec b
ld a, [hl-]
inc bc
nop
dec b
db $10
ld [de], a
rst $38
add b
rst $38
inc e
rst $38
ld [hl+], a
di
dec b
jp $ff17
nop
dec b
ret nc
ld a, [de]
dec b
call nz, $f112
ld hl, $20f1
ldh a, [rNR41]
ldh a, [rNR41]
rst $38
rra
dec b
ret nc
inc de
db $fc
rst $38
ld [bc], a
inc bc
ld [bc], a
inc bc
ld [bc], a
rst $38
db $fc
jr_03f_41f5:
rst $38
rlca
cp $08
ld hl, sp+$10
di
inc hl
rst $30
inc h
rst $30
inc h
di
inc hl
ldh a, [rNR41]
rst $38
ldh [$1f], a
db $10
rrca
ld [$c4c7], sp
rst $20
inc h
rst $38
jr @+$01
jr_03f_4212:
ret nz
ccf
jr nc, jr_03f_4212
db $10
rst $38
rrca
rst $38
jr_03f_421a:
nop
rst $38
inc e
rst $38
inc hl
di
jr nz, jr_03f_421a
jr @+$01
rlca
dec b
inc d
jr nz, @+$07
ld [$e720], sp
call nz, $04c7
rra
jr @+$01
ldh [rIE], a
rra
rst $38
jr nz, @-$0e
jr nz, jr_03f_423f
ld b, $24
di
jr nz, @+$01
jr_03f_423f:
ld hl, sp-$01
inc b
rlca
inc b
rst $38
ld hl, sp+$05
ret nc
ld de, $fff0
ld [$4405], sp
jr z, @+$07
db $ec
db $10
rrca
ld [$f0ff], sp
dec b
ret nc
ld de, $5105
inc hl
nop
inc b
dec b
inc b
dec b
nop
rrca
nop
dec b
db $f4
rst $38
ld c, l
dec b
ld d, h
rrca
ld c, l
dec b
or h
rrca
ld c, l
dec b
inc d
rra
ld c, l
dec b
ld [hl], h
rra
ld c, l
dec b
call nc, Call_03f_4d1f
dec b
inc [hl]
cpl
ld c, l
dec b
sub h
cpl
ld c, l
dec b
call nc, $1f2f
ld [bc], a
ld [bc], a
dec b
ld b, d
ld [hl], $05
jp nc, $002f
inc bc
ld bc, $0101
ld bc, $0303
ld bc, $0301
dec b
rst $08
cpl
nop
ld [bc], a
ld [bc], a
ld [bc], a
dec b
ld l, c
ld [hl-], a
inc bc
inc bc
inc bc
ld bc, $0502
ld b, [hl]
jr nc, jr_03f_42b3
call nc, $0529
ld h, l
inc sp
jr_03f_42b3:
dec b
and [hl]
ld [hl-], a
dec b
ld h, [hl]
ld sp, $d305
add hl, hl
dec b
add h
jr nc, jr_03f_42c5
jp nz, $013a
ld [bc], a
dec b
jr_03f_42c5:
call nc, $0528
and h
ld [hl], $05
and [hl]
ld [hl], $05
and b
ld hl, sp+$00
inc b
ld bc, HeaderLogo
nop
rrca
nop
ld bc, $fff4
ld c, l
ld bc, $0f54
ld c, l
ld bc, $0fb4
ld c, l
ld bc, $1f14
ld c, l
ld bc, $1f74
ld c, l
ld bc, $ffa0
ld c, l
ld bc, $2f53
ld c, l
ld bc, $2fb3
ld c, l
ld bc, $3f13
ld c, l
ld bc, $3f73
ld c, l
ld bc, $3fd3
add hl, de
nop
inc b
rlca
ld bc, $0007
rrca
nop
rlca
db $f4
rst $38
ld c, l
rlca
inc d
rrca
inc c
ld [bc], a
rlca
inc d
ld [$0202], sp
rlca
add h
inc c
ld [bc], a
ld b, $07
inc d
ld [$0606], sp
rlca
and c
inc bc
inc bc
inc bc
rlca
adc l
inc bc
ld b, $07
or e
dec bc
rlca
pop bc
inc bc
rlca
ret
inc bc
ld [bc], a
ld b, $07
jp nc, $070d
pop bc
inc b
rlca
db $eb
rrca
add hl, bc
rlca
jp z, $0103
ld bc, $0007
db $10
rlca
inc d
rra
inc b
rlca
jp z, $0701
jr nc, @+$1e
ld [bc], a
rlca
ld h, b
db $10
rlca
jp $0703
db $ed
inc bc
rlca
or e
add hl, bc
rlca
jr nz, @+$0e
rlca
ld [hl], b
rra
dec c
rlca
ldh a, [$0c]
rlca
jr nz, jr_03f_4374
rlca
ld [$030f], a
rlca
ret nz
jr_03f_4374:
rra
dec c
rlca
and c
dec c
rlca
pop af
inc c
rlca
and c
inc c
rlca
pop af
dec c
rlca
ld h, h
rla
rlca
dec l
cpl
ld [bc], a
rlca
ld [c], a
inc b
rlca
ld a, [bc]
rra
ld b, $07
and c
add hl, bc
rlca
ld [hl], b
cpl
ld a, [bc]
rlca
ld l, e
inc de
rlca
sub h
cpl
inc e
rlca
ld b, [hl]
daa
rlca
adc $2f
dec h
rlca
add h
ld a, [de]
rlca
inc d
ccf
dec bc
rlca
or d
rrca
inc b
rlca
ld c, c
ccf
inc b
dec b
dec b
dec b
inc b
rlca
add e
jr nc, jr_03f_43c1
rlca
adc b
jr nc, jr_03f_43c4
rlca
jr_03f_43c1:
add d
jr nc, @+$07
jr_03f_43c4:
dec b
rlca
inc d
ld [$8307], sp
ld sp, $a007
dec sp
rlca
sub h
ccf
add hl, sp
nop
inc b
ld [$0801], sp
nop
rrca
nop
ld [$fff4], sp
ld c, l
ld [$0f14], sp
nop
ld [bc], a
ld [bc], a
ld [$0086], sp
ld bc, $0301
ld [$008f], sp
ld [$0a14], sp
ld [$018f], sp
ld [$09a2], sp
ld [$0814], sp
ld [$0ea2], sp
ld [$0fb2], sp
ld c, l
ld [$0ff2], sp
dec de
ld [$0282], sp
ld [$1f46], sp
inc c
ld [$1663], sp
inc b
ld [$108f], sp
ld [$0f14], sp
ld bc, $e208
inc b
ld [$1f90], sp
inc hl
ld [$1665], sp
ld [$1d90], sp
inc b
inc b
inc b
ld [$08e2], sp
ld [$1c90], sp
ld [$108f], sp
ld [$09e2], sp
ld [$2f11], sp
nop
ld [$2c40], sp
ld [$2f34], sp
add hl, de
dec b
ld [$2f80], sp
nop
ld [$2f74], sp
ld c, l
ld [$2fd4], sp
add hl, sp
ld b, $08
ld b, b
ccf
nop
ld [$3f34], sp
add hl, de
rlca
rlca
ld [$0ce2], sp
ld b, $07
ld [$3a74], sp
ld [$3ea0], sp
ld [$3f94], sp
add hl, sp
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop