-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_05e.asm
executable file
·15030 lines (13158 loc) · 153 KB
/
bank_05e.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 "DQM.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 $05e", ROMX[$4000], BANK[$5e]
Jump_05e_4000:
ld e, [hl]
dec b
ld b, b
bit 0, b
ld a, [$dd60]
or a
ret z
Jump_05e_400a:
ld de, $4071
call Call_05e_413a
ld a, [$dd68]
or a
Call_05e_4014:
jr z, jr_05e_4021
ld a, [$daa4]
cp $03
jr z, jr_05e_4021
cp $04
jr nz, jr_05e_4031
jr_05e_4021:
ld hl, $ffc3
inc [hl]
ld hl, $ffc3
inc [hl]
ld hl, $ffc3
inc [hl]
ld hl, $ffc3
inc [hl]
jr_05e_4031:
ld a, [$dd66]
ldh [$c8], a
ld a, [$dd62]
or a
jr nz, jr_05e_4041
ld a, $00
ld [$dd60], a
jr_05e_4041:
ld a, [$dd68]
or a
ret nz
ld a, [$daa4]
cp $03
jr z, jr_05e_4051
cp $04
jr nz, jr_05e_4061
jr_05e_4051:
ldh a, [$c3]
cp $d0
ret c
ld a, $04
ld [$dd65], a
ld a, $01
ld [$dd68], a
ret
jr_05e_4061:
ldh a, [$c3]
cp $c0
ret c
ld a, $00
ld [$dd60], a
ld a, $01
ld [$dd68], a
ret
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
adc e
ld b, c
rst $00
ld b, e
cp l
ld b, h
db $ec
ld b, l
or a
ld b, a
ld h, b
ld c, c
jr nz, @+$4e
ld l, [hl]
ld d, c
add sp, $53
ld b, h
ld e, [hl]
xor h
ld l, d
dec a
ld [hl], c
ld a, $01
ld [$dd62], a
ld a, [$dd68]
or a
jr z, jr_05e_40e8
ld a, [$db54]
cp $07
jr nc, jr_05e_4123
add a
ld hl, $412c
add l
ld l, a
ld a, $00
adc h
ld h, a
ld a, [hl]
jr_05e_40e8:
ld hl, $ffc3
ld a, a
ld [hl+], a
ld a, $00
ld [hl+], a
ld a, $60
ld [hl+], a
ld a, $00
ld [hl+], a
ld a, [$daa4]
ld [hl+], a
ld a, $00
ld [hl+], a
ld a, $00
ld [hl+], a
ld a, $00
ld [hl+], a
ld a, $01
ld [$dd60], a
ld hl, $dd63
ld a, l
ld [$d7b4], a
ld a, h
ld [$d7b5], a
ld hl, $0205
rst $10
ld hl, $dd62
ld a, l
ld [$d7b4], a
ld a, h
ld [$d7b5], a
ret
jr_05e_4123:
xor a
ld [$dd60], a
xor a
ld [$dd62], a
ret
nop
nop
ld d, b
nop
jr c, jr_05e_4132
jr_05e_4132:
ld l, b
nop
jr nz, jr_05e_4136
jr_05e_4136:
ld d, b
nop
add b
nop
Call_05e_413a:
ldh a, [$cb]
cp $28
jr nc, jr_05e_418a
ldh a, [$c7]
ld l, a
ld h, $00
add hl, hl
add hl, de
ld e, [hl]
inc hl
ld d, [hl]
ldh a, [$c8]
ld l, a
ld h, $00
add hl, hl
add hl, de
ld e, [hl]
inc hl
ld d, [hl]
ldh a, [$cb]
sla a
sla a
ld l, a
ld h, $c0
jr_05e_415d:
ld a, [de]
inc de
cp $80
jr z, jr_05e_418a
ld b, a
ldh a, [$c5]
add b
add $10
ld [hl+], a
ld a, [de]
inc de
ld b, a
ldh a, [$c3]
add b
add $08
ld [hl+], a
ldh a, [$c9]
ld b, a
ld a, [de]
inc de
add b
ld [hl+], a
ld a, [de]
inc de
ld b, a
ldh a, [$ca]
xor b
ld [hl+], a
ldh a, [$cb]
inc a
ldh [$cb], a
cp $28
jr c, jr_05e_415d
jr_05e_418a:
ret
bit 0, c
call c, $fd41
ld b, c
ld h, $42
ld d, a
ld b, d
ld [hl], h
ld b, d
adc l
ld b, d
sbc d
ld b, d
and a
ld b, d
call nz, $fd42
ld b, d
ld h, d
ld b, e
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
add $43
ret c
inc bc
jr nz, jr_05e_41cf
jr_05e_41cf:
ret c
dec bc
ld hl, $d000
inc bc
ld [hl+], a
nop
ret nc
dec bc
inc hl
nop
add b
call c, $2000
nop
call c, $2108
nop
call nc, $2200
nop
call nc, $2308
nop
db $e4
ld hl, sp+$20
ld h, b
db $e4
ldh a, [rNR42]
ld h, b
db $ec
ld hl, sp+$22
ld h, b
db $ec
ldh a, [rNR44]
ld h, b
add b
ldh a, [$f4]
inc l
nop
ld hl, sp-$10
dec l
nop
add sp, -$08
ld a, [hl+]
nop
add sp, $00
dec hl
nop
ret nc
inc b
inc h
nop
ret nc
inc c
dec h
nop
ret c
nop
ld h, $00
ret c
ld [$0027], sp
ldh [$fb], a
jr z, jr_05e_4221
jr_05e_4221:
ldh [$03], a
add hl, hl
nop
add b
ld hl, sp-$10
inc l
nop
ldh a, [$ec]
ld l, $00
ret c
ld [$0025], sp
ret nc
inc c
ld l, $00
ret nc
inc b
inc h
nop
ret c
nop
jr z, jr_05e_427e
ldh [$fc], a
ld h, $00
ldh [rDIV], a
jr_05e_4244:
daa
nop
add sp, -$09
jr z, jr_05e_424a
jr_05e_424a:
add sp, -$01
add hl, hl
nop
ldh a, [$f4]
ld a, [hl+]
nop
ldh a, [$fc]
dec hl
nop
add b
ld hl, sp-$12
ld l, $00
ldh a, [$f3]
ld l, $00
add sp, -$08
ld l, $00
ldh [$fe], a
ld l, $00
ret c
inc bc
ld l, $00
ret nc
ld [$002e], sp
ldh [$f6], a
inc h
nop
add b
ld hl, sp-$12
ld l, $00
ldh a, [$f3]
ld l, $00
add sp, -$08
jr_05e_427e:
ld l, $00
ldh [$fe], a
cpl
nop
ret c
inc bc
cpl
nop
ld hl, sp-$1a
inc h
nop
add b
ld hl, sp-$10
cpl
nop
ldh a, [$f5]
cpl
nop
add sp, -$06
cpl
nop
add b
ld hl, sp-$08
inc e
nop
ld hl, sp+$00
ld e, $00
ldh a, [$fd]
rra
nop
add b
ld hl, sp-$04
dec e
nop
ld hl, sp+$04
ld e, $00
ldh a, [$fc]
ld a, [de]
nop
ldh a, [rDIV]
jr_05e_42b5:
dec de
nop
ld hl, sp-$0c
inc e
nop
ldh a, [$f4]
add hl, de
nop
ld [$00fa], a
jr nz, jr_05e_4244
ld hl, sp-$04
ld c, $00
add sp, -$04
ld a, [de]
jr nz, jr_05e_42b5
jr_05e_42cd:
db $f4
dec de
jr nz, @-$0e
db $fc
dec e
jr nz, jr_05e_42cd
jr_05e_42d5:
db $f4
inc d
nop
ld hl, sp+$04
jr_05e_42da:
ld d, $00
ldh a, [$0c]
add hl, de
jr nz, @-$06
jr_05e_42e1:
inc c
jr_05e_42e2:
inc e
jr nz, jr_05e_42d5
db $ec
dec de
jr nz, jr_05e_42e1
db $ec
jr_05e_42ea:
ld e, $20
ld [c], a
cp $00
nop
add sp, $04
jr_05e_42f2:
inc c
nop
ldh a, [rDIV]
ld e, $00
ldh a, [$f4]
ld c, $00
add b
ret nc
jr_05e_42fe:
ld hl, sp+$00
jr nz, jr_05e_42da
jr_05e_4302:
nop
ld bc, $d820
ld hl, sp+$02
jr nz, jr_05e_42ea
jr_05e_430a:
nop
inc b
jr nz, @-$1e
jr_05e_430e:
ld hl, sp+$05
jr nz, jr_05e_42f2
jr_05e_4312:
ldh a, [rTMA]
jr nz, jr_05e_42fe
db $10
rlca
jr nz, jr_05e_4302
ld [$2008], sp
add sp, $00
add hl, bc
jr nz, jr_05e_430a
jr_05e_4322:
ld hl, sp+$0a
jr nz, jr_05e_430e
ldh a, [$0b]
jr nz, jr_05e_4312
jr_05e_432a:
add sp, $0c
jr nz, @-$0e
jr_05e_432e:
db $10
dec c
jr nz, jr_05e_4322
jr_05e_4332:
ld [$200e], sp
ldh a, [rP1]
rrca
jr nz, jr_05e_432a
ld hl, sp+$10
jr nz, jr_05e_432e
jr_05e_433e:
ldh a, [rNR11]
jr nz, jr_05e_4332
jr_05e_4342:
add sp, $12
jr nz, jr_05e_433e
db $10
inc de
jr nz, jr_05e_4342
jr_05e_434a:
ld [$2014], sp
ld hl, sp+$00
dec d
jr nz, jr_05e_434a
jr_05e_4352:
ld hl, sp+$16
jr nz, @-$06
ldh a, [rNR22]
jr nz, jr_05e_4352
add sp, $18
jr nz, jr_05e_433e
inc c
inc bc
jr nz, jr_05e_42e2
ret nc
nop
nop
nop
ret c
ld hl, sp+$01
nop
ret c
nop
ld [bc], a
nop
ldh [$f8], a
inc b
nop
ldh [rP1], a
dec b
nop
ldh [$08], a
ld b, $00
add sp, -$18
rlca
nop
add sp, -$10
ld [$e800], sp
ld hl, sp+$09
nop
add sp, $00
ld a, [bc]
nop
add sp, $08
dec bc
nop
add sp, $10
inc c
nop
ldh a, [$e8]
dec c
nop
ldh a, [$f0]
ld c, $00
ldh a, [$f8]
rrca
nop
ldh a, [rP1]
stop
ldh a, [$08]
ld de, $f000
db $10
ld [de], a
nop
ld hl, sp-$18
inc de
nop
ld hl, sp-$10
inc d
nop
ld hl, sp-$08
dec d
nop
ld hl, sp+$00
ld d, $00
ld hl, sp+$08
rla
nop
ld hl, sp+$10
jr jr_05e_43c2
jr_05e_43c2:
ldh [$ec], a
inc bc
nop
add b
rlca
ld b, h
db $10
ld b, h
add hl, hl
ld b, h
ld b, d
ld b, h
ld e, e
ld b, h
sbc h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
cp h
ld b, h
ret nc
ld hl, sp+$04
nop
ret nc
nop
dec b
nop
add b
ldh [$f8], a
inc b
nop
ldh [rP1], a
jr_05e_4416:
dec b
nop
ret c
ld hl, sp+$02
nop
ret c
nop
inc bc
nop
ret nc
ld hl, sp+$00
nop
ret nc
nop
ld bc, $8000
call c, $17f8
nop
call c, $1700
jr nz, jr_05e_4416
ldh a, [$15]
jr_05e_4434:
nop
db $e4
ld hl, sp+$16
jr_05e_4438:
nop
db $e4
ld [$2015], sp
db $e4
nop
ld d, $20
add b
db $e4
nop
rlca
nop
db $e4
ld [$0008], sp
db $e4
ld hl, sp+$07
jr nz, @-$1a
ldh a, [$08]
jr nz, @-$22
ld hl, sp+$00
nop
call c, Boot
nop
add b
call nc, $0df8
jr nz, jr_05e_4434
ldh a, [$0e]
jr nz, jr_05e_4438
nop
dec c
nop
call nc, $0e08
nop
call c, $0f00
nop
call c, $1008
nop
call c, $1110
nop
call c, $10f0
jr nz, @-$22
add sp, $11
jr nz, @-$22
ld hl, sp+$0f
jr nz, @-$1a
ld hl, sp+$12
jr nz, @-$1a
ldh a, [rNR13]
jr nz, @-$1a
add sp, $14
jr nz, @-$1a
nop
ld [de], a
nop
db $e4
ld [$0013], sp
db $e4
db $10
jr_05e_4499:
inc d
nop
add b
call c, $09f8
jr nz, @-$22
ldh a, [$0a]
jr nz, @-$22
nop
add hl, bc
nop
call c, $0a08
nop
db $e4
ld hl, sp+$0b
jr nz, @-$1a
ldh a, [$0c]
jr nz, jr_05e_4499
nop
dec bc
nop
db $e4
ld [$000c], sp
add b
db $fd
ld b, h
ld b, $45
rla
ld b, l
ld b, h
ld b, l
add l
ld b, l
jp nz, $e345