-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmf3.dis
4737 lines (4735 loc) · 51.6 KB
/
mf3.dis
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
; z80dasm 1.1.0
; command line: z80dasm --origin=0 --sym-input=sysvarp3.sym -l -o mf3.asm original.rom
org 00000h
SWAP: equ 0x5b00
BANKM: equ 0x5b5c
BANK678: equ 0x5b67
LODDRV: equ 0x5b79
SAVDRV: equ 0x5b7a
BANK1: equ 0x7ffd
l0000h:
jp l0641h
l0003h:
inc d
l0004h:
ld bc,l1461h
l0007h:
nop
l0008h:
ld h,d
l0009h:
ld l,a
l000ah:
ld (hl),d
l000bh:
ld (hl),h
jr nz,l0053h
l000eh:
ld (hl),d
ld h,c
l0010h:
ld (hl),e
l0011h:
ld h,l
l0012h:
ld a,(l0606h)
l0015h:
djnz l001eh
ld de,l1302h
ld bc,l0116h
rlca
l001eh:
ld d,001h
l0020h:
dec de
inc d
l0022h:
ld bc,04e45h
ld d,h
ld b,l
ld d,d
inc d
nop
l002ah:
push hl
ld hl,02006h
jr l0035h
jp l1each
nop
l0034h:
jp (hl)
l0035h:
set 1,(hl)
l0037h:
pop hl
ret
l0039h:
ld b,006h
ld de,l1002h
rlca
ld d,000h
l0041h:
nop
l0042h:
dec de
inc sp
rla
dec de
ld c,h
nop
inc bc
dec de
ld b,b
l004bh:
ld b,a
defb 0edh;next byte illegal after ed
l004dh:
in a,(057h)
ld (hl),d
ld l,c
ld (hl),h
l0052h:
ld h,l
l0053h:
jr nz,l00c5h
ld (hl),d
ld l,a
ld (hl),h
ld h,l
ld h,e
ld (hl),h
ld h,l
ld h,h
jr nz,$+8
l005fh:
ld d,000h
ld d,010h
ld bc,00611h
nop
nop
jp l0102h
l006bh:
jp l1190h
l006eh:
jp l0dc9h
l0071h:
jp l0dd6h
l0074h:
call sub_1380h
jp nc,l0202h
ld a,(02002h)
ld hl,(02000h)
l0080h:
dec a
jr nz,l0034h
ex de,hl
ld hl,03fe4h
ld (hl),e
inc hl
ld (hl),d
rst 0
sub_008bh:
ld hl,060b3h
ld bc,005b3h
l0091h:
ld de,0202dh
jr l00a7h
sub_0096h:
ld a,(06000h)
xor 002h
ld (06000h),a
ld de,0c000h
ld hl,04000h
ld bc,l1b00h
l00a7h:
jp l05f1h
sub_00aah:
ld hl,025e1h
ld de,050c0h
ld b,008h
l00b2h:
push bc
ld bc,00040h
ldir
ld e,0c0h
pop bc
djnz l00b2h
l00bdh:
ld de,05ac0h
ld bc,00040h
ldir
l00c5h:
ret
ld bc,l0403h
ld b,012h
ld bc,l1220h
nop
l00cfh:
ld b,(hl)
ld l,c
ld l,h
ld h,l
l00d3h:
jr nz,l0149h
ld l,a
ld l,a
jr nz,$+100
ld l,c
ld h,a
ld b,006h
l00ddh:
ld d,001h
rra
ccf
sub_00e1h:
ld hl,025e1h
ld de,05fe0h
ld bc,l002ah
ldir
ret
sub_00edh:
call sub_02e9h
ld bc,03fffh
ld hl,0c000h
sub_00f6h:
ld (hl),000h
ld d,h
ld e,l
inc de
ldir
ret
ret
l00ffh:
ld hl,(l0000h)
l0102h:
ld (03ffeh),sp
l0106h:
ld sp,03ffeh
l0109h:
push af
push hl
ld a,i
push af
di
l010fh:
ld a,r
push af
l0112h:
push de
push bc
l0114h:
ex af,af'
l0115h:
push af
l0116h:
ex af,af'
exx
push hl
push de
push bc
exx
push ix
l011eh:
push iy
ld iy,05c3ah
l0124h:
ld sp,(03ffeh)
ex (sp),hl
ld sp,03fe6h
push hl
ld sp,(03ffeh)
ex (sp),hl
ld sp,03fd4h
call sub_1d9eh
xor a
ld (0201dh),a
ld (0200ah),a
ld i,a
ld a,010h
ld (03ff6h),a
ld bc,07f3fh
l0149h:
in a,(c)
and 00fh
ld c,a
l014eh:
ld a,(03ff6h)
or c
ld (03ff6h),a
ld bc,01f3fh
in a,(c)
and 00fh
rlca
rlca
rlca
rlca
ld c,a
ld a,(03ff8h)
and 004h
or c
ld (03ff8h),a
ld hl,03fe3h
ld de,00f10h
ld c,0fdh
l0172h:
ld b,0ffh
out (c),d
in a,(c)
ld (hl),a
ld a,d
and 00ch
cp 008h
jr nz,l0185h
ld b,0bfh
xor a
out (c),a
l0185h:
dec hl
dec d
dec e
jr nz,l0172h
ei
halt
di
ld hl,02006h
ld a,(03ff8h)
bit 1,(hl)
jr z,l0199h
set 0,a
l0199h:
ld (03ff8h),a
im 1
ld hl,(02027h)
ld de,0260bh
and a
sbc hl,de
add hl,de
ld de,03fc3h
jr c,l01bbh
l01adh:
and a
ex de,hl
sbc hl,de
jr c,l01bbh
ex de,hl
ld de,(02029h)
ld (hl),e
inc hl
ld (hl),d
l01bbh:
call sub_0274h
call sub_0312h
call 05ff7h
ld hl,03ff6h
jr z,l01cbh
res 4,(hl)
l01cbh:
call sub_0336h
l01ceh:
call 05ff7h
ex af,af'
call sub_030dh
ex af,af'
ld a,(03ff6h)
jr z,l01e2h
ld hl,02006h
set 3,(hl)
jr l01e4h
l01e2h:
res 3,a
l01e4h:
ld (03ff6h),a
ld (0201eh),a
call sub_00e1h
ld hl,02003h
ld a,(hl)
cp 052h
l01f3h:
jr nz,l0204h
inc hl
ld a,(hl)
cp 055h
jr nz,l0204h
inc hl
ld a,(hl)
cp 04eh
l01ffh:
jp z,l0074h
l0202h:
ld (hl),000h
l0204h:
di
ld hl,SWAP
ld de,0202dh
ld bc,005b3h
ldir
ld hl,SWAP
ld bc,l00ffh
call sub_00f6h
call sub_026eh
jr z,l0232h
call sub_0336h
ld hl,l02c5h
ld de,05fe0h
ld bc,l0037h
ldir
call 05fe0h
call sub_02fch
l0232h:
call sub_0263h
call sub_0241h
jp l11a1h
sub_023bh:
call sub_05ffh
call sub_05cbh
sub_0241h:
call sub_02fch
call sub_058bh
ld hl,050c0h
ld de,025e1h
ld b,008h
l024fh:
push bc
ld bc,00040h
ldir
ld l,0c0h
pop bc
djnz l024fh
ld hl,05ac0h
ld bc,00040h
l0260h:
ldir
ret
sub_0263h:
ld hl,l1b78h
ld de,05fe0h
ld bc,l00d3h
jr l0260h
sub_026eh:
ld hl,02006h
bit 3,(hl)
ret
sub_0274h:
ld hl,05fe0h
push hl
ld de,025e1h
ld bc,l002ah
push bc
ldir
ld hl,l029ch
pop bc
pop de
ldir
ld hl,0260bh
ld de,03fc3h
call 05fe0h
ld hl,(06008h)
dec hl
dec hl
dec hl
dec hl
ld (02027h),hl
ret
l029ch:
in a,(0bfh)
l029eh:
and a
sbc hl,de
add hl,de
jr z,l02bfh
ld a,(hl)
inc hl
cp 0f1h
jr nz,l029eh
ld a,(hl)
inc hl
cp 0c9h
jr nz,l029eh
l02b0h:
ld (06008h),hl
in a,(0bfh)
ld a,(l0000h+1)
cp 0afh
ex af,af'
in a,(03fh)
ex af,af'
ret
l02bfh:
ld hl,04004h
jr l02b0h
nop
l02c5h:
in a,(0bfh)
ld hl,l00bdh
ld de,SWAP
ld bc,l0052h
ldir
ld hl,0cf07h
ld (BANKM),hl
ld a,014h
ld (BANK678),hl
ld a,041h
ld (LODDRV),a
ld (SAVDRV),a
in a,(03fh)
sub_02e7h:
ld a,010h
sub_02e9h:
ld bc,BANK1
l02ech:
out (c),a
ret
sub_02efh:
call sub_033dh
ld a,(BANKM)
or 007h
ld (BANKM),a
jr sub_02e9h
sub_02fch:
ld a,007h
out (0feh),a
call sub_02e7h
ld (BANKM),a
sub_0306h:
ld a,014h
ld (BANK678),a
jr l031ah
sub_030dh:
ld a,010h
sub_030fh:
call sub_02e9h
sub_0312h:
ld a,040h
sub_0314h:
rrca
rrca
rrca
rrca
and 00fh
l031ah:
or 010h
ld bc,BANK2
jr l02ech
sub_0321h:
ld a,(BANK678)
and 0f8h
call l031ah
ld (BANK678),a
l032ch:
ld a,(BANKM)
and 0e7h
ld (BANKM),a
jr sub_02e9h
sub_0336h:
xor a
call sub_0314h
xor a
jr sub_02e9h
sub_033dh:
ld a,(BANK678)
or 014h
ld (BANK678),a
call l031ah
jr l032ch
sub_034ah:
ld hl,0c000h
push hl
ld bc,l0000h
call sub_03dbh
pop de
push hl
and a
sbc hl,de
ex de,hl
ld hl,04000h
and a
sbc hl,de
pop hl
jr z,l0383h
push de
ex de,hl
ld hl,0c000h
ld c,(hl)
inc hl
ld b,(hl)
ld l,c
ld h,b
ex de,hl
ld (hl),e
inc hl
ld (hl),d
pop hl
inc hl
inc hl
ex de,hl
ld hl,0c000h
ld (hl),e
inc hl
ld (hl),d
xor a
inc a
l037dh:
scf
ccf
ret
l0380h:
xor a
jr l037dh
l0383h:
ld hl,0c000h
l0386h:
xor a
cp (hl)
jr nz,l0380h
inc hl
ld a,l
or h
jr nz,l0386h
scf
ret
sub_0391h:
ld a,(05fe0h)
bit 6,a
jr nz,l03aeh
ld hl,04000h
push hl
ld bc,SWAP
call sub_03dbh
pop de
and a
sbc hl,de
ld (05ffch),hl
ld hl,05fe0h
set 6,(hl)
l03aeh:
call sub_02e7h
ld a,(05fe0h)
bit 7,a
ret nz
ld hl,060b3h
ld (05ff6h),hl
ld bc,l0000h
ld (05ff8h),bc
call sub_03dbh
ld (05ffeh),hl
ld de,05fe0h
and a
sbc hl,de
ld (05ffah),hl
ld hl,05fe0h
set 7,(hl)
ret
l03d9h:
pop hl
ret
sub_03dbh:
push bc
ld a,(02006h)
l03dfh:
bit 0,a
jr nz,l03d9h
push hl
dec hl
dec bc
dec bc
l03e7h:
inc hl
and a
sbc hl,bc
jr nc,l0400h
add hl,bc
ld a,(hl)
cp 037h
jr nz,l03e7h
inc hl
ld a,(hl)
cp 0edh
jr nz,l03e7h
inc hl
ld a,(hl)
cp 0cbh
jr nz,l03e7h
scf
l0400h:
pop hl
jr c,l03d9h
l0403h:
exx
pop bc
push hl
exx
push hl
pop de
l0409h:
ld bc,l0000h
ld a,(de)
l040dh:
inc de
inc bc
push de
exx
pop hl
and a
sbc hl,bc
exx
jr z,l041dh
ex de,hl
cp (hl)
ex de,hl
jr z,l040dh
l041dh:
push af
ex af,af'
ld a,c
and 0f8h
or b
jr nz,l0433h
pop af
push af
ld b,c
l0428h:
ld (hl),a
inc hl
djnz l0428h
l042ch:
pop af
jr nz,l0409h
exx
pop hl
exx
ret
l0433h:
ld (hl),c
inc hl
ld (hl),b
inc hl
ex af,af'
ld (hl),a
inc hl
ld (hl),037h
inc hl
ld (hl),0edh
inc hl
ld (hl),0cbh
inc hl
jr l042ch
sub_0445h:
call sub_04dfh
call sub_026eh
ret z
bit 4,(hl)
ret nz
ld a,011h
call sub_04adh
jr c,l0460h
ld (0601ah),de
set 0,(hl)
jr z,l0460h
set 4,(hl)
l0460h:
ld a,013h
call sub_04adh
jr c,l0471h
ld (0601ch),de
set 1,(hl)
jr z,l0471h
set 5,(hl)
l0471h:
ld a,014h
call sub_04adh
jr c,l0482h
ld (0601eh),de
set 2,(hl)
jr z,l0482h
set 6,(hl)
l0482h:
ld a,016h
call sub_04adh
jr c,l0493h
ld (06020h),de
set 3,(hl)
jr z,l0493h
set 7,(hl)
l0493h:
ld a,017h
call sub_04adh
ld hl,06019h
jr c,l04a7h
ld (06022h),de
set 3,(hl)
jr z,l04a7h
set 7,(hl)
l04a7h:
call sub_02e7h
xor a
inc a
ret
sub_04adh:
call sub_02e9h
call sub_034ah
jr z,l04cfh
ld a,(0c002h)
or a
jr nz,l04d1h
ld de,(0c000h)
ld hl,l0008h
l04c2h:
and a
sbc hl,de
jr nz,l04d1h
call sub_0529h
l04cah:
ld hl,06018h
scf
ret
l04cfh:
jr c,l04cah
l04d1h:
jr nz,l04d6h
ld de,04000h
l04d6h:
ld hl,06018h
scf
ccf
ret
sub_04dch:
call sub_04e8h
sub_04dfh:
ld hl,06018h
ld bc,l000bh
jp sub_00f6h
sub_04e8h:
ld a,(06018h)
rlca
jr c,l050bh
l04eeh:
rlca
jr c,l0514h
l04f1h:
rlca
jr c,l051dh
l04f4h:
rlca
jr nc,l04fch
ld a,011h
call sub_0526h
l04fch:
ld a,(06019h)
bit 7,a
jr z,l0508h
ld a,017h
call sub_0526h
l0508h:
jp sub_02e7h
l050bh:
push af
ld a,016h
call sub_0526h
pop af
jr l04eeh
l0514h:
push af
ld a,014h
call sub_0526h
pop af
jr l04f1h
l051dh:
push af
ld a,013h
call sub_0526h
pop af
jr l04f4h
sub_0526h:
call sub_02e9h
sub_0529h:
ld hl,0c000h
ld c,(hl)
inc hl
ld b,(hl)
dec bc
dec bc
dec hl
add hl,bc
push hl
ld e,(hl)
inc hl
ld d,(hl)
ld hl,0c000h
ld (hl),e
inc hl
ld (hl),d
ld de,l0000h
pop hl
ld ix,0c000h
call sub_054ah
xor a
ret
sub_054ah:
dec hl
dec de
dec ix
and a
sbc hl,de
add hl,de
ret z
l0553h:
push hl
push de
push ix
pop de
and a
sbc hl,de
pop de
pop hl
ret z
ld a,(hl)
push af
cp 0cbh
dec hl
jr z,l056ah
l0565h:
pop af
ld (de),a
dec de
jr l0553h
l056ah:
ld a,(hl)
cp 0edh
jr nz,l0565h
dec hl
ld a,037h
cp (hl)
jr z,l0578h
inc hl
jr l0565h
l0578h:
pop af
dec hl
ld a,(hl)
dec hl
ld b,(hl)
dec hl
ld c,(hl)
dec hl
l0580h:
ld (de),a
dec de
dec bc
ex af,af'
ld a,b
or c
jr z,l0553h
ex af,af'
jr l0580h
sub_058bh:
ld a,(05fe0h)
bit 6,a
jr z,l05a9h
sub_0592h:
ld ix,04000h
push ix
pop hl
ld de,(05ffch)
add hl,de
ld de,SWAP
call sub_054ah
ld hl,05fe0h
res 6,(hl)
l05a9h:
ld a,(05fe0h)
bit 7,a
ret z
sub_05afh:
call sub_02e7h
ld hl,(05ffeh)
ld ix,(05ff6h)
ld de,l0000h
call sub_054ah
ld hl,05fe0h
res 7,(hl)
ret
sub_05c5h:
call sub_05cbh
call sub_05e8h
sub_05cbh:
ld a,(BANKM)
and 0f0h
or 001h
call sub_02e9h
ld hl,0c000h
ld de,02f1bh
ld bc,l1000h
jr l05f1h
sub_05e0h:
ld a,(BANKM)
or 007h
call sub_02e9h
sub_05e8h:
ld hl,0c000h
ld de,08000h
ld bc,04000h
l05f1h:
ld a,(hl)
ex af,af'
ld a,(de)
ld (hl),a
ex af,af'
ld (de),a
inc hl
inc de
dec bc
ld a,b
or c
jr nz,l05f1h
ret
sub_05ffh:
ld a,(BANKM)
and 0f0h
or 007h
l0606h:
call sub_02e9h
ld (BANKM),a
ld hl,0db00h
ld de,025e1h
ld bc,l0939h
call l05f1h
ld hl,0e600h
ld bc,l0000h+1
jr l05f1h