-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank_059.asm
executable file
·13800 lines (12941 loc) · 137 KB
/
bank_059.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 $059", ROMX[$4000], BANK[$59]
ld e, c
inc de
ld b, b
rst $28
ld b, b
adc a
ld b, l
add b
ld b, [hl]
inc h
ld c, b
ret nc
ld c, b
db $e4
ld d, d
db $eb
ld d, d
ld a, [c]
ld d, d
xor a
ld hl, $c0d8
ld bc, $0028
call $12c7
xor a
ld hl, $c8da
ld bc, $0008
call $12c7
xor a
ld hl, $ffc3
ld bc, $0012
call $12c7
xor a
ld hl, $dd62
ld bc, $0006
call $12c7
xor a
ld hl, $c500
ld bc, $0240
call $12c7
call $1264
ld hl, $c817
ld [hl], $00
inc hl
ld [hl], $00
ld hl, $0801
rst $10
xor a
ld [$dd60], a
xor a
ld [$c8ec], a
ld hl, $9700
ld de, $0901
call $098f
call Call_059_42c0
ld hl, $8800
ld de, $0601
call $098f
xor a
ld [$c823], a
ld a, $03
ld [$c822], a
call Call_059_52e4
ld hl, $9700
ld de, $0901
ld a, l
ld [$c827], a
ld a, h
ld [$c828], a
ld a, e
ld [$c829], a
ld a, d
ld [$c82a], a
ld de, $2e00
ld hl, $8d00
call $14cf
ld hl, $9800
ld a, l
ld [$d9f8], a
ld a, h
ld [$d9f9], a
ld hl, $c500
ld de, $4511
call Call_059_5ca8
ld hl, $c500
ld de, $4546
call Call_059_5ca8
call Call_059_42ec
call Call_059_432d
ld a, $fc
call $1688
ld a, $07
ldh [$b5], a
ld a, $ff
ldh [$b6], a
ld a, $00
ldh [$bb], a
ld a, $00
ldh [$b7], a
call $122f
xor a
ld [$c8a4], a
ld [$c8a5], a
xor a
ld [$c892], a
ld a, $03
ld [$c8a1], a
call $125d
ld a, $01
jp $11cb
ld a, [$c850]
or a
ret nz
ld a, [$c843]
xor $ff
ld b, a
ld a, [$c842]
ld [$c76c], a
or a
jr z, jr_059_4104
and b
jr_059_4104:
ld [$c76d], a
ld a, [$c0d8]
rst $00
rla
ld b, c
ld e, l
ld b, c
ld h, l
ld b, c
ld l, [hl]
ld b, c
ld a, [bc]
ld b, d
ld h, b
ld b, d
call Call_059_4276
ld a, [$c76d]
and $01
jr nz, jr_059_413c
ld a, [$c76d]
and $02
jr nz, jr_059_4152
ld a, [$c76d]
and $c0
jr nz, jr_059_4130
ret
jr_059_4130:
ld a, [$c8da]
xor $01
ld [$c8da], a
call Call_059_432d
ret
jr_059_413c:
ld a, [$c8da]
set 7, a
ld [$c8da], a
call Call_059_432d
ld a, [$c8da]
and $01
add $03
ld [$c0d8], a
ret
jr_059_4152:
ld a, $04
call $1688
ld a, $05
ld [$c0d8], a
ret
ld hl, $c0d8
inc [hl]
call Call_059_42c0
ret
ld a, $04
ld [$c0d8], a
call Call_059_42ec
ret
call Call_059_4276
ld a, [$c842]
and $40
jr nz, jr_059_419c
ld a, [$c842]
and $80
jr nz, jr_059_41a7
ld a, [$c842]
and $20
jr nz, jr_059_41b2
ld a, [$c842]
and $10
jr nz, jr_059_41bd
ld a, [$c76d]
and $01
jr nz, jr_059_41c8
ld a, [$c76d]
and $02
jr nz, jr_059_41fa
ret
jr_059_419c:
ld a, $02
ld [$dd64], a
ld a, $00
ldh [$ca], a
jr jr_059_41db
jr_059_41a7:
ld a, $00
ld [$dd64], a
ld a, $00
ldh [$ca], a
jr jr_059_41db
jr_059_41b2:
ld a, $01
ld [$dd64], a
ld a, $20
ldh [$ca], a
jr jr_059_41db
jr_059_41bd:
ld a, $01
ld [$dd64], a
ld a, $00
ldh [$ca], a
jr jr_059_41db
jr_059_41c8:
ld a, [$c0e1]
ld b, a
ld a, [$dd64]
sub b
ld [$dd64], a
ld a, [$c0e1]
xor $03
ld [$c0e1], a
jr_059_41db:
ld a, [$c0e1]
ld b, a
ld a, [$dd64]
add b
ld [$dd64], a
xor a
ld [$dd65], a
ld hl, $dd63
ld a, l
ld [$d7b4], a
ld a, h
ld [$d7b5], a
ld hl, $0205
rst $10
ret
jr_059_41fa:
ld a, [$c8da]
res 7, a
ld [$c8da], a
call Call_059_432d
xor a
ld [$c0d8], a
ret
ld a, [$c76d]
and $01
jr nz, jr_059_424a
call Call_059_4276
ld a, [$c76d]
and $02
jr nz, jr_059_4250
ld a, [$c842]
and $20
jr nz, jr_059_422a
ld a, [$c842]
and $10
jr nz, jr_059_423a
ret
jr_059_422a:
ld a, [$c8dc]
or a
jr nz, jr_059_4232
ld a, $d7
jr_059_4232:
dec a
ld [$c8dc], a
call Call_059_42ec
ret
jr_059_423a:
ld a, [$c8dc]
inc a
cp $d7
jr c, jr_059_4243
xor a
jr_059_4243:
ld [$c8dc], a
call Call_059_42ec
ret
jr_059_424a:
ld a, $01
ld [$c0d8], a
ret
jr_059_4250:
ld a, [$c8da]
res 7, a
ld [$c8da], a
call Call_059_432d
xor a
ld [$c0d8], a
ret
ld a, $00
ld [$c88a], a
xor a
ld [$c88b], a
xor a
ld [$c88c], a
xor a
ld [$c88d], a
ld hl, $c88e
inc [hl]
ret
Call_059_4276:
ld hl, $ffc3
ld a, $50
ld [hl+], a
ld a, $00
ld [hl+], a
ld a, $48
ld [hl+], a
ld a, $00
ld [hl+], a
ld a, [$c0e0]
add $10
ld [hl+], a
inc hl
ld a, $00
ld [hl], a
ld hl, $dd63
ld a, l
ld [$d7b4], a
ld a, h
ld [$d7b5], a
ld hl, $0205
rst $10
ldh a, [$c8]
cp $ff
ret z
ld hl, $0402
rst $10
ld hl, $dd62
ld a, l
ld [$d7b4], a
ld a, h
ld [$d7b5], a
ld hl, $0200
rst $10
ld a, [$dd62]
or a
ret nz
xor a
ld [$dd65], a
ret
Call_059_42c0:
ld a, [$c8dc]
ld l, a
ld [$c0e0], a
ld h, $00
add hl, hl
ld a, l
add $63
ld l, a
ld a, h
adc $43
ld h, a
ld e, [hl]
inc hl
ld d, [hl]
ld h, $80
ld l, $00
call $1577
ld a, [$c8dc]
ld [$c823], a
ld a, $05
ld [$c822], a
ld hl, $4102
rst $10
ret
Call_059_42ec:
ld a, [$c0e0]
ld l, a
ld h, $00
call $5b7d
ld hl, $c521
ld a, [$c0e8]
add $f0
ld [hl+], a
ld a, [$c0e9]
add $f0
ld [hl+], a
ld a, [$c0ea]
add $f0
ld [hl+], a
ld a, [$c8dc]
ld l, a
ld h, $00
call $5b7d
ld hl, $c708
ld a, [$c0e8]
add $f0
ld [hl+], a
ld a, [$c0e9]
add $f0
ld [hl+], a
ld a, [$c0ea]
add $f0
ld [hl], a
ld hl, $5005
rst $10
ret
Call_059_432d:
ld hl, $c500
ld de, $457f
call Call_059_5ca8
ld a, [$c8da]
ld hl, $458b
and $01
add a
add l
ld l, a
ld a, $00
adc h
ld h, a
ld a, [hl+]
ld h, [hl]
ld l, a
ld a, l
add $00
ld l, a
ld a, h
adc $c5
ld h, a
ld a, [$c8da]
bit 7, a
jr nz, jr_059_435b
ld a, $e8
jr jr_059_435d
jr_059_435b:
ld a, $e9
jr_059_435d:
ld [hl], a
ld hl, $5005
rst $10
ret
ld bc, $022f
cpl
inc bc
cpl
inc b
cpl
dec b
cpl
ld b, $2f
rlca
cpl
ld [$092f], sp
cpl
ld a, [bc]
cpl
dec bc
cpl
inc c
cpl
dec c
cpl
ld c, $2f
rrca
cpl
db $10
cpl
nop
jr c, @+$03
jr c, jr_059_438a
jr c, @+$05
jr_059_438a:
jr c, jr_059_4390
jr c, @+$07
jr c, jr_059_4396
jr_059_4390:
jr c, @+$09
jr c, jr_059_439c
jr c, @+$0b
jr_059_4396:
jr c, jr_059_43a2
jr c, @+$0d
jr c, jr_059_43a8
jr_059_439c:
jr c, @+$0f
jr c, jr_059_43ae
jr c, @+$11
jr_059_43a2:
jr c, jr_059_43b4
jr c, @+$13
jr c, jr_059_43ba
jr_059_43a8:
jr c, @+$15
jr c, jr_059_43c0
jr c, @+$17
jr_059_43ae:
jr c, jr_059_43c6
jr c, @+$19
jr c, jr_059_43cc
jr_059_43b4:
jr c, @+$1b
jr c, jr_059_43d2
jr c, @+$1d
jr_059_43ba:
jr c, jr_059_43d8
jr c, @+$1f
jr c, jr_059_43de
jr_059_43c0:
jr c, @+$21
jr c, jr_059_43e4
jr c, @+$23
jr_059_43c6:
jr c, jr_059_43ea
jr c, @+$25
jr c, jr_059_43f0
jr_059_43cc:
jr c, @+$27
jr c, jr_059_43f6
jr c, @+$29
jr_059_43d2:
jr c, jr_059_43fc
jr c, @+$2b
jr c, jr_059_4402
jr_059_43d8:
jr c, @+$2d
jr c, jr_059_4408
jr c, @+$2f
jr_059_43de:
jr c, jr_059_440e
jr c, @+$31
jr c, jr_059_4414
jr_059_43e4:
jr c, @+$33
jr c, jr_059_441a
jr c, jr_059_441d
jr_059_43ea:
jr c, @+$36
jr c, jr_059_4423
jr c, jr_059_4426
jr_059_43f0:
jr c, jr_059_4429
jr c, jr_059_442c
jr c, jr_059_442f
jr_059_43f6:
jr c, jr_059_4432
jr c, jr_059_4435
jr c, jr_059_4438
jr_059_43fc:
jr c, jr_059_443b
jr c, jr_059_443e
jr c, jr_059_4441
jr_059_4402:
jr c, @+$42
jr c, jr_059_4447
jr c, jr_059_444a
jr_059_4408:
jr c, jr_059_444d
jr c, @+$46
jr c, jr_059_4453
jr_059_440e:
jr c, @+$48
jr c, jr_059_4459
jr c, jr_059_4414
jr_059_4414:
add hl, sp
ld bc, $0239
add hl, sp
inc bc
jr_059_441a:
add hl, sp
inc b
add hl, sp
jr_059_441d:
dec b
add hl, sp
ld b, $39
rlca
add hl, sp
jr_059_4423:
ld [$0939], sp
jr_059_4426:
add hl, sp
ld a, [bc]
add hl, sp
jr_059_4429:
dec bc
add hl, sp
inc c
jr_059_442c:
add hl, sp
dec c
add hl, sp
jr_059_442f:
ld c, $39
rrca
jr_059_4432:
add hl, sp
db $10
add hl, sp
jr_059_4435:
ld de, $1239
jr_059_4438:
add hl, sp
inc de
add hl, sp
jr_059_443b:
inc d
add hl, sp
dec d
jr_059_443e:
add hl, sp
ld d, $39
jr_059_4441:
rla
add hl, sp
jr jr_059_447e
add hl, de
add hl, sp
jr_059_4447:
ld a, [de]
add hl, sp
dec de
jr_059_444a:
add hl, sp
inc e
add hl, sp
jr_059_444d:
dec e
add hl, sp
ld e, $39
rra
add hl, sp
jr_059_4453:
jr nz, jr_059_448e
ld hl, $2239
add hl, sp
jr_059_4459:
inc hl
add hl, sp
inc h
add hl, sp
dec h
add hl, sp
ld h, $39
daa
add hl, sp
jr z, jr_059_449e
add hl, hl
add hl, sp
ld a, [hl+]
add hl, sp
dec hl
add hl, sp
inc l
add hl, sp
dec l
add hl, sp
ld l, $39
cpl
add hl, sp
jr nc, jr_059_44ae
ld sp, $3239
add hl, sp
inc sp
add hl, sp
inc [hl]
add hl, sp
dec [hl]
jr_059_447e:
add hl, sp
ld [hl], $39
scf
add hl, sp
jr c, jr_059_44be
add hl, sp
add hl, sp
ld a, [hl-]
add hl, sp
dec sp
add hl, sp
inc a
add hl, sp
dec a
jr_059_448e:
add hl, sp
ld a, $39
ccf
add hl, sp
ld b, b
add hl, sp
ld b, c
add hl, sp
ld b, d
add hl, sp
ld b, e
add hl, sp
ld b, h
add hl, sp
ld b, l
jr_059_449e:
add hl, sp
ld b, [hl]
add hl, sp
ld b, a
add hl, sp
nop
ld a, [hl-]
ld bc, $023a
ld a, [hl-]
inc bc
ld a, [hl-]
inc b
ld a, [hl-]
dec b
jr_059_44ae:
ld a, [hl-]
ld b, $3a
rlca
ld a, [hl-]
ld [$093a], sp
ld a, [hl-]
ld a, [bc]
ld a, [hl-]
dec bc
ld a, [hl-]
inc c
ld a, [hl-]
dec c
jr_059_44be:
ld a, [hl-]
ld c, $3a
rrca
ld a, [hl-]
db $10
ld a, [hl-]
ld de, $123a
ld a, [hl-]
inc de
ld a, [hl-]
inc d
ld a, [hl-]
dec d
ld a, [hl-]
ld d, $3a
rla
ld a, [hl-]
jr jr_059_450f
add hl, de
ld a, [hl-]
ld a, [de]
ld a, [hl-]
dec de
ld a, [hl-]
inc e
ld a, [hl-]
dec e
ld a, [hl-]
ld e, $3a
rra
ld a, [hl-]
jr nz, jr_059_451f
ld hl, $223a
ld a, [hl-]
inc hl
ld a, [hl-]
inc h
ld a, [hl-]
dec h
ld a, [hl-]
ld h, $3a
daa
ld a, [hl-]
jr z, jr_059_452f
add hl, hl
ld a, [hl-]
ld a, [hl+]
ld a, [hl-]
dec hl
ld a, [hl-]
inc l
ld a, [hl-]
dec l
ld a, [hl-]
ld l, $3a
cpl
ld a, [hl-]
jr nc, jr_059_453f
ld sp, $323a
ld a, [hl-]
inc sp
ld a, [hl-]
inc [hl]
ld a, [hl-]
dec [hl]
ld a, [hl-]
jr_059_450f:
ld [hl], $3a
nop
nop
ld a, [$efef]
rst $28
ei
ld a, [$efef]
rst $28
rst $28
rst $28
rst $28
jr_059_451f:
rst $28
rst $28
rst $28
ei
ret c