-
Notifications
You must be signed in to change notification settings - Fork 1
/
bank_04a.asm
14294 lines (13024 loc) · 172 KB
/
bank_04a.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 $04a", ROMX[$4000], BANK[$4a]
ld e, $03
ld l, d
ld hl, $5a4f
rra
jp $2145
add a
ld b, d
ld [hl+], a
ld [hl+], a
ld d, e
ld hl, $541b
dec de
Call_04a_4013:
sub a
ld l, e
jr_04a_4015:
inc e
ld [hl], b
ld d, e
rra
jp nz, $207d
ld e, [hl]
ld b, c
jr nz, jr_04a_4015
ld a, b
db $20, $bc
ld b, d
ld a, [de]
or l
ld l, h
ld e, $7b
ld l, e
ld e, $58
ld [hl], c
ld a, [de]
cpl
ld e, d
ld [hl+], a
inc a
ld d, h
ld hl, $7850
ld e, $b3
ld e, c
ld e, $0f
ld b, e
jr nz, @-$33
ld a, h
jr_04a_403f:
db $20, $ad
ld [hl], a
jr nz, jr_04a_4081
ld a, d
ld e, $89
ld l, b
inc e
adc $69
jr nz, jr_04a_405d
jr_04a_404d:
ld a, [hl]
rra
rst $00
ld c, a
ld e, $00
ld a, l
dec e
ld l, c
ld l, c
inc e
ld sp, $1d55
jr nz, jr_04a_40ce
jr_04a_405d:
ld hl, $61a7
inc e
xor a
ld e, b
ld e, $31
ld e, e
jr nz, jr_04a_404d
ld c, d
inc e
or d
ld a, l
dec de
sbc d
ld c, l
ld e, $33
ld [hl], a
jr nz, jr_04a_408d
ld b, h
dec e
db $dd
ld h, a
ld hl, $4dda
ld hl, $7270
inc e
add hl, hl
ld c, [hl]
jr_04a_4081:
ld a, [de]
ret
ld [hl], d
ld a, [de]
sub d
ld h, [hl]
ld hl, $797c
rra
reti
ld l, e
jr_04a_408d:
ld a, [de]
pop bc
jr_04a_408f:
ld d, c
inc e
and d
ld c, d
ld a, [de]
add h
jr_04a_4095:
ld h, h
ld hl, $62dd
jr nz, jr_04a_403f
ld d, l
ld hl, $4a16
rra
and $76
ld [hl+], a
ld [hl], a
ld b, e
ld [hl+], a
di
ld e, h
dec de
pop de
ld b, a
dec de
ld a, [de]
ld d, a
dec de
dec [hl]
ld d, l
dec de
rst $10
ld [hl], d
dec e
adc [hl]
ld c, [hl]
inc e
db $ec
ld c, a
ld hl, $519b
ld hl, $5f37
jr_04a_40c0:
jr nz, jr_04a_4095
ld b, [hl]
jr nz, @-$07
ld e, d
ld e, $8e
ld a, e
ld h, c
ld b, $0c
ld c, $0d
jr_04a_40ce:
add hl, bc
ld a, [bc]
ld [$2205], sp
inc b
nop
ld [bc], a
ld b, h
ld [bc], a
inc bc
inc hl
ld bc, $2cec
push bc
xor [hl]
ldh [rNR41], a
ld [bc], a
inc b
inc b
inc c
inc c
nop
inc d
ld [hl+], a
ld h, $03
ld b, d
ld b, c
ld b, e
nop
add c
add c
add b
add b
ret nz
add c
ret nz
ld b, b
ld h, b
ld h, c
ld d, b
jr nc, jr_04a_4128
inc e
inc de
rrca
ld [$0607], sp
adc d
push de
inc e
add b
ld b, b
ld h, b
db $10
jr jr_04a_408f
inc b
ld h, [hl]
ld a, [de]
ld b, c
ccf
inc b
ld a, [hl]
adc b
ld a, b
sub b
ld a, b
call c, $3cf0
inc sp
ld e, $19
ld [$070f], sp
inc b
inc bc
inc bc
sub h
ld [c], a
inc c
inc bc
inc b
inc c
jr_04a_4128:
db $10
ld [de], a
nop
inc h
ld b, b
ld c, b
jr nz, jr_04a_40c0
ret nz
jr nz, jr_04a_4176
add b
ld b, b
ldh [$27], a
nop
add c
ld [bc], a
ld bc, $0205
dec c
add d
xor $91
rst $38
jr nz, @+$01
nop
rst $18
ldh [$7f], a
rst $38
call c, Call_04a_7f39
rlca
cp a
nop
ld a, a
nop
cp a
nop
rst $38
nop
adc a
ld [hl], b
ld hl, sp+$07
rst $38
ret nz
ccf
inc a
inc bc
inc bc
ret
nop
dec de
add hl, de
inc bc
ld [bc], a
rlca
rlca
adc b
adc b
ld sp, $6971
ld de, $6127
ld h, c
and b
or d
ld h, c
ld e, l
or d
sbc b
jr_04a_4176:
ld a, a
ld l, a
jp hl
adc e
adc c
inc bc
ld de, $1643
ld [de], a
ld bc, $0c0c
ld h, c
rrca
rlca
rlca
dec bc
ld [$1314], sp
jr nz, jr_04a_41c5
ret nz
ret nz
nop
ld bc, $0600
nop
ld [$0843], sp
nop
dec e
nop
stop
jr nz, jr_04a_419f
ld b, b
jr_04a_419f:
rlca
add c
sbc a
inc bc
cp $0c
ld hl, sp+$30
jp nc, $f851
ld a, h
and c
ret nz
rst $38
ld bc, $07fb
ld a, [$04fa]
ld h, $f7
ld hl, sp+$47
rst $38
nop
add hl, bc
cp $01
ld bc, $aafe
ld d, l
push de
dec hl
cp $fe
jr_04a_41c5:
ld h, c
dec de
ld [$8138], sp
rst $00
ld a, b
ld b, b
ld a, a
jr nc, @-$1f
ld e, h
cp $67
sbc h
add h
inc c
ld b, $02
ld c, $89
rla
sub [hl]
ld [$44fc], a
ld a, b
cp b
ldh [$60], a
xor a
nop
inc d
ldh [$2f], a
add c
add c
ld b, b
pop bc
ld a, [hl-]
ld a, [hl-]
rlca
rlca
nop
add $00
jr c, @+$2a
nop
ld d, c
nop
ld a, [hl+]
nop
ld d, l
nop
ld [c], a
inc e
sbc l
ld h, d
cp $e1
db $fd
ldh a, [$fa]
ld hl, sp+$7d
ldh a, [$ea]
add b
db $fd
nop
rst $38
jp Jump_04a_7c3d
dec a
ld d, h
ld a, b
ld [$205d], sp
rst $28
db $10
ld b, l
rst $38
nop
add hl, bc
ld hl, sp+$07
rrca
ldh a, [$5f]
and b
cp b
ld c, h
ld a, [c]
di
jp $e100
dec b
ld [hl], a
ld [hl], h
rst $38
adc b
ld a, a
sbc h
ld b, e
rst $20
ld [hl+], a
rla
daa
pop de
or $11
ld d, e
db $10
or e
jr @-$13
add sp, $09
ld [$0c09], sp
dec c
inc e
inc h
ld h, h
inc c
add [hl]
cp [hl]
adc [hl]
ld [hl], d
ld [hl], e
add e
nop
ld c, b
dec b
rrca
rrca
jr nz, jr_04a_4284
ret nz
ret nz
ld b, e
ld b, b
nop
rlca
ldh [$e0], a
db $10
db $10
ld a, c
ld [$0f78], sp
ld b, e
ld a, h
rlca
ld a, [de]
cp [hl]
inc bc
ld a, [hl]
inc bc
cp a
ld bc, $015f
cpl
ld bc, $019f
cp e
nop
ld a, l
ld [bc], a
cp $40
ld a, e
inc h
or c
ld [hl+], a
ld a, [c]
pop bc
push af
ld b, b
ld a, [$00a4]
pop de
jr_04a_4284:
ldh [rKEY1], a
ld hl, sp+$07
jr_04a_4288:
db $e4
dec de
cp [hl]
ld b, c
db $fd
ld [bc], a
cp $07
ld sp, hl
add hl, bc
ld a, b
ld [$1030], sp
ldh [$e0], a
ret nz
ret nz
jr_04a_429a:
ldh a, [$30]
ld hl, sp+$08
db $fc
inc e
rst $38
ld h, e
cp $81
ld a, $01
ld e, $01
adc h
add e
cp $43
ld a, h
and h
ld [hl], b
xor b
ld a, b
sbc b
jr_04a_42b2:
cp [hl]
ld c, [hl]
or c
ld c, c
rst $10
jr z, jr_04a_4288
jr nc, jr_04a_429a
jr nz, jr_04a_42fc
ret nz
cpl
nop
db $10
rlca
ld b, a
ret z
ccf
jr nc, jr_04a_42d6
inc c
rlca
ld [de], a
dec de
ld hl, $4115
ld a, [hl+]
add b
push de
nop
ld l, [hl]
add b
ld b, e
ccf
jr_04a_42d6:
ret nz
ld b, e
rra
ldh [$e0], a
inc hl
rrca
pop af
rlca
ld sp, hl
ld a, [bc]
or $8c
db $fc
ld d, b
ld [hl], b
or b
jr nc, jr_04a_4335
inc c
and d
ld e, $41
cp a
dec b
ld a, e
adc e
ld [hl], l
ld d, a
add hl, hl
ld [$f816], a
ld hl, sp+$20
ldh [$a0], a
ld h, b
jr_04a_42fc:
ld h, b
and b
ret nz
ld b, b
adc l
ld bc, $e06e
Call_04a_4304:
add hl, hl
ld b, $06
rra
add hl, de
rst $38
pop hl
ld c, [hl]
ld a, [c]
inc h
db $fc
ld hl, sp-$08
ld a, b
ld [$043c], sp
ld a, [hl-]
ld b, $72
ld c, $e2
ld e, $c6
ld a, [$3ae6]
db $f4
inc e
call c, $c82c
jr c, jr_04a_42b2
ld [hl], h
inc b
db $fc
add h
ld a, h
call z, $ec34
inc d
ld b, e
ld hl, sp+$08
dec b
add sp, $18
jr_04a_4335:
add sp, -$68
adc b
cp b
ld b, e
add h
db $fc
add hl, bc
Jump_04a_433d:
sub h
db $ec
jp z, $d6d6
jp z, $222e
cpl
ld hl, $1743
ld de, $0e03
ld a, [bc]
inc b
inc b
ld a, a
adc c
nop
ret nz
dec b
sbc [hl]
ld a, c
ld h, [hl]
rra
cp c
rlca
add a
ld bc, $0330
rst $38
ld sp, hl
pop de
ld hl, $0183
ld a, [hl-]
and e
nop
adc $0a
ei
rst $38
dec a
ld h, l
dec a
ld d, h
ld a, c
ld [$205f], sp
rst $38
add h
ld bc, $e0bf
jr nz, @-$02
adc b
ld a, b
adc b
ld hl, sp+$10
pop de
jr nc, jr_04a_43b9
pop de
or $11
ld e, e
add hl, bc
or e
rla
pop hl
pop hl
ld [bc], a
ld [bc], a
inc b
inc c
ld de, $2710
ld h, b
dec c
add e
cp [hl]
adc [hl]
ld [hl], b
ld [hl], c
nop
ld [hl+], a
ld [bc], a
add a
ld bc, $88e8
ld [bc], a
jr nc, jr_04a_43a3
jr_04a_43a3:
ld h, d
add e
ld [bc], a
ld a, [hl-]
ldh [rNR42], a
rra
ld bc, $010f
adc a
ld bc, $86dc
ld a, [c]
ld c, d
ld a, [$d83a]
inc a
ld h, h
db $ec
jr_04a_43b9:
or l
or h
ld c, c
ret z
dec e
ld [$042f], sp
ld e, l
ld [bc], a
adc [hl]
ld [hl], c
ld [hl], e
call z, $323d
ld c, $0d
add a
ld [bc], a
ld [hl], b
rra
dec bc
rst $30
adc l
rst $38
ld d, c
ld [hl], e
or c
ld sp, $6020
nop
sub b
nop
sub b
or [hl]
sub [hl]
cp a
sbc c
rra
ld sp, $321e
ld d, h
inc a
ld e, b
jr c, jr_04a_4462
jr jr_04a_4428
ld d, h
cp d
ld d, [hl]
ld b, e
or d
ld e, [hl]
ld b, e
or [hl]
ld e, d
add hl, bc
or h
ld e, h
ld a, h
sbc h
ld a, b
sbc b
ld d, h
xor h
inc [hl]
call z, $e243
ld e, $03
jp nz, $023e
cp $43
add d
ld a, [hl]
ld b, e
call nz, $06bc
ret z
cp b
adc b
ld hl, sp-$50
jr_04a_4414:
ldh a, [$e0]
ld b, e
ldh [$c0], a
inc b
ret nz
ret nz
ret nz
add b
ret nz
and h
nop
ld [de], a
nop
add b
adc e
inc bc
ld b, b
inc b
jr_04a_4428:
inc sp
rst $10
ldh a, [$f8]
nop
add e
ld bc, $02af
ldh a, [$03]
rrca
adc e
nop
sbc e
sub c
inc bc
ld h, h
add hl, bc
and $1e
xor a
ld h, c
add [hl]
add c
ld b, $81
rrca
ld b, c
ld b, e
rst $18
ld hl, $fc0b
ld b, [hl]
ld a, [c]
jp z, $2a3a
jr jr_04a_446d
inc d
inc e
dec [hl]
inc [hl]
add l
inc bc
or b
ld b, e
or b
sub b
add hl, bc
db $10
jr nc, jr_04a_446f
jr c, jr_04a_44b9
inc a
jr_04a_4462:
ld e, h
ccf
ld a, a
rra