-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_037.asm
executable file
·15269 lines (13686 loc) · 163 KB
/
bank_037.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 $037", ROMX[$4000], BANK[$37]
scf
ld a, c
ld b, b
ld c, $44
xor e
ld b, h
ld h, a
ld b, l
push af
ld b, l
and h
ld b, [hl]
sbc h
ld b, a
ld e, e
ld c, b
jp c, $8548
ld c, c
ld e, c
ld c, d
xor $4d
adc b
ld c, [hl]
inc c
ld c, a
ret nc
ld c, a
sub c
ld d, b
inc a
ld d, c
ld sp, hl
ld d, c
xor e
ld d, d
ld l, h
ld d, e
jr nz, jr_037_407f
or l
ld d, a
dec h
ld e, b
or l
ld e, b
dec [hl]
ld e, c
xor l
ld e, c
dec [hl]
ld e, d
xor e
ld e, d
ld [de], a
ld e, e
and l
ld e, e
dec l
ld e, h
db $f4
ld e, [hl]
or d
ld e, a
ld a, h
ld h, b
ld d, d
ld h, c
inc e
ld h, d
ld [c], a
ld h, d
xor [hl]
ld h, e
ld e, [hl]
ld h, h
scf
ld h, l
dec c
ld h, [hl]
call nc, $9768
ld l, c
ld h, [hl]
ld l, d
inc l
ld l, e
rst $28
ld l, e
and $6c
xor b
ld l, l
ld [hl], d
ld l, [hl]
ld c, c
ld l, a
jr z, jr_037_40d7
rst $28
ld [hl], d
cp h
ld [hl], e
and e
ld [hl], h
add hl, sp
ld [hl], l
rrca
db $76
call c, $9876
ld [hl], a
ld h, h
ld a, b
ld b, l
ld a, c
nop
ld [$7f02], sp
ld a, a
adc b
jr_037_407f:
rst $20
adc b
rst $20
ret nc
ret nc
ld hl, sp-$7a
ret nz
cp [hl]
ret nz
cp [hl]
ret nz
ret nz
rst $38
rst $38
ld [$08e7], sp
rst $20
jr @+$1a
cp $01
add b
ld a, a
add b
ld a, a
nop
nop
ld [bc], a
db $10
ld [bc], a
nop
nop
ld a, b
ld b, $40
jr_037_40a4:
ld a, $40
ld a, $38
jr c, @+$01
rst $38
jr jr_037_40a4
ld [$01e7], sp
ld bc, $1802
ld [bc], a
db $10
db $10
ld [bc], a
db $10
ld [bc], a
add b
add b
ld [bc], a
jr z, jr_037_40be
jr_037_40be:
ld b, c
ccf
ld bc, $fe01
cp $09
rst $20
add hl, bc
rst $20
inc bc
inc bc
rst $38
ld bc, $7f81
add c
ld a, a
add e
add e
cp $81
ret nz
cp a
add b
jr_037_40d7:
add b
rst $38
rst $38
rst $38
rst $38
or b
or b
sub b
sub b
sub b
ret c
ld a, a
nop
ld b, b
ccf
ld [bc], a
ld h, h
ld [bc], a
db $10
db $10
db $10
jr jr_037_40fe
jr @+$04
ld [hl], b
ld c, $00
ld a, a
ld [bc], a
ld [hl], h
rrca
add hl, bc
ld a, l
inc bc
ld b, c
ccf
add c
add c
jr_037_40fe:
ld [bc], a
ld h, [hl]
nop
ld de, $1111
add hl, de
ld de, $0219
nop
ld [bc], a
ret nz
ret nz
ld [bc], a
ld [$c302], sp
jp Jump_037_5002
ld [bc], a
ld bc, $0201
ld e, b
ld [bc], a
add c
add c
rst $08
and b
ld [bc], a
ld [bc], a
nop
jp $f9c3
add a
ld [bc], a
ld a, [bc]
ld [bc], a
rst $08
ld hl, $5202
nop
add c
add c
ld [bc], a
ld e, b
ld [bc], a
inc bc
inc bc
ld [bc], a
ldh [rSC], a
pop bc
pop bc
ld [bc], a
ld [$8002], sp
add b
rst $08
jr nz, jr_037_4142
ld [de], a
nop
jr_037_4142:
sub b
sub b
ld [bc], a
jr jr_037_414b
rst $18
jr nc, jr_037_414c
ld [de], a
jr_037_414b:
nop
jr_037_414c:
inc bc
inc bc
ld a, c
rlca
ld [bc], a
ld a, [hl+]
nop
nop
nop
ld [bc], a
db $10
ld [de], a
nop
nop
ld [bc], a
jr jr_037_4161
ld [bc], a
db $10
ld [de], a
db $10
jr_037_4161:
db $10
ld [bc], a
ld c, b
ld [bc], a
inc bc
inc bc
ld [bc], a
ldh a, [rSC]
ld de, $0211
ld e, b
ld [bc], a
ld bc, $b001
ld hl, sp-$01
rst $38
add b
cp b
add b
ldh [$80], a
ret nz
add b
ret nz
add c
pop bc
ld a, a
ld a, a
ld sp, $ff39
rst $38
add c
cp a
add c
pop hl
add c
pop bc
add c
pop bc
add e
jp $ffff
jr nc, jr_037_41cb
rst $38
rst $38
add b
cp [hl]
ld [bc], a
ld h, [hl]
ld d, $02
add b
ld a, [de]
ld [bc], a
ld a, [hl]
inc e
rst $38
rst $38
inc de
dec de
ld [bc], a
ld [hl], d
jr_037_41a6:
jr jr_037_41a6
cp $02
ldh [rSC], a
ld [bc], a
add $04
add c
add c
ld [bc], a
ldh a, [rP1]
add hl, de
rst $30
ld sp, $0231
ld e, b
inc d
ld [bc], a
jr_037_41bc:
ret nz
ld a, [de]
add b
add b
ld [bc], a
ldh a, [rSC]
add hl, sp
add hl, sp
ld [bc], a
ld e, b
inc d
cp $81
add b
jr_037_41cb:
rst $38
ld [bc], a
ld h, h
ld [bc], a
ld [bc], a
ld l, h
nop
sub b
ret c
ccf
ld b, c
ld bc, $027f
or h
ld [$6002], sp
ld de, $8502
rla
inc sp
dec sp
ld [bc], a
or d
jr_037_41e5:
rra
add hl, bc
ret nz
ret nz
ld [bc], a
db $10
db $10
jr jr_037_41e5
jr nc, jr_037_4220
ld [bc], a
jr c, jr_037_4208
ld [bc], a
pop hl
inc bc
ld [bc], a
ld [$801a], sp
add b
ld [bc], a
jr c, jr_037_4218
ld [bc], a
add $00
ld [bc], a
ld a, [hl+]
ld d, $18
rst $30
db $10
db $10
jr_037_4208:
ld [bc], a
jr c, jr_037_4225
ld [$0208], sp
ld [hl], b
nop
ld b, b
ccf
ld [bc], a
ld l, $14
jr c, jr_037_424f
cp [hl]
jr_037_4218:
ld bc, $9f20
jr nz, jr_037_41bc
ld [bc], a
ld l, $14
jr_037_4220:
ld [bc], a
ld h, $12
ret nz
cp [hl]
jr_037_4225:
ret c
ret c
rst $18
ld sp, $5202
nop
add e
add e
ld [bc], a
ld hl, sp+$05
ld [bc], a
jr_037_4232:
ld sp, $0213
ld c, b
ld a, [de]
jp $02c3
ld e, b
inc d
sbc l
ld h, d
cp h
ld b, e
dec c
ld a, [c]
ld [hl], c
adc [hl]
db $76
adc c
ld c, $f1
xor $11
db $ed
ld [de], a
db $e3
inc e
inc l
jr_037_424f:
db $d3
adc l
ld [hl], d
db $e3
inc e
rst $00
jr c, jr_037_4232
inc h
add hl, sp
add $d6
add hl, hl
inc de
db $ec
ld d, a
xor b
ld e, b
and a
adc e
ld [hl], h
ld h, a
sbc b
ld l, a
sub b
or a
ld c, b
adc b
ld [hl], a
adc $31
or h
ld c, e
dec sp
call nz, Call_037_48b7
ret nz
ccf
db $db
inc h
dec de
db $e4
push hl
ld a, [de]
di
inc c
jp $053c
ld a, [$837c]
ld a, l
add d
jr_037_4286:
ld a, [hl]
add c
cp b
ld b, a
add e
ld a, h
adc a
ld [hl], b
ld l, a
sub b
adc h
ld [hl], e
db $10
rst $28
rst $30
ld [$04fb], sp
ei
inc b
ld h, c
sbc [hl]
cp e
ld b, h
ret c
daa
sbc a
ld h, b
inc c
di
ld h, b
sbc a
rst $28
db $10
rst $30
ld [$08f7], sp
dec b
ld a, [$817e]
and [hl]
ld e, c
ld d, $e9
cp b
ld b, a
jp $df3c
jr nz, @-$0f
db $10
ld [bc], a
ld b, b
inc a
rst $28
db $10
rst $28
db $10
ld [bc], a
ld d, h
jr c, jr_037_4286
ld b, b
rst $18
jr nz, jr_037_42cd
ld h, h
inc a
jr_037_42cd:
cp [hl]
ld b, c
ld a, $c1
ld [bc], a
ld a, b
inc [hl]
ld a, a
ld a, a
add b
rst $38
sbc a
rst $18
and b
rst $28
xor a
rst $38
xor d
db $fd
and l
or $a2
di
cp $fe
ld bc, $f9ff
ld sp, hl
dec b
db $fd
add hl, bc
add hl, bc
sub c
sub c
ld c, c
reti
and l
ld l, l
and e
ld a, [c]
and a
db $f4
xor [hl]
ld sp, hl
xor a
rst $38
and b
ldh [$9f], a
rst $18
add b
ret nz
ld a, a
ld a, a
and l
ld h, l
ld c, c
ret
sub c
sub c
add hl, bc
add hl, de
dec b
dec c
ld sp, hl
ld sp, hl
ld [bc], a
ld c, [hl]
nop
jr_037_4313:
ld [bc], a
ret nz
inc sp
rst $38
sub b
ret nc
adc c
ret
sub e
jp c, $f4a7
cp $fe
ld bc, $fdfd
db $fd
dec b
push af
push af
push af
push de
dec [hl]
and l
ld h, l
ld b, l
push bc
and l
and $92
db $d3
adc c
ret
sub b
ret c
and b
ldh a, [rSC]
ld [$4532], a
push bc
and l
ld h, l
ld d, l
or l
push af
push af
dec b
dec b
ld [bc], a
ld a, [$ac3a]
db $fc
xor [hl]
ld a, [$f9af]
xor e
db $fc
ld [bc], a
db $10
ld b, b
ld sp, hl
ld sp, hl
dec b
push af
dec [hl]
dec [hl]
ld [hl], l
ld d, l
push de
or l
push de
dec [hl]
ld [bc], a
call z, $a130
pop af
and h
or $aa
ei
sub c
pop de
ld [bc], a
db $ec
ld [hl-], a
ld b, l
push bc
add l
add l
dec h
dec [hl]
ld d, l
ld e, l
adc c
adc c
ld [bc], a
db $fc
inc [hl]
sub c
pop de
xor d
ei
and h
or $a1
pop af
ld [bc], a
ldh [$30], a
ld [bc], a
ret nc
jr nc, jr_037_4313
adc c
ld d, l
ld e, l
dec h
dec [hl]
add l
add l
ld [bc], a
jr nc, jr_037_43d4
xor [hl]
ld sp, hl
xor l
ei
xor d
cp $ac
db $fc
ld [bc], a
add sp, $34
push de
dec [hl]
push af
sub l
ld [hl], l
ld d, l
dec [hl]
dec [hl]
dec b
dec b
db $fd
db $fd
ld [bc], a
ld c, [hl]
nop
ldh a, [rIF]
jp $8e33
ld l, [hl]
sbc e
ld e, e
dec a
cp l
scf
or a
ld a, e
ei
dec a
cp l
rrca
ldh a, [rSCX]
ld c, h
pop af
or $f9
ld a, [$dddc]
or h
or l
ld l, [hl]
ld l, a
ld a, [$5ffb]
rst $18
db $76
or $2d
xor l
jr_037_43d4:
dec sp
cp e
sbc a
ld e, a
adc a
ld l, a
jp nz, $f032
rrca
cp h
cp l
sbc $df
db $ec
db $ed
cp h
cp l
reti
jp c, $7671
jp $0fcc
ldh a, [rSC]
and b
rst $38
ld c, l
ld [bc], a
ld e, a
ld e, a
ld c, l
ld [bc], a
cp a
ld e, a
ld c, l
ld [bc], a
rra
ld l, a
ld c, l
ld [bc], a
ld a, a
ld l, a
ld c, l
ld [bc], a
rst $18
ld l, a
ld c, l
ld [bc], a
ccf
ld a, a
ld c, l
ld [bc], a
sbc a
ld a, a
ld c, l
nop
ld [bc], a
inc b
jr z, jr_037_443c
inc b