-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_015.asm
executable file
·12472 lines (11623 loc) · 127 KB
/
bank_015.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 $015", ROMX[$4000], BANK[$15]
dec d
add hl, bc
ld b, b
or e
ld b, d
cp h
ld b, [hl]
ld h, c
ld d, h
ld hl, sp+$00
ld a, l
ld [$da7b], a
ld a, h
ld [$da7c], a
xor a
ld hl, $c8da
ld bc, $0008
call $12c7
xor a
ld hl, $c827
ld bc, $0012
call $12c7
ld hl, $99c1
ld a, l
ld [$c83e], a
ld a, h
ld [$c83f], a
xor a
ld hl, $c8d2
ld bc, $0008
call $12c7
call $1264
xor a
ld [$c8c7], a
ld a, [$c88b]
rst $00
ld c, a
ld b, b
and b
ld b, b
ld [hl], d
ld b, c
jr @+$44
ld hl, $c817
ld [hl], $00
inc hl
ld [hl], $00
ld hl, $0801
rst $10
ld hl, $5f02
rst $10
ld a, $fc
call $1688
ld a, $07
ldh [$b5], a
ld a, $ff
ldh [$b6], a
ld a, $00
ldh [$bb], a
ld a, $00
ldh [$b7], a
xor a
ld [$c8a4], a
ld [$c8a5], a
xor a
ld [$c892], a
ld a, $00
ld [$c865], a
ld a, $00
ld [$c866], a
ld [$c86c], a
ld [$c86d], a
xor a
ld [$c863], a
ld [$c864], a
ld a, $03
ld [$c8a1], a
ld a, $01
jp $11cb
ld a, $02
call $1c89
call $1013
ld hl, $c817
ld [hl], $00
inc hl
ld [hl], $00
ld hl, $0801
rst $10
ld hl, $1709
rst $10
ld hl, $170a
rst $10
ld a, $fc
call $1688
ld hl, $ff8a
ld bc, $0021
xor a
call $12c7
ld hl, $c8ea
ld bc, $1100
xor a
call $12c7
ld a, $04
ld [$c8ee], a
call Call_015_60c4
ld de, $2e1e
ld hl, $9000
call $14cf
ld de, $2e1f
ld hl, $8800
call $14cf
ld de, $2e20
ld hl, $8a00
call $14cf
ld de, $2e00
ld hl, $8d00
call $14cf
ld hl, $8b00
ld de, $1202
call $098f
ld hl, $c8da
ld bc, $0008
ld a, $00
call $12c7
xor a
ld hl, $c8d2
ld bc, $0008
call $12c7
ld hl, $9800
ld a, l
ld [$c8d6], a
ld a, h
ld [$c8d7], a
call Call_015_5e70
ld a, $24
call $1ae1
ld a, $07
ldh [$b5], a
ld a, $ff
ldh [$b6], a
ld a, $00
ldh [$bb], a
ld a, $00
ldh [$b7], a
xor a
ld [$c8a4], a
ld [$c8a5], a
xor a
ld [$c892], a
ld a, $00
ld [$c865], a
ld a, $00
ld [$c866], a
xor a
ld [$c864], a
ld [$c86c], a
ld [$c86d], a
xor a
ld [$c863], a
ld [$c864], a
ld a, $03
ld [$c8a1], a
ld a, $09
jp $11cb
ld hl, $c817
ld [hl], $00
inc hl
ld [hl], $00
ld hl, $0801
rst $10
ld a, $fc
call $1688
ld a, $04
ld [$c8ee], a
call Call_015_60c4
ld de, $2e1e
ld hl, $9000
call $14cf
ld de, $2e1f
ld hl, $8800
call $14cf
ld de, $2e20
ld hl, $8a00
call $14cf
ld de, $2e00
ld hl, $8d00
call $14cf
ld hl, $8b00
ld de, $1202
call $098f
ld hl, $c8da
ld bc, $0008
ld a, $00
call $12c7
xor a
ld hl, $c8d2
ld bc, $0008
call $12c7
ld hl, $9800
ld a, l
ld [$c8d6], a
ld a, h
ld [$c8d7], a
call Call_015_5e70
ld hl, $c0d8
ld bc, $0017
ld a, $ff
call $12c7
ld a, $24
call $1ae1
ld a, $07
ldh [$b5], a
ld a, $ff
ldh [$b6], a
ld a, $00
ldh [$bb], a
ld a, $00
ldh [$b7], a
xor a
ld [$c8a4], a
ld [$c8a5], a
xor a
ld [$c892], a
xor a
ld [$c873], a
xor a
ld [$c86e], a
ld a, $03
ld [$c8a1], a
ld a, $09
jp $11cb
ld hl, $c817
ld [hl], $00
inc hl
ld [hl], $00
ld hl, $0801
rst $10
ld a, $fc
call $1688
ld a, $04
ld [$c8ee], a
call Call_015_60c4
ld de, $2e1e
ld hl, $9000
call $14cf
ld de, $2e1f
ld hl, $8800
call $14cf
ld de, $2e20
ld hl, $8a00
call $14cf
ld de, $2e00
ld hl, $8d00
call $14cf
ld hl, $8b00
ld de, $1202
call $098f
ld hl, $c8da
ld bc, $0008
ld a, $00
call $12c7
xor a
ld hl, $c8d2
ld bc, $0008
call $12c7
ld hl, $9800
ld a, l
ld [$c8d6], a
ld a, h
ld [$c8d7], a
call Call_015_5e70
ld a, $24
call $1ae1
ld a, $07
ldh [$b5], a
ld a, $ff
ldh [$b6], a
ld a, $00
ldh [$bb], a
ld a, $00
ldh [$b7], a
xor a
ld [$c8a4], a
ld [$c8a5], a
xor a
ld [$c892], a
xor a
ld [$c873], a
xor a
ld [$c86e], a
ld a, $03
ld [$c8a1], a
ld a, $09
jp $11cb
ld a, [$c88b]
rst $00
ret nz
ld b, d
jp z, $9e42
ld b, [hl]
ld b, a
ld d, h
ret
ld a, $f4
call $1275
ld hl, $5f03
rst $10
ret
call Call_015_42f1
di
ld a, [$c86d]
or a
jr z, jr_015_42ef
ld a, [$c86d]
ld b, a
xor a
ld [$c86d], a
ld a, [$c88e]
or a
jr nz, jr_015_42ef
ld a, b
call $126b
jr_015_42e6:
ld a, [$c864]
and $03
cp $03
jr nz, jr_015_42e6
jr_015_42ef:
ei
ret
Call_015_42f1:
ld a, [$c8d2]
rst $00
ld bc, $4243
ld b, e
push bc
ld b, e
rst $18
ld b, e
ld [bc], a
ld b, h
dec de
ld b, h
ld a, $f4
call $1275
call Call_015_5e61
ld de, $6439
ld hl, $a002
call $20ee
or a
jr z, jr_015_4318
ld de, $6462
jr_015_4318:
call Call_015_5d74
call Call_015_5fc8
ld de, $43b2
ld hl, $a002
call $20ee
or a
jr z, jr_015_432d
ld de, $43b7
jr_015_432d:
xor a
ld [$c8df], a
ld a, [$c8da]
ld [$c8e0], a
call Call_015_6087
call Call_015_5da5
ld hl, $c8d2
inc [hl]
ret
ld a, [$c850]
or a
ld a, $f4
call nz, $1275
ret nz
ld de, $43b2
ld b, $01
ld hl, $a002
call $20ee
or a
jr z, jr_015_435f
ld de, $43b7
ld b, $04
jr_015_435f:
ld hl, $c8da
ld a, [$c8e0]
ld [$c8da], a
call Call_015_5f6a
ld a, [$c8da]
ld [$c8e0], a
ld de, $43b6
ld hl, $a002
call $20ee
or a
jr z, jr_015_4380
ld de, $43c1
jr_015_4380:
ld a, [$c8da]
and $7f
add e
ld e, a
ld a, $00
adc d
ld d, a
ld a, [de]
call $1275
ld a, [$c846]
bit 0, a
jp z, Jump_015_43b1
ld a, [$c8da]
and $7f
cp $02
jr z, jr_015_43a9
cp $03
jr z, jr_015_43a9
ld a, $59
call $1b2c
jr_015_43a9:
ld hl, $c8d2
inc [hl]
xor a
ld [$c8d3], a
Jump_015_43b1:
ret
ld hl, $ff00
rst $38
db $f4
ld hl, $6100
nop
and c
nop
pop hl
nop
rst $38
rst $38
db $f4
db $f4
ld a, [c]
di
ld a, [$c8da]
and $7f
ld b, a
ld hl, $a002
call $20ee
or a
jr nz, jr_015_43d5
inc b
jr_015_43d5:
ld a, b
rst $00
ld a, [hl+]
ld b, h
inc bc
ld b, [hl]
ld e, h
ld b, [hl]
ld a, l
ld b, [hl]
ld a, $f4
call $1275
ld a, $04
call $1688
ld a, $01
ld [$c88a], a
ld a, $00
ld [$c88b], a
ld a, $00
ld [$c88c], a
ld a, $00
ld [$c88d], a
ld hl, $c88e
inc [hl]
ret
ld a, $f4
call $1275
ld hl, $021b
call $096d
ld de, $2e07
call Call_015_5d74
call Call_015_5da5
ld hl, $c8d2
inc [hl]
ret
ld a, $f4
call $1275
ld a, [$c825]
or a
ret nz
xor a
ld [$c8d2], a
ret
ld a, $f4
call $1275
ld a, [$c8d3]
rst $00
scf
ld b, h
pop hl
ld b, l
di
call $21b2
ei
ld hl, $1700
rst $10
jr jr_015_44bc
ld a, [$c969]
or a
jr z, jr_015_44bc
ld a, [$d9e7]
or a
jr z, jr_015_44b2
ld a, $01
ld [$c8ea], a
ld a, $01
ld [$c96c], a
ld a, $00
ld [$c96d], a
ld [$c96e], a
ld hl, $00e8
ld a, l
ld [$c96f], a
ld a, h
ld [$c970], a
ld hl, $0058
ld a, l
ld [$c971], a
ld a, h
ld [$c972], a
ld a, $00
ldh [$8d], a
ld a, $02
ldh [$8f], a
ld a, $02
ldh [$8e], a
ldh a, [$8f]
add $00
ld [$d7b8], a
xor a
ld [$d7ba], a
ld [$d7bb], a
ld [$d7b6], a
ld hl, $d7b6
ld a, l
ld [$d7b4], a
ld a, h
ld [$d7b5], a
ldh a, [$8a]
ld [$d7b7], a
ld hl, $0200
rst $10
ld a, [$d7ba]
ldh [$8b], a
ld hl, $0109
rst $10
jr jr_015_44c8
jr_015_44b2:
ld a, $01
ld [$d9e7], a
di
call $2128
ei
jr_015_44bc:
ld a, [$d974]
cp $06
jr z, jr_015_44c8
ld a, $80
ld [$c8ea], a
jr_015_44c8:
ld a, [$c8eb]
bit 4, a
jr nz, jr_015_44d3
xor a
ld [$c8eb], a
jr_015_44d3:
xor a
ld [$d9e7], a
ld hl, $0103
rst $10
ld de, $ca42
ld hl, $9000
call Call_015_5e13
call Call_015_4593
ld de, $662b
call Call_015_5d74
ld a, [$cab8]
ld c, a
ld b, $00
ld hl, HeaderComplementCheck
call Call_015_5d18
call $20ad
ld a, [$cab7]
ld c, a
ld b, $00
ld hl, $0150
call Call_015_5d18
call $20ad
ld a, [$ca8d]
or a
jr z, jr_015_455d
ld hl, $cb0c
ld a, $00
call $224a
ld c, a
ld b, $00
ld hl, $01a4
call Call_015_5d18
call $2082
ld a, [$ca8d]
cp $01
jr z, jr_015_4563
ld hl, $cb0c
ld a, $01
call $224a
ld c, a
ld b, $00
ld hl, $01aa
call Call_015_5d18
call $2082
ld a, [$ca8d]
cp $02
jr z, jr_015_4569
ld hl, $cb0c
ld a, $02
call $224a
ld c, a
ld b, $00
ld hl, $01b0
call Call_015_5d18
call $2082
jr jr_015_456f
jr_015_455d:
ld hl, $0181
call Call_015_4577
jr_015_4563:
ld hl, $0187
call Call_015_4577
jr_015_4569:
ld hl, $018d
call Call_015_4577
jr_015_456f:
call Call_015_5da5
ld hl, $c8d3
inc [hl]
ret
Call_015_4577:
push hl
call Call_015_5d18
ld a, $e0
ld [hl+], a
ld [hl+], a
ld [hl+], a
ld [hl+], a
ld [hl], a
pop hl
ld a, l
add $21
ld l, a
ld a, h
adc $00
ld h, a
call Call_015_5d18
ld a, $e0
ld [hl+], a
ld [hl], a
ret
Call_015_4593:
ld hl, $cac2
ld a, $00
call $2229
ld e, l
ld d, h
ld hl, $9040
ld a, $01
call Call_015_45ca
ld hl, $cac2
ld a, $01
call $2229
ld e, l
ld d, h
ld hl, $9080
ld a, $02
call Call_015_45ca
ld hl, $cac2
ld a, $02
call $2229
ld e, l
ld d, h
ld hl, $90c0
ld a, $03
call Call_015_45ca
ret
Call_015_45ca:
ld b, a
ld a, [$ca8d]
cp b
jp nc, Jump_015_5e13
ld b, $20
jr_015_45d4:
ld a, $ff
call $1ab9
xor a
call $1ab9
dec b
jr nz, jr_015_45d4
ret
ld a, [$c846]
bit 0, a
jr z, jr_015_45f3
ld a, $59
call $1b2c
ld hl, $c8d2
inc [hl]
jr jr_015_4602
jr_015_45f3:
ld a, [$c846]
bit 1, a
jr z, jr_015_4602
ld hl, $c8d2
dec [hl]
ld hl, $c8d2
dec [hl]
jr_015_4602:
ret
ld a, $f4
call $1275
ld a, [$c8d3]
rst $00
ld [de], a
ld b, [hl]
ld [de], a
ld b, [hl]
ld [de], a
ld b, [hl]
ld hl, $ff8a
ld bc, $0021
xor a
call $12c7
ld hl, $c8ea
ld bc, $1100
xor a
call $12c7
ld a, $04
ld [$c8ee], a
xor a
ld [$c8ea], a
ld hl, $c8d2
inc [hl]
xor a
ld [$d8d7], a
ld a, $2f
ld [$c968], a
ld [$c96a], a
ld a, $00
ld [$c969], a
ld [$c96b], a
ld a, $00
ld [$ca8d], a
ld a, $ff
ld [$ca8e], a
ld a, $ff
ld [$ca8f], a
ld a, $ff
ld [$ca90], a
ret
ld a, [$c8df]
cp $ff
jr z, jr_015_466e
ld a, $00
ld [$c841], a
ld a, $f0
ld [$c86d], a
ret
jr_015_466e:
ld a, $59
call $1b2c
xor a
ld [$c86d], a
ld a, $04
ld [$c8d2], a
ret
ld a, [$c8df]
cp $ff
jr z, jr_015_468f
ld a, $00
ld [$c841], a
ld a, $f1
ld [$c86d], a
ret
jr_015_468f:
ld a, $59
call $1b2c
xor a
ld [$c86d], a
ld a, $04
ld [$c8d2], a
ret
call $047e
ld a, [$c8d2]
cp $06
jr z, jr_015_46b1
cp $14
jr z, jr_015_46b1
cp $1c
jr z, jr_015_46b1
ret
jr_015_46b1:
call Call_015_5397
call Call_015_53d3
ld hl, $1702
rst $10
ret
ld a, [$c8d2]
rst $00
ld a, [bc]
ld b, a
sbc h
ld b, a
add hl, hl
ld c, c
db $f4
ld c, c
ld sp, hl
ld c, c
ld [hl+], a
ld c, d
ldh a, [rWY]
ld b, $4b
inc a
ld c, e
ld d, b
ld c, e
ld a, b
ld c, e
adc $4b
ld [c], a
ld c, e
ld a, [bc]
ld c, h
ld a, c
ld c, h
rlca
ld c, l
xor l
ld c, l
ld a, $4e
ld b, e
ld c, [hl]
ld l, h
ld c, [hl]
ld b, b
ld c, a
ld d, [hl]
ld c, a
adc h
ld c, a
sbc h
ld c, a
db $dd
ld c, a
push af
ld c, a
dec b
ld d, b
ld [hl-], a
ld d, b
ret z
ld d, b
db $e3
ld d, b
add hl, de
ld d, c
ld c, l
ld d, c
adc a
ld d, c
sbc a
ld d, c
add [hl]
ld d, d
ld hl, $4153
ld d, e
call Call_015_4715
call Call_015_4754
ld hl, $c8d2
inc [hl]
ret
Call_015_4715:
ld de, $cac1
ld b, $00