-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_038.asm
executable file
·14235 lines (13309 loc) · 157 KB
/
bank_038.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 $038", ROMX[$4000], BANK[$38]
db $38, $91
ld b, b
rst $30
ld b, b
or e
ld b, c
ld l, e
ld b, d
db $fd
ld b, d
push bc
ld b, e
xor c
ld b, h
add [hl]
ld b, l
ld a, h
ld b, [hl]
ld e, d
ld b, a
ld b, a
ld c, b
inc a
ld c, c
ld l, $4a
inc bc
ld c, e
jp hl
ld c, e
push hl
ld c, h
call z, $9c4d
ld c, [hl]
ld e, [hl]
ld c, a
ld b, l
ld d, b
inc l
ld d, c
db $10
ld d, d
rst $38
ld d, d
db $eb
ld d, e
jp $b154
ld d, l
and [hl]
ld d, [hl]
adc [hl]
ld d, a
adc l
ld e, b
adc e
ld e, c
ld [hl], e
ld e, d
ld e, h
ld e, e
jr c, jr_038_409f
inc bc
ld e, l
xor e
ld e, l
sbc [hl]
ld e, [hl]
ld a, a
ld e, a
ld a, h
ld h, b
ld e, d
ld h, c
ld d, [hl]
ld h, d
ld c, l
ld h, e
inc sp
ld h, h
db $ec
ld h, h
jp nz, $9665
ld h, [hl]
adc c
ld h, a
ld c, b
ld l, b
cpl
ld l, c
rst $20
ld l, c
cp h
ld l, d
cp c
ld l, e
and d
ld l, h
ld a, c
ld l, l
ld c, l
ld l, [hl]
cpl
ld l, a
nop
ld [hl], b
cp h
ld [hl], b
or h
ld [hl], c
and [hl]
ld [hl], d
jr z, jr_038_40ec
dec d
ld [hl], h
rst $08
ld [hl], h
ld b, d
ld [hl], l
inc bc
db $76
sbc $76
xor e
ld [hl], a
sbc h
ld a, b
ld a, b
ld a, c
ld d, h
ld a, d
jr c, jr_038_4108
dec e
ld a, h
ld bc, $007d
ld bc, $0101
rst $38
or $20
jr nz, jr_038_40ba
jr nz, jr_038_40ec
ld [hl], b
inc b
rlca
jr_038_409f:
ld a, [bc]
dec c
rla
ld a, [de]
ld [hl+], a
dec a
inc h
ccf
inc de
rra
rrca
rrca
nop
nop
ld bc, $0210
rla
ld a, [de]
ld [de], a
dec e
inc d
rra
dec bc
rrca
rlca
rlca
jr_038_40ba:
inc b
rlca
ld [$100f], sp
rra
jr nz, jr_038_4101
jr nz, jr_038_4103
db $10
ld bc, $031b
ld bc, $0032
ld bc, $0244
ld [$070f], sp
rlca
ld b, b
ret nz
ld h, b
and b
ldh a, [$50]
ld c, b
cp b
adc b
ld hl, sp+$70
ldh a, [$e0]
ldh [rP1], a
nop
ld bc, $0250
ldh a, [$50]
ld d, b
or b
sub b
ldh a, [$60]
jr_038_40ec:
ldh [$c0], a
ret nz
ld bc, $ffa0
ld c, l
ld bc, $0fcf
dec e
nop
ld bc, $0401
rlca
ld a, [bc]
dec c
rla
ld a, [de]
ld h, d
jr_038_4101:
ld a, l
add h
jr_038_4103:
rst $38
add e
rst $38
ld [hl], b
ld a, a
jr_038_4108:
rrca
rrca
ld bc, $0002
ld [de], a
dec e
inc h
ccf
ld b, e
ld a, a
ld b, b
ld a, a
jr nc, jr_038_4156
rrca
rrca
ld bc, $f0fc
ld b, c
ld b, c
db $e3
and d
ld b, c
ld b, c
ld [$1c08], sp
inc d
dec bc
dec bc
inc b
inc b
ld c, $0a
inc b
inc b
add b
add b
nop
nop
ld bc, $0030
call nz, $20c4
jr nz, jr_038_41aa
ld d, b
ld hl, $0321
ld [bc], a
ld b, c
ld b, c
db $e3
and e
ld b, h
ld b, a
ld [$100f], sp
db $10
jr c, jr_038_4173
db $10
db $10
jr_038_414d:
add b
add b
ld [bc], a
ld [bc], a
rst $00
push bc
ld [hl+], a
ld [c], a
db $10
jr_038_4156:
ldh a, [rSB]
jr nz, jr_038_4169
dec l
inc b
rlca
ld [$080f], sp
rrca
jr nc, jr_038_41a2
ld b, b
ld a, a
ld b, b
ld a, a
jr c, @+$41
jr_038_4169:
rlca
rlca
jr nz, jr_038_414d
ld d, b
or b
add sp, $58
ld b, h
cp h
jr_038_4173:
add h
db $fc
ld a, h
db $fc
inc c
db $fc
ldh a, [$f0]
ld bc, $00a2
ld [$110f], sp
rra
jr nz, jr_038_41c3
jr nz, jr_038_41c5
jr jr_038_41a7
rlca
rlca
ld d, b
or b
ldh a, [$50]
ld d, b
or b
jr_038_4190:
ld [$fcf8], sp
db $fc
inc b
db $fc
jr jr_038_4190
ldh [$e0], a
ld bc, $00a0
db $10
rra
ld h, b
ld a, a
add b
jr_038_41a2:
rst $38
add b
ld bc, $010b
jr_038_41a7:
ld bc, $00e2
jr_038_41aa:
db $10
rra
jr nz, jr_038_41af
and a
jr_038_41af:
ld bc, $1c01
nop
nop
ld bc, $0102
ld bc, $1717
dec e
rra
dec de
ld d, $1e
ld de, $171f
ld a, [de]
jr_038_41c3:
dec e
daa
jr_038_41c5:
ld a, [hl-]
ld [bc], a
cp $fa
ld a, [hl-]
dec a
ld a, [hl+]
dec a
jr_038_41cd:
ld c, h
ld a, a
ld e, a
ld a, e
ld b, a
ld a, h
ld b, e
ld a, a
jr nz, jr_038_4216
jr jr_038_41f8
rlca
rlca
ld b, a
ld a, d
adc d
db $fd
adc h
rst $38
sbc a
ei
add a
db $fc
ld b, e
ld a, a
jr nc, jr_038_4228
rrca
rrca
nop
nop
dec bc
dec bc
ld c, $0f
dec c
dec bc
rrca
ld [$0f0f], sp
db $10
jr_038_41f8:
rra
db $10
rra
add b
add b
add sp, -$18
cp b
ld hl, sp-$28
ld l, b
jr c, jr_038_41cd
ld hl, sp-$08
inc d
db $ec
inc a
call nc, $3f20
ld [bc], a
ld h, b
ld [bc], a
ld [bc], a
ld c, h
nop
inc c
rrca
inc bc
jr_038_4216:
inc bc
ld d, d
xor $62
cp $7e
sbc $fe
ld [c], a
ld e, $fe
inc b
db $fc
jr @-$06
ldh [$e0], a
ld [bc], a
jr_038_4228:
db $fc
ldh a, [rSC]
ld b, d
inc b
rra
rra
jr nz, jr_038_4270
nop
nop
ld [bc], a
ld d, b
ld a, [bc]
ld b, b
ld a, a
ld [bc], a
and b
ld [bc], a
ld [bc], a
ld h, b
nop
ld [bc], a
inc l
nop
inc a
call nc, $7002
ld b, $0c
db $fc
ldh a, [$f0]
ld [bc], a
nop
ld b, $1e
dec e
inc de
ld [bc], a
adc l
ld bc, $c002
ld [$3f33], sp
jr nz, jr_038_4299
ld [bc], a
and b
ld b, $02
inc l
nop
ld b, b
ld a, a
add b
rst $38
ld [bc], a
ld a, [c]
ld [bc], a
ld b, b
ld [bc], a
dec sp
ld bc, $0100
ld bc, $7070
jr_038_4270:
ld sp, hl
ret
rst $38
or [hl]
rst $38
cp d
cp $b5
ld a, e
ld l, a
ld [hl], d
ld e, l
rst $30
sbc d
ld [$ecbd], a
cp a
rst $38
cp e
ld [hl], a
ld e, h
inc a
cpl
rra
inc de
rrca
inc c
inc bc
inc bc
inc a
inc a
ld a, [hl]
ld h, d
ld a, a
ld c, l
rst $38
sbc [hl]
rst $38
sbc l
rst $38
jr_038_4299:
cp b
rst $38
or c
ld a, a
ld h, c
nop
nop
db $10
db $10
jr c, jr_038_42cc
ld hl, sp-$18
ld hl, sp+$48
ret z
cp b
ld a, b
ld hl, sp+$14
db $ec
ld a, a
ld d, c
ld d, c
ld a, a
ld l, a
ld [hl], c
ld [hl], a
ld c, c
dec sp
dec h
dec e
inc de
ld c, $09
rlca
rlca
inc a
call nc, $ee52
ld h, d
cp $7e
sbc $7e
ld [c], a
ld e, [hl]
cp $8c
db $fc
jr_038_42cc:
ldh a, [$f0]
ld bc, $0b20
ld [hl], c
ld bc, $0630
ld hl, sp-$58
ld bc, $003c
ld [hl], c
ld [hl], c
ei
jp z, $b6fd
rst $38
sbc a
rst $38
call nz, Call_038_727f
ld a, a
ld e, c
rst $38
adc [hl]
add [hl]
rst $38
rst $38
add e
ei
add l
ld [hl], a
ld c, b
cpl
jr nc, jr_038_4314
db $10
ld bc, $001c
ld bc, $ffa0
ld c, l
nop
Jump_038_42fe:
ld bc, $0003
nop
ld e, $1e
add hl, bc
rrca
rlca
rlca
dec e
rra
add hl, hl
ccf
ld e, l
ld [hl], a
rst $38
ei
inc bc
db $fc
ld a, [c]
ret nz
jr_038_4314:
ret nz
ld [hl], b
ldh a, [$28]
ld hl, sp+$74
call c, $befe
inc l
jr_038_431e:
ccf
ld d, $1b
rla
ld e, $18
rra
inc a
daa
dec sp
dec sp
inc bc
ld a, [$01f4]
ld bc, $f3f3
ld c, l
ld a, a
add hl, hl
ccf
dec e
rla
rra
dec de
nop
nop
ldh a, [$f0]
jr_038_433c:
jr nz, jr_038_431e
sbc $de
ld h, h
db $fc
jr z, jr_038_433c
ld [hl], b
ret nc
ldh a, [$b0]
nop
nop
ld [$1c08], sp
inc d
rrca
dec bc
dec e
rra
dec h
ccf
ld c, c
ld a, a
pop af
rst $38
inc h
ccf
inc h
ccf
ld [de], a
rra
dec a
dec h
jr c, jr_038_439a
inc bc
db $fc
ld a, [c]
cp b
ld hl, sp+$7e
cp $18
ld hl, sp-$08
add sp, $03
ld l, b
inc b
inc bc
ld d, b
ld [bc], a
rst $38
ei
ld c, l
ld a, a
dec [hl]
ccf
add hl, de
rra
ld de, $081f
ld [$1818], sp
jr z, jr_038_43bb
ld d, e
ld [hl], e
ld e, l
ld a, a
ld d, d
ld a, a
inc [hl]
ccf
jr c, jr_038_43cc
nop
nop
ld h, b
ld h, b
ld [hl], b
ld d, b
cp b
xor b
ld [hl], h
db $fc
ld b, d
cp $02
jr_038_439a:
cp $59
rst $28
dec h
ccf
ld c, a
ld a, a
ld a, b
ld c, b
inc bc
ld a, b
ld b, $4e
cp $21
rst $38
cp $9e
ld [hl], b
ld [hl], b
inc bc
ld a, [$3cf4]
inc a
sub d
sbc [hl]
ret
rst $08
and [hl]
rst $20
sbc b
rst $38
jr_038_43bb:
ld b, b
ld a, a
jr nz, @+$41
inc h
ccf
inc bc
and b
rst $38
dec c
nop
ld bc, $0001
nop
inc b
inc b
jr_038_43cc:
ld b, $06
dec d
rla
dec e
rra
rra
rra
add hl, de
rra
dec l
ccf
nop
nop
ld a, b
ld a, b
ldh [$e0], a
ld d, b
ret nc
ld [hl], b
ldh a, [$f0]
ldh a, [$30]
ldh a, [rBCPS]
ld hl, sp+$4a
ld a, a
call nz, $fcff
rst $38
ld b, a
ld a, [hl]
ld a, a
ld a, c
ld c, a
ld a, a
ld e, b
ld l, b
jr c, @+$3a
and h
db $fc
ld e, h
db $fc
ld h, [hl]
cp $fe
sbc [hl]
ld [c], a
ld a, $fa
or $1e
ld e, $01
ld a, [$0ef4]
ld c, $18
jr jr_038_447e
ld [hl], b
ld d, b
ld [hl], b
or a
rst $30
ld bc, $f0fe
jr nz, jr_038_4438
jr nc, jr_038_444a
xor b
cp b
add sp, -$08
db $fc
db $fc
ld a, [c]
cp $b8
rst $38
rst $28
rst $38
ld a, [c]
rst $38
ld c, a
ld a, a
ld [hl], b
ld a, a
sbc a
rst $28
cp [hl]
sbc $60
ld h, b
ld a, d
cp $ff
rst $28
ld [hl], c
rst $38
jr_038_4438:
pop de
rst $38
dec sp
db $fd
adc $fe
db $e4
call c, $3c3c
ld bc, $f0fe
jr @+$1a
jr nc, jr_038_4479
ld h, b
jr_038_444a:
ld h, b
ld h, b
ld h, b
and b
ldh [$97], a
rst $30
ld bc, $0852
ld [hl], d
ld a, [hl]
ld a, [$b8fe]
rst $38
and a
rst $38
db $f4
ld bc, $0165
rst $08