-
Notifications
You must be signed in to change notification settings - Fork 0
/
trakker.z80
2522 lines (2519 loc) · 26.6 KB
/
trakker.z80
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
;
flo:
equ #1c
bild:
equ #100
puf:
equ #800
puf1:
equ #900
hadr:
equ #12c0
font:
equ #1c00
tabel:
equ #2200
spc:
equ #2400
misc:
equ spc+3
clg:
equ spc+6
para:
equ spc+#c
setup:
equ spc+#f
mfont:
equ spc+#12
help:
equ spc+#18
sped:
equ #4bfb
loot:
equ #4bfc
leng:
equ #4bfd
higt:
equ #4bfe
panz:
equ #4bff
disc:
equ #8000
cls:
equ #8003
decz:
equ #8006
ied:
equ #8800
oed:
equ #8803
chan:
equ #af08
kbd:
equ #bb1b
org #9000
xy:
defb 0,0
jp este
jp chr
jp xt
jp maus
jp hexo
jp hexo2
jp oli
jp cler
jp taus
jp sync
jp swi1
jp wahl
jp chos
jp init
jp mfs
jp prins
jp ddr
jp name
jp jupp
jp sur1
jp maxi
;ent $
este:
ld a,(#8000)
cp #c3
ret nz
ld a,1
call #bc0e
ld bc,#bc01
out (c),c
inc b
xor a
out (c),a
ld b,a
ld c,a
call #bc32
ld a,1
ld bc,#1a1a
call #bc32
ld a,2
ld bc,#202
call #bc32
ld a,3
ld bc,#909
call #bc32
ld bc,0
call #bc38
call rick
ld hl,(key1)
call #bb3f
xor a
ld (ins),a
ld (pins),a
dec a
ld (#be78),a
ld a,1
ld (ch1),a
ld (ch2),a
ld (ch3),a
ld (#be66),a
ld a,ein
ld (reg7),a
ld a,(pek)
ld (num),a
ld a,#c9
ld (#bb5a),a
ld hl,#4ad0
ld (posa),hl
ld hl,blk
ld (#af00),hl
ld hl,menu
ld (#af02),hl
ld hl,msg1
ld (#af04),hl
ld hl,fad+1
ld (#af06),hl
ld hl,tona
ld (chan),hl
ld (#b000),hl
ld hl,tonb
ld (#b002),hl
ld hl,tonc
ld (#b004),hl
ld hl,#bef0
ld de,#bef1
ld bc,15
ld (hl),0
ldir
ld bc,#7fc5
out (c),c
ld hl,#100
ld de,#4000
ld bc,#3f00
push hl
push de
push bc
ldir
ld bc,#7fc6
out (c),c
pop bc
pop hl
pop de
ldir
ld bc,#7fc4
out (c),c
call bild
ld hl,#100
ld de,#101
ld bc,#bff
ld (hl),l
ldir
call mfont
ld hl,msg1
call xt
ld hl,msg1b
call xt
call clg
call help
ld a,64
ld (leng),a
ld a,23
ld (mad),a
call name
xor a
call mfs
ld a,(panz)
call ddr
xor a
call prins
xor a
call swan
ld a,3
call endoc
xor a
call jupp
call sync
ld bc,#bc01
out (c),c
ld bc,#bd28
out (c),c
ld hl,menu
ld (blk),hl
xor a
call init
ld hl,#bf00
ld de,irq
ld bc,#80ff
call #bcd7
main:
call kbd
jr nc,main
cp #fc
jp z,ende
cp "["
call z,pag1
cp "]"
call z,pag2
call wahl
call z,chos
call swi
call oli
jp main
swi:
cp 9
call z,para
jr swi1
defw mfs,ddr,laus,psped,ppos,patn
swi1:
cp #87
call z,incep
cp #84
call z,decep
swi2:
cp #88
call z,nexti
cp #85
call z,previ
cp #89
call z,octu
cp #86
call z,octd
cp #81
call z,io1
cp #82
call z,io2
cp #83
call z,io3
ret
ende:
call taus
ld hl,#bf00
call #bcdd
ld bc,#7fc5
out (c),c
ld hl,#4000
ld de,#100
ld bc,#3f00
ldir
ld bc,#7fc0
out (c),c
ld a,#cf
ld (#bb5a),a
xor a
ld (#be78),a
ret
pag1:
ld hl,#1000
ld a,(hadr+1)
sub h
ret z
ld (hadr),hl
jp help
pag2:
ld hl,#12d0
ld a,(hadr+1)
sub h
ret z
ld (hadr),hl
jp help
wahl:
cp 240
call z,bup
cp 241
call z,bdow
cp 242
call z,blef
cp 243
call z,brig
cp 32
ret z
cp 13
ret
bup:
ld ix,(blk)
call erz
ld a,(mp)
cp b
jr c,hut
call eras
ld a,(mp)
sub b
ld (mp),a
jp bar
bdow:
ld ix,(blk)
call erz
ld a,(mp)
cp b
jr nc,hut
call eras
ld a,(mp)
add a,b
ld (mp),a
jp bar
hut:
xor a
ret
erz:
ld b,(ix)
inc b
srl b
ret
blef:
call eras
ld ix,(blk)
ld a,(mp)
or a
jr z,neul
dec a
ld (mp),a
jp bar
neul:
ld a,(ix)
ld (mp),a
jp bar
brig:
call eras
ld ix,(blk)
ld a,(mp)
cp (ix)
jr z,neur
inc a
init:
ld (mp),a
jp bar
neur:
xor a
ld (mp),a
jp bar
eras:
ld a,(mp)
push bc
call qer
call txt
pop bc
ret
bar:
ld a,(mp)
call qer
ld a,22
call chr
call txt
ld a,22
jp chr
rbar:
ld hl,(luc)
ld (xy),hl
ld b,(ix+2)
inc b
inc b
juk:
push bc
call maus
ld hl,xy+1
inc (hl)
pop bc
djnz juk
ret
qer:
ld b,a
ld ix,(blk)
inc ix
or a
ret z
su1:
ld d,0
ld e,(ix+2)
add ix,de
ld de,5
add ix,de
djnz su1
ret
txt:
ld h,(ix)
ld l,(ix+1)
ld (xy),hl
ld (luc),hl
ld a,32
call chr
ld b,(ix+2)
push ix
pop hl
inc hl
inc hl
inc hl
pri1:
ld a,(hl)
call chr
inc hl
djnz pri1
ld a,32
call chr
ld e,(hl)
inc hl
ld d,(hl)
ex de,hl
ld (pnt),hl
ret
chos:
ld hl,(pnt)
ld a,h
or l
ret z
push hl
call bar
call rbar
call cler
pop hl
call #1e
call bar
xor a
ret
spie:
xor a
ld (spie1),a
ld a,(pek)
ld (num),a
ld a,#c9
ld (toki),a
call resv
spiel:
call sync
ld a,(dly)
ld hl,sped
cp (hl)
call z,ple
call kbd
jr nc,spiel
cp #fc
jp z,send
call swi1
jp spiel
rec:
xor a
ld (spie1),a
ld (cur),a
ld a,(pek)
ld (num),a
ld a,#c9
ld (daun),a
ld hl,hexe
ld (pexe),hl
call resv
ld a,-3
call rech
rec0:
call kbd
jr nc,rec0
cp #fc
jr nz,reca
renda:
xor a
ld (daun),a
ld a,#c9
ld (cur),a
ld hl,play
ld (pexe),hl
jp sand
rec1:
call kbd
jr nc,rec2
cp #fc
jr z,renda
cp 242
call z,left
cp 243
call z,rigt
cp 246
call z,shil
cp 247
call z,shir
reca:
call swi2
call input
call cler
rec2:
ld a,(dly)
ld hl,sped
cp (hl)
call z,plu
jp rec1
song:
ld a,21
call #bb1e
ld a,0
jr nz,star
ld a,(ppos)
star:
call begi
call mfs1
xor a
ld (spie1),a
ld a,(anpa+1)
ld (down),a
ld a,#c9
ld (toki),a
ld hl,funk
call xt
call tein
call resv
songl:
call sync
ld a,(dly)
ld hl,sped
cp (hl)
call z,plur
call kbd
jr nc,songl
cp #fc
jr z,send
cp #81
call z,io1
cp #82
call z,io2
cp #83
call z,io3
jr songl
plur:
call ple
ld hl,down
dec (hl)
ret nz
ld a,(anpa+1)
ld (hl),a
call resv
ld a,(ppos)
inc a
ld hl,panz
cp (hl)
jp nz,mfs1
ld a,(loot)
jp mfs1
begi:
ld hl,panz
cp (hl)
ret c
xor a
ret
resv:
ld a,16
ld (tona+lins),a
ld (tonb+lins),a
ld (tonc+lins),a
ret
send:
xor a
ld (toki),a
ld (path+1),a
sand:
ld a,#c9
ld (spie1),a
ld a,(pek)
call rech
ld a,(patn)
call jupp
call taus
call clg
jp cler
spie1:
ret
call spc
ld hl,dly
dec (hl)
ret nz
ld a,(sped)
ld (hl),a
ret
disk:
call disc
call name
ld a,(sped)
call psped
jp help
insed:
call ied
jp help
orned:
call oed
jp help
setu:
call setup
jp help
other:
call misc
jp help
edit:
xor a
ld (cur),a
ld a,#c9
ld (psped),a
ld a,(xp)
call cur
loop:
call kbd
jr nc,loop
cp #fc
jp z,end
cp 9
call z,swit
cp 16
call z,klo
cp 128
call z,inse
cp 138
call z,entf
cp 240
call z,patu
cp 241
call z,patd
cp 244
call z,spau
cp 245
call z,spad
cp 224
call z,plu
cp 242
call z,left
cp 243
call z,rigt
cp 246
call z,shil
cp 247
call z,shir
cp "!"
call z,cutv
cp 34
call z,clrv
cp "#"
call z,cpyv
cp "$"
call z,cutp
cp "%"
call z,clrp
cp "&"
call z,cpyp
ld hl,(xy)
push hl
call swi1
pop hl
ld (xy),hl
call input
jp loop
end:
call taus
xor a
ld (psped),a
ld a,#c9
ld (cur),a
call patt
cler:
call kbd
jr c,cler
ret
input:
ld b,a
ld ix,(eadr)
ld a,(typ)
cp 1
jr z,octin
jr nc,hexin
tonin:
ld a,b
cp 127
jr z,delt
push ix
call oli
pop ix
or a
ret z
ld a,(lastk)
ld b,1
cp 12
jr c,nodiv
div:
inc b
sub 12
cp 12
jr nc,div
nodiv:
inc a
and 15
add a,a
add a,a
add a,a
add a,a
or b
ld (ix),a
ld a,(ix+1)
and 15
ld b,a
ld a,(ins)
add a,a
add a,a
add a,a
add a,a
or b
ld (ix+1),a
jp daun
delt:
xor a
ld (ix),a
ld (ix+1),a
ld (ix+2),a
jp daun
octin:
ld a,b
cp 49
ret c
cp 57
ret nc
ld c,a
sub 48
ld b,a
schi:
ld a,(ix)
or a
ret z
cp #d0
ret z
and 240
or b
ld (ix),a
jp daun
hexin:
ld a,b
cp 127
jp z,delh
cp 48
ret c
cp 59
jr c,nozi
res 5,a
cp "A"
ret c
cp "G"
ret nc
sub 7
nozi:
sub 48
ld b,a
ld a,(xp)
cp 7
jr c,nosub
sub 6
cp 7
jr c,nosub
sub 6
nosub:
sub 3
jr z,inp0
dec a
jr z,inp1
dec a
jr z,inp2
inp3:
ld a,(ix+2)
call inlo
ld (ix+2),a
jr daun
inp2:
ld a,(ix+2)
call inhi
ld (ix+2),a
jr daun
inp1:
ld a,(ix+1)
call inlo
ld (ix+1),a
jr daun
inp0:
ld a,(ix+1)
call inhi
ld (ix+1),a
daun:
nop
call pla0
ld a,(dflg)
or a
jp nz,patd
ld a,(xp)
jp cur
klo:
ld hl,(eadr)
ld (hl),#d0
jp daun
inhi:
and 15
ld c,a
ld a,b
rlca
rlca
rlca
rlca
or c
ret
inlo:
and 240
or b
ret
delh:
ld a,(ix+1)
and 240
ld (ix+1),a
ld (ix+2),0
jr daun
shil:
ld a,(xp)
cp 7
jr c,shi1
sub 6
jr nrig+2
shi1:
add a,12
jr nrig+2
shir:
ld a,(xp)
cp 13
jr nc,shi2
add a,6
jr nrig+2
shi2:
sub 12
jr nrig+2
left:
ld a,(xp)
cp 1
jr z,nlef
dec a
jr nrig+2
nlef:
ld a,18
jr nrig+2
rigt:
ld a,(xp)
cp 18
jr z,nrig
inc a
jr nrig+2
nrig:
ld a,1
ld (xp),a
cur:
ret
push af
ld hl,#515
ld (xy),hl
ld a,(num)
add a,3
call anpa
call getp
ld (eadr),hl
push hl
pop ix
ld hl,fast
ld (exe+1),hl
ld hl,tabel+138
ld (sta),hl
ld hl,foh+3
call line
ld hl,chr
ld (exe+1),hl
pop af
dec a
ld d,0
ld e,a
ld hl,pss
add hl,de
add hl,de
ld a,(hl)
inc a
inc a
ld (merk),a
ld (xy+1),a
inc hl
ld a,(hl)
ld (typ),a
ld b,7
call maus+2
ld hl,tona
ld b,0
ld a,(xp)
cp 7
jr c,eintr
ld hl,tonb
inc b
cp 13
jr c,eintr
ld hl,tonc
inc b
eintr:
ld (chan),hl
ld a,b
ld (ch),a
add a,a
add a,b
ld d,0
ld e,a
ld ix,(eadr)
add ix,de
ld (eadr),ix
ld hl,(panf)
add hl,de
ld (voic),hl
xor a
ret
inse:
call ganz
ret z
ld ix,(voic)
ld de,(npln)
add ix,de
ld de,-9
add ix,de
einf:
ld a,(ix-9)
ld (ix),a
ld a,(ix-8)
ld (ix+1),a
ld a,(ix-7)
ld (ix+2),a
add ix,de
djnz einf
jr klar
entf:
call ganz
ret z
ld ix,(eadr)
ld de,9
entf1:
ld a,(ix+9)
ld (ix),a
ld a,(ix+10)
ld (ix+1),a
ld a,(ix+11)
ld (ix+2),a
add ix,de
djnz entf1
klar:
xor a
ld (ix),a
ld (ix+1),a
ld (ix+2),a
jp patt
ganz:
ld a,(num)
add a,3
call anpa
ld c,a
ld a,b
sub c
dec a
ld b,a
ret
clir:
call cls
ld hl,cltx
call xt
call maus
waic:
call cler
call #bb06
cp #fc
jp z,help
res 5,a
cp "A"
jr z,all
cp "S"
jr z,csng
cp "I"
jr z,cins
jr waic
all:
call wirk
jp nz,help
ld ix,alct
jr obi
csng:
call wirk
jp nz,help
ld ix,snct
obi:
call kill