8-Bit Software Online Conversion
Xterm Update - Listing
10REM>CXTerm35
90MODE&87:IFFNB(0,1,0)>5:PRINT"Callin
g Basic version":CHAIN"BXTerm"
100IFFNR(130,0,0)<>&FFFF:PRINT"I/O Pro
cessor Only":END
110OSCLI"FX229,1":OSCLI"FX7,7":OSCLI"F
X8,7":U%=FALSE:h%=&3800:M%=TOP+40:IF!M%=
TRUE:FORA%=M%+8TOM%+8+M%!4-1:VDU?A%:NEXT
:M%=A%
150IF!M%=TRUE:FORA%=0TOM%!4-1:A%?&9A0=
M%?(A%+8):NEXT:U%=&9AE:M%=M%+A%+8
160IF!M%=TRUE:FORA%=0TOM%!4-1STEP4:A%!
h%=M%!(A%+8):NEXT:M%=M%+A%+8
170MODE&80-3*(HIMEM<&8000):HIMEM=h%:IF
U%:A%=78:CALLU%
180I%=0:L%=0:ONERRORREPORT:PRINTERL:PR
OCH:END
190IFU%=0:OSCLI"BUFFER SERIN":OSCLI"LO
AD `TERM":OSCLI"LOAD `FTP"
200m%=h%:o%=h%+3:p%=h%+6:w%=h%+9:PROCG
:£%=&780:q%=&7C0:CALLm%:CLS:E$="0.35":i%
=FALSE:A%=FN`80:ONERRORIFFNM:PROCH:END
230IFi%:A%=FN`81
240X%=q%:Y%=X%DIV256:REPEATUNTILFNO(US
Ro%AND&FF):END
260DEFFNM:OSCLI"FX3":REPORT:IFERR<128A
NDERR<>17:PRINT" at line ";ERL;
270IFc%:c%=FALSE:OSCLI"FX2,1":OSCLI"FX
3,1":PROCB:OSCLI"FX3":*FX2,2
280PROCE:PRINT:=INKEY-1
310DEFFNO(A%):IFPOS:PRINT
320=EVAL("FN`"+STR$÷A%)
330DEFFN`80:PRINT"XTerm C"E$" 24-Jan-1
998 (C)J.G.Harston":PRINT"f0=Help f1=*Co
mmand f2=Baud f5=Download f6=Upload f7=M
ODE 7 f8=MODE 0 f9=Exit"':=0
350DEFFN`81:OSCLI"FX229":i%=TRUE:REPEA
TINPUTLINE"="A$:OSCLIA$:UNTILA$="":OSCLI
"FX229,1":i%=FALSE:=0
360DEFFN`82:INPUT"Baud rate: "A$:IFA$=
"":=0
370A%=(LN(VALA$DIV75)/LN2):OSCLI"FX7,"
+STR$A%:OSCLI"FX8,"+STR$A%:=0
380DEFFN`83:W%=NOTW%:PRINT"Debug: "FNP
(W%):=0
390DEFFN`84:J%=(J%EOR&480)EOR(((J%AND&
FF)=0)AND&1000):PRINT"Tx size: ";J%AND&F
FF;" CRC:"FNP((J%AND&1000)<>0):=0
400DEFFN`85:PROCM:=0
410DEFFN`86:PROCI:=0
420DEFFN`87:VDU22,&87:=0
430DEFFN`88:VDU22,&80:=0
440DEFFN`89:PRINT"Exit":PROCH:=TRUE
450DEFFN`8A:=0
460DEFFN`8B:=0
470DEFFN`8C:=0
480DEFFN`8D:=0
490DEFFN`8E:=0
500DEFFN`8F:=0
530DEFFNB(A%,X%,Y%):=((USR&FFF4)AND&FF
00)DIV256
540DEFFNR(A%,X%,Y%):=((USR&FFF4)AND&FF
FF00)DIV256
550DEFPROCN(A%,C%,D%,N%):?X%=C%:X%!1=D
%:X%!5=N%:X%!9=PTR#C%:CALL&FFD1:ENDPROC
560DEFFND(A$,A%):$£%=A$:?X%=£%:X%?1=£%
DIV256:=(USR&FFDD)AND&FF
570DEFPROCH:OSCLI"FX229":OSCLI"FX225,1
":OSCLI"FX2":OSCLI"FX3":PROCE:PROCJ:ENDP
ROC
580DEFPROCE:IFI%:A%=I%:I%=0:CLOSE#A%
590IFL%:A%=L%:L%=0:CLOSE#A%
600ENDPROC
670DEFPROCG:c%=FALSE:L=2:W%=FALSE:J=&8
6:J%=&80:B=0:M=1:N=2:H=4:K=6:O=21:I=24:Q
=26:G=-1:A=1:C=2:D=6:F=12:E=27:DIMO%1023
,A$(7):FORz%=0TO7:READA$(z%):NEXT:ENDPRO
C
710DATA Ok,Bad data,No data,Bad sequen
ce,Remote abort,Local abort
720DATA Can't open file,No signal
740DEFFNE:PRINT"(T)ext or (B)inary? ";
:REPEATA%=GETAND&DF:UNTILINSTR("TB",CHR$
A%):VDUA%:=A%=ASC"T"
750DEFFNP(A%)=MID$("OFFON",-3*A%+1,3)
760DEFFNI(A%):IFA%<0:="?"ELSE=A%
770DEFFNJ(A%):=LEFT$($A%,INSTR($A%,CHR
$0)-1)
820DEFPROCA(A$,A%):OSCLI"FX3":PRINTCHR
$6;CHR$13;A$;SPC((9-LENA$)AND(LENA$<10))
" '"C$"' Pkt ";FNI(G%);": ";FNI(F%);" by
tes";:IFA%:VDU13:OSCLI"FX3,3":ENDPROC
830IFE%>0:t%=100*F%DIVE%:PRINT", ";t%;
"% of ";E%;:t%=j%*(100-t%)DIV(t%+1)DIV10
0:PRINT" ";t%DIV60;":";RIGHT$("0"+STR$(t
%MOD60),2);
840PRINT" ";100*F%DIVj%;"c/s "MID$("12
81k",(H%DIV&100),3)"-"MID$("SUMCRC",-3*Q
%+1,3)" "MID$("TIMEOUTOk BadCRCEOT
BadPkt",3*(B%AND-2)+7-(B%>=0),6-(B%<0));
SPC6;STRING$(15,CHR$8);:OSCLI"FX3,3":END
PROC
890DEFPROCM:PRINT"XYModem download. ";
:*FX229
900INPUT"Destination file/directory: "
B$:d%=FNE:IFd%:PRINT" - Converting incom
ing LF to CR";
920OSCLI"FX229,1":PRINT:B%=FNS(B$,d%):
PRINT:IFB%<>B:PRINT"Download error: ";A$
(B%)
930PRINT:ENDPROC
1020DEFFNS(B$,d%):OSCLI"FX3,3":OSCLI"FX
2,1":Z%=FNB(229,1,0):c%=TRUE:REPEATB%=FN
F:UNTILB%<>B:c%=FALSE:OSCLI"FX3":OSCLI"F
X2,2":Z%=FNB(229,Z%,0):=(B%AND15)DIV2
1120DEFFNF:F$=B$:C$="":D$="":E%=-1:u%=-
1:v%=-1:G%=-1:H%=-1:Q%=-1:k%=-1:F%=-1:P%
=TIME:j%=1:e%=FALSE:B%=FNA:IFB%<>B:=B%
1140IFG%>1:PROCB:=D
1150IFG%=0:PROCK:e%=TRUE:IFC$="":PROCC:
=A
1160L%=FNG:IFL%=0:PROCB:=F
1170P%=TIME:IFG%=0:PROCC:B%=FNA:IFB%<>B
:PROCF:PROCB:=B%
1180K%=1:F%=0:REPEATB%=FNK:UNTILB%<>B:P
ROCF:IFB%=H:PROCA("Finishing",FALSE):PRO
CC:B%=B:IFNOTe%:B%=A
1200=B%
1280DEFFNA:`%=3*3*3:REPEATPROCA("Negoti
ating",FALSE):IF`%MOD3=0:a%=ASCMID$("G"+
CHR$21+"C",(`%DIV3-1)MOD3+1,1):Q%=a%<>21
:k%=a%=ASC"G"
1310VDUa%:B%=FNC:IFB%=HORB%=C:PROCD
1320`%=`%-1:UNTIL`%=0ORB%=IORB%=EORB%=B
:=B%
1410DEFFNK:IFG%=K%:PROCL:F%=F%+f%:K%=(K
%+1)AND255
1430PROCA("Receiving",FALSE):IFG%=((K%-
1)AND255):PROCC:=FNH
1440=D
1500DEFPROCL:PROCA("Writing",TRUE):f%=H
%:IFE%>=0ANDF%+f%>E%:f%=E%-F%
1520PROCN(L,L%,O%,f%):ENDPROC
1600DEFPROCC:IFNOTk%:VDUK
1610ENDPROC
1660DEFPROCD:REPEATUNTILINKEY0<0:ENDPRO
C
1730DEFFNH:R%=3:REPEATB%=FNC:R%=R%-1:UN
TILR%=0OR(B%<>GANDB%<>C)ORk%:=B%
1850DEFFNC:!J=O%:A%=(d%AND1)OR(Q%AND&80
):A%=USRp%:j%=TIME-P%:B%=A%AND&FF:IFB%=B
:G%=(A%AND&FF00)DIV256:H%=(A%AND&FF0000)
DIV512
1870IFB%=E:PROCB
1880=B%
1910DEFPROCB:PROCD:PRINTSTRING$(8,CHR$I
);:ENDPROC
1940DEFPROCK:IF?O%=0:ENDPROC
1950O%?127=13:C$=FNJ(O%):D$=FNJ(O%+1+LE
NC$):IFD$<>"":E%=VALD$
1980ENDPROC
2050DEFFNG:A%=2:IFB$<>"":A%=FND(B$,5):I
FA%=1:IFC$="":C$=B$ELSEIFA%=1:REPEATB$=L
EFT$(B$,LENB$-1):UNTILRIGHT$(B$,1)="."OR
B$="":B$=LEFT$(B$,LENB$-1)
2080IFC$="":C$="T"+RIGHT$("00000"+STR$T
IME,6)
2100PROCA("Opening",FALSE):IFE%>=0:X%!2
=0:X%!6=0:X%!10=0:X%!14=E%:A%=FND(B$+LEF
T$(".",B$<>"")+C$,7)
2120=OPENOUT(B$+LEFT$(".",B$<>"")+C$)
2180DEFPROCF:PROCA("Closing",FALSE):CLO
SE#L%:L%=0:IFG%<0:ENDPROC
2200ENDPROC
2500DEFPROCI:INPUT"XModem upload file:
"C$:IFC$="":ENDPROC
2510PRINT"File '"C$"' ";:G%=1:s%=1:F%=0
:V%=0:H%=J%AND&FFF:Q%=(J%AND&1000)<>0:I%
=OPENINC$:IFI%=0:PRINT"not found":ENDPRO
C
2530E%=EXT#I%:PRINT"is ";1+E%DIVH%;" bl
ocks":l%=FNE:IFl%:PRINT" - Converting ou
tgoing CR to LF";
2550PRINT:P%=TIME:j%=1:B%=0:T%=0:OSCLI"
FX2,1":*FX3,3
2560PROCA("Waiting",FALSE):OSCLI"FX229"
:REPEATA%=INKEY200:UNTILA%=21OR(A%=ASC"C
"ANDQ%):REPEATPROCA("Waiting",TRUE):IFA%
=0:REPEATA%=INKEY200:UNTILA%=6ORA%=21ORA
%=24
2600IFA%=24:REPEATA%=INKEY200:UNTILA%=6
ORA%=21ORA%=24
2610B%=((A%AND&E)DIV2)-((A%=6)AND3):IFB
%=B:V%=V%OR1:F%=PTR#I%:G%=G%+1
2630j%=TIME-P%:IFV%<>3ANDB%<>4:PROCO
2650A%=0:UNTILV%=3ORB%>2:PROCA("Finishi
ng",0):CLOSE#I%:I%=0:OSCLI"FX3":PRINT'A$
(B%):OSCLI"FX229,1":ENDPROC
2680DEFPROCO:V%=0:IFEOF#I%ANDT%=0:VDU4:
V%=2:ENDPROC
2690IFF%+H%>E%:H%=128
2700PROCA("Sending",0):PTR#I%=F%:g%=0:F
ORn%=0TOH%-1:IFT%:b%=T%:T%=0ELSEIFEOF#I%
:b%=26ELSEb%=BGET#I%
2730IFb%=13ANDl%:b%=10:r%=BGET#I%:PTR#I
%=PTR#I%-1-EOF#I%:IFr%=13:T%=32
2740g%=FNQ(b%,g%):O%?n%=b%:NEXT:REPEATA
%=INKEY0:UNTILA%<>21:IFA%<>-1:B%=3:ENDPR
OC
2760VDUH%DIV1024+1,G%,255-G%:FORn%=0TOH
%-1:VDUO%?n%:NEXT:VDUg%:IFQ%:VDUg%DIV256
2790s%=G%:ENDPROC
2810DEFFNQ(A%,S%):LOCALz%:IFNOTQ%:=(S%+
A%)AND255
2820S%=S%EOR(A%*256):FORz%=1TO8:S%=S%*2
:IF(S%AND&10000):S%=S%EOR&1021
2830NEXT:=S%AND&FFFF
2880DEFPROCJ:IFU%:A%=!&FFB7:!&22A=A%!&2
A:!&22C=A%!&2C
2890IFU%=0:*BUFFER OFF
2900ENDPROC