-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbank_04e.asm
14062 lines (12980 loc) · 170 KB
/
bank_04e.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 $04e", ROMX[$4000], BANK[$4e]
dec de
jr nc, @+$72
db $fc
adc h
ld a, d
ld b, [hl]
ld d, c
ld l, a
ld hl, $203f
ccf
inc d
rra
add hl, bc
rrca
dec bc
rrca
ld de, $131f
rra
ld [de], a
rra
ld de, $101f
rra
ld b, e
ld [$050f], sp
inc b
rlca
ld [bc], a
inc bc
ld bc, $6101
rlca
rlca
rlca
inc b
rlca
ld [bc], a
ld [bc], a
ld bc, $ec01
jr z, jr_04e_4037
ld bc, $0202
jr_04e_4037:
inc bc
add h
xor a
ldh [rSCX], a
ld bc, $1f03
inc e
ld l, a
ld [hl], b
sub a
add sp, $0b
db $f4
rla
add sp, $0b
rst $30
call z, $30fc
db $30, $80
add b
add c
pop bc
ld h, e
db $e3
sbc $ff
ld l, e
rst $38
dec e
cp $0a
push af
dec d
ld [$f58b], a
ld h, d
ld a, [hl]
sub h
call c, $fcec
jr c, jr_04e_40a4
rrca
rrca
add e
add a
ld bc, $81e1
sbc c
ld b, b
ld b, h
jr nz, jr_04e_4097
ld hl, $1139
rla
ld de, $0e11
rrca
ld [$1008], sp
db $10
and h
add e
ld [bc], a
add hl, bc
inc b
ld b, $83
nop
jr z, jr_04e_4097
ld c, $19
ccf
jr nz, @+$60
pop bc
inc c
inc bc
rrca
and a
db $fc
and h
ld [hl], b
jr_04e_4097:
ld hl, sp+$61
ldh [$2e], a
add b
add b
ret nz
ld h, b
ldh a, [rNR10]
ldh [rNR41], a
ret nz
jr_04e_40a4:
ld b, b
add [hl]
add [hl]
dec c
rrca
dec sp
ccf
ld d, a
ld a, a
xor l
cp $f7
ld hl, sp+$5f
pop hl
rst $38
add e
cp a
ld b, e
ld a, [hl]
adc [hl]
or [hl]
db $76
ld b, h
call nz, $8d8c
inc c
adc l
ld c, $8d
dec c
ld c, d
dec a
ld a, [hl-]
ld a, l
ld a, e
db $ed
ld b, h
ei
rst $08
ldh [rNR42], a
adc $db
sbc a
sbc [hl]
rrca
ld e, $4d
adc $87
xor h
set 4, h
rst $28
ldh [$ef], a
and b
ld a, a
ld b, b
ld e, a
ld hl, sp+$23
inc a
jr @+$21
rlca
rrca
add b
sub b
ld a, b
ld hl, sp+$17
rst $30
ld h, b
ldh [$b1], a
nop
ld l, $e0
inc h
ld h, b
ld h, b
or b
ldh a, [$58]
ld hl, sp-$44
db $fc
rst $28
rst $38
db $fc
ccf
db $ec
cp a
ld sp, hl
sbc $5a
ld a, l
ld e, a
ld a, [hl]
ld h, c
ld h, c
ld b, b
ld b, c
nop
add c
ld b, b
ld b, c
ld b, b
ld b, d
ldh [rNR43], a
ldh a, [$7c]
db $fd
db $fc
cp $22
rst $38
rlca
cp a
rst $38
jr_04e_4120:
ld l, [hl]
jr_04e_4121:
sbc a
rst $38
rlca
ei
rlca
ld b, e
db $fd
inc bc
add hl, de
ld hl, sp+$3f
db $ec
ld l, a
ld a, b
rst $38
ld hl, sp-$09
ldh a, [rIF]
pop hl
rra
add a
ld a, [hl]
dec sp
db $fc
db $fd
jp nz, $20df
rrca
ld d, e
inc a
inc a
ret nz
ret nz
ld a, e
ld bc, $c0c0
and e
nop
or b
ldh [rSTAT], a
cp [hl]
ld b, [hl]
ld a, a
add c
rst $28
sub b
ld a, a
ld [hl], b
ld a, $09
ld e, h
rlca
xor [hl]
inc bc
ld e, e
dec b
or a
add hl, bc
ld c, a
jr nc, jr_04e_4121
ld b, a
ld a, c
rst $38
sbc [hl]
cp $20
ldh a, [$c0]
pop bc
ldh [$8e], a
ret nz
jr nc, jr_04e_4120
ld b, b
ldh [$1f], a
ld a, b
ldh [$5c], a
db $fc
cp a
jr_04e_4178:
jp Jump_04e_609f
rst $20
add hl, de
xor c
rlca
ld b, [hl]
ld b, $8a
ld c, $32
cp [hl]
pop bc
rst $38
ld e, a
ld h, b
ld h, b
ld b, l
dec h
dec h
rrca
rra
db $f4
ld [hl+], a
nop
scf
nop
add b
jp $cb00
jp $c900
add hl, bc
db $10
ldh a, [$08]
ld hl, sp-$78
ld hl, sp-$01
jr_04e_41a3:
rst $38
add d
jp nz, $0423
add hl, bc
jr jr_04e_41a3
db $10
db $10
jr nz, @+$22
ld h, b
ld h, b
sbc b
ld hl, sp+$43
add h
db $fc
inc bc
call nc, $b8fc
cp b
adc e
or e
inc bc
ret nz
ld b, b
ret nz
ld b, b
rst $00
or [hl]
ld bc, $0101
and l
adc a
dec bc
rlca
ld c, $36
ld a, e
ld hl, sp-$79
ld [hl], c
ld c, a
inc hl
ccf
inc e
inc e
ld h, c
adc c
nop
ld h, $0d
jr nz, jr_04e_423d
ld d, b
jr nc, @+$72
ld d, b
ld l, b
ld e, b
ld l, b
sbc b
add sp, -$68
db $e4
sbc h
ld b, e
call nz, $193c
ret z
jr c, jr_04e_4178
ld a, b
sub b
ld [hl], b
db $10
ldh a, [$60]
pop hl
scf
rst $38
ld e, d
cp a
or e
rst $08
ld e, a
ldh [$37], a
Jump_04e_4200:
add hl, sp
ld c, $0e
add h
add h
db $e4
db $e4
add e
nop
adc h
xor c
ld bc, $15f8
dec b
rlca
ld a, [bc]
rrca
dec c
rra
ld a, [de]
rra
dec l
ld a, $2b
inc a
ld e, a
ld a, b
ld e, a
pop af
xor a
di
ld a, a
db $e3
cp [hl]
adc $83
ld bc, $0a00
rst $38
and b
ld a, a
ld e, b
ld b, a
ld hl, sp+$2d
ld a, $1a
rra
rlca
add h
xor a
rla
ld [hl], b
ld [hl], b
sbc b
ld hl, sp+$74
db $fc
ld l, [hl]
jr_04e_423d:
cp $2a
cp $97
rst $38
rst $30
ld a, a
xor e
ld a, a
ld a, [$ee3f]
cp a
db $f4
rst $18
ld d, h
ld a, a
add e
ld bc, $833c
ld [bc], a
jr nc, jr_04e_425c
ld h, b
ldh [$b8], a
ld e, b
ld a, h
add h
cp [hl]
jr_04e_425c:
ld b, d
add e
ld bc, $659c
rrca
jr nc, jr_04e_4294
ld a, h
ld c, h
ld e, d
ld h, [hl]
dec a
inc hl
inc l
inc sp
ld c, $11
ld d, $19
rlca
jr_04e_4271:
ld [$0b43], sp
inc c
ld de, $0605
inc b
rlca
ld c, $0b
rra
ld de, $231c
add hl, sp
ld b, a
ld h, d
ld e, [hl]
rst $08
cp a
db $f4
rst $30
add e
ld [bc], a
ld e, h
push bc
ld [bc], a
dec sp
ld b, h
jr nz, jr_04e_4271
inc b
pop hl
inc de
jr_04e_4294:
rst $30
dec c
rst $38
adc [hl]
nop
ldh a, [rTIMA]
adc h
db $db
add h
rst $28
ret nz
rst $38
adc d
ld bc, $8e05
ld bc, $0650
rlca
db $fc
rlca
ld a, b
adc a
ld hl, sp+$77
adc c
ld bc, $ff66
ld h, c
ld bc, $0c0c
ld [hl+], a
inc de
db $10
ld de, $7b3f
dec e
adc c
dec a
ld b, l
inc a
inc h
jr jr_04e_42e1
ld [$080c], sp
ld [$1818], sp
inc hl
ld [$0000], sp
ld [hl+], a
db $10
rlca
inc e
inc e
ld [hl+], a
ld h, $21
daa
add hl, hl
daa
ld b, e
db $10
rra
inc bc
ld [$070f], sp
jr_04e_42e1:
rlca
db $ec
ccf
rrca
ld h, b
ld h, b
sub c
sub e
jr jr_04e_42f8
or b
sbc e
ld e, h
ld e, a
rst $08
jp $40ce
rlca
add b
ld b, e
rlca
nop
jr_04e_42f8:
inc e
rrca
jr jr_04e_4313
inc [hl]
ld bc, $392a
Jump_04e_4300:
ld a, d
dec sp
ld a, b
ld a, a
sbc b
ld a, a
add b
ld a, a
add e
db $fd
ld b, $ff
inc b
rst $30
sbc b
ld a, a
add sp, $75
db $f4
jr_04e_4313:
ld b, $04
dec b
ld [hl+], a
inc b
nop
ld bc, $0443
nop
jr z, jr_04e_4321
nop
nop
jr_04e_4321:
ld b, h
ld [bc], a
nop
dec h
ld bc, $0001
ld bc, $23ec
inc hl
add b
ldh [$32], a
jr @-$06
inc a
inc b
ld a, b
ld [$10f0], sp
add sp, $38
db $e4
db $fc
ld [c], a
ld a, $e4
inc a
add sp, $38
db $e4
inc e
ld a, [c]
ld e, $f4
inc e
ei
rrca
ld sp, hl
rrca
cp l
ld [hl], a
db $fc
ld [hl], a
cp $73
cp e
ld h, l
rst $30
ld c, $ff
rrca
ld a, a
rrca
rst $30
ld c, $7f
nop
cp a
nop
ld e, a
nop
cpl
add h
add e
nop
ld d, a
push bc
add l
inc c
ld b, b
ccf
ld b, b
sbc l
ld [hl+], a
ld e, l
ld [hl+], a
xor $11
ld a, [$7f8d]
add a
ld b, e
ld a, [hl]
ld b, d
ld bc, $423e
ld b, e
ld a, $22
inc b
inc l
inc h
inc d
ld b, h
ld a, [bc]
ld [hl+], a
add d
rlca
ld c, h
ld b, h
xor h
call c, $b8b8
ldh [$f0], a
db $ec
daa
rla
call nz, $2ae4
ld [$f731], a
ret nz
rst $38
db $fc
ccf
rst $38
ld bc, $e07f
rst $30
ld sp, hl
ld a, l
ei
cp a
ld a, e
rst $08
inc sp
cp $01
ld c, a
rst $38
nop
dec c
ld a, a
nop
ccf
ld bc, $811f
sub a
add c
ld c, e
ld b, c
rla
ld b, c
cpl
ld hl, $1f45
ld de, $0b0d
ld hl, $2024
db $10
db $10
add hl, bc
ld [$1917], sp
rla
rla
ld c, $1e
db $ec
dec h
dec de
ld bc, $2101
ld hl, $5353
adc a
cp a
rlca
rst $38
ei
cp $b5
ld a, e
rst $18
or c
rst $30
ld sp, hl
db $dd
ei
rst $28
rst $18
or a
rst $08
rst $38
rrca
rst $30
rrca
add e
add e
dec c
rst $28
rra
rst $18
ccf
rst $38
ccf
ei
ld a, a
push de
rst $38
xor l
db $fd
ld d, h
ld a, h
ld b, e
inc h
inc a
dec c
inc b
inc a
ld c, b
ld a, b
ret z
ld hl, sp-$48
cp b
ld [hl], b
ld [hl], b
nop
nop
add b
add b
pop de
nop
rst $20
inc c
inc bc
rlca
dec bc
rra
dec h
ccf
inc bc
ld a, [hl]
ld d, a
ld a, [hl]
ld l, e
rst $38
rst $10
ld [hl+], a
rst $38
ld a, [bc]
db $fc
cp $7f
rst $38
ld e, a
ld a, a
ccf
ld a, a
ld e, b
ld a, h
or b
ld [hl+], a
ldh a, [$03]
and b
ldh [$60], a
ldh [rNR52], a
ret nz
ld b, e
ld b, b
ret nz
inc hl
ldh [rNR51], a
ldh a, [rSB]
ld hl, sp-$10
dec hl
ld hl, sp+$28
db $fc
inc c
ld a, h
ld a, h
ld e, h
ld a, h
ld l, b
ld a, h
ld e, b
ld a, b
ld h, h
ld a, h
add h
db $fc
sbc b
add e
push af
sub b
ld bc, $064d
add b
ret nz
ldh [$f0], a
ldh a, [$30]
ldh a, [rSCX]
ret c
ld hl, sp+$06
jr c, @-$06
ld hl, sp-$18
add sp, -$60
xor b
jp $01cf
add b
add b
db $ec
ld d, a
ld [bc], a
ld bc, $0201
call nz, $a380
ld [bc], a
ld e, a
and l
ld [bc], a
ld h, $04
Call_04e_4481:
ld bc, $0201
inc bc
ld [bc], a
and a
ld [bc], a
ld e, h
inc bc
ld [bc], a
nop