-
Notifications
You must be signed in to change notification settings - Fork 1
/
bank_00a.asm
12929 lines (11511 loc) · 161 KB
/
bank_00a.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 $00a", ROMX[$4000], BANK[$a]
call $31f3
ld c, $50
call $0468
call $0fdb
call $300b
call $1ad2
xor a
ldh [$cf], a
ldh [$d0], a
ld c, $50
call $0468
call $0fdb
call $1ad2
call $0e51
call $0e58
ld a, $5b
ld hl, $569a
rst $08
call $3200
ld hl, $c543
ld b, $02
ld c, $0c
ld d, h
ld e, l
ld a, $13
ld hl, $535b
rst $08
ld hl, $c56c
ld de, $4419
call $1078
call Call_00a_4eff
call $3200
ld hl, $cf5d
xor a
ld [hl+], a
ld [hl], $50
ld a, [$c2dc]
cp $01
jp nz, Jump_00a_4177
Jump_00a_405d:
call Call_00a_4426
call Call_00a_4499
call Call_00a_4434
xor a
ld [$cf56], a
call $087d
ldh a, [$cb]
cp $02
jr nz, jr_00a_4091
ld c, $03
call $0468
xor a
ldh [$cd], a
ld a, $01
ldh [rSC], a
ld a, $81
ldh [rSC], a
call $045a
xor a
ldh [$cd], a
ld a, $01
ldh [rSC], a
ld a, $81
ldh [rSC], a
jr_00a_4091:
ld de, $0000
call $3b97
ld c, $03
call $0468
xor a
ldh [rIF], a
ld a, $08
ldh [rIE], a
ld hl, $d1f3
ld de, $d206
ld bc, $0011
call $075f
ld a, $fe
ld [de], a
ld hl, $c800
ld de, $d26b
ld bc, $01a8
call $075f
ld a, $fe
ld [de], a
ld hl, $c608
ld de, $c6d0
ld bc, $00c8
call $075f
xor a
ldh [rIF], a
ld a, $1d
ldh [rIE], a
call Call_00a_47ab
ld hl, $d26b
call Call_00a_47ca
push hl
ld bc, $000b
add hl, bc
ld a, [hl]
pop hl
and a
jp z, Jump_00a_4b22
cp $07
jp nc, Jump_00a_4b22
ld de, $c800
ld bc, $01a2
call Call_00a_479e
ld de, $c6d0
ld hl, $c813
ld c, $02
jr_00a_40fe:
ld a, [de]
inc de
and a
jr z, jr_00a_40fe
cp $fd
jr z, jr_00a_40fe
cp $fe
jr z, jr_00a_40fe
cp $ff
jr z, jr_00a_411d
push hl
push bc
ld b, $00
dec a
ld c, a
add hl, bc
ld a, $fe
ld [hl], a
pop bc
pop hl
jr jr_00a_40fe
jr_00a_411d:
ld hl, $c90f
dec c
jr nz, jr_00a_40fe
ld hl, $c800
ld de, $d26b
ld bc, $000b
call $3026
ld de, $d280
ld a, [hl+]
ld [de], a
inc de
jr_00a_4135:
ld a, [hl+]
cp $ff
jr z, jr_00a_414e
ld [$d265], a
push hl
push de
ld hl, $7908
ld a, $3e
rst $08
pop de
pop hl
ld a, [$d265]
ld [de], a
inc de
jr jr_00a_4135
jr_00a_414e:
ld [de], a
ld hl, $c813
call Call_00a_468a
ld a, $a8
ld [$d102], a
ld a, $d3
ld [$d103], a
ld de, $0000
call $3b97
ldh a, [$cb]
cp $02
ld c, $42
call z, $0468
ld de, $002b
call $3b97
jp Jump_00a_47e3
Jump_00a_4177:
call Call_00a_4426
call Call_00a_4595
call Call_00a_4434
call Call_00a_5dba
ld a, [$c2dd]
and a
jp z, Jump_00a_43b2
ldh a, [$cb]
cp $02
jr nz, jr_00a_41ae
ld c, $03
call $0468
xor a
ldh [$cd], a
ld a, $01
ldh [rSC], a
ld a, $81
ldh [rSC], a
call $045a
xor a
ldh [$cd], a
ld a, $01
ldh [rSC], a
ld a, $81
ldh [rSC], a
jr_00a_41ae:
ld de, $0000
call $3b97
ld c, $03
call $0468
xor a
ldh [rIF], a
ld a, $08
ldh [rIE], a
ld hl, $d1f3
ld de, $d206
ld bc, $0011
call $075f
ld a, $fe
ld [de], a
ld hl, $c800
ld de, $d26b
ld bc, $01c2
call $075f
ld a, $fe
ld [de], a
ld hl, $c608
ld de, $c6d0
ld bc, $00c8
call $075f
ld a, [$c2dc]
cp $02
jr nz, jr_00a_41fd
ld hl, $c9f4
ld de, $cb84
ld bc, $0186
call Call_00a_43f2
jr_00a_41fd:
xor a
ldh [rIF], a
ld a, $1d
ldh [rIE], a
ld de, $0000
call $3b97
call Call_00a_47ab
ld hl, $d26b
call Call_00a_47ca
ld de, $c800
ld bc, $01b9
call Call_00a_479e
ld de, $c6d0
ld hl, $c813
ld c, $02
jr_00a_4224:
ld a, [de]
inc de
and a
jr z, jr_00a_4224
cp $fd
jr z, jr_00a_4224
cp $fe
jr z, jr_00a_4224
cp $ff
jr z, jr_00a_4243
push hl
push bc
ld b, $00
dec a
ld c, a
add hl, bc
ld a, $fe
ld [hl], a
pop bc
pop hl
jr jr_00a_4224
jr_00a_4243:
ld hl, $c90f
dec c
jr nz, jr_00a_4224
ld a, [$c2dc]
cp $02
jp nz, Jump_00a_42fe
ld hl, $cb84
jr_00a_4254:
ld a, [hl+]
cp $20
jr nz, jr_00a_4254
jr_00a_4259:
ld a, [hl+]
cp $fe
jr z, jr_00a_4259
cp $20
jr z, jr_00a_4259
dec hl
ld de, $cb84
ld bc, $0190
call $3026
ld hl, $cb84
ld bc, $00c6
jr_00a_4272:
ld a, [hl]
cp $21
jr nz, jr_00a_4279
ld [hl], $fe
jr_00a_4279:
inc hl
dec bc
ld a, b
or c
jr nz, jr_00a_4272
ld de, $cc9e
jr_00a_4282:
ld a, [de]
inc de
cp $ff
jr z, jr_00a_4294
ld hl, $cc4a
dec a
ld b, $00
ld c, a
add hl, bc
ld [hl], $fe
jr jr_00a_4282
jr_00a_4294:
ld hl, $cb84
ld de, $c9f4
ld b, $06
jr_00a_429c:
push bc
ld bc, $0021
call $3026
ld a, $0e
add e
ld e, a
ld a, $00
adc d
ld d, a
pop bc
dec b
jr nz, jr_00a_429c
ld de, $c9f4
ld b, $06
jr_00a_42b4:
push bc
ld a, $21
add e
ld e, a
ld a, $00
adc d
ld d, a
ld bc, $000e
call $3026
pop bc
dec b
jr nz, jr_00a_42b4
ld b, $06
ld de, $c9f4
jr_00a_42cc:
push bc
push de
ld a, $77
ld hl, $65c8
rst $08
ld a, c
or a
jr z, jr_00a_42ee
sub $03
jr nc, jr_00a_42e4
ld a, $77
ld hl, $7203
rst $08
jr jr_00a_42ee
jr_00a_42e4:
cp $02
jr nc, jr_00a_42ee
ld a, $77
ld hl, $7220
rst $08
jr_00a_42ee:
pop de
ld hl, $002f
add hl, de
ld d, h
ld e, l
pop bc
dec b
jr nz, jr_00a_42cc
ld de, $cb0e
xor a
ld [de], a
Jump_00a_42fe:
ld hl, $c800
ld de, $d26b
ld bc, $000b
call $3026
ld de, $d280
ld bc, $0008
call $3026
ld de, $d276
ld bc, $0002
call $3026
ld de, $d288
ld bc, $01a4
call $3026
ld a, $a8
ld [$d102], a
ld a, $d3
ld [$d103], a
ld de, $0000
call $3b97
ldh a, [$cb]
cp $02
ld c, $42
call z, $0468
ld a, [$c2dc]
cp $03
jr nz, jr_00a_43a9
ld a, $0c
ld [$d22f], a
call $0fdb
ld a, $13
ld hl, $5354
rst $08
ld hl, $cfcc
ld a, [hl]
push af
and $20
or $03
ld [hl], a
ld hl, $d26b
ld de, $c656
ld bc, $000b
call $3026
call $222a
ld a, [$c2d7]
push af
ld a, $01
ld [$c2d7], a
ldh a, [rIE]
push af
ldh a, [rIF]
push af
xor a
ldh [rIF], a
ldh a, [rIE]
set 1, a
ldh [rIE], a
pop af
ldh [rIF], a
ld a, $16
call $2d83
ldh a, [rIF]
ld h, a
xor a
ldh [rIF], a
pop af
ldh [rIE], a
ld a, h
ldh [rIF], a
pop af
ld [$c2d7], a
pop af
ld [$cfcc], a
ld a, $05
ld hl, $500c
rst $08
jp Jump_00a_4b22
jr_00a_43a9:
ld de, $002b
call $3b97
jp Jump_00a_47e3
Jump_00a_43b2:
ld de, $43ed
ld b, $0a
jr_00a_43b7:
call $045a
call $0908
dec b
jr nz, jr_00a_43b7
xor a
ld [hl-], a
ld [hl], a
ldh [$9e], a
push de
ld hl, $c590
ld b, $04
ld c, $12
push de
ld d, h
ld e, l
ld a, $13
ld hl, $535b
rst $08
pop de
pop hl
ld bc, $c5b9
call $13e5
call $04b6
call $0fdb
ld b, $08
call $3340
call $3200
ret
ld d, $83
ld b, c
ld [hl], c
ld d, b
Call_00a_43f2:
ld a, $01
ldh [$cc], a
jr_00a_43f6:
ld a, [hl]
ldh [$cd], a
call $078a
push bc
ld b, a
inc hl
ld a, $30
jr_00a_4401:
dec a
jr nz, jr_00a_4401
ldh a, [$cc]
and a
ld a, b
pop bc
jr z, jr_00a_4411
dec hl
xor a
ldh [$cc], a
jr jr_00a_43f6
jr_00a_4411:
ld [de], a
inc de
dec bc
ld a, b
or c
jr nz, jr_00a_43f6
ret
adc a
adc e
add h
add b
sub d
add h
ld a, a
sub [hl]
add b
adc b
sub e
rst $20
ld d, b
Call_00a_4426:
ld hl, $c800
ld bc, $0514
jr_00a_442c:
xor a
ld [hl+], a
dec bc
ld a, b
or c
jr nz, jr_00a_442c
ret
Call_00a_4434:
ld hl, $d1f3
ld a, $fd
ld b, $07
jr_00a_443b:
ld [hl+], a
dec b
jr nz, jr_00a_443b
ld b, $0a
jr_00a_4441:
call $2f8c
cp $fd
jr nc, jr_00a_4441
ld [hl+], a
dec b
jr nz, jr_00a_4441
ld hl, $c608
ld a, $fd
ld [hl+], a
ld [hl+], a
ld [hl+], a
ld b, $c8
xor a
jr_00a_4457:
ld [hl+], a
dec b
jr nz, jr_00a_4457
ld hl, $c818
ld de, $c612
ld bc, $0000
jr_00a_4464:
inc c
ld a, c
cp $fd
jr z, jr_00a_448c
ld a, b
dec a
jr nz, jr_00a_447f
push bc
ld a, [$c2dc]
cp $01
ld b, $0d
jr z, jr_00a_447a
ld b, $27
jr_00a_447a:
ld a, c
cp b
pop bc
jr z, jr_00a_4495
jr_00a_447f:
inc hl
ld a, [hl]
cp $fe
jr nz, jr_00a_4464
ld a, c
ld [de], a
inc de
ld [hl], $ff
jr jr_00a_4464
jr_00a_448c:
ld a, $ff
ld [de], a
inc de
ld bc, $0100
jr jr_00a_4464
jr_00a_4495:
ld a, $ff
ld [de], a
ret
Call_00a_4499:
ld de, $c800
ld a, $fd
ld b, $06
jr_00a_44a0:
ld [de], a
inc de
dec b
jr nz, jr_00a_44a0
ld hl, $d47d
ld bc, $000b
call $3026
push de
ld hl, $dcd7
ld a, [hl+]
ld [de], a
inc de
jr_00a_44b5:
ld a, [hl+]
cp $ff
jr z, jr_00a_44ce
ld [$d265], a
push hl
push de
ld hl, $78f1
ld a, $3e
rst $08
pop de
pop hl
ld a, [$d265]
ld [de], a
inc de
jr jr_00a_44b5
jr_00a_44ce:
ld [de], a
pop de
ld hl, $0008
add hl, de
ld d, h
ld e, l
ld hl, $dcdf
ld c, $06
jr_00a_44db:
push bc
call Call_00a_44f6
ld bc, $0030
add hl, bc
pop bc
dec c
jr nz, jr_00a_44db
ld hl, $ddff
call Call_00a_44f0
ld hl, $de41
Call_00a_44f0:
ld bc, $0042
jp $3026
Call_00a_44f6:
ld b, h
ld c, l
push de
push bc
ld a, [hl]
ld [$d265], a
ld hl, $78f1
ld a, $3e
rst $08
pop bc
pop de
ld a, [$d265]
ld [de], a
inc de
ld hl, $0022
add hl, bc
ld a, [hl+]
ld [de], a
inc de
ld a, [hl]
ld [de], a
inc de
xor a
ld [de], a
inc de
ld hl, $0020
add hl, bc
ld a, [hl]
ld [de], a
inc de
ld a, [bc]
cp $51
jr z, jr_00a_4528
cp $52
jr nz, jr_00a_4530
jr_00a_4528:
ld a, $17
ld [de], a
inc de
ld [de], a
inc de
jr jr_00a_4544
jr_00a_4530:
push bc
dec a
ld hl, $542b
ld bc, $0020
call $30fe
ld bc, $0002
ld a, $14
call $0e8d
pop bc
jr_00a_4544:
push bc
ld hl, $0001
add hl, bc
ld bc, $001a
call $3026
pop bc
ld hl, $001f
add hl, bc
ld a, [hl]
ld [de], a
ld [$d143], a
inc de
push bc
ld hl, $0024
add hl, bc
ld bc, $0008
call $3026
pop bc
push de
push bc
ld a, [bc]
dec a
push bc
ld b, $00
ld c, a
ld hl, $7656
add hl, bc
ld a, $3e
call $304d
ld [$d23b], a
pop bc
ld hl, $000a
add hl, bc
ld c, $05
ld b, $01
ld a, $0d
call $2d83
pop bc
pop de
ldh a, [$b5]
ld [de], a
inc de
ldh a, [$b6]
ld [de], a
inc de
ld h, b
ld l, c
ret
Call_00a_4595:
ld de, $c800
ld a, $fd
ld b, $06
jr_00a_459c:
ld [de], a
inc de
dec b
jr nz, jr_00a_459c
ld hl, $d47d
ld bc, $000b
call $3026
ld hl, $dcd7
ld bc, $0008
call $3026
ld hl, $d47b
ld bc, $0002
call $3026
ld hl, $dcdf
ld bc, $0120
call $3026
ld hl, $ddff
ld bc, $0042
call $3026
ld hl, $de41
ld bc, $0042
call $3026
ld a, [$c2dc]
cp $02
ret nz
ld de, $c9f4
ld a, $20
call Call_00a_4682
ld a, $00
call $2fcb
ld hl, $a600
ld b, $06
jr_00a_45ef:
push bc
ld bc, $0021
call $3026
ld bc, $000e
add hl, bc
pop bc
dec b
jr nz, jr_00a_45ef
ld hl, $a600
ld b, $06
jr_00a_4603:
push bc
ld bc, $0021
add hl, bc
ld bc, $000e
call $3026
pop bc
dec b
jr nz, jr_00a_4603
ld b, $06
ld de, $a600
ld hl, $c9f9
jr_00a_461a:
push bc
push hl
push de
push hl
ld a, $77
ld hl, $65c8
rst $08
pop de
ld a, c
or a
jr z, jr_00a_463f
sub $03
jr nc, jr_00a_4635
ld a, $77
ld hl, $71e6
rst $08
jr jr_00a_463f
jr_00a_4635:
cp $02
jr nc, jr_00a_463f
ld a, $77
ld hl, $7220