-
Notifications
You must be signed in to change notification settings - Fork 1
/
bank_00f.asm
10973 lines (9158 loc) · 145 KB
/
bank_00f.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 $00f", ROMX[$4000], BANK[$f]
Call_00f_4000:
xor a
ld [$c664], a
ld [$c6fc], a
ld [$d0ec], a
ld [$c734], a
inc a
ld [$d264], a
ld hl, $d2aa
ld bc, $002f
ld d, $03
jr_00f_4019:
inc d
ld a, [hl+]
or [hl]
jr nz, jr_00f_4021
add hl, bc
jr jr_00f_4019
jr_00f_4021:
ld a, d
ld [$d430], a
ld a, [$c2dc]
and a
jr z, jr_00f_4031
ldh a, [$cb]
cp $02
jr z, jr_00f_404c
jr_00f_4031:
ld a, [$d22d]
dec a
jr z, jr_00f_4047
xor a
ld [$c718], a
call Call_00f_5834
call Call_00f_5867
call Call_00f_5c18
call Call_00f_54e1
jr_00f_4047:
ld c, $28
call $0468
jr_00f_404c:
call $309d
call Call_00f_5873
ld a, d
and a
jp z, Jump_00f_538e
call $30b4
ld a, [$d230]
cp $02
jp z, Jump_00f_40e2
cp $03
jp z, Jump_00f_40e2
xor a
ld [$d109], a
jr_00f_406b:
call Call_00f_5887
jr nz, jr_00f_4076
ld hl, $d109
inc [hl]
jr jr_00f_406b
jr_00f_4076:
ld a, [$d0d4]
ld [$c71a], a
ld a, [$d109]
ld [$d0d4], a
inc a
ld hl, $dcd7
ld c, a
ld b, $00
add hl, bc
ld a, [hl]
ld [$d108], a
ld [$d205], a
ld hl, $c505
ld a, $09
call Call_00f_5490
call $309d
call Call_00f_557a
call Call_00f_5a0d
call Call_00f_5ab1
call Call_00f_726d
call Call_00f_5bde
call Call_00f_5c18
call Call_00f_5b5f
call Call_00f_6dd1
call $309d
call $3985
call Call_00f_5c23
ld a, [$c2dc]
and a
jr z, jr_00f_40df
ldh a, [$cb]
cp $02
jr nz, jr_00f_40df
xor a
ld [$c718], a
call Call_00f_5834
call Call_00f_5867
call Call_00f_5c18
call Call_00f_54e1
call $3989
call Call_00f_5c23
jr_00f_40df:
jp Jump_00f_412f
Jump_00f_40e2:
jp Jump_00f_6139
Call_00f_40e5:
Jump_00f_40e5:
call $30b4
ld a, [$d0ee]
and $c0
add $02
ld [$d0ee], a
ld a, [$c2dc]
and a
ld hl, $47bd
jr z, jr_00f_4115
ld a, [$d0ee]
and $c0
ld [$d0ee], a
ld hl, $47cf
call Call_00f_52e0
jr nc, jr_00f_4115
ld hl, $cd2a
bit 4, [hl]
jr nz, jr_00f_4118
ld hl, $5863
jr_00f_4115:
call $3ad5
jr_00f_4118:
call Call_00f_4eec
call Call_00f_52e0
jr c, jr_00f_4126
ld de, $002b
call $3c23
jr_00f_4126:
call $3985
ld a, $01
ld [$c734], a
ret
Jump_00f_412f:
call Call_00f_41bf
call Call_00f_43f5
jp c, Jump_00f_41be
xor a
ld [$c710], a
ld [$c711], a
ld [$d264], a
ld [$c73f], a
ld [$c740], a
ld [$d256], a
ld [$d257], a
call Call_00f_427c
call $399c
ld a, $11
ld hl, $40ce
rst $08
call Call_00f_52f1
jr nz, jr_00f_4174
ld a, $40
ld hl, $4da5
rst $08
ld a, $40
ld hl, $4641
rst $08
ld a, $40
ld hl, $4dd8
rst $08
jp c, Jump_00f_41be
jr_00f_4174:
call Call_00f_4410
jr c, jr_00f_418a
jr_00f_4179:
call Call_00f_6139
jr c, jr_00f_41be
ld a, [$c734]
and a
jr nz, jr_00f_41be
ld a, [$d232]
and a
jr nz, jr_00f_41be
jr_00f_418a:
call Call_00f_4434
jr nz, jr_00f_4179
call Call_00f_4300
jr c, jr_00f_41be
call Call_00f_4314
jr c, jr_00f_419e
call Call_00f_45fe
jr jr_00f_41a1
jr_00f_419e:
call Call_00f_4664
jr_00f_41a1:
call Call_00f_52e0
jr c, jr_00f_41be
ld a, [$d232]
and a
jr nz, jr_00f_41be
ld a, [$c734]
and a
jr nz, jr_00f_41be
call Call_00f_41d6
ld a, [$c734]
and a
jr nz, jr_00f_41be
jp Jump_00f_412f
Jump_00f_41be:
jr_00f_41be:
ret
Call_00f_41bf:
ret
ld a, $05
call $2fcb
ld hl, $a89b
inc [hl]
jr nz, jr_00f_41d2
dec hl
inc [hl]
jr nz, jr_00f_41d2
dec [hl]
inc hl
dec [hl]
jr_00f_41d2:
call $2fe1
ret
Call_00f_41d6:
ldh a, [$cb]
cp $01
jr z, jr_00f_41fe
call Call_00f_423c
ret c
call Call_00f_4a26
call Call_00f_423c
ret c
call Call_00f_4b9e
call Call_00f_423c
ret c
call Call_00f_4874
call Call_00f_423c
ret c
call Call_00f_4801
call Call_00f_423c
ret c
jr jr_00f_421e
jr_00f_41fe:
call Call_00f_425c
ret c
call Call_00f_4a26
call Call_00f_425c
ret c
call Call_00f_4b9e
call Call_00f_425c
ret c
call Call_00f_4874
call Call_00f_425c
ret c
call Call_00f_4801
call Call_00f_425c
ret c
jr_00f_421e:
call Call_00f_48eb
call Call_00f_493c
call Call_00f_4a8f
call Call_00f_4afb
call Call_00f_4b36
call Call_00f_5e97
call Call_00f_5cf9
call $399c
call $309d
jp Jump_00f_44df
Call_00f_423c:
call Call_00f_4710
jr nz, jr_00f_424a
call Call_00f_514e
ld a, [$c734]
and a
jr nz, jr_00f_425a
jr_00f_424a:
call Call_00f_470b
jr nz, jr_00f_4258
call Call_00f_4d55
ld a, [$c734]
and a
jr nz, jr_00f_425a
jr_00f_4258:
and a
ret
jr_00f_425a:
scf
ret
Call_00f_425c:
call Call_00f_470b
jr nz, jr_00f_426a
call Call_00f_4d55
ld a, [$c734]
and a
jr nz, jr_00f_427a
jr_00f_426a:
call Call_00f_4710
jr nz, jr_00f_4278
call Call_00f_514e
ld a, [$c734]
and a
jr nz, jr_00f_427a
jr_00f_4278:
and a
ret
jr_00f_427a:
scf
ret
Call_00f_427c:
ldh a, [$cb]
cp $01
jr z, jr_00f_4287
call Call_00f_428a
jr jr_00f_4296
jr_00f_4287:
call Call_00f_4296
Call_00f_428a:
call $3985
ld de, $dce0
ld a, [$d0d4]
ld b, a
jr jr_00f_42a0
Call_00f_4296:
jr_00f_4296:
call $3989
ld de, $d289
ld a, [$c663]
ld b, a
jr_00f_42a0:
push de
push bc
ld hl, $7db2
ld a, $0d
rst $08
ld a, [hl]
ld [$d265], a
sub $98
pop bc
pop de
ret nz
ld [hl], a
ld h, d
ld l, e
ld a, b
call $3927
xor a
ld [hl], a
ld a, $02
call $39e7
push af
set 7, [hl]
ld a, $0c
call $39e7
push hl
push af
xor a
ld [hl], a
ld [$c667], a
ld [$c70d], a
ld a, $0d
ld hl, $61c8
rst $08
pop af
pop hl
ld [hl], a
call $3468
ld hl, $4bde
call $3ad5
ld hl, $63b8
ld a, $0d
rst $08
pop af
bit 7, a
ret nz
xor a
ld [$cfca], a
ld de, $0103
call Call_00f_6e0f
call Call_00f_48e4
ld hl, $4d97
jp $3ad5
Call_00f_4300:
ld a, [$c2dc]
and a
jr z, jr_00f_430d
ld a, [$d430]
cp $0f
jr z, jr_00f_430f
jr_00f_430d:
and a
ret
jr_00f_430f:
call Call_00f_40e5
scf
ret
Call_00f_4314:
ld a, [$c2dc]
and a
jr z, jr_00f_435b
ld a, [$d430]
cp $0e
jr z, jr_00f_435b
cp $0d
jr z, jr_00f_435b
sub $04
jr c, jr_00f_435b
ld a, [$d0ec]
cp $02
jr nz, jr_00f_434c
ldh a, [$cb]
cp $02
jr z, jr_00f_4341
call $2f9f
cp $80
jp c, Jump_00f_43f1
jp Jump_00f_43f3
jr_00f_4341:
call $2f9f
cp $80
jp c, Jump_00f_43f3
jp Jump_00f_43f1
jr_00f_434c:
ld hl, $446c
ld a, $0e
rst $08
call $3989
call Call_00f_5c23
jp Jump_00f_43f3
jr_00f_435b:
ld a, [$d0ec]
and a
jp nz, Jump_00f_43f1
call Call_00f_45b4
jr z, jr_00f_436d
jp c, Jump_00f_43f1
jp Jump_00f_43f3
jr_00f_436d:
call $3985
ld hl, $7db2
ld a, $0d
rst $08
push bc
ld hl, $7dc1
ld a, $0d
rst $08
pop de
ld a, d
cp $4a
jr nz, jr_00f_4391
ld a, b
cp $4a
jr z, jr_00f_439f
call $2f9f
cp e
jr nc, jr_00f_43c5
jp Jump_00f_43f1
jr_00f_4391:
ld a, b
cp $4a
jr nz, jr_00f_43c5
call $2f9f
cp c
jr nc, jr_00f_43c5
jp Jump_00f_43f3
jr_00f_439f:
ldh a, [$cb]
cp $02
jr z, jr_00f_43b5
call $2f9f
cp c
jp c, Jump_00f_43f3
call $2f9f
cp e
jp c, Jump_00f_43f1
jr jr_00f_43c5
jr_00f_43b5:
call $2f9f
cp e
jp c, Jump_00f_43f1
call $2f9f
cp c
jp c, Jump_00f_43f3
jr jr_00f_43c5
jr_00f_43c5:
ld de, $c644
ld hl, $d21e
ld c, $02
call $31db
jr z, jr_00f_43d8
jp nc, Jump_00f_43f1
jp Jump_00f_43f3
jr_00f_43d8:
ldh a, [$cb]
cp $02
jr z, jr_00f_43e9
call $2f9f
cp $80
jp c, Jump_00f_43f1
jp Jump_00f_43f3
jr_00f_43e9:
call $2f9f
cp $80
jp c, Jump_00f_43f3
Jump_00f_43f1:
scf
ret
Jump_00f_43f3:
and a
ret
Call_00f_43f5:
ld a, [$d230]
cp $06
jr nz, jr_00f_440e
ld a, [$dc79]
and a
jr nz, jr_00f_440e
ld a, [$d0ee]
and $c0
add $02
ld [$d0ee], a
scf
ret
jr_00f_440e:
and a
ret
Call_00f_4410:
ld a, [$c66b]
and $20
jp nz, Jump_00f_4432
ld hl, $c66f
res 3, [hl]
ld hl, $c66a
res 3, [hl]
ld a, [hl]
and $12
jp nz, Jump_00f_4432
ld hl, $c668
bit 6, [hl]
jp nz, Jump_00f_4432
and a
ret
Jump_00f_4432:
scf
ret
Call_00f_4434:
call Call_00f_4410
jp c, Jump_00f_44ba
ld hl, $c66c
bit 4, [hl]
jr z, jr_00f_4449
ld a, [$c71b]
ld [$c6e3], a
jr jr_00f_447c
jr_00f_4449:
ld a, [$d0ec]
cp $02
jr z, jr_00f_44ce
and a
jr nz, jr_00f_44b5
ld a, [$c66a]
and $01
jr nz, jr_00f_44ba
xor a
ld [$d235], a
inc a
ld [$cfc2], a
call Call_00f_64bc
push af
call $30b4
call $39d4
ld a, [$c6e3]
cp $a5
jr z, jr_00f_4476
call $2009
jr_00f_4476:
ld a, $01
ldh [$d4], a
pop af
ret nz
jr_00f_447c:
call $3985
ld hl, $5e40
ld a, $0d
rst $08
xor a
ld [$c732], a
ld a, [$c610]
cp $77
jr z, jr_00f_4494
xor a
ld [$c678], a
jr_00f_4494:
ld a, [$c610]
cp $51
jr z, jr_00f_44a4
ld hl, $c66b
res 6, [hl]
xor a
ld [$c72b], a
jr_00f_44a4:
ld a, [$c610]
cp $6f
jr z, jr_00f_44c9
cp $74
jr z, jr_00f_44c9
xor a
ld [$c679], a
jr jr_00f_44c9
jr_00f_44b5:
ld hl, $c66a
res 0, [hl]
Jump_00f_44ba:
jr_00f_44ba:
xor a
ld [$c678], a
ld [$c679], a
ld [$c72b], a
ld hl, $c66b
res 6, [hl]
jr_00f_44c9:
call Call_00f_67c1
xor a
ret
jr_00f_44ce:
xor a
ld [$c678], a
ld [$c679], a
ld [$c72b], a
ld hl, $c66b
res 6, [hl]
xor a
ret
Jump_00f_44df:
ldh a, [$cb]
cp $01
jr z, jr_00f_44ea
call Call_00f_44ed
jr jr_00f_4518
jr_00f_44ea:
call Call_00f_4518
Call_00f_44ed:
ld hl, $c66c
bit 4, [hl]
ret z
ld a, [$c676]
dec a
ld [$c676], a
jr z, jr_00f_450a
ld hl, $c634
ld a, [$d0d5]
ld c, a
ld b, $00
add hl, bc
ld a, [hl]
and $3f
ret nz
jr_00f_450a:
ld hl, $c66c
res 4, [hl]
call $3989
ld hl, $4c8a
jp $3ad5
Call_00f_4518:
jr_00f_4518:
ld hl, $c671
bit 4, [hl]
ret z
ld a, [$c67e]
dec a
ld [$c67e], a
jr z, jr_00f_4535
ld hl, $d20e
ld a, [$c6e9]
ld c, a
ld b, $00
add hl, bc
ld a, [hl]
and $3f
ret nz
jr_00f_4535:
ld hl, $c671
res 4, [hl]
call $3985
ld hl, $4c8a
jp $3ad5
Call_00f_4543:
ld a, [$d22d]
dec a
jr nz, jr_00f_4596
ld a, [$c66c]
bit 7, a
jr nz, jr_00f_4596
ld a, [$c731]
and a
jr nz, jr_00f_4596
ld a, [$d214]
and $27
jr nz, jr_00f_4596
ld a, [$d204]
ld de, $0001
ld hl, $45b1
call $30e1
jr c, jr_00f_4598
call $2f9f
ld b, a
cp $80
jr nc, jr_00f_4596
push bc
ld a, [$d204]
ld de, $0001
ld hl, $45a8
call $30e1
pop bc
jr c, jr_00f_4598
ld a, b
cp $1a
jr nc, jr_00f_4596
ld a, [$d204]
ld de, $0001
ld hl, $459a
call $30e1
jr c, jr_00f_4598
jr_00f_4596:
and a
ret
jr_00f_4598:
scf
ret
ld d, c
ld e, b
ld [hl], d
ld a, d
add l
adc c
sub e
sub h
or b
push bc
ret
pop de
sub $ff
ld l, b
sub b
sub c
sub d
jp $e7e1
ret c
rst $38
di
db $f4
rst $38
Call_00f_45b4:
ld a, [$c6e3]
call Call_00f_45c5
ld b, a
push bc
ld a, [$c6e4]
call Call_00f_45c5
pop bc
cp b
ret
Call_00f_45c5:
ld b, a
cp $e9
ld a, $00
ret z
call Call_00f_45ec
ld hl, $45df
jr_00f_45d1:
ld a, [hl+]