-
Notifications
You must be signed in to change notification settings - Fork 1
/
bank_03c.asm
13493 lines (12510 loc) · 164 KB
/
bank_03c.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 $03c", ROMX[$4000], BANK[$3c]
ret nz
inc c
ld b, b
ld bc, $4162
ld [bc], a
ld b, a
ld b, d
inc bc
ld e, $43
jp c, $a400
push hl
ld [hl], a
pop hl
ld [de], a
dec h
db $db
ld [bc], a
ret c
inc c
sub l
rrca
rst $28
ldh a, [$d6]
ld d, b
sub b
ret nz
rst $28
rst $38
push de
ld b, b
sub b
nop
or e
sub c
ld [hl], c
ld hl, $0fef
sub $40
ld [hl], b
or b
rst $28
rst $38
push de
jr nz, jr_03c_40a5
nop
ld b, e
sub c
ld b, c
sub $91
jr nz, jr_03c_408d
sub b
ret nz
push de
sub b
Call_03c_4041:
nop
sub $c3
ret c
ld b, $91
push de
ld hl, $2161
ld h, c
sub c
pop bc
call c, $d6a4
Call_03c_4051:
rst $00
inc bc
push de
dec hl
rlca
ret c
ld b, $95
inc bc
sub $c1
push de
ld hl, $4143
ld d, c
ld b, c
ld bc, $0171
sub c
ld bc, $01c1
rst $28
ldh a, [$d4]
ld hl, $91d5
ld d, c
call nc, $ef21
rst $38
ld de, $91d5
ld d, c
call nc, $ef11
rrca
push de
pop bc
ld bc, $01c1
or a
rst $28
rst $38
inc bc
ld hl, $b351
or c
call nc, $d521
or c
jr_03c_408d:
ld bc, $0171
ld d, c
ld bc, $0121
rst $28
rrca
ld b, a
rst $28
rst $38
ld d, a
rst $28
ldh a, [$61]
ld bc, $0161
ld [hl], c
ld bc, $ef83
rst $38
jr_03c_40a5:
sub c
ld b, b
nop
sub $c0
nop
push de
ld b, b
nop
jp $9191
or c
ld bc, $01b1
ld b, e
ld [hl], c
ld bc, $0cd8
sub l
rlca
call nc, $db62
ld bc, $06d8
ld [hl], l
sub b
ret nz
db $d3
ld b, a
ret c
inc c
sub e
db $db
ld [bc], a
rrca
ret c
ld b, $91
rst $28
ldh a, [$d5]
ld d, c
sub $c1
sub c
push de
ld d, c
rst $28
rrca
sub $c1
sub c
pop bc
push de
ld d, c
call c, $efa4
rst $38
ld b, a
rlca
db $db
inc bc
call c, $0384
add c
and c
jp $33d4
inc hl
ret c
ld [$d584], sp
ret nz
call nc, $d520
ret nz
and d
ret c
inc c
add h
ld [hl], b
nop
ld [hl], c
jr nz, jr_03c_4104
jr_03c_4104:
ld [hl], c
inc sp
ld d, e
ld [hl], c
ret nz
nop
ret nz
call nc, $3120
ld [hl], c
ld d, c
ret c
ld [$3084], sp
ld d, b
jr nc, jr_03c_4139
ret c
inc c
add h
push de
ret nz
nop
and c
ld [hl], b
nop
and c
Call_03c_4121:
call nc, $3353
ld hl, $5090
push de
ret nz
call nc, $9050
nop
sub b
or b
jp $9003
ld h, b
push de
ret nz
call nc, $9060
nop
jr_03c_4139:
sub b
or b
jp $2003
push de
ret nz
ld [hl], b
call nc, $d520
ret nz
ld [hl], b
call nc, $d520
ret nz
ld [hl], b
jr nz, jr_03c_41bd
or b
call nc, $7020
or b
db $d3
jr nz, @-$23
ld [bc], a
call nc, $1025
push de
ret nz
call nc, $0323
db $fd
nop
ld d, [hl]
ld b, b
pop hl
ld [de], a
inc h
db $db
ld [bc], a
ret c
inc c
rst $00
rrca
push de
sub b
nop
or b
nop
ret nz
nop
call nc, $2143
push de
or c
sub c
ld [hl], b
nop
sub b
nop
or b
nop
call nc, $d523
pop bc
or c
pop bc
sub b
nop
or b
nop
ret nz
nop
sub e
or c
pop bc
call nc, Call_03c_4121
push de
ld [hl], c
call nc, VBlankInterrupt
dec h
ld bc, $5040
call c, Call_03c_73b7
ld bc, $9070
ld [hl], b
nop
ld d, b
nop
ld b, b
nop
ld [hl], b
nop
ld e, l
jr nz, @+$42
ld d, e
ld bc, $7050
ld d, b
nop
ld b, b
nop
jr nz, jr_03c_41b4
jr_03c_41b4:
ld d, b
nop
ld c, e
ld bc, $c0d5
call nc, Call_03c_4320
jr_03c_41bd:
ld bc, $5040
ld b, b
nop
jr nz, jr_03c_41c4
jr_03c_41c4:
push de
pop bc
call nc, RST_20
ld b, e
sub e
jp nz, $2002
ld b, b
ld d, c
push de
sub c
pop bc
call nc, Call_03c_4051
push de
ld [hl], b
ret nz
call nc, $2040
push de
ld d, b
or b
call nc, $d520
rlc e
call c, $dba7
jr_03c_41e7:
inc bc
ld bc, $d4c0
jr nz, jr_03c_421e
ld [hl], c
ld d, c
ret c
ld [$30a7], sp
ld d, b
jr nc, jr_03c_4218
ret c
inc c
and a
push de
ret nz
nop
and c
ld [hl], b
nop
and c
call nc, $3353
ld hl, $8001
and b
pop bc
db $d3
ld sp, $d821
ld [$d4a7], sp
ret nz
db $d3
jr nz, jr_03c_41e7
ret nz
and d
ret c
inc c
and a
jr_03c_4218:
add b
nop
ld [hl], c
jr nz, jr_03c_421d
jr_03c_421d:
ld [hl], c
jr_03c_421e:
pop hl
nop
nop
call c, $d387
ld d, e
ld [hl], e
jr nc, jr_03c_4278
ld a, e
ld bc, $5030
ld a, e
ld bc, $b0d4
ret nz
db $d3
ld a, [hl+]
inc b
pop hl
Call_03c_4235:
ld [de], a
inc h
call c, $dba7
ld [bc], a
call nc, $a0b5
sub b
ld [hl], e
ld bc, $5040
db $fd
nop
sbc c
ld b, c
ret c
inc c
dec h
rrca
dec b
call nc, $0553
dec b
push de
sub e
dec b
dec b
ld h, e
dec b
sub $73
push de
jr nz, jr_03c_425b
jr_03c_425b:
or e
and b
sub b
ld [hl], c
sub $b1
ret c
inc c
dec h
ret nz
inc b
ret nz
ret nz
ld bc, $00c0
push de
ld [hl], c
sub $70
nop
push de
jr nz, @+$06
jr nz, jr_03c_4295
ld bc, $0020
jr_03c_4278:
sub c
sub $90
nop
ld [hl], b
inc b
ld [hl], b
ld [hl], b
ld [hl], b
nop
ld [hl], b
nop
push de
ld [hl], c
jr nz, jr_03c_4288
jr_03c_4288:
sub $c0
inc b
ret nz
ret nz
ld bc, $00c0
push de
jp $0490
sub b
jr_03c_4295:
sub b
add b
nop
add b
nop
ld [hl], c
ld [hl], b
nop
ret c
ld b, $25
push de
ld hl, $9161
pop bc
call nc, Call_03c_6121
sub c
pop bc
call nc, $d825
inc c
dec h
inc b
ret c
ld b, $25
sub $51
add hl, bc
ld d, c
ld d, c
ld [hl], c
ld bc, $0171
push de
inc hl
inc de
Call_03c_42bf:
sub $c1
add hl, bc
pop bc
pop bc
inc bc
pop bc
ld bc, $fea7
ld de, $7143
add hl, bc
pop bc
pop bc
pop bc
ld bc, $a1b7
ld bc, $11fe
ld b, e
ld [hl], c
add hl, bc
pop bc
pop bc
pop bc
ld bc, $a1b7
ld bc, $51d5
add hl, bc
ld d, c
ld d, c
inc bc
ld d, c
ld bc, $91c3
ld [hl], c
ld h, c
add hl, bc
ld h, c
ld h, c
inc bc
ld h, c
ld bc, $23d4
push de
or c
sub c
ld [hl], c
add hl, bc
ld [hl], c
ld [hl], c
sub $71
ld bc, $0171
push de
ld [hl], e
sub $71
sub c
push de
ld a, e
sub c
and c
or a
inc bc
sub $b3
db $fd
nop
ld h, c
ld b, d
add c
add hl, bc
add c
add c
and c
ld bc, $01a1
push de
ld d, e
sub $a3
rst $38
db $e3
inc bc
Call_03c_4320:
ret c
inc c
ld b, c
ld sp, $4040
ld sp, $7333
cp $6c
ld b, e
cp $6c
ld b, e
cp $6c
ld b, e
ld sp, $4040
ld sp, $4117
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
cp $7a
ld b, e
db $fd
nop
jr c, jr_03c_43af
jr_03c_436c:
jr nc, jr_03c_439e
ld b, b
ld b, b
ld sp, $8081
add b
ld [hl], c
add b
add b
add b
add b
rst $38
ld b, c
add b
add b
add b
nop
ld b, b
ld b, b
ld bc, $3141
ld b, c
rst $38
ret nz
sub d
ld b, e
ld bc, $444d
ld [bc], a
ei
ld b, h
inc bc
xor c
ld b, l
jp c, $9200
push hl
ld [hl], a
db $db
inc bc
and $00
ld bc, $10e1
jr_03c_439e:
dec d
rst $28
rrca
ret c
inc c
or d
ld bc, $d401
ld de, $1351
push de
and c
call nc, $d511
jr_03c_43af:
add e
and c
ld [hl], c
inc de
call nc, $d531
pop bc
inc sp
call nc, Call_03c_5111
inc de
push de
and c
call nc, $d511
and e
and c
ld de, $8131
ld de, $8113
call nc, Call_03c_5111
ld de, $51d5
and c
call nc, $d511
add c
ld h, b
add b
and c
ld de, $3171
call nc, $d531
jp $d451
ld de, $5151
push de
ld d, c
add c
call nc, $d511
add c
jr nc, jr_03c_436c
call nc, $d511
pop bc
add c
ld d, b
ld h, b
add c
add c
ld h, a
call c, $a3b4
call nc, $d511
xor c
ld d, e
add c
ld d, c
call c, $85b2
call c, Call_03c_63b4
and c
add c
ld h, c
call c, $a3b2
call c, $23b4
ld d, c
add e
call c, Call_03c_57b3
call c, $a1b4
add c
and c
call nc, $dc13
or d
push de
and l
call c, $81b4
ld d, c
add c
call nc, $d513
add c
call nc, $1131
push de
pop bc
and c
call c, $83b2
jp $b4dc
add c
ld d, c
call nc, $d511
ld d, e
ld d, c
call nc, $d511
ld d, c
add e
call nc, $d511
ld d, c
call c, $11b2
add c
add e
db $fd
nop
and l
ld b, e
db $db
inc bc
pop hl
ld [de], a
ld [hl], $d8
inc c
jp nz, $10d4
jr_03c_4457:
jr nc, jr_03c_4457
sbc $44
ld h, b
ld d, b
ld sp, $d531
pop bc
call nc, $d511
ld d, c
Jump_03c_4465:
ld d, c
call nc, $3010
cp $de
ld b, h
ld h, b
ld d, b
ld sp, $d531
Call_03c_4471:
pop bc
call c, $d4c4
rla
push de
and c
and c
call nc, $1111
ld h, c
and c
add c
ld h, c
push de
add c
add c
call nc, $1111
ld d, c
add c
ld h, c
ld d, c
push de
ld h, c
ld h, c
and c
and c
call nc, Call_03c_6131
ld d, c
ld sp, $3151
ld hl, $2131
push de
or c
and c
add c
and c
and c
call nc, $1111
ld h, c
and c
add c
ld h, c
push de
add c
add c
call nc, $1111
ld d, c
add c
ld h, c
ld d, c
ld h, c
ld d, c
ld sp, $dc61
jp nz, $3353
call c, $11c4
push de
add c
call nc, $d551
add c
call nc, $d511
add c
call nc, $d551
add c
call nc, $d511
add c
call nc, $d551
add c
call c, $d4c2
ld de, $1111
call nc, $3010
db $fd
nop
ld e, b
ld b, h
ld d, c
ld d, c
add c