-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnabu_source.asm
2898 lines (2898 loc) · 27.5 KB
/
nabu_source.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
ld a,0x02
ld (0xffee),a
out (0x00),a
ld sp,0xffee
ld hl,0x06c9
ld b,0x08
ld c,0xa1
outi
ld a,b
or 0x80
out (0xa1),a
and 0x7f
jr nz,0x0011
ld hl,0xffef
ld de,0xfff0
ld bc,0x0009
xor a
ld (hl),a
ldir
call 0x0521
xor a
call 0x052a
call 0x052a
call 0x052a
call 0x052a
call 0x052a
ld a,0x40
call 0x052a
ld a,0x4e
call 0x052a
ld a,0x04
call 0x052a
call 0x04e3
call 0x0532
jp z,0x01ca
ld a,0x3a
out (0x00),a
ld h,0x0a
ld c,0x20
ld de,0xe000
ld b,0x01
call 0x0363
jr z,0x006a
djnz 0x006a
jr 0x008c
call 0x064d
jr z,0x0061
in a,(0x90)
cp 0x31
jr z,0x0082
cp 0x3d
jr nz,0x0061
bit 0,h
jr z,0x0061
dec h
jr z,0x0088
jr 0x0061
bit 0,h
jr nz,0x0061
jr 0x007d
ld hl,0xffef
inc (hl)
ld a,(0xfff6)
bit 0,a
jr nz,0x0098
call 0x04d1
out (0x00),a
xor a
ld (0xffff),a
ld ix,0x0ffd
ld de,0xffff
xor a
ld h,a
ld l,a
ld b,a
ld c,(ix+0)
add hl,bc
add ix,de
jr c,0x00a7
ld a,(0x0ffe)
cp l
jr nz,0x00bb
ld a,(0x0fff)
sub h
jr z,0x00be
call 0x04a6
call 0x046a
xor a
out (0xa1),a
ld a,0x40
out (0xa1),a
xor a
ld de,0x0001
ld ix,0xc000
out (0xa0),a
inc a
add ix,de
jr nc,0x00d0
ld ix,0xc000
xor a
ld c,a
ld b,a
ld h,a
ld l,a
ld a,l
out (0xa1),a
ld a,h
out (0xa1),a
in a,(0xa0)
cp c
jr nz,0x0103
ld a,l
out (0xa1),a
ld a,h
or 0x40
out (0xa1),a
ld a,c
cpl
out (0xa0),a
ld a,l
out (0xa1),a
ld a,h
out (0xa1),a
in a,(0xa0)
cpl
cp c
jr z,0x0106
call 0x04a6
inc c
inc hl
ld de,0x0001
add ix,de
jr nc,0x00e0
call 0x04e3
call 0x053e
call 0x046a
xor a
ld ix,0x2000
ld hl,0x2100
ld de,0x0001
ld (ix+0),a
inc a
inc ix
add hl,de
jr nc,0x0123
xor a
ld c,a
ld hl,0x2100
ld ix,0x2000
ld b,a
ld a,(ix+0)
cp c
jr nz,0x0147
cpl
ld (ix+0),a
ld a,(ix+0)
cpl
cp c
jr z,0x014a
call 0x04a6
inc ix
inc c
add hl,de
jr nc,0x0136
call 0x046a
ld b,0x10
ld c,0x00
ld a,b
dec a
out (0x41),a
ld a,c
out (0x40),a
djnz 0x0157
ld c,0x00
ld b,0xff
ld a,c
out (0x41),a
ld a,b
out (0x40),a
in a,(0x40)
call 0x017e
call nz,0x04a6
srl b
jr c,0x0164
inc c
ld a,0x0e
cp c
jr nz,0x0162
jr 0x0199
ld hl,0x018b
ld e,c
ld d,0x00
add hl,de
and (hl)
ld e,a
ld a,b
and (hl)
cp e
ret
rst 0x38
rrca
rst 0x38
rrca
rst 0x38
rrca
rra
rst 0x38
rra
rra
rra
rst 0x38
rst 0x38
rrca
call 0x046a
call 0x0521
ld de,0x0000
ld b,0x05
ld c,0x20
call 0x064d
jr z,0x01c1
in a,(0x90)
cp 0x95
jr nc,0x01c1
cp 0x91
jr c,0x01c1
cp 0x94
jr z,0x01bc
call 0x04a6
call 0x046a
jr 0x01ca
dec de
ld a,d
or e
jr nz,0x01a4
djnz 0x01a4
jr 0x01b9
in a,(0x80)
call 0x0386
jr z,0x01e3
call 0x04a6
jr 0x0206
ld a,0x05
ld (0xfff7),a
ld (0xfffe),a
call 0x04a6
jr 0x01ca
ld c,0x82
call 0x0379
jr nz,0x01d6
ld a,0x01
out (0x80),a
call 0x067a
in a,(0x80)
jr nz,0x01d6
ld (0xfff8),a
ld c,0x10
call 0x036c
jr nz,0x01d6
ld c,0xe1
call 0x036c
jr nz,0x01d6
call 0x0532
call nz,0x046a
ld a,(0xffef)
or a
jp nz,0x008c
ld a,(0xfff6)
bit 0,a
jr nz,0x0221
ld a,0x02
ld (0xffee),a
out (0x00),a
ld hl,0xfff8
bit 7,(hl)
jr z,0x029f
ld hl,0x06d1
call 0x056b
ld hl,0xfff9
ld de,0x02c7
call 0x057c
ld hl,0xfff9
xor a
ld c,a
ld b,0x04
ld a,(hl)
bit 0,b
jr z,0x024c
sla a
bit 4,a
jr z,0x024c
res 4,a
inc a
add a,c
ld c,a
inc hl
djnz 0x023e
and 0x0f
cp (hl)
jr z,0x0266
ld hl,0x07ac
call 0x056b
ld c,0x90
ld de,0xe000
call 0x06a2
jr 0x022e
ld hl,0xfff9
ld b,0x04
ld de,0x0000
ld a,(hl)
sla e
rl d
sla e
rl d
sla e
rl d
sla e
rl d
add a,e
ld e,a
inc hl
djnz 0x026e
push de
ld c,0x85
call 0x0379
jp nz,0x01d6
pop de
ld a,d
out (0x80),a
ld c,0x40
call 0x064d
ld a,e
out (0x80),a
call 0x05ee
jp nz,0x01d6
ld c,0x81
call 0x0379
jp nz,0x01d6
ld a,0x8f
out (0x80),a
ld c,0x40
call 0x064d
ld a,0x05
out (0x80),a
call 0x05ee
jp nz,0x01d6
ld a,0x05
ld (0xfff8),a
ld hl,0x0000
ld de,0x0000
ld bc,0x1000
ldir
ld a,(0xffee)
set 0,a
out (0x00),a
ld hl,0x072c
call 0x056b
xor a
ld (0x1000),a
ld (0x1001),a
ld (0x1003),a
inc a
ld (0x1002),a
ld bc,0x100b
ld (0x1004),bc
ld bc,0x140d
ld (0x1008),bc
xor a
ld (0x140b),a
ld (0x140c),a
xor a
out (0x41),a
out (0x40),a
call 0x068a
call 0x03b0
jp nz,0x01d6
xor a
out (0x41),a
ld a,(0x1003)
sla a
sla a
cpl
out (0x40),a
ld hl,(0x1004)
ld bc,0x000b
add hl,bc
ld a,(hl)
ld (0x100a),a
ld hl,(0x1006)
ld bc,0xffee
add hl,bc
push hl
pop bc
ld hl,(0x140b)
add hl,bc
ld (0x140b),hl
ld hl,(0x1004)
ld de,0x0010
add hl,de
ld de,(0x1008)
ldir
ld (0x1008),de
ld a,(0x100a)
bit 4,a
jr nz,0x034e
ld hl,0x1003
inc (hl)
jr 0x0302
ld a,0xa5
ld (0xfffe),a
ld a,0x5a
ld (0xffff),a
ld a,0x07
out (0x41),a
ld a,0x7f
out (0x40),a
jp 0x140f
dec de
ld a,d
or e
jr z,0x036a
xor a
dec a
inc a
ret
push bc
call 0x067a
pop bc
ret nz
in a,(0x80)
sub c
ret z
ld a,0x02
ret
ld a,c
out (0x80),a
ld c,0x10
call 0x036c
ret nz
ld c,0x06
jr 0x036c
ld b,0x04
ld a,0x83
push af
out (0x80),a
pop af
ld c,0x10
ld hl,0x03a4
push hl
call 0x036c
cp 0x02
jr z,0x038d
cp 0x00
ret z
pop af
djnz 0x0388
xor a
inc a
ret
ld c,0x06
ld hl,0x03ab
jr 0x0393
ld c,0xe4
pop hl
jr 0x0393
exx
xor a
dec a
ld d,a
ld e,a
exx
ld c,0x84
call 0x0379
ret nz
ld b,0x04
ld hl,0x1003
ld c,0x40
call 0x064d
jr z,0x03c1
ld a,(hl)
out (0x80),a
dec l
djnz 0x03c1
ld c,0xe4
call 0x036c
ret nz
ld b,0x18
ld de,0x0001
ld hl,0x0000
add hl,de
jr nc,0x03eb
djnz 0x03eb
ld hl,0x06f5
call 0x056b
pop bc
jp 0x02d7
ld c,0x80
call 0x064d
jr z,0x03dc
in a,(0x80)
sub 0x91
ret nz
ld a,0x10
out (0x80),a
ld c,0x40
call 0x064d
jr z,0x03fb
ld c,0x80
call 0x064d
ld hl,(0x1004)
ld bc,0x0000
res 0,e
ld a,0x06
out (0x80),a
push de
ld de,0xffff
ld a,0x0f
out (0x41),a
in a,(0x40)
bit 0,a
jr nz,0x0428
call 0x0363
jr nz,0x0465
jr 0x0417
pop de
in a,(0x80)
cp 0x10
jr nz,0x0441
bit 0,e
jr z,0x043d
res 0,e
ld (hl),a
call 0x065d
inc hl
inc bc
jr 0x0413
set 0,e
jr 0x0413
bit 0,e
jr nz,0x044d
ld (hl),a
call 0x065d
inc hl
inc bc
jr 0x0413
ld (0x1006),bc
cp 0xe1
jp nz,0x03b0
exx
ld a,e
cp 0x0f
jp nz,0x03b0
ld a,d
cp 0x1d
jp nz,0x03b0
xor a
ret
pop de
pop de
jp 0x01d6
ld c,0x50
ld hl,0xfff6
bit 1,(hl)
jr z,0x0475
ld c,0x90
ld de,0xcc00
call 0x06a2
res 1,(hl)
ld hl,0x8000
ld de,0x0001
add hl,de
jr nc,0x0483
ld a,(0xfff7)
ld c,a
sub 0x05
jr z,0x0490
add a,0x06
ld (0xfff7),a
ld a,(0xfff6)
bit 0,a
jp nz,0x05f3
call 0x04d1
out (0x00),a
ld (0xffee),a
jp 0x05f3
push af
push de
push hl
ld a,(0xfff6)
bit 0,a
jr nz,0x04ba
call 0x04d1
or 0x10
out (0x00),a
ld (0xffee),a
ld a,0x03
ld (0xfff6),a
ld hl,0xfff0
ld d,0x00
ld a,(0xfff7)
ld e,a
add hl,de
inc (hl)
jr nz,0x04cd
dec (hl)
pop hl
pop de
pop af
ret
ld hl,0x04dd
ld a,(0xfff7)
ld e,a
ld d,0x00
add hl,de
ld a,(hl)
ret
ld hl,(0x2a0a)
ld a,(bc)
ld (0xaf02),hl
out (0xa1),a
ld a,0x41
out (0xa1),a
ld c,0xa0
ld d,0x04
ld hl,0x083c
ld b,0xff
otir
dec d
jr nz,0x04f1
xor a
out (0xa1),a
ld a,0x48
out (0xa1),a
ld a,0x20
ld hl,0xfc40
ld de,0x0001
out (0xa0),a
add hl,de
jr nc,0x0507
ld b,0x07
ld hl,0x07d3
ld de,0x000f
push bc
push hl
push de
call 0x056b
pop de
pop hl
pop bc
add hl,de
djnz 0x0514
ret
ld a,0x07
out (0x41),a
ld a,0x7f
out (0x40),a
ret
out (0x91),a
nop
nop
nop
nop
nop
ret
ld hl,0xfffe
ld a,(hl)
sub 0xa5
ret nz
inc hl
ld a,(hl)
sub 0x5a
ret
ld c,0x05
push bc
call 0x05f3
pop bc
dec c
jp m,0x054c
push bc
jr 0x0541
ld a,(0xffef)
or a
ret z
ld hl,(0x07d0)
ld (0xfff9),hl
ld a,(0x07d2)
ld (0xfffb),a
ld de,(0x0ffc)
ld (0xfffc),de
ld hl,0xfff9
jp 0x056b
ld b,(hl)
inc hl
ld a,(hl)
out (0xa1),a
inc hl
ld a,(hl)
add a,0x48
out (0xa1),a
inc hl
ld c,0xa0
otir
ret
ld b,0x05
in a,(0x91)
bit 1,a
jr z,0x057e
in a,(0x90)
push af
sub 0x30
jr c,0x05c2
cp 0x0a
jr c,0x05a3
sub 0x07
cp 0x0a
jr c,0x05c2
cp 0x10
jr c,0x05a3
sub 0x20
cp 0x0a
jr c,0x05c2
cp 0x10
jr nc,0x05c2
ld c,a
ld a,b
or a
jr nz,0x05ab
pop af
jr 0x057e
ld a,e
out (0xa1),a
ld a,d
or 0x48
out (0xa1),a
pop af
cp 0x5b
jr c,0x05ba
sub 0x20
out (0xa0),a
ld (hl),c
inc hl
inc de
dec b
jr 0x057e
pop af
cp 0x0d
jr z,0x05cb
cp 0xe7
jr nz,0x05d0
ld a,b
or a
jr nz,0x057e
ret
cp 0x7f
jr z,0x05d8
cp 0xe1
jr nz,0x057e
ld a,b
cp 0x05
jr z,0x057e
dec de
dec hl
inc b
ld a,e
out (0xa1),a
ld a,d
or 0x48
out (0xa1),a
ld a,0x20
out (0xa0),a
jr 0x057e
ld c,0xe4
jp 0x036c
ld a,(0xffef)
or a
jr z,0x061c
ld a,0x02
ld (0xfff9),a
ld de,0x0028
ld b,c
inc b
ld hl,0x012b
add hl,de
djnz 0x0606
ld (0xfffa),hl
ld hl,0xfff0
add hl,bc
ld de,0xfffc
call 0x0633
ld hl,0xfff9
jp 0x056b
ld hl,0xfff0
ld b,0x00
add hl,bc
ld a,(hl)
or a
ret z
ld hl,0x073a
ld de,0x0013
inc c
dec c
jp z,0x056b
add hl,de
jr 0x062c
ld a,(hl)
srl a
srl a
srl a
srl a
call 0x0643
inc de
ld a,(hl)
and 0x0f
add a,0x30
cp 0x3a
jr c,0x064b
add a,0x07
ld (de),a
ret
ld a,0x0e
out (0x41),a
ld a,c
out (0x40),a
ld a,0x0f
out (0x41),a
in a,(0x40)
bit 0,a
ret
push af
exx
xor d
ld c,a
ld b,0x00
sla c
rl b
ld d,e
ld iy,0x0b74
add iy,bc
ld a,(iy+0)
ld e,a
ld a,(iy+1)
xor d
ld d,a
exx
pop af
ret
ld de,0xffff
call 0x0363
ret nz
ld c,0x80
call 0x064d
jr z,0x067d
xor a
ret
ld a,0x07
out (0x41),a
ld a,0x7e
out (0x40),a
ld a,0x08
out (0x41),a
ld a,0x06
out (0x40),a
ld a,0x01
out (0x41),a
dec a
out (0x40),a
ret
push af
push hl
push bc
push de
call 0x068a
xor a
out (0x41),a
ld a,c
out (0x40),a
ld hl,0x0001
ld b,0x04
ex de,hl
add hl,de
jr nc,0x06b5
pop hl
push hl
djnz 0x06b5
ld a,0x07
out (0x41),a
ld a,0x7f
out (0x40),a
pop de
pop bc
pop hl
pop af
ret
push af
nop
nop
nop
nop
ld (bc),a
ret nc
nop
ld hl,0x02ab
ld d,b
ld c,h
ld b,l
ld b,c
ld d,e
ld b,l
jr nz,0x0730
ld e,c
ld d,b
ld b,l
jr nz,0x072a
ld c,(hl)
jr nz,0x0727
ld c,b
ld b,c
ld c,(hl)
ld c,(hl)
ld b,l
ld c,h
jr nz,0x072f
ld c,a
ld b,h
ld b,l
jr nz,0x0711
jr nz,0x0713
jr nz,0x0715
inc (hl)
ld hl,0x5303
ld b,l
ld b,l
jr nz,0x071f
ld c,c
ld b,(hl)
jr nz,0x0754
ld c,a
ld c,l
ld b,l
ld d,h
ld c,b
ld c,c
ld c,(hl)
ld b,a
jr nz,0x0752
ld c,a
ld b,l
ld d,e
jr nz,0x0767
ld d,d
ld c,a
ld c,(hl)
ld b,a
ld (0x4920),hl
ld c,(hl)
jr nz,0x073a
jr nz,0x073c
jr nz,0x073e
jr nz,0x0740
ld c,a
ld d,a
ld c,(hl)
ld b,l
ld d,d
ld d,e
jr nz,0x076f
ld d,l
ld c,c
ld b,h
ld b,l
dec bc
ld hl,0x5003
ld c,h
ld b,l
ld b,c
ld d,e
ld b,l
jr nz,0x078e
ld b,c
ld c,c
ld d,h
djnz 0x0785
ld bc,0x4f52
ld c,l
jr nz,0x0788
ld b,c
ld c,c
ld c,h
ld d,l
ld d,d
ld b,l
jr nz,0x076a
jr nz,0x076c
jr nz,0x075e
ld (hl),c
ld bc,0x4956
ld b,h
ld b,l
ld c,a
jr nz,0x079d
ld b,c