-
Notifications
You must be signed in to change notification settings - Fork 1
/
bank_052.asm
14483 lines (13131 loc) · 173 KB
/
bank_052.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 "crystalkaizo.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 $052", ROMX[$4000], BANK[$52]
ld l, c
Call_052_4001:
dec b
dec b
rlca
ld [bc], a
Call_052_4005:
inc bc
ld bc, $6c01
dec b
inc b
inc b
ld b, $06
rlca
ld [bc], a
ld b, e
rlca
inc bc
ld [hl+], a
inc bc
inc hl
ld bc, $030e
inc bc
rlca
inc c
rra
db $10
ccf
jr nz, jr_052_4056
ld b, b
ld l, d
ld b, b
ld d, a
add b
db $eb
ld b, h
add b
rst $38
rrca
rst $18
and b
ld l, e
ld d, h
ld d, l
ld l, d
ld [hl+], a
dec a
db $10
rra
dec d
rra
dec bc
ld a, [bc]
ld [bc], a
ld [bc], a
inc hl
inc b
ld [bc], a
nop
inc b
nop
ld h, $08
add h
add $14
inc c
inc bc
rlca
ld bc, $8203
add e
and c
pop hl
ld e, b
ld hl, sp-$42
cp $3f
ccf
cpl
jr_052_4056:
ccf
inc hl
scf
jr nc, jr_052_40cc
dec h
ld [hl], b
ldh [$34], a
ld [hl], c
ld [hl], c
ld sp, $3372
or d
or a
or h
cp $f8
rst $20
db $f4
push hl
or $fb
db $fc
rst $18
add sp, $7e
push bc
cp $43
cp $03
rst $38
ld bc, $00ff
cp $01
db $fd
ld [bc], a
ld a, [$f405]
dec bc
jr_052_4083:
xor b
ld d, a
ld b, b
cp a
add c
ld a, a
and e
rst $38
rst $08
ld a, l
ld sp, hl
ld sp, $28e8
ld l, h
jr z, jr_052_40d4
ld [hl+], a
ld b, h
nop
ld [bc], a
inc h
add d
ld bc, $8180
ld h, a
ldh [rNR44], a
add b
add b
ret nz
ldh [rSVBK], a
jr_052_40a5:
ldh a, [$f8]
ld hl, sp-$04
db $fc
ld a, h
ld a, h
cp [hl]
cp $ae
cp $ee
cp $37
ccf
ld [hl], a
ld a, [hl]
or a
call z, Call_052_40bf
rst $38
nop
xor a
nop
ld d, a
Call_052_40bf:
nop
cp a
nop
ld e, a
nop
ld b, l
rst $38
nop
jr jr_052_4083
ld b, l
ld d, l
xor d
jr_052_40cc:
jr z, jr_052_40a5
ld [de], a
rst $38
adc a
db $fd
rst $28
ld a, b
jr_052_40d4:
ld e, a
ret c
rst $18
ld d, c
ld d, a
pop de
sub e
sub c
add d
and c
ld [bc], a
ld hl, $2402
ld [hl+], a
ld a, [bc]
or [hl]
and d
xor d
and d
or [hl]
and d
cp h
and d
rra
and c
ld c, a
ld b, h
ld d, c
ld e, a
ld a, c
add hl, de
ret nz
ret nz
ldh a, [$30]
ret
dec sp
db $f4
inc a
db $fd
ld a, $ff
rra
rst $38
rrca
rst $30
rrca
db $eb
rla
pop de
cpl
jp hl
rla
ret nc
cpl
and b
ld e, a
ld b, e
ld bc, $0bff
rlca
cp $8f
ld hl, sp-$72
ld hl, sp-$2b
ld hl, sp+$2a
jr nc, @+$7f
ld b, b
ld b, e
ccf
jr nz, jr_052_412b
ld e, a
ld h, b
ld a, a
ld b, b
ccf
jr nz, jr_052_4133
dec [hl]
dec d
jr_052_412b:
ld a, [de]
add e
nop
ld c, d
ld bc, $0f0c
add e
jr_052_4133:
nop
jr_052_4134:
jr z, jr_052_4159
ld [bc], a
ld [hl], b
nop
ld bc, $0083
ld d, b
ldh [$2d], a
ld [$3108], sp
jr nc, jr_052_41ab
ld h, e
sbc h
jr_052_4146:
or h
jr z, jr_052_4181
ld d, b
jr c, jr_052_4134
jr_052_414c:
jr c, jr_052_4146
ld a, b
ld hl, sp-$04
ld hl, sp-$64
cp h
call c, $fede
rst $18
db $fd
jr_052_4159:
rst $38
db $fc
ei
rst $38
jr c, jr_052_4197
ld a, [hl]
ld l, [hl]
rst $38
add c
rst $38
nop
cp a
nop
ld e, [hl]
ld bc, $01fe
ld a, a
nop
add e
nop
sbc [hl]
add e
add e
ld bc, $2bd4
add e
nop
and h
dec c
and b
ld e, a
jr nz, @+$01
ldh a, [$df]
ld sp, hl
rrca
jr_052_4181:
ld a, a
rra
jr nc, jr_052_4195
jr nz, jr_052_41a7
ld l, l
dec bc
jr nc, jr_052_41fb
adc b
adc b
ld [$3008], sp
jr nc, @-$3e
ld b, b
add b
add b
jr_052_4195:
ld [hl], e
rlca
jr_052_4197:
add b
add b
ldh [$60], a
ldh a, [rNR10]
ldh [$e0], a
add $9a
ldh [rNR43], a
ldh a, [$08]
ld hl, sp+$10
jr_052_41a7:
ldh a, [$88]
ld hl, sp+$48
jr_052_41ab:
ld hl, sp+$44
db $fc
inc h
cp h
inc d
sbc h
jr jr_052_414c
ld [$04c8], sp
db $fc
ld [$28f8], sp
add sp, $40
call nz, $a4a4
jr nz, @+$34
sub d
sub d
sub c
sbc c
rst $38
ld [hl], c
jr_052_41c8:
ldh [$29], a
rra
rra
inc a
inc hl
jr c, @+$29
ld hl, $113e
ld e, $13
inc e
dec bc
inc c
rrca
ld [$0407], sp
ld [bc], a
rlca
ld [bc], a
inc bc
inc de
ld sp, $2e2f
jr z, jr_052_4210
ld b, [hl]
ld e, b
ld a, [hl]
ld b, b
ccf
jr nz, jr_052_420c
db $10
ld a, [bc]
dec c
ld [bc], a
inc bc
ld bc, $7b01
dec de
ld bc, $0403
inc c
db $10
jr_052_41fb:
stop
jr nz, jr_052_4210
jr nz, @+$01
ret nz
ld a, [hl]
pop bc
rst $38
ld b, b
rst $18
jr nz, jr_052_41c8
ld h, b
xor [hl]
ld d, c
jr_052_420c:
rst $00
rrca
rlca
add b
jr_052_4210:
add a
inc b
ld b, h
rlca
inc d
ld b, $00
rrca
inc sp
inc c
inc bc
rrca
ld bc, $1f43
nop
ld bc, $003f
ld b, e
rst $38
nop
dec d
ld a, a
add b
rst $38
add b
cp a
ret nz
rrca
ld d, b
inc hl
inc l
inc b
inc hl
inc de
db $10
dec bc
ld [$0700], sp
inc b
inc b
inc bc
inc bc
ld h, a
ld [$e0c0], sp
ld [hl], c
add hl, de
ld a, [hl]
ld b, $fc
nop
cp $83
xor e
ld bc, $bf80
ld b, l
ld b, b
rst $38
ld [bc], a
add b
rst $38
nop
ld b, l
rst $28
ld d, b
inc bc
rst $38
ld bc, $18e7
ld b, e
rst $38
add b
ld c, [hl]
rst $38
nop
ld [bc], a
ld bc, $00ff
and e
xor c
dec bc
ld a, a
add d
rst $00
dec a
rst $38
ld c, $79
adc c
jr nc, jr_052_42c3
ldh [$e0], a
ld h, l
dec bc
rlca
rrca
ld sp, $817f
rst $38
inc bc
ld a, a
ld b, a
ccf
rst $20
rra
ld b, h
rst $38
rrca
ld b, e
rra
rst $38
ldh [$32], a
ccf
cp $1e
cp $06
cp $12
rst $28
add hl, hl
rst $08
jp hl
jr_052_4296:
ld [hl], a
dec c
db $e3
sub e
db $eb
sub d
ld [hl], a
adc d
rst $38
ld [bc], a
db $fd
ld [bc], a
ei
inc b
rst $38
nop
or $39
rst $00
ld c, l
add e
add l
rst $00
ld a, [hl-]
rst $38
ld [bc], a
cp $03
jr_052_42b2:
rst $38
ld b, $ff
inc b
rst $38
ld [$f0ff], sp
rst $38
add e
ld a, h
ld a, h
xor c
nop
ld c, [hl]
dec h
add b
jr_052_42c3:
rst $08
add b
ld h, c
dec bc
ld [hl], b
ld [hl], b
adc b
adc b
jr @+$0a
jr nc, jr_052_42df
ld h, b
jr nz, jr_052_42b2
and b
ld b, e
ldh a, [$90]
ld d, $b0
ldh a, [$e8]
xor b
ret z
ret z
adc h
inc b
jr_052_42df:
adc h
ld b, h
xor h
ld b, h
sbc h
ld b, h
inc l
add h
ret c
ld [$08f8], sp
ldh a, [rNR10]
ldh [$a8], a
nop
sbc l
and h
adc e
ld a, [bc]
rlca
ld [bc], a
inc bc
dec b
rlca
dec bc
ld a, [bc]
dec bc
dec bc
ld [de], a
ld d, $a3
sbc l
inc bc
rrca
ld [$0506], sp
add a
nop
jr c, jr_052_4296
nop
ld [hl], b
rlca
add e
rrca
add c
sbc a
ld b, b
rst $38
nop
rst $38
adc d
nop
add l
add [hl]
nop
ret nz
nop
nop
sub b
nop
ret z
and e
sbc l
ldh [$28], a
ld [bc], a
db $fd
ld [bc], a
cp $02
rst $38
rlca
ei
dec sp
rst $10
ld d, e
db $d3
ld l, a
cp c
ld b, h
ld a, c
add h
db $fd
ld [bc], a
rst $38
ld bc, $06fb
rst $30
ld [$e1de], sp
rra
ld sp, $190f
rra
ld [$02ff], a
cp $01
ei
inc b
rst $30
ld [$018b], sp
ld [hl], $05
ld bc, $0e01
rrca
jr @+$19
ld b, e
ld de, $031e
add hl, bc
ld c, $0b
inc c
adc e
rst $38
ld b, e
rrca
add b
adc h
rst $28
ld bc, $ff00
ld h, h
inc de
ld b, $0e
ld de, $233f
rst $38
add e
rst $38
rlca
ld a, a
rst $00
ccf
rlca
add b
add a
nop
rlca
jr jr_052_4385
inc b
add a
nop
ld a, b
dec b
rst $38
nop
jr_052_4385:
rst $28
jr nc, @+$01
ld b, b
adc c
nop
add $ff
ld h, c
ld [bc], a
ld bc, $0001
inc hl
ld [bc], a
ld a, [de]
inc bc
ld b, $07
ld [$080b], sp
rrca
ld de, $1316
inc e
dec bc
inc c
rrca
ld [$090f], sp
rrca
ld [$0c0b], sp
dec b
ld b, $04
rlca
ld [bc], a
jr_052_43af:
inc bc
jp $23a0
ld bc, $0245
inc bc
rst $00
add [hl]
add l
add a
ld [bc], a
ld [bc], a
inc bc
ld bc, $0744
inc b
ld bc, $0303
ld h, l
ld de, $1404
ld [de], a
ld [de], a
and c
xor c
jp nz, $04d6
ld l, h
ld [bc], a
ld a, [$fc04]
ld [$88f8], sp
ld a, b
ld b, e
call nz, $103c
ret z
jr c, jr_052_43af
ccf
ret
add hl, sp
add b
ld [hl], c
nop
ld [$f500], a
add b
db $eb
add b
rst $38
add b
ld c, l
rst $38
nop
rrca
ld e, a
add b
xor d
ld h, b
push af
rra
ld a, a
db $10
rst $38
ldh [rIE], a
sub b
sbc a
ld [$c0ff], sp
ld b, e
rst $38
nop
inc b
rst $20
pop bc
rst $38
ld a, $3e
add h
pop de
nop
inc b
inc hl
ld a, [bc]
add hl, bc
dec d
dec d
jr_052_4414:
jr nz, @+$30
jr nz, jr_052_4457
ld b, b
ld a, a
ld c, h
ld [hl], e
ld b, e
sbc [hl]
pop hl
nop
cp [hl]
ld b, e
pop bc
ld a, $00
pop de
ld b, e
inc a
jp $1901
rst $20
xor [hl]
rrc a
rst $38
ld [bc], a
rst $38
dec b
rst $38
dec h
rst $38
db $f4
rst $38
ld [de], a
rst $38
ld [hl+], a
rst $30
ld [hl+], a
rst $38
inc e
ld b, [hl]
rst $38
nop
inc bc
jr_052_4443:
jr c, @+$01
rst $00
rst $00
ld h, e
add hl, de
jr z, @+$2a
ld d, h
ld d, h
ld b, h
ld b, h
add h
adc h
ld [$0858], sp
xor b