-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathxl.txt
1795 lines (1759 loc) · 31.9 KB
/
xl.txt
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
;---------------------------------------
; InterWord Extra.Lib
;---------------------------------------
*= $0800
jmp mbase-12
jmp udtdoc
jmp scupx
jmp scdnx
jmp mpl
jmp div
jmp diw
jmp ask
jmp chkdir
jmp erase
jmp copy
jmp paste
jmp nomem
jmp udtscr
jmp udruler
jmp clch
jmp diskmen
jmp ttfn
jmp dfs
jmp dfl
jmp dfs2
jmp dfl2
jmp print
lib = $c000
init = lib
setc = lib+3
writ = lib+6
updt = lib+9
atoc = lib+12
opnw = lib+15
clsw = lib+18
invt = lib+21
scla = lib+24
scup = lib+27
scdn = lib+30
setx = lib+33
invs = lib+36
mbase = $1800+12
ch40 = mbase
width = mbase+1
ruler = mbase+2
format = mbase+3
x = mbase+7
y = mbase+8
cpos = mbase+10
spos = mbase+12
linelx = mbase+15
linel = mbase+16
linehx = mbase+39
lineh = mbase+40
spacz = mbase+62
fmatsx = mbase+83
fmats = mbase+84
blkb = mbase+106
blke = mbase+108
dcl = mbase+111
dcm = mbase+113
rm = mbase+115
lm = mbase+116
wd = mbase+117
line = mbase+118
topln = mbase+198
botln = mbase+278
cornln = mbase+358
nmrt = mbase+360
denm = mbase+363
quotient = mbase+365
rul1 = mbase+366
lms = mbase+606
rms = mbase+609
dlfl = mbase+612
flnm = mbase+614
dcnames = mbase+630
naml = mbase+645
rll = mbase+646
fox = mbase+649
foy = mbase+650
flx = mbase+651
fly = mbase+652
fcx = mbase+653
fcy = mbase+654
fire = mbase+655
rcnt = mbase+656
rcrd = mbase+657
xlm = mbase+659
crd = mbase+660
chs = mbase+662
chc = mbase+664
endbuf = mbase+666
dfval = mbase+668
buffer = $8000
bfsize = 12
misc = $dd
misc2 = $df
lspc .byte 0
lspca .byte 0
mwd .byte 0
acty .byte 0
xad .byte 0,0
cr .byte 0
stl .byte 0
ls .byte 0
trix .byte 0
wrtn .byte 0
nike .byte 0
xdff .byte 0
lspcx .byte 0
unim .byte 0
begad .byte 0,0
fukad .byte 0,0
cutt .byte 0
hitit .byte 0
udat .byte 0,3,0,21
care .byte 0
nec .byte 0
imod .byte 0
lc .byte 0
indat = $d9
outdat = $db
scr80 = $9000
udtdoc stx begad
sty begad+1
stx $fb
sty $fc
pha
pha
and #$80
sta hitit
pla
and #$40
sta care
bne udj3
lda cpos
sta indat
lda cpos+1
sta indat+1
udj3 pla
and #$3f
sta stl
sta ls
tax
lda fmats,x
sta format
lda #255
sta trix
lda #0
sta wrtn
sta cutt
sta imod
lda #1
sta nike
lda stl
bne udloop1
lda $fb
cmp dcl
bne udjump15
lda $fc
cmp dcm
bne udjump15
lda #0
sta linehx
jmp udloop1
udjump15 sec
lda $fb
sbc #1
sta $fb
lda $fc
sbc #0
sta $fc
ldx #$ff
ldy #0
sty nike
lda #13
udloop8 dec $fb
cpx $fb
bne udjump12
dec $fc
udjump12 cmp ($fb),y
bne udloop8
clc
lda $fb
adc #1
sta $fb
lda $fc
adc #0
sta $fc
udloop1 lda #0
sta nec
ldx ls
jsr scla
stx $fd
sty $fe
ldx ls
lda stl
clc
adc #1
cmp ls
bcs udjump11
lda format
cmp fmats,x
bne udjump11
lda linel,x
cmp $fb
bne udjump11
lda lineh,x
cmp $fc
bne udjump11
jmp udjump5
udjump11 lda wd
sta mwd
clc
lda #<line
adc lm
sta $f9
lda #>line
adc #0
sta $fa
ldx ls
lda $fb
sta linel,x
lda $fc
sta lineh,x
lda format
sta fmats,x
ldy #79
lda #$80
udloop2 sta line,y
dey
bpl udloop2
lda #255
sta lspc
ldy #0
sty cr
lda lm
sta acty
inc acty
udloop3 clc
tya
adc $fb
sta xad
lda #0
adc $fc
sta xad+1
cmp indat+1
bne udjump35
lda xad
cmp indat
bne udjump35
lda hitit
bne udjump35
lda #1
sta nike
sta hitit
sta nec
lda #255
sta ($f9),y
clc
lda $f9
adc #1
sta $f9
lda $fa
adc #0
sta $fa
udjump35 lda ($fb),y
cmp #33
bcs udjump1x
cmp #32
bne udjump3
sty lspc
sta lc
udjump1x jmp udjump1
udjump3 cmp #22
bne udj7
sty lspc
lda #"-"
sta lc
jmp udj4
udj7 cmp #23
bne udj5
lda #0
sta imod
jmp udj4
udj5 cmp #24
bne udj6
lda #$80
sta imod
jmp udj4
udj6 cmp #25
bcc udjump46
cmp #29
bcs udjump46
sec
sbc #25
sta format
udj4 clc
lda $fb
adc #1
sta $fb
lda $fc
adc #0
sta $fc
jmp udloop3
udjump46 cmp #31
beq udjump7
inc $fb
bne udjump4
inc $fc
udjump4 cmp #13
bne udjump9
lda #" "
sta lc
inc cr
dec $fb
lda $fb
cmp #$ff
bne udjump8
dec $fc
udjump8 sty lspc
jmp udjump6
udjump7 lda #$20
sta ($f9),y
ldx acty
udloop7 cpx #80
beq udjump10
lda scr80+$a0,x
inx
cmp #$e6
beq udjump8
and #$fd
cmp #$e8
bne udloop7
udjump10 txa
sec
sbc acty
sbc #1
sta unim
stx acty
ldx nike
beq udjump25
clc
adc $f9
sta $f9
lda $fa
adc #0
sta $fa
udjump25 sec
lda mwd
sbc unim
sta mwd
iny
jmp udjump2
udjump9 cmp #0
bne udjump2
lda #" "
sta lc
inc cr
inc cutt
lda #0
sta trix
sty lspc
jmp udjump6
udjump1 jsr atoc
ora imod
sta ($f9),y
iny
inc acty
udjump2 cpy mwd
beq udjump6
jmp udloop3
udjump6 sty misc
lda acty
sec
sbc misc
sta xdff
lda lspc
sta lspcx
cmp #255
bne udjump38
lda mwd
sec
sbc #1
sta lspc
sbc #1
sta lspcx
ldy lspc
dey
jmp udjump43
udjump38 ldy lspc
lda #$20
sta ($f9),y
udjump43 lda mwd
sec
sbc #1
sbc lspc
ldx ls
sta spacz,x
lda lspc
clc
adc xdff
adc nec
tay
dey
lda lc
sta line,y
iny
lda #$80
udloop5 sta line,y
iny
cpy #78
bne udloop5
lda nike
beq udjump13
lda format
jsr fline
ldy #0
ldx #0
udloop4 lda line,x
cmp #255
bne udjump36
lda #1
sta hitit
lda care
bne udj1
clc
tya
adc $fd
sta spos
lda $fe
adc #0
sta spos+1
udj1 lda ls
sta outdat+1
sty outdat
lda care
bne udj2
lda outdat+1
sta y
lda outdat
sta x
udj2 inx
jmp udloop4
udjump36 bit prntn
beq udx1
stx misc
sty misc+1
jsr $ffd2
ldx misc
ldy misc+1
jmp udx2
udx1 sta ($fd),y
udx2 iny
inx
cpy #80
bne udloop4
bit prntn
beq udx3
lda #$0d
jsr $ffd2
jmp udjump13
udx3 inc ls
clc
lda $fd
adc #$50
sta $fd
lda $fe
adc #0
sta $fe
udjump13 lda $fb
sta fukad
lda $fc
sta fukad+1
lda #33
cmp lc
lda $fb
adc lspcx
sta $fb
lda $fc
adc #0
sta $fc
cmp begad+1
bne udjump14
lda $fb
cmp begad
bne udjump14
inc nike
ldx ls
lda fukad
sta linelx,x
lda fukad+1
sta linehx,x
lda format
sta fmatsx,x
ldx #79
udloop10 lda line,x
sta topln,x
dex
bpl udloop10
udjump14 lda cutt
bne udjump5
lda ls
cmp #21
beq udjump5
jmp udloop1
udjump5 ldx ls
lda $fb
and trix
sta linel,x
lda $fc
and trix
sta lineh,x
lda format
sta fmats,x
cpx #21
bne udjump16
ldx #79
udloop9 lda line,x
sta botln,x
dex
bpl udloop9
udjump16 lda hitit
bne udjump37
lda care
bne udjump37
lda indat+1
cmp lineh+21
bcc udjump37
bne udjump42
lda indat
cmp linel+21
bcc udjump37
udjump42 ldx #3
jsr scupx
ldx linel+21
ldy lineh+21
lda #20
jsr udtdoc
lda #0
sta stl
lda #21
sta ls
jsr udall
rts
udjump37 lda lineh,x
bne udjump39
jmp udjump41
udloop40 ldx ls
lda lineh,x
beq udjump39
udjump41 ldx ls
cpx #21
beq udjump39
lda #0
sta lineh,x
jsr scla
stx $fb
sty $fc
lda #$80
ldy #78
udloop37 sta ($fb),y
dey
bpl udloop37
inc ls
jmp udloop40
udjump39 jsr udall
rts
fline cmp #0
bne fljump1
rts
fljump1 cmp #1
bne fljump2
lda cr
bne fljump4
lda lspc
clc
adc xdff
sta lspc
dec lspc
lda rm
clc
adc #1
sec
sbc lspc
sta misc
beq fljump4
flloop2 ldx lspc
flloop1 lda line,x
cmp #32
beq fljump5
dex
bpl flloop1
jmp flloop2
fljump5 dex
stx misc2
ldy rm
flloop3 lda line,y
sta line+1,y
dey
cpy misc2
bne flloop3
lda #$80
sta line+1,x
inc lspc
dec misc
bne flloop1
fljump4 rts
fljump2 tax
lda rm
sec
sbc lspc
sbc xdff
cpx #3
bne fljump3
lsr a
sec
sbc #1
fljump3 sta misc
lda rm
clc
adc #2
tax
sta misc2
lda rm
sec
sbc misc
tay
cpy misc2
beq fljump6
flloop4 lda line,y
sta line,x
dex
dey
bpl flloop4
lda #$80
flloop5 sta line,x
dex
bpl flloop5
fljump6 rts
udall lda width
sta udat+2
lda stl
clc
adc #3
sta udat+1
lda ls
sec
sbc stl
sta udat+3
cmp #0
bne uajump1
inc udat+3
uajump1 lda care
bne uaj2
ldx #<udat
ldy #>udat
lda ch40
jsr updt
uaj2 rts
xpst .byte 0,0
scupx stx xpst
dex
dex
dex
sxloop1 lda lineh,x
sta linehx,x
lda linel,x
sta linelx,x
inx
cpx #22
bne sxloop1
ldx xpst
jsr scup
inc cornln
rts
scdnx stx xpst
dex
dex
dex
dex
stx xpst+1
ldx #21
dxloop1 lda linehx,x
sta lineh,x
lda linelx,x
sta linel,x
dex
cpx xpst+1
bne dxloop1
ldx xpst
jsr scdn
dec cornln
rts
num1 .byte 0
num2 .byte 0,0
product .byte 0,0
maxbits = 8
mpl stx num1
sty num2
lda #0
sta product
sta product+1
sta num2+1
ldx #maxbits
mploop1 lsr num1
bcc mpjump1
clc
lda num2
adc product
sta product
lda num2+1
adc product+1
sta product+1
mpjump1 asl num2
rol num2+1
dex
bpl mploop1
ldx product
ldy product+1
rts
div lda #0
sta nmrt+1
sta denm+1
cpy #0
beq djump2
stx nmrt
sty denm
diw lda #0
sta quotient
sta nmrt+2
ldx #7
dloop1 asl nmrt
rol nmrt+1
rol nmrt+2
lda nmrt+2
cmp denm+1
bcc djump1
bne djump3
lda nmrt+1
cmp denm
bcc djump1
djump3 lda nmrt+1
sbc denm
sta nmrt+1
lda nmrt+2
sbc denm+1
sta nmrt+2
sec
djump1 rol quotient
dex
bpl dloop1
djump2 ldy quotient
rts
askw .byte 28,10,22,5
.byte "{222}",64,20,"{cm k}","{cm t}"
wl .text "{cm asterisk} {cm asterisk}"
.text "{cm asterisk} {cm asterisk}"
.text "{cm asterisk} {cm z} Ja {cm p} {cm z} Nej {cm p} {cm asterisk}"
.byte "{sh space}",64,20,"{cm i}","{cm @}"
ask stx $fb
sty $fc
lda #32
ldx #20
aql1 sta wl,x
sta wl+22,x
dex
bne aql1
lda #<(wl+1)
sta $fd
lda #>(wl+1)
sta $fe
lda #2
sta misc2
aqloop3 ldy #0
aqloop1 lda ($fb),y
iny
cmp #13
bne aqloop1
sty misc
lda #20
sec
sbc misc
lsr a
clc
adc $fd
sta aq+1
lda $fe
adc #0
sta aq+2
ldy #0
aqloop2 lda ($fb),y
cmp #13
beq aqjump1
aq sta $0400,y
iny
jmp aqloop2
aqjump1 iny
tya
clc
adc $fb
sta $fb
lda $fc
adc #0
sta $fc
lda $fd
adc askw+2
sta $fd
lda $fe
adc #0
sta $fe
dec misc2
bne aqloop3
ldx #<askw
ldy #>askw
jsr opnw
aqloop4 jsr $ffe4
cmp #"{arrow left}"
bne aqj1
lda #40
sta misc
jmp aqj2
aqj1 lda fire
bne aqloop4
ldx fcx
ldy fcy
jsr clch
lda rcrd+1
cmp #13
bne aqloop4
lda rcrd
sec
sbc #32
lsr a
cmp #7
bcs aqloop4
cmp #3
beq aqloop4
bcs aqjump2
ldx #32
jmp aqjump3
aqjump2 ldx #40
aqjump3 stx misc
ldy #13
lda #6
jsr invt
aqloop5 lda fire
beq aqloop5
ldx misc
ldy #13
lda #6
jsr invt
ldx flx
ldy fly
jsr clch
lda rcrd+1
cmp #13
bne aqloop4
lda rcrd
sec
sbc #32
lsr a
cmp #7
bcs aqloop4
cmp #3
beq aqloop4
bcs aqjump4
ldx #32
jmp aqjump5
aqjump4 ldx #40
aqjump5 cpx misc
bne aqloop4
aqj2 ldx #<askw
ldy #>askw
lda ch40
jsr clsw
lda #0
ldx misc
cpx #32
bne aqjump6
lda #1
aqjump6 rts
chkdir lda #<dol
sta $bb
lda #>dol
sta $bc
lda #$01
sta $b7
lda #$08
sta $ba
lda #$60
sta $b9
jsr $f3d5
lda $ba
jsr $ffb4
lda $b9
jsr $ff96
lda #$00
sta $90
dirloop1 jsr $ffa5
ldy $90
bne dirjump1
cmp #34
bne dirloop1
ldy #0
dirloop2 sty $8c
jsr $ffa5
ldy $8c
cmp #34
beq dirjump2
sta cnme,y
iny
jmp dirloop2
dirjump2 ldx $8c
dex
cpx #15
bne dirloop1
dirloop3 lda flnm,x
cmp cnme,x
bne dirloop1
dex
bpl dirloop3
jsr $f642
lda #1
rts
dirjump1 jsr $f642
lda #0
rts
cnme .text " "
cnl .byte 0
dol .byte "$"
erase lda blkb
sta $fb
sta cpos
lda blkb+1
sta $fc
sta cpos+1
clc
lda blke
adc #1
sta $fd
lda blke+1
adc #0
sta $fe
ldy #0
erloop1 lda ($fd),y
sta ($fb),y
inc $fb
bne erjump1
inc $fc
erjump1 inc $fd
bne erjump2
inc $fe
erjump2 lda $fb
cmp dcl+1
bne erloop1
lda $fc
cmp dcm+1
bne erloop1
lda $fd
sta dcl+1
lda $fe
sta dcm+1
jsr udtscr
rts
bex .byte 0,0
copy lda blke
clc
adc #1
sta bex
lda blke+1
adc #0
sta bex+1
lda bex+1
sec
sbc blkb+1
cmp #bfsize
bcc cpjump1
jmp nomem
cpjump1 lda #<buffer