-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_013.asm
executable file
·14199 lines (13115 loc) · 152 KB
/
bank_013.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 $013", ROMX[$4000], BANK[$13]
inc de
add hl, bc
ld b, b
ld d, b
ld b, b
xor [hl]
ld b, b
ld h, [hl]
ld [hl], e
ld a, [$cac0]
ld hl, $caca
call $223b
ld a, [hl]
ld [$da31], a
ld hl, $0301
rst $10
ld a, [$da35]
ld bc, $0129
call $1de6
ld a, l
add $e6
ld l, a
ld a, h
adc $41
ld h, a
push hl
ld a, [$cac0]
ld hl, $cb0c
call $223b
ld a, [hl]
ld b, a
add a
pop hl
add l
ld l, a
ld a, $00
adc h
ld h, a
ld a, b
add l
ld l, a
ld a, $00
Jump_013_4044:
adc h
ld h, a
ld a, [hl+]
ldh [$d5], a
ld a, [hl+]
ldh [$d6], a
ld a, [hl+]
ldh [$d7], a
ret
ld a, [$cac0]
ld hl, $cb0c
call $223b
ld a, [hl]
or a
ret z
ld a, [$cac0]
ld hl, $caca
call $223b
ld a, [hl]
ld [$da31], a
ld hl, $0301
rst $10
ld a, [$da35]
ld bc, $0129
call $1de6
ld a, l
add $e6
ld l, a
ld a, h
adc $41
ld h, a
push hl
ld a, [$cac0]
ld hl, $cb0c
call $223b
ld a, [hl]
dec a
ld b, a
add a
pop de
add e
ld e, a
ld a, $00
adc d
ld d, a
ld a, b
add e
ld e, a
ld a, $00
adc d
ld d, a
push de
ld a, [$cac0]
ld hl, $cb0e
call $223b
pop de
ld a, [de]
ld [hl+], a
inc de
ld a, [de]
ld [hl+], a
inc de
ld a, [de]
ld [hl], a
ret
ld a, [$cac0]
ld hl, $caca
call $223b
ld a, [hl]
ld [$da31], a
ld hl, $0301
rst $10
xor a
ld [$c8d0], a
ld a, [$cac0]
ld hl, $cb0c
call $223b
push hl
ld a, [$cac0]
ld hl, $cb0d
call $223b
ld a, [hl]
dec a
pop hl
cp [hl]
jr nc, jr_013_40e1
ld a, $01
ld [$c8d0], a
jr_013_40e1:
ld a, [$da3c]
call Call_013_411e
call Call_013_4163
ld [$c8ca], a
ld a, [$da3d]
call Call_013_411e
ld [$c8cb], a
ld a, [$da3e]
call Call_013_411e
call Call_013_4163
ld [$c8cc], a
ld a, [$da3f]
call Call_013_411e
ld [$c8cd], a
ld a, [$da40]
call Call_013_411e
ld [$c8ce], a
ld a, [$da41]
call Call_013_411e
ld [$c8cf], a
ret
Call_013_411e:
ld c, $63
call $1dbe
ld a, l
add $06
ld l, a
ld a, h
adc $67
ld h, a
push hl
ld a, [$cac0]
ld hl, $cb0c
call $223b
ld a, [hl]
pop hl
add l
ld l, a
ld a, $00
adc h
ld h, a
ld a, [hl]
ld [$c8cf], a
ld a, [$c8d0]
or a
jr nz, jr_013_414b
ld a, [$c8cf]
ret
jr_013_414b:
ld a, [$cac0]
ld hl, $cb0c
call $223b
ld c, [hl]
ld a, [$c8cf]
call $1dbe
ld a, $64
call $1e0d
ld a, l
inc a
ret
Call_013_4163:
ld [$c8cf], a
ld [$c8d1], a
ld a, [$c8d0]
or a
jr nz, jr_013_41a1
ld a, [$cac0]
ld hl, $cb0c
call $223b
ld a, [hl]
cp $0e
jr c, jr_013_41a1
ld b, $01
ld c, $13
ld d, $06
call Call_013_41a5
ld b, $0a
ld c, $14
ld d, $08
call Call_013_41a5
ld b, $14
ld c, $1e
ld d, $06
call Call_013_41a5
ld b, $32
ld c, $64
ld d, $05
call Call_013_41a5
jr_013_41a1:
ld a, [$c8cf]
ret
Call_013_41a5:
push de
push bc
call $12d0
ld a, [$c899]
ld l, a
ld a, [$c89a]
ld h, a
pop bc
push bc
ld a, c
call $1e0d
pop bc
add b
ld b, a
pop de
push de
push bc
ld a, [$cac0]
ld hl, $cb23
call $223b
pop bc
pop de
ld a, [hl]
cp b
ret c
ld a, [$c8d1]
ld b, a
ld a, d
call $1dfb
ld a, b
or a
jr nz, jr_013_41d9
inc a
jr_013_41d9:
ld b, a
ld a, [$c8cf]
add b
jr nc, jr_013_41e2
ld a, $ff
jr_013_41e2:
ld [$c8cf], a
ret
nop
nop
nop
ld [bc], a
nop
nop
rlca
nop
nop
rrca
nop
nop
ld e, $00
nop
ld [hl-], a
nop
nop
ld e, d
nop
nop
adc h
nop
nop
rst $10
nop
nop
ld c, d
ld bc, $f400
ld bc, $f800
ld [bc], a
nop
jr c, jr_013_4210
nop
ret z
dec b
nop
jr_013_4210:
cp h
rlca
nop
jr z, jr_013_421f
nop
inc [hl]
dec c
nop
ld [$0011], sp
call z, $0015
jr_013_421f:
ld h, $1b
nop
inc [hl]
ld hl, $0400
add hl, hl
nop
ld h, h
ld [hl-], a
nop
ld d, h
dec a
nop
call nc, $0049
db $e4
ld d, a
nop
add h
ld h, a
nop
or h
ld a, b
nop
ld [hl], h
adc e
nop
call nz, $009f
and h
or l
nop
inc d
call $1400
and $00
and h
nop
ld bc, $1cc4
ld bc, $3a74
ld bc, $59b4
ld bc, $7a84
ld bc, $9ce4
ld bc, $c0d4
ld bc, $e654
ld bc, $0d64
ld [bc], a
ld e, h
jr c, jr_013_4269
inc a
ld h, a
jr_013_4269:
ld [bc], a
inc b
sbc d
ld [bc], a
or h
ret nc
ld [bc], a
ld c, h
dec bc
inc bc
call z, $0349
inc [hl]
adc h
inc bc
add h
jp nc, $bc03
inc e
inc b
call c, $046a
db $e4
cp h
inc b
call nc, $0512
xor h
ld l, h
dec b
ld l, h
jp z, $1405
inc l
ld b, $bc
adc l
ld b, $64
rst $28
ld b, $0c
ld d, c
rlca
or h
or d
rlca
ld e, h
inc d
ld [$7604], sp
ld [$d7ac], sp
ld [$3954], sp
add hl, bc
db $fc
sbc d
add hl, bc
and h
db $fc
add hl, bc
ld c, h
ld e, [hl]
ld a, [bc]
db $f4
cp a
ld a, [bc]
sbc h
ld hl, $440b
add e
dec bc
db $ec
db $e4
dec bc
sub h
ld b, [hl]
inc c
inc a
xor b
inc c
db $e4
add hl, bc
dec c
adc h
ld l, e
dec c
inc [hl]
call $dc0d
ld l, $0e
add h
sub b
ld c, $2c
ld a, [c]
ld c, $d4
ld d, e
rrca
ld a, h
or l
rrca
inc h
rla
db $10
call z, $1078
ld [hl], h
jp c, $1c10
inc a
ld de, $9dc4
ld de, $ff6c
ld de, $6114
ld [de], a
cp h
jp nz, Jump_013_6412
inc h
inc de
inc c
add [hl]
inc de
or h
rst $20
inc de
ld e, h
ld c, c
inc d
inc b
xor e
inc d
xor h
inc c
dec d
ld d, h
ld l, [hl]
dec d
db $fc
rst $08
dec d
and h
ld sp, $0016
nop
nop
ld [bc], a
nop
nop
rlca
nop
nop
rrca
nop
nop
ld e, $00
nop
ld [hl-], a
nop
nop
ld e, d
nop
nop
adc h
nop
nop
rst $10
nop
nop
ld c, d
ld bc, $f400
ld bc, $f800
ld [bc], a
nop
jr c, jr_013_4339
nop
ret z
dec b
nop
jr_013_4339:
cp h
rlca
nop
jr z, jr_013_4348
nop
inc [hl]
dec c
nop
ld [$0011], sp
call z, $0015
jr_013_4348:
ld h, $1b
nop
inc [hl]
ld hl, $0400
add hl, hl
nop
ld h, h
ld [hl-], a
nop
ld d, h
dec a
nop
call nc, $0049
db $e4
ld d, a
nop
add h
ld h, a
nop
or h
ld a, b
nop
ld [hl], h
adc e
nop
call nz, $009f
and h
or l
nop
inc d
call $1400
and $00
and h
nop
ld bc, $1cc4
ld bc, $3a74
ld bc, $59b4
ld bc, $7a84
ld bc, $9ce4
ld bc, $c0d4
ld bc, $e654
ld bc, $0d64
ld [bc], a
ld b, h
inc a
ld [bc], a
db $f4
ld [hl], d
ld [bc], a
ld [hl], h
or c
ld [bc], a
call nz, $02f7
db $e4
ld b, l
inc bc
call nc, $039b
sub h
ld sp, hl
inc bc
inc h
ld e, a
inc b
add h
call z, $b404
ld b, c
dec b
db $e4
or [hl]
dec b
inc d
inc l
ld b, $44
and c
ld b, $74
ld d, $07
and h
adc e
rlca
call nc, $0800
inc b
db $76
ld [$eb34], sp
ld [$6064], sp
add hl, bc
sub h
push de
add hl, bc
call nz, $0a4a
db $f4
cp a
ld a, [bc]
inc h
dec [hl]
dec bc
ld d, h
xor d
dec bc
add h
rra
inc c
or h
sub h
inc c
db $e4
add hl, bc
dec c
inc d
ld a, a
dec c
ld b, h
db $f4
dec c
ld [hl], h
ld l, c
ld c, $a4
sbc $0e
call nc, $0f53
inc b
jr_013_43ee:
ret
rrca
inc [hl]
ld a, $10
ld h, h
or e
db $10
sub h
jr z, jr_013_440a
call nz, $119d
db $f4
ld [de], a
ld [de], a
inc h
adc b
ld [de], a
ld d, h
db $fd
ld [de], a
add h
ld [hl], d
inc de
or h
rst $20
jr_013_440a:
inc de
db $e4
ld e, h
inc d
inc d
jp nc, Jump_013_4414
ld b, a
dec d
Jump_013_4414:
ld [hl], h
cp h
dec d
and h
ld sp, $d416
and [hl]
ld d, $04
inc e
rla
inc [hl]
sub c
rla
ld h, h
ld b, $18
sub h
ld a, e
jr jr_013_43ee
ldh a, [rNR23]
db $f4
ld h, l
add hl, de
inc h
db $db
add hl, de
ld d, h
ld d, b
ld a, [de]
add h
push bc
ld a, [de]
nop
nop
nop
ld [bc], a
nop
nop
rlca
nop
nop
rrca
nop
nop
ld e, $00
nop
ld [hl-], a
nop
nop
ld e, d
nop
nop
adc h
nop
nop
rst $10
nop
nop
ld c, d
ld bc, $f400
ld bc, $f800
ld [bc], a
nop
jr c, jr_013_4462
nop
ret z
dec b
nop
jr_013_4462:
cp h
rlca
nop
jr z, jr_013_4471
nop
inc [hl]
dec c
nop
ld [$0011], sp
call z, $0015
jr_013_4471:
ld h, $1b
nop
inc [hl]
ld hl, $0400
add hl, hl
nop
inc l
inc sp
nop
xor h
ccf
nop
add h
ld c, [hl]
nop
or h
ld e, a
nop
inc a
ld [hl], e
nop
inc e
adc c
nop
ld d, h
and c
nop
db $e4
cp e
nop
call z, $00d8
inc c
ld hl, sp+$00
and h
add hl, de
ld bc, $3d94
ld bc, $63dc
ld bc, $8c7c
ld bc, $b774
ld bc, $e4c4
ld bc, $146c
ld [bc], a
ld l, h
ld b, [hl]
ld [bc], a
call nz, $027a
ld [hl], h
or c
ld [bc], a
inc c
db $ec
ld [bc], a
adc h
ld a, [hl+]
inc bc
db $f4
ld l, h
inc bc
ld b, h
or e
inc bc
ld a, h
db $fd
inc bc
sbc h
ld c, e
inc b
and h
sbc l
inc b
sub h
di
inc b
ld l, h
ld c, l
dec b
inc l
xor e
dec b
call nc, $060c
ld a, h
ld l, [hl]
ld b, $24
ret nc
ld b, $cc
ld sp, $7407
sub e
rlca
inc e
push af
rlca
call nz, $0856
ld l, h
cp b
ld [$1a14], sp
add hl, bc
cp h
ld a, e
add hl, bc
ld h, h
db $dd
add hl, bc
inc c
ccf
ld a, [bc]
or h
and b
ld a, [bc]
ld e, h
ld [bc], a
dec bc
inc b
ld h, h
dec bc
xor h
push bc
dec bc
ld d, h
daa
inc c
db $fc
adc b
inc c
and h
ld [$4c0c], a
ld c, h
dec c
db $f4
xor l
dec c
sbc h
rrca
ld c, $44
ld [hl], c
ld c, $ec
jp nc, $940e
inc [hl]
rrca
inc a
sub [hl]
rrca
db $e4
rst $30
rrca
adc h
ld e, c
db $10
inc [hl]
cp e
db $10
call c, $111c
add h
ld a, [hl]
ld de, $e02c
ld de, $41d4
ld [de], a
ld a, h
and e
ld [de], a
inc h
dec b
inc de
call z, $1366
ld [hl], h
ret z