-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_007.asm
executable file
·11351 lines (9907 loc) · 136 KB
/
bank_007.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 $007", ROMX[$4000], BANK[$7]
rlca
add hl, bc
ld b, b
ld d, [hl]
ld h, h
ld l, b
ld h, h
add sp, $56
ld a, [$c90d]
rst $00
xor a
ld l, d
rla
ld b, b
ret z
ld b, e
xor b
ld b, h
inc b
ld l, e
ld hl, $c90d
inc [hl]
call Call_007_6a8f
call Call_007_402b
call Call_007_690d
call Call_007_405c
call Call_007_690d
ret
Call_007_402b:
ld de, $7051
call Call_007_68dc
ld de, $7094
call Call_007_68dc
ld a, [$ca4b]
ldh [$d5], a
ld a, [$ca4c]
ldh [$d6], a
ld a, [$ca4d]
ldh [$d7], a
ld hl, $002e
call Call_007_6880
call $1fb9
call Call_007_6c8f
ld de, $44b4
ld a, [$c8da]
call Call_007_6d4e
ret
Call_007_405c:
ld a, [$ca8d]
or a
jr z, jr_007_40c4
ld a, $00
ld hl, $caca
call $224a
ld hl, $95c0
call Call_007_43ab
ld a, $00
ld hl, $caca
call $224a
ld hl, $8500
call Call_007_66b1
ld a, [$ca8d]
cp $01
jr z, jr_007_40c4
ld a, $01
ld hl, $caca
call $224a
ld hl, $8800
call Call_007_43ab
ld a, $01
ld hl, $caca
call $224a
ld hl, $8600
call Call_007_66b1
ld a, [$ca8d]
cp $02
jr z, jr_007_40c4
ld a, $02
ld hl, $caca
call $224a
ld hl, $8a40
call Call_007_43ab
ld a, $02
ld hl, $caca
call $224a
ld hl, $8700
call Call_007_66b1
jr_007_40c4:
call Call_007_4469
call Call_007_4226
ld a, [$ca8d]
or a
ret z
ld a, $5c
ld hl, $00e1
call Call_007_4154
ld a, $20
ld hl, $01c1
call Call_007_4173
ld hl, $00e1
ld a, $00
call Call_007_4181
ld a, $00
ld hl, $9590
call Call_007_41aa
ld hl, $01e1
ld a, $00
call Call_007_41b7
ld a, [$ca8d]
cp $01
ret z
ld a, $80
ld hl, $00e7
call Call_007_4154
ld a, $24
ld hl, $01c7
call Call_007_4173
ld hl, $00e7
ld a, $01
call Call_007_4181
ld a, $01
ld hl, $95a0
call Call_007_41aa
ld hl, $01e7
ld a, $01
call Call_007_41b7
ld a, [$ca8d]
cp $02
ret z
ld a, $a4
ld hl, $00ed
call Call_007_4154
ld a, $28
ld hl, $01cd
call Call_007_4173
ld hl, $00ed
ld a, $02
call Call_007_4181
ld a, $02
ld hl, $95b0
call Call_007_41aa
ld hl, $01ed
ld a, $02
call Call_007_41b7
ret
Call_007_4154:
ld c, a
ld a, [$c92f]
or a
ret nz
ld a, c
ld c, $06
jr_007_415d:
push hl
push af
call Call_007_6880
pop af
ld b, $06
jr_007_4165:
ld [hl+], a
inc a
dec b
jr nz, jr_007_4165
pop hl
ld de, $0020
add hl, de
dec c
jr nz, jr_007_415d
ret
Call_007_4173:
push af
call Call_007_6880
pop af
ld [hl+], a
inc a
ld [hl+], a
inc a
ld [hl+], a
inc a
ld [hl], a
inc a
ret
Call_007_4181:
push af
ld a, l
ld [$c820], a
ld a, h
ld [$c821], a
pop af
push af
ld hl, $caca
call $2229
ld a, [hl]
ld [$c81e], a
pop af
add $04
ld [$c81f], a
ld a, [$c92f]
or a
ret nz
ld hl, $1706
rst $10
ld hl, $1708
rst $10
ret
Call_007_41aa:
push hl
ld hl, $cacc
call $2229
ld a, [hl]
pop hl
call Call_007_6a3d
ret
Call_007_41b7:
push hl
ldh [$d5], a
call Call_007_6880
ld a, $de
ld [hl+], a
ld a, $df
ld [hl+], a
ld a, $e4
ld [hl+], a
ldh a, [$d5]
add $59
inc hl
inc hl
ld [hl-], a
dec hl
push hl
ld hl, $cb0c
ldh a, [$d5]
call $224a
pop hl
ld c, a
ld b, $00
call Call_007_700b
pop hl
ld a, l
add $20
ld l, a
ld a, h
adc $00
ld h, a
push hl
call Call_007_6880
ld a, $e0
ld [hl+], a
ld a, $e1
ld [hl+], a
ld a, $e4
ld [hl+], a
push hl
ld hl, $cb11
ldh a, [$d5]
call $224f
pop hl
call Call_007_6fe6
pop hl
ld a, l
add $20
ld l, a
ld a, h
adc $00
ld h, a
push hl
call Call_007_6880
ld a, $e0
ld [hl+], a
ld a, $e2
ld [hl+], a
ld a, $e4
ld [hl+], a
push hl
ld hl, $cb15
ldh a, [$d5]
call $224f
pop hl
call Call_007_6fe6
pop hl
ret
Call_007_4226:
ld a, [$c92f]
or a
ret z
ld a, $59
ld [$c823], a
ld a, $02
ld [$c822], a
ld hl, $95c0
ld de, $1401
call Call_007_69b6
ld de, $ca42
ld hl, $93c0
call Call_007_69ef
ld de, $7cf2
call Call_007_68dc
ld b, $00
ld c, $00
jr_007_4251:
push bc
ld hl, $ca94
ld a, b
call $267e
pop bc
jr z, jr_007_425d
inc c
jr_007_425d:
inc b
ld a, b
cp $f0
jr nz, jr_007_4251
ld b, $00
ld hl, $0110
call Call_007_6880
call $2071
ld a, [$cab8]
ld c, a
ld b, $00
ld hl, $00ae
call Call_007_6880
call $20ad
ld a, [$cab7]
ld c, a
ld b, $00
ld hl, $00b1
call Call_007_6880
call $20ad
call Call_007_42b4
ret
Call_007_4290:
ld a, [$c92f]
or a
ret z
ld a, [$cab8]
ld c, a
ld b, $00
ld hl, $00ae
call Call_007_6889
call $20ad
ld a, [$cab7]
ld c, a
ld b, $00
ld hl, $00b1
call Call_007_6889
call $20ad
ret
Call_007_42b4:
ld hl, HeaderOldLicenseeCode
call Call_007_42cd
ld hl, $0151
call Call_007_4301
ld hl, $016b
call Call_007_4331
ld hl, $0171
call Call_007_436e
ret
Call_007_42cd:
call Call_007_6880
push hl
ld de, $cac1
ld b, $14
ld c, $00
jr_007_42d8:
push de
ld a, [de]
or a
jr z, jr_007_42ee
cp $02
jr z, jr_007_42ee
ld a, e
add $63
ld e, a
ld a, d
adc $00
ld d, a
ld a, [de]
or a
jr nz, jr_007_42ee
inc c
jr_007_42ee:
pop de
ld a, e
add $95
ld e, a
ld a, d
adc $00
ld d, a
dec b
jr nz, jr_007_42d8
pop hl
ld b, $00
call $2082
ret
Call_007_4301:
call Call_007_6880
push hl
ld de, $cac1
ld b, $14
ld c, $00
jr_007_430c:
push de
ld a, [de]
or a
jr z, jr_007_431e
ld a, e
add $63
ld e, a
ld a, d
adc $00
ld d, a
ld a, [de]
or a
jr z, jr_007_431e
inc c
jr_007_431e:
pop de
ld a, e
add $95
ld e, a
ld a, d
adc $00
ld d, a
dec b
jr nz, jr_007_430c
pop hl
ld b, $00
call $2082
ret
Call_007_4331:
call Call_007_6880
ld c, $00
ld a, [$ca41]
bit 7, a
jr z, jr_007_4368
push hl
ld hl, $b124
ld b, $14
ld c, $00
jr_007_4345:
push hl
call $20ee
or a
jr z, jr_007_435b
ld a, l
add $63
ld l, a
ld a, h
adc $00
ld h, a
call $20ee
or a
jr nz, jr_007_435b
inc c
jr_007_435b:
pop hl
ld a, l
add $95
ld l, a
ld a, h
adc $00
ld h, a
dec b
jr nz, jr_007_4345
pop hl
jr_007_4368:
ld b, $00
call $2082
ret
Call_007_436e:
call Call_007_6880
ld c, $00
ld a, [$ca41]
bit 7, a
jr z, jr_007_43a5
push hl
ld hl, $b124
ld b, $14
ld c, $00
jr_007_4382:
push hl
call $20ee
or a
jr z, jr_007_4398
ld a, l
add $63
ld l, a
ld a, h
adc $00
ld h, a
call $20ee
or a
jr z, jr_007_4398
inc c
jr_007_4398:
pop hl
ld a, l
add $95
ld l, a
ld a, h
adc $00
ld h, a
dec b
jr nz, jr_007_4382
pop hl
jr_007_43a5:
ld b, $00
call $2082
ret
Call_007_43ab:
cp $ff
ret z
push hl
ld l, a
ld h, $00
add hl, hl
ld a, l
add $9f
ld l, a
ld a, h
adc $2b
ld h, a
ld e, [hl]
inc hl
ld d, [hl]
pop hl
ld a, [$c92f]
or a
ret nz
call $1577
ret
call Call_007_4290
ld hl, $c8da
res 7, [hl]
ld a, [$c846]
and $30
jr z, jr_007_43e1
ld a, [$c8da]
xor $01
ld [$c8da], a
jr jr_007_43f0
jr_007_43e1:
ld a, [$c846]
and $c0
jr z, jr_007_43f6
ld a, [$c8da]
xor $02
ld [$c8da], a
jr_007_43f0:
xor a
ld [$c914], a
jr jr_007_445c
jr_007_43f6:
ld a, [$c846]
and $08
jr z, jr_007_441b
ld a, [$c92f]
xor $01
ld [$c92f], a
ld hl, $c5a0
ld bc, $0100
ld a, $e0
call $12c7
call Call_007_690d
call Call_007_405c
call Call_007_690d
jr jr_007_445c
jr_007_441b:
ld a, [$c846]
and $06
jr z, jr_007_442c
ld hl, $c90d
inc [hl]
ld hl, $c90d
inc [hl]
jr jr_007_445c
jr_007_442c:
ld a, [$c846]
bit 0, a
jr z, jr_007_445c
ld a, $59
call $1b2c
ld hl, $c90d
inc [hl]
call Call_007_6a8f
call Call_007_402b
call Call_007_690d
xor a
ld [$c90e], a
ld hl, $c8da
set 7, [hl]
ld hl, $c8db
ld bc, $0007
ld a, $00
call $12c7
call Call_007_4469
jr_007_445c:
ld de, $44b4
ld a, [$c8da]
call Call_007_6c94
call Call_007_6779
ret
Call_007_4469:
ld hl, $9200
ld a, $01
call Call_007_4482
ld hl, $9240
ld a, $02
call Call_007_4482
ld hl, $9280
ld a, $03
call Call_007_4482
ret
Call_007_4482:
ld b, a
ld a, [$ca8d]
cp b
jr nc, jr_007_4498
ld b, $20
jr_007_448b:
ld a, $ff
call $1ab9
xor a
call $1ab9
dec b
jr nz, jr_007_448b
ret
jr_007_4498:
push hl
ld a, b
dec a
ld hl, $cac2
call $2229
ld e, l
ld d, h
pop hl
call Call_007_69ef
ret
ld a, [$c8da]
rst $00
cp [hl]
ld b, h
adc d
ld c, d
ld h, d
ld d, e
sub h
ld e, h
ld hl, $2600
nop
ld h, c
nop
ld h, [hl]
nop
rst $38
rst $38
ld a, [$c90e]
rst $00
ldh [rLY], a
ei
ld b, l
ld d, l
ld b, [hl]
xor e
ld b, [hl]
or b
ld b, [hl]
cp c
ld b, [hl]
jp z, $fe46
ld b, a
jr nc, jr_007_451c
xor e
ld c, b
and $48
ld [de], a
ld c, d
ld e, d
ld c, d
ld h, [hl]
ld c, d
ld a, b
ld c, d
call Call_007_4469
Call_007_44e3:
ld de, $70b1
call Call_007_68dc
ld de, $70fb
call Call_007_68dc
ld de, $71b3
call Call_007_68dc
ld a, [$c8db]
ld [$cac0], a
call Call_007_466d
call Call_007_4689
ld de, $7253
call Call_007_68dc
call Call_007_451e
call Call_007_6c8f
ld de, $4632
ld a, [$c8db]
call Call_007_6d4e
call Call_007_690d
ld hl, $c90e
jr_007_451c:
inc [hl]
ret
Call_007_451e:
call Call_007_45ee
ld hl, $cac2
call Call_007_6da8
ld e, l
ld d, h
ld hl, $93c0
call Call_007_69ef
ld hl, $cacc
call Call_007_6dba
ld hl, $9300
call Call_007_6a3d
ld hl, $cb0c
call Call_007_6dba
push af
ld hl, $cb0d
call Call_007_6da8
pop af
cp [hl]
ld a, $90
jr c, jr_007_4550
ld a, $ac
jr_007_4550:
ld hl, $8800
call Call_007_6a41
ld hl, $cb0c
call Call_007_6dba
ld c, a
ld b, $00
ld hl, $0031
call Call_007_6880
call $2082
ld hl, $cb19
ld de, $0070
call Call_007_45e2
ld hl, $cb1b
ld de, $00b0
call Call_007_45e2
ld hl, $cb1d
ld de, $00f0
call Call_007_45e2
ld hl, $cb1f
ld de, $0130
call Call_007_45e2
ld hl, $cb21
ld de, $0170
call Call_007_45e2
ld hl, $cb11
ld de, $01cc
call Call_007_45e2
ld hl, $cb13
ld de, $01d0
call Call_007_45e2
ld hl, $cb15
ld de, $020c
call Call_007_45e2
ld hl, $cb17
ld de, $0210
call Call_007_45e2
ld hl, $cb0b
call Call_007_6dba
ld b, a
ld hl, $01f0
call Call_007_6880
bit 0, b
ld a, $e0
jr z, jr_007_45ce
ld a, $d7
jr_007_45ce:
ld [hl+], a
bit 2, b
ld a, $e0
jr z, jr_007_45d7
ld a, $d8
jr_007_45d7:
ld [hl+], a
bit 7, b
ld a, $e0
jr z, jr_007_45e0
ld a, $d9
jr_007_45e0:
ld [hl], a
ret
Call_007_45e2:
push de
call Call_007_6dcd
pop hl
call Call_007_6880
call $2071
ret
Call_007_45ee:
ld a, [$c8eb]
bit 1, a
ret z
ld a, [$c8db]
ld [$cac0], a
ret
call Call_007_463a
jr z, jr_007_460f
call Call_007_45ee
call Call_007_451e
call Call_007_690d
call Call_007_466d
call Call_007_4689
jr_007_460f:
ld a, [$c846]
bit 1, a
jr z, jr_007_4620
call Call_007_6a8f
ld a, $01
ld [$c90d], a
jr jr_007_4631
jr_007_4620:
ld a, [$c846]
bit 0, a
jp z, Jump_007_4631
ld a, $59
call $1b2c
ld hl, $c90e
inc [hl]
Jump_007_4631:
jr_007_4631:
ret
ld h, c
nop
and c
nop
pop hl
nop
rst $38
rst $38
Call_007_463a:
ld de, $4632
ld hl, $c8db
ld a, [$ca8d]
ld b, a
ld a, [hl]
push af
call Call_007_6c3f
pop af
ld hl, $c8db
and $7f
ld b, a
ld a, [hl]
and $7f
cp b
ret
Call_007_4655:
call Call_007_466d
call Call_007_4689
ld de, $7253
call Call_007_68dc
call Call_007_690d