8-Bit Software Online Conversion
:2.$.LZSSC - Listing
180MODE7:PROCa:PROCb:PROCc:PROCd
230PROCe:PROCf(g$,h$,i%,j%):IFFNkTHENG
OTO230
260VDU22,7:PROCl:END
300DEFPROCb:m%=0:ONERRORPROCn
330PROCo:PROCp:PRINT'"Please wait, ini
tialising...":DIMq%64:CLOSE#0:ENDPROC
400DEFPROCd:LOCALr%,j%,s%,t%,u%,v%:DIM
r%-1:IFHIMEM-r%>=29821THENw%=12ELSEw%=11
460j%=7::s%=2^w%:t%=(1+w%+j%)DIV9:u%=t
%+2^j%:v%=s%+u%:DIMx%v%+u%:DIMy%6*(v%+1)
:ENDPROC
550DEFPROCn:IFm%<>0ANDERR>=128THENREPO
RT:PRINT:GOTO230
570VDU22,7:CLOSE#0:PROCl:IFERR<>17THEN
REPORT:PRINT" at line ";ERL
610END
630DEFPROCo:*FX4,1
650ENDPROC
670DEFPROCl:*FX4
690ENDPROC
710DEFPROCa:VDU23,1,0;0;0;0;:ENDPROC
750DEFPROCz:VDU23,1,1;0;0;0;:ENDPROC
790DEFPROCc:LOCALaa%,ba%,ca%,da%,ea%,f
a%,A%,X%,Y%:aa%=OPENIN("LZSSCX"):IFaa%=0
THENPRINT'"Sorry, I can't find LZSSCX."'
:PROCl:END
830DIMga%FNha(aa%):?q%=aa%:q%!1=ga%:q%
!5=FNha(aa%):A%=4:X%=q%MOD256:Y%=q%DIV25
6:CALL&FFD1:ba%=FNha(aa%):FORca%=1TOFNha
(aa%):da%=FNha(aa%):ea%=ga%?da%+256*ga%?
(da%+1):fa%=ea%-ba%+ga%:ga%?da%=fa%MOD25
6:ga%?(da%+1)=fa%DIV256:NEXT:CLOSE#aa%:i
a=ga%+&6CB:ja=ga%+&6CC:x=&82:y=&84
1000s=ga%+&6D3:v=&86:u=&7F:t=ga%+&6D7:i
=ga%+&6D8:j=ga%+&6D9:ka=ga%+&6DD:la=ga%+
&6DE:ma=ga%+&6DF:na=ga%+&6E0:oa=ga%+&6CE
:pa=&8A:ENDPROC
1140DEFFNha(qa%):=BGET#qa%+256*BGET#qa%
1170DEFPROCra($x%):LOCALX%,Y%:X%=x%MOD2
56:Y%=x%DIV256:CALL&FFF7:ENDPROC
1240DEFPROCp:CLS:PRINTTAB(8,0);CHR$141;
CHR$132;CHR$157;CHR$135;"LZSS compressio
n ";CHR$156:PRINTTAB(8,1);CHR$141;CHR$1
32;CHR$157;CHR$135;"LZSS compression ";
CHR$156:PRINTCHR$131;"Version 1.00 (C) S
teven Flintham 1996":ENDPROC
1310DEFPROCe:LOCALqa%:IFm%=1THENGOTO139
0
1340IFm%=2THENGOTO1450
1350PROCp:VDU28,0,24,39,4:PRINT"Wheneve
r a filename is requested you canalso en
ter a * command":m%=1
1390REPEAT:g$=FNsa("Input file: "):qa%=
OPENIN(g$):IFqa%<>0THENCLOSE#qa%ELSEPRIN
T'"That file does not exist!"
1430UNTILqa%<>0:m%=2
1450REPEAT:h$=FNsa("Output file: "):UNT
ILFNta(h$):qa%=OPENOUT(h$):CLOSE#qa%:m%=
0:i%=FNua("Offset bits:",6,w%):IFi%<=7TH
ENva%=i%ELSEva%=7
1530j%=FNua("Length bits:",2,va%):VDU26
:ENDPROC
1570DEFFNsa(wa$):LOCALxa$:REPEAT:PRINT'
wa$;:xa$=FNya(FNg(1,255,FALSE)):PRINT:IF
LEFT$(xa$,1)="*"THENPROCra(xa$)
1630UNTILLEFT$(xa$,1)<>"*":=xa$
1660DEFFNya(za$):REPEAT:IFLEFT$(za$,1)=
" "THENza$=MID$(za$,2)
1690UNTILLEFT$(za$,1)<>" ":=za$
1720DEFFNta(h$):LOCALqa%:qa%=OPENIN(h$)
:IFqa%=0THEN=TRUE
1760CLOSE#qa%:PRINT'"That file already
exists. Are you sure you want to overwr
ite it? (Y/N) ";:IFNOTFNabTHENPRINT"No":
=FALSE
1790PRINT"Yes":qa%=OPENOUT(h$):CLOSE#qa
%:=TRUE
1840DEFFNua(wa$,bb%,cb%):LOCALua%:REPEA
T:PRINT'wa$;" (";bb%;"-";cb%;") ";:ua%=V
AL(FNg(1,LEN(STR$(cb%)),TRUE)):PRINT:UNT
ILua%>=bb%ANDua%<=cb%:=ua%
1920DEFPROCf(g$,h$,i%,j%):LOCALg%,h%,db
%,A%,X%,Y%,s%,t%,u%,v%,eb%,fb%,gb%,hb%,b
b%,ib%:PROCp:PRINT'"Input file: ";CHR$13
1;g$:PRINT"Output file:";CHR$131;h$:PRIN
T"Offset bits:";CHR$131;i%:PRINT"Length
bits:";CHR$131;j%:PRINT'"Please wait, co
mpressing..."
2000PRINT'"Bytes read: ";CHR$131;"&";
:?ka=POS:?la=VPOS:PRINT"000000":PRINT"By
tes written:";CHR$131;"&";:?ma=POS:?na=V
POS:PRINT"000000";:g%=OPENIN(g$):h%=OPEN
OUT(h$):FORdb%=1TO4:BPUT#h%,ASC(MID$("LZ
SS",db%,1)):NEXT:BPUT#h%,0::BPUT#h%,i%:B
PUT#h%,j%:BPUT#h%,0::$(q%+32)=g$:q%!0=q%
+32:A%=5:X%=q%MOD256:Y%=q%DIV256:CALL&FF
DD
2120FORdb%=10TO13:BPUT#h%,q%?db%:NEXT:F
ORdb%=2TO9:BPUT#h%,q%?db%:NEXT:FORdb%=1T
O4:BPUT#h%,0:NEXT::?ia=g%:?ja=h%:s%=2^i%
:t%=(1+i%+j%)DIV9:u%=t%+2^j%:v%=s%+u%:x?
0=x%MOD256:x?1=x%DIV256:y?0=y%MOD256:y?1
=y%DIV256:s?0=s%MOD256:s?1=s%DIV256:v?0=
v%MOD256:v?1=v%DIV256:?u=u%:?t=t%:?i=i%:
?j=j%:eb%=TIME:CALLga%
2310eb%=TIME-eb%:IFeb%=0THENeb%=1:
2330fb%=oa!0AND&FFFFFF:gb%=24+pa!0AND&F
FFFFF::PRINTTAB(?ka,?la);RIGHT$("000000"
+STR$÷fb%,6):PRINTTAB(?ma,?na);RIGHT$("0
00000"+STR$÷gb%,6):hb%=eb%DIV360000:bb%=
(eb%-hb%*360000)DIV6000:ib%=(eb%-hb%*360
000-bb%*6000)DIV100:PRINT'"Time taken:
";CHR$131;hb%;":";RIGHT$("00"+STR$
(bb%),2);":";RIGHT$("00"+STR$(ib%),2)
2410PRINT"Speed: ";CHR$131;
(100*fb%)DIVeb%;" bytes/second":PRINT"Ou
tput/input ratio:";CHR$131;gb%*100DIVfb%
;"%":CLOSE#g%:CLOSE#h%:ENDPROC
2470DEFFNk:PRINT'"Compress another file
? (Y/N)";:=FNab
2510DEFFNab:LOCALjb$:*FX21
2540REPEAT:jb$=CHR$(GETAND&DF):UNTILjb$
="Y"ORjb$="N":=(jb$="Y")
2590DEFFNg(bb%,cb%,kb%):LOCALg$,jb$:g$=
"":*FX21
2630PROCz:REPEAT:REPEAT:jb$=GET$:UNTIL(
jb$>="0"ANDjb$<="9")OR(NOTkb%ANDjb$>=" "
ANDjb$<="÷")ORjb$=CHR$13ORjb$=CHR$127:IF
jb$<>CHR$13ANDjb$<>CHR$127ANDLEN(g$)<cb%
THENg$=g$+jb$:PRINTjb$;
2690IFjb$=CHR$127ANDg$<>""THENg$=LEFT$(
g$,LEN(g$)-1):VDU127
2700UNTILLEN(g$)>=bb%ANDLEN(g$)<=cb%AND
jb$=CHR$13:PROCa:=g$