/
bank_02e.asm
executable file
·15043 lines (14411 loc) · 151 KB
/
bank_02e.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 $02e", ROMX[$4000], BANK[$2e]
ld l, $4f
ld b, b
inc d
ld b, d
ld [hl], $42
ld d, e
ld b, d
ld h, [hl]
ld b, d
ld a, c
ld b, d
adc h
ld b, d
sbc a
ld b, d
or d
ld b, d
push bc
ld b, d
ret c
ld b, d
db $eb
ld b, d
cp $42
ld de, $7b43
ld b, h
ld [de], a
ld b, l
ld [hl], c
ld b, l
jp hl
ld b, [hl]
cp l
ld b, a
ret
ld c, b
sbc b
ld c, c
ld a, [c]
ld c, d
dec l
ld c, e
ld l, a
ld c, e
xor c
ld c, e
jp c, $1c4b
ld c, h
ld d, [hl]
ld c, h
sub h
ld c, h
push bc
ld c, h
inc h
ld c, l
ld b, l
ld d, b
ld h, c
ld d, b
ld [hl], h
ld d, b
ld e, b
ld d, c
sub h
ld d, c
or a
ld d, d
or a
ld h, d
sbc [hl]
ld c, d
nop
inc bc
ld bc, $ff01
rst $38
dec l
rst $38
db $10
rst $38
jr z, @+$01
jr z, @+$01
ld b, h
rst $38
ld a, h
Call_02e_4060:
rst $38
add d
rst $38
add d
rst $38
nop
rst $38
ld a, [hl]
rst $38
ld [$5201], sp
ld bc, $ff88
adc b
rst $38
ld [hl], b
rst $38
nop
rst $38
cp $ff
add b
rst $38
add b
rst $38
db $fc
ld bc, $0162
cp $ff
nop
rst $38
nop
rst $38
inc e
rst $38
ld [hl+], a
rst $38
ld e, l
ld bc, $0176
ld [hl+], a
rst $38
inc e
rst $38
nop
rst $38
ld a, $ff
ld a, a
rst $38
ld c, c
rst $38
ld c, c
rst $38
ld [hl], a
rst $38
ld a, $ff
ld a, [hl+]
ld bc, $0170
ld [hl], $ff
ld h, e
rst $38
ld [hl], a
rst $38
ld [hl], $ff
ld a, $ff
ld a, $01
db $10
rrca
ld e, $3c
rst $38
ld b, d
rst $38
add b
rst $38
sbc [hl]
rst $38
add d
rst $38
ld b, d
rst $38
inc a
rst $38
nop
ld bc, $0162
ld bc, $04e1
ld bc, $006d
ld bc, $004b
ld b, h
rst $38
ld b, h
ld bc, $0142
db $10
ld bc, $016e
ld bc, $0aff
ld bc, $004b
add d
rst $38
cp $01
db $10
inc de
ld bc, $00ef
add $ff
xor d
rst $38
sub d
ld bc, $1518
db $fc
ld bc, HeaderDestinationCode
ld bc, $0267
add b
rst $38
nop
rst $38
jr @+$01
jr jr_02e_40fe
ld l, [hl]
jr_02e_40fe:
ld bc, $4101
inc d
ld [bc], a
rst $38
inc b
rst $38
ld [$10ff], sp
rst $38
jr nz, @+$01
ld b, b
ld bc, $113c
db $10
rst $38
sub d
rst $38
ld d, h
rst $38
jr c, @+$01
ld d, h
rst $38
sub d
ld bc, $01fc
ld [$0cff], sp
rst $38
ld a, [hl]
rst $38
ld a, a
rst $38
ld a, [hl]
rst $38
inc c
rst $38
ld [$00ff], sp
rst $38
ld [hl], b
rst $38
ld a, b
rst $38
ld a, h
rst $38
ld a, [hl]
rst $38
ld a, h
rst $38
ld a, b
ld bc, $015c
ld [hl], b
rst $38
ld c, b
rst $38
ld b, h
rst $38
ld b, d
rst $38
ld b, h
rst $38
ld c, b
ld bc, $015c
nop
rst $38
rst $38
rst $38
add c
rst $38
add c
rst $38
jp $e7ff
ld bc, $1342
ld bc, $129f
rst $38
ld bc, $03fe
ld h, b
ld bc, $11c0
ld a, a
rst $38
ld a, a
ld bc, $13c0
ld b, $01
ret nc
ld de, $fffe
cp $01
ret nc
inc de
ld bc, $06ff
ld bc, $14b7
ld bc, $16b7
ld bc, $006f
ld bc, $0249
ld bc, $1211
ld a, h
ld bc, $115e
jr nc, @+$01
db $10
ld bc, $2314
ld bc, $200d
ld bc, $0049
ld [bc], a
rst $38
inc c
rst $38
jr nc, @+$01
ld b, b
ld bc, $016c
ld bc, $2221
inc a
rst $38
ld [bc], a
ld bc, $230a
inc c
rst $38
inc d
rst $38
inc h
rst $38
ld b, h
rst $38
add h
rst $38
cp $ff
inc b
ld bc, $112e
ld bc, $0263
ld bc, $2439
ld bc, $0049
ld bc, $0065
ld bc, $2409
ld a, [hl]
ld bc, $2122
inc b
ld bc, $1152
ld bc, $107d
ld bc, $0249
ld bc, $2481
ld bc, $14ff
ld a, [hl]
ld bc, $2538
nop
rst $38
rra
rst $38
ccf
rst $38
ld [hl], b
ld bc, $13c0
ld h, b
rst $38
nop
rst $38
ld hl, sp-$01
db $fc
rst $38
ld c, $01
ret nc
inc de
ld b, $01
xor b
dec h
ld [hl], b
rst $38
ccf
rst $38
rra
rst $38
nop
ld bc, $25b8
ld c, $ff
db $fc
rst $38
ld hl, sp+$01
cp [hl]
dec d
ld bc, $26e1
ld bc, $24b9
ld bc, $23b9
ld b, b
nop
ld bc, $deda
rst $18
db $e4
ld sp, hl
ld sp, hl
ldh [$db], a
ld bc, $0201
call c, $0101
ld bc, $f401
ld hl, sp-$20
pop hl
db $e3
ld sp, hl
ld sp, hl
ld sp, hl
ldh [rSB], a
jr nz, jr_02e_423c
ld bc, $f8a0
ld b, b
nop
ld bc, $e2da
db $e3
jr_02e_423c:
ld sp, hl
ld sp, hl
ld sp, hl
ldh [$db], a
ld bc, $0201
call c, $0101
ld bc, $f401
ld hl, sp-$20
jr_02e_424c:
ld bc, $0f20
nop
ld bc, $f8a0
stop
nop
rst $38
db $10
rst $38
db $10
rst $28
jr c, jr_02e_424c
ld d, h
rst $38
xor d
xor e
sub $83
cp $ff
ld a, h
stop
nop
rst $30
ld c, $ff
inc c
rst $38
ld e, $f7
db $ec
rst $38
cp $ff
xor [hl]
rst $38
inc e
rst $28
ld [hl], b
stop
ld bc, $00ff
rst $38
jr @+$01
db $db
rst $38
jp $3cff
rst $38
ld a, [hl]
rst $38
ld a, [hl]
rst $38
inc a
jr_02e_428c:
stop
nop
rst $38
ld b, $fd
dec bc
rst $38
ld d, $fd
inc hl
rst $20
ld d, [hl]
cp e
add $f3
or b
rst $38
ret nz
stop
nop
rst $38
jr jr_02e_428c
inc h
rst $20
inc h
jp $d342
ld d, d
rst $30
db $76
rst $38
jr jr_02e_428c
jr @+$12
nop
nop
cp e
add d
rst $38
ld b, h
rst $38
jr z, @+$01
ld a, h
cp e
cp $d7
sub d
rst $38
cp $ff
ld a, h
stop
nop
rst $38
jr @+$01
ld [hl], $eb
ld a, [hl+]
rst $30
dec d
db $eb
dec hl
rst $18
ld d, [hl]
cp a
and b
rst $38
ret nz
stop
ld bc, $00ff
rst $38
ld a, h
rst $38
cp $ff
sub d
rst $38
xor $ff
cp $ff
ld d, h
rst $38
jr c, jr_02e_42fc
nop
ld bc, $00ff
rst $38
ld a, h
rst $00
add $ef
xor d
xor e
add d
rst $10
sub $ab
xor d
jr_02e_42fc:
rst $38
ld a, h
stop
nop
cp e
ld a, h
ld a, l
add $ff
cp d
ld a, l
or $bb
ld l, h
rst $10
jr c, @+$01
jr z, @-$27
jr c, jr_02e_4312
jr_02e_4312:
ld [bc], a
inc bc
rst $38
ld hl, sp-$01
add h
rst $38
add h
rst $38
db $fc
rst $38
add d
rst $38
add d
rst $38
db $fc
rst $38
nop
rst $38
inc a
rst $38
ld b, d
rst $38
add b
inc bc
inc d
ld bc, $ff42
inc a
rst $38
inc bc
rst $38
ld a, [c]
inc bc
add hl, bc
nop
add d
rst $38
add h
rst $38
ld hl, sp-$01
nop
rst $38
cp $03
inc d
ld bc, $03fc
inc d
inc bc
nop
rst $38
ld a, h
rst $38
db $10
inc bc
ld b, d
dec b
ld a, h
rst $38
nop
rst $38
add d
rst $38
jp nz, $a2ff
rst $38
sub d
rst $38
adc d
rst $38
add [hl]
rst $38
add d
rst $38
nop
rst $38
add h
rst $38
adc b
rst $38
sub b
rst $38
or b
rst $38
ret z
inc bc
ld [hl+], a
ld bc, $ff00
jr c, @+$01
ld b, h
inc bc
inc h
inc bc
ld b, h
rst $38
jr c, @+$01
nop
inc bc
ld b, $05
adc b
inc bc
ld l, d
inc bc
ld a, b
rst $38
add h
rst $38
add b
rst $38
ld a, h
rst $38
ld [bc], a
rst $38
add d
inc bc
ld c, h
ld bc, $03fe
ld b, d
rlca
db $10
inc bc
ld c, [hl]
ld bc, $b103
ld b, $03
ld c, l
ld [bc], a
sub d
rst $38
xor d
rst $38
xor d
rst $38
add $ff
add $03
ld e, h
ld bc, $ffc6
ld b, h
rst $38
jr z, @+$01
db $10
rst $38
jr z, @+$01
ld b, h
rst $38
add $03
ld l, $01
inc b
rst $38
ld [$10ff], sp
rst $38
jr nz, @+$01
ld b, b
rst $38
cp $ff
inc bc
rst $28
cp $03
and l
ld [$ad03], sp
nop
inc bc
rrca
ld d, $60
rst $38
ld h, b
rst $38
nop
inc bc
inc d
inc bc
adc d
rst $38
adc d
rst $38
add h
rst $38
db $f4
rst $38
nop
rst $38
ldh [$03], a
inc d
ld bc, $03ea
ld [bc], a
ld bc, $03ea
ld c, $11
inc bc
ld c, c
ld [bc], a
inc bc
xor e
ld [bc], a
nop
rst $38
adc c
rst $38
ret
rst $38
ret
rst $38
xor c
rst $38
sbc c
rst $38
sbc c
rst $38
adc c
rst $38
nop
rst $38
di
rst $38
ld bc, $01ff
rst $38
pop hl
inc bc
ld h, d
ld de, $fff3
nop
rst $38
sub c
rst $38
add hl, de
rst $38
add hl, de
rst $38
dec d
rst $38
inc de
rst $38
inc de
rst $38
sub c
rst $38
nop
rst $38
ld b, h
inc bc
sub $03
ld a, h
inc bc
ld [$0301], sp
rrca
db $10
inc b
rst $38
dec c
rst $38
rra
rst $38
rra
rst $38
dec c
rst $38
inc b
inc bc
ld c, $11
inc bc
ld h, l
nop
ldh a, [rIE]
ldh a, [rIE]
or b
rst $38
sub b
inc bc
ld c, $11
ld [$18ff], sp
rst $38
jr c, @+$01
jr c, @+$01
jr @+$01
ld [$0e03], sp
inc bc
ld b, d
rst $38
inc e
inc bc
ld [$0315], sp
ld sp, $8c14
rst $38
adc b
rst $38
add sp, -$01
nop
rst $38
jr nz, @+$01
ld d, b
rst $38
ld b, b
rst $38
ldh a, [rIE]
ld b, b
inc bc
add sp, $11
inc bc
and b
db $fd
nop
inc bc
ld [bc], a
ld [bc], a
and b
rst $38
ld c, l
ld [bc], a
ld e, a
rrca
ld c, l
ld [bc], a
cp a
rrca
ld c, l
ld [bc], a
rra
rra
ld c, l
ld [bc], a
ld a, a
rra
ld c, l
ld [bc], a
rst $18
rra
ld c, l
rst $38
ld hl, sp-$01
add h
rst $38
add d
ld [bc], a
ld b, h
ld hl, $ff84
ld hl, sp-$01
nop
rst $38
cp $ff
add b
rst $38
add b
rst $38
db $fc
ld [bc], a
ld d, d
ld hl, $ff80
nop
rst $38
add h
rst $38
adc b
rst $38
sub b
rst $38
or b
rst $38
ret z
ld [bc], a
ld b, d
ld hl, $ff00
add d
rst $38
jp nz, $a2ff
rst $38
sub d
rst $38
adc d
rst $38
add [hl]
ld [bc], a
ld l, h
inc hl
ld [bc], a
add c
ld h, $7c
ld [bc], a
ld a, [hl]
inc hl
ld b, h
rst $38
ld b, h
rst $38