-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_05a.asm
executable file
·14935 lines (13423 loc) · 162 KB
/
bank_05a.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 $05a", ROMX[$4000], BANK[$5a]
ld e, d
Call_05a_4001:
ld b, c
ld b, b
add sp, $41
ld l, [hl]
ld b, h
add e
ld b, a
pop de
ld c, c
sub a
ld c, h
ld a, d
ld c, a
xor h
ld d, b
sbc c
ld d, d
ld e, a
ld d, l
ld d, c
ld d, [hl]
ld d, l
ld e, b
ld h, e
ld e, d
or b
ld e, h
rst $30
ld e, [hl]
ld l, e
ld h, b
ld l, l
ld h, d
xor d
ld h, h
adc l
ld h, a
push de
ld l, b
jp nz, Jump_05a_5369
ld l, d
push hl
ld l, d
and l
ld l, e
and [hl]
ld l, h
and h
ld l, [hl]
jp z, $a06f
ld [hl], d
ld e, e
ld [hl], h
ld e, $77
ld h, b
ld a, b
ld c, e
ld a, e
nop
ld [$000b], sp
ld bc, $4701
ld b, $0f
add hl, bc
ld e, $13
inc a
inc de
inc a
ld hl, $685e
scf
nop
ret nz
ret nz
jr_05a_4057:
ldh a, [$30]
ld sp, hl
ret c
inc l
ld l, h
sub [hl]
db $e4
ld a, [de]
add $39
sub e
ld l, h
nop
nop
ld bc, $0200
ld bc, $0300
nop
ld b, $00
ld c, h
dec bc
db $fd
ldh a, [$b9]
ld h, [hl]
dec a
jp nz, $1a7d
ld c, a
ld a, [hl-]
rst $00
dec hl
add c
ld b, a
nop
jp Jump_05a_4300
sub [hl]
ld l, a
ld e, h
and a
call c, $fe32
ld a, b
ld a, [c]
inc a
ret nz
scf
add b
ld h, e
add b
ld h, b
ret nz
nop
jr nz, jr_05a_4057
jr nz, @+$42
db $10
jr nz, jr_05a_409c
jr_05a_409c:
stop
stop
nop
nop
sub b
nop
jr c, jr_05a_40a6
jr_05a_40a6:
inc [hl]
dec bc
ld d, [hl]
ld bc, $1018
ld [$0b00], sp
ld e, d
ld bc, $fa0b
db $f4
nop
ld bc, $0201
ld bc, $0b82
di
ld a, [$0118]
nop
ld h, c
add hl, de
ld h, a
ld c, $33
ld c, $19
inc de
inc a
ld de, $377e
add sp, -$03
ld [bc], a
add b
ld b, a
ret nz
ld a, h
ldh a, [$39]
srl h
rst $00
jr c, @-$12
ld [de], a
cp $03
rst $20
jr jr_05a_40e0
jr_05a_40e0:
nop
nop
add b
ret nz
jr nz, @-$4e
dec bc
ld sp, hl
db $f4
or b
ccf
ldh a, [rNR23]
cp a
ld e, $21
rrca
inc e
rlca
inc c
rlca
add hl, de
inc e
db $e3
jr nc, jr_05a_413b
ld [c], a
rra
db $fc
inc bc
sbc $20
or a
ld a, b
di
jr_05a_4103:
ld e, h
pop bc
ld [hl-], a
ret nz
ld hl, $8040
nop
ldh [$0b], a
ld hl, sp-$0b
add b
add b
nop
nop
add b
ld b, b
add b
ld b, b
and b
nop
ld b, b
dec bc
jp hl
rst $38
dec b
ld [bc], a
ld [$b00b], sp
nop
nop
ld h, c
add hl, sp
rst $00
ld b, $3f
rlca
inc c
add hl, de
ld c, $39
ld c, $00
jr nc, jr_05a_4172
jr nz, @-$78
ld [hl], c
ret z
db $f4
jr nc, @-$16
jr nc, jr_05a_4103
jr_05a_413b:
add sp, $1e
adc $39
dec bc
rst $30
or $10
nop
nop
ld h, b
ld b, b
add b
ld c, c
ld a, $84
ld c, a
adc [hl]
rla
ld de, $208f
add hl, de
jr nz, jr_05a_415f
ld e, e
nop
ld b, b
ret z
inc a
ret c
jr nc, jr_05a_41d8
or b
add $f8
jr_05a_415f:
ld [bc], a
call nz, $0201
nop
ld bc, $0380
nop
nop
inc b
jr @+$04
inc b
ld bc, $0006
inc bc
ld b, c
jr_05a_4172:
add d
ld [hl+], a
ld e, h
inc c
dec bc
ei
ld a, [c]
ld b, $80
dec c
ret c
nop
ldh a, [$08]
jr nz, jr_05a_4193
ld [de], a
dec b
inc b
nop
inc b
jr jr_05a_4193
inc [hl]
ld bc, $0306
inc b
ld b, $88
inc e
ld h, b
nop
jr_05a_4193:
jr nz, jr_05a_41ad
inc b
db $10
ld [$0c30], sp
ld hl, sp+$00
inc c
sub b
nop
call z, Call_05a_4700
nop
jr nz, jr_05a_41b0
and b
rst $38
ld c, l
dec bc
rst $38
rra
ld c, l
dec bc
jr_05a_41ad:
ld e, a
cpl
ld c, l
jr_05a_41b0:
dec bc
cp a
cpl
ld c, l
dec bc
rra
ccf
ld c, l
dec bc
ld a, a
ccf
ld c, l
dec bc
rst $18
ccf
ld c, l
dec bc
ccf
ld c, a
ld c, l
dec bc
sbc a
ld c, a
ld c, l
dec bc
rst $38
ld c, a
ld c, l
dec bc
ld e, a
ld e, a
ld c, l
dec bc
cp a
ld e, a
ld c, l
dec bc
rra
ld l, a
ld c, l
jr_05a_41d8:
dec bc
ld a, a
ld l, a
ld c, l
dec bc
rst $18
ld l, a
ld c, l
dec bc
ccf
ld a, a
ld c, l
dec bc
sbc a
ld a, a
ld c, l
nop
ld [$0909], sp
rst $38
db $f4
ld bc, $0121
ld bc, $1101
ld bc, $0001
nop
nop
ld [$1209], sp
ld bc, $0004
inc b
nop
add h
add b
adc h
add hl, bc
jr jr_05a_4208
inc c
jr_05a_4208:
db $10
inc e
jr nz, jr_05a_4244
jr nc, jr_05a_4237
ld [hl], b
ld l, c
ld d, b
ld l, e
ld de, $197a
ld a, [hl]
dec de
db $fc
ld e, $f9
dec [hl]
ei
ld [hl], a
ei
ld l, d
rst $30
rst $20
cp $00
add b
nop
add b
nop
add h
nop
add h
add b
call nz, $c600
add b
ld c, [hl]
add h
ld l, d
jr_05a_4232:
ld bc, $0181
add e
inc bc
jr_05a_4237:
add e
inc bc
jp $c301
ld bc, $0063
ld [hl], c
jr_05a_4240:
jr nz, jr_05a_4293
db $d3
cpl
jr_05a_4244:
reti
daa
ld e, h
and e
inc l
db $d3
add h
ei
call $fdf2
ld [c], a
ld a, c
or $b1
cp $a3
db $fc
db $e3
db $fc
ld [c], a
db $fd
ld h, [hl]
ld sp, hl
inc [hl]
ei
or h
ld a, e
jr @+$01
jr nz, jr_05a_4240
jr nc, jr_05a_4232
or b
call z, $c6b8
call c, $ece2
ld a, [c]
ld h, h
ld a, [$fe30]
inc b
rlca
dec b
ld b, $07
ld l, $03
cpl
inc bc
ld l, a
rlca
ld a, e
ld l, l
ld d, e
ld a, c
ld b, a
srl a
sub a
ld a, e
ei
rst $20
jp nc, $b6ef
rst $08
ld l, l
sbc [hl]
ld l, e
sbc h
ld b, a
cp b
db $10
jr_05a_4293:
rst $28
dec de
db $e4
adc c
db $76
xor h
ld d, e
and h
ld e, e
or b
ld c, a
ld sp, $73ce
adc h
sbc e
rst $20
ld d, e
rst $28
add [hl]
ld a, a
adc [hl]
ld a, a
ret z
ccf
ret c
scf
db $f4
dec sp
pop hl
ld a, $00
ld [c], a
nop
add $00
adc h
nop
cp h
db $10
add sp, $20
jp nc, $2ec0
adc b
ld [hl], h
cp c
rst $00
sbc c
and $4c
ld [hl], a
ld h, [hl]
ld a, l
dec [hl]
ld a, [hl]
ld e, $3f
rrca
ld a, a
ld b, $7f
add e
db $fc
db $e3
sbc h
rst $30
ld [$c03f], sp
sbc a
jr_05a_42db:
ld h, h
sbc a
ld h, [hl]
ld c, a
or e
rrca
pop af
rst $38
nop
cp $01
cp $01
cp $11
cp $11
rst $38
db $10
rst $38
jr nc, @+$01
ldh [$82], a
db $fd
sub [hl]
ld sp, hl
dec e
di
dec sp
rst $30
ld a, $f7
ld a, h
rst $38
pop af
ld l, [hl]
Jump_05a_4300:
db $e3
ld e, h
nop
ldh a, [rLCDC]
pop hl
add b
and $00
cp $10
db $ec
ld h, b
sbc b
ldh [$30], a
ret nz
add sp, $01
daa
nop
rra
ld b, $19
inc bc
call z, Call_05a_7f00
ld b, $3f
inc bc
rrca
nop
inc bc
and a
ret c
rst $28
ret c
add hl, sp
and $17
rst $28
rrca
rst $38
cp a
ld a, b
rst $28
ldh a, [$03]
db $fc
rst $38
ld h, b
add hl, bc
ld d, b
ld de, $ff30
add e
cp $c7
db $fd
ld c, $ff
ld [$3fc0], sp
sbc c
ld h, a
di
rrca
cp a
ld a, a
ld hl, sp-$01
rst $38
nop
ldh a, [rIF]
add b
ld a, a
ldh [$dc], a
add b
ld hl, sp-$80
di
nop
cp $e0
jr jr_05a_42db
ld a, h
nop
adc [hl]
nop
ld [bc], a
inc bc
rst $38
dec b
ei
add h
ld a, e
jp nz, $fb3d
add h
rst $18
ldh [$6f], a
ldh a, [rPCM34]
ld hl, sp+$00
stop
inc e
ld bc, $000e
ld b, c
nop
inc c
nop
jr jr_05a_437d
jr_05a_437d:
stop
nop
rrca
inc sp
ld [hl], $cf
call c, $f83f
cp $00
ld hl, sp+$00
nop
nop
jr nz, jr_05a_438f
jr_05a_438f:
ld b, b
nop
stop
jr jr_05a_4395
jr_05a_4395:
ld [$0c00], sp
nop
inc c
ld [$181c], sp
inc a
jr jr_05a_4414
add hl, bc
ld [de], a
nop
ld [$0814], sp
dec d
inc c
dec de
inc c
dec de
inc c
sbc a
ld b, $8d
jr nc, jr_05a_442d
jr nc, @-$12
ld [hl], b
jp hl
ld [hl], b
db $eb
ld a, b
rst $30
ld a, l
or e
rst $30
add hl, sp
db $db
ccf
nop
add b
nop
and b
nop
sub b
add b
ret nc
add b
ret c
add b
ret c
sub b
add sp, -$30
xor d
rlca
rst $08
jr_05a_43d1:
ld bc, $00c7
ld h, e
ld sp, $1f7a
ccf
rrca
inc de
rlca
jr jr_05a_43de
jr_05a_43de:
rlca
rst $30
jr jr_05a_43d1
sbc b
db $eb
call c, $c9f6
ld a, a
pop hl
rst $38
or e
sbc $bf
db $fc
ld e, $c0
ld [hl], d
jr_05a_43f1:
ret nz
ld [hl], d
ld b, b
and $80
db $fc
and b
call c, $b840
nop
ldh [rP1], a
nop
ld a, b
sbc h
db $10
ld a, c
ld de, $163b
xor [hl]
jr jr_05a_43f1
db $10
jr nc, jr_05a_4415
sbc h
db $10
rra
ldh [rSB], a
ld a, $00
inc bc
jr_05a_4414:
add hl, bc
jr_05a_4415:
db $fd
jr_05a_4416:
rst $30
add hl, bc
or c
inc de
inc b
inc c
inc b
inc e
inc c
inc [hl]
inc e
ld h, h
inc [hl]
ld c, l
jr jr_05a_4491
ld [$003a], sp
cp [hl]
inc d
xor d
inc e
jr_05a_442d:
ld [c], a
jr c, jr_05a_4416
ld a, b
or h
add hl, bc
and b
rst $38
ld c, l
add hl, bc
cp a
cpl
ld c, l
add hl, bc
rra
ccf
ld c, l
add hl, bc
ld a, a
ccf
ld c, l
add hl, bc
rst $18
ccf
ld c, l
add hl, bc
ccf
ld c, a
ld c, l
add hl, bc
sbc a
ld c, a
ld c, l
add hl, bc
rst $38
ld c, a
ld c, l
add hl, bc
ld e, a