8-Bit Software Online Conversion
:2.$.LZSSDF - Listing
130MODE7:PROCa:PROCb:PROCc:PROCd
180PROCe:PROCf(g$,h$):IFFNiTHENGOTO180
210VDU22,7:PROCj:END
250DEFPROCb:k%=0:ONERRORPROCl
280PROCm:PROCn:PRINT'"Please wait, ini
tialising...":o%=TRUE:DIMp%64:IFo%THENDI
Mq%512
340CLOSE#0:ENDPROC
370DEFPROCd:DIMr%-1:s%=HIMEM-r%-1024:D
IMt%s%:ENDPROC
430DEFPROCl:IFk%<>0ANDERR>=128THENREPO
RT:PRINT:GOTO180
450VDU22,7:CLOSE#0:PROCj:IFERR<>17THEN
REPORT:PRINT" at line ";ERL
490END
510DEFPROCm:*FX4,1
530ENDPROC
550DEFPROCj:*FX4
570ENDPROC
590DEFPROCa:VDU23,1,0;0;0;0;:ENDPROC
630DEFPROCu:VDU23,1,1;0;0;0;:ENDPROC
670DEFPROCc:LOCALv%,w%,x%,y%,z%,aa%,A%
,X%,Y%:IFo%THENv%=OPENIN("LZSSDMB")ELSEv
%=OPENIN("LZSSDM")
700DIMba%FNca(v%):?p%=v%:p%!1=ba%:p%!5
=FNca(v%):A%=4:X%=p%MOD256:Y%=p%DIV256:C
ALL&FFD1:w%=FNca(v%):FORx%=1TOFNca(v%):y
%=FNca(v%):z%=ba%?y%+256*ba%?(y%+1):aa%=
z%-w%+ba%:ba%?y%=aa%MOD256:ba%?(y%+1)=aa
%DIV256:NEXT:CLOSE#v%:da=&77:ea=&73:fa=&
78:ga=&79:ha=&7A:ia=&7F:ja=&8C:ENDPROC
920DEFFNca(ka%):=BGET#ka%+256*BGET#ka%
950DEFPROCla($p%):LOCALX%,Y%:X%=p%MOD2
56:Y%=p%DIV256:CALL&FFF7:ENDPROC
1020DEFPROCn:CLS:PRINTTAB(4,0);CHR$141;
CHR$132;CHR$157;CHR$135;"LZSS fast decom
pression ";CHR$156:PRINTTAB(4,1);CHR$14
1;CHR$132;CHR$157;CHR$135;"LZSS fast dec
ompression ";CHR$156:PRINTCHR$131;"Vers
ion 1.00 (C) Steven Flintham 1996":ENDPR
OC
1090DEFPROCe:IFk%=1THENGOTO1170
1110IFk%=2THENGOTO1210
1120PROCn:VDU28,0,24,39,4:PRINT"Wheneve
r a filename is requested you canalso en
ter a * command":PRINT'"Maximum decompre
ssed file size is &";STR$÷s%:k%=1
1170REPEAT:g$=FNma("Input file: "):UNTI
LFNna(g$):k%=2
1210REPEAT:h$=FNma("Output file: "):UNT
ILFNoa(h$):k%=0:VDU26:ENDPROC
1280DEFFNma(pa$):LOCALqa$:REPEAT:PRINT'
pa$;:qa$=FNra(FNg(1,255,FALSE)):PRINT:IF
LEFT$(qa$,1)="*"ANDLEN(qa$)<64THENPROCla
(qa$)
1340UNTILLEFT$(qa$,1)<>"*":=qa$
1370DEFFNra(sa$):REPEAT:IFLEFT$(sa$,1)=
" "THENsa$=MID$(sa$,2)
1400UNTILLEFT$(sa$,1)<>" ":=sa$
1430DEFFNna(qa$):LOCALka%,ta%,ua%:ka%=O
PENIN(qa$):IFka%=0THENPRINT'"That file d
oes not exist!":=FALSE
1470FORta%=0TO11:p%?ta%=BGET#ka%:NEXT:C
LOSE#ka%:ua%=p%?4:p%?4=13:IF$p%<>"LZSS"T
HENPRINT'"That is not an LZSS file!":=FA
LSE
1530IFua%<>0THENPRINT'"That is not a ve
rsion 0 LZSS file!":=FALSE
1540IFp%!8>s%THENPRINT'"The decompresse
d file would be too"'"large!":=FALSE
1550=TRUE
1570DEFFNoa(h$):LOCALka%:ka%=OPENIN(h$)
:IFka%=0THEN=TRUE
1610CLOSE#ka%:PRINT'"That file already
exists. Are you sure you want to overwr
ite it? (Y/N) ";:IFNOTFNvaTHENPRINT"No":
=FALSE
1640PRINT"Yes":ka%=OPENOUT(h$):CLOSE#ka
%:=TRUE
1690DEFPROCf(g$,h$):LOCALv%,wa%,xa%,ya%
,za%,ab%,bb%,cb%,db%,eb%,A%,X%,Y%:PROCn:
PRINT'"Input file: ";CHR$131;RIGHT$(g$,2
7):PRINT"Output file:";CHR$131;RIGHT$(h$
,27):v%=OPENIN(g$):?da=v%:PTR#v%=5:?ga=B
GET#v%:?ha=BGET#v%:PRINT"Offset bits:";C
HR$131;?ga:PRINT"Length bits:";CHR$131;?
ha:PRINT'"Please wait, decompressing..."
1790PTR#v%=8:FORfb%=0TO11:p%?fb%=BGET#v
%:NEXT:gb%=!p%:db%=p%!4:eb%=p%!8:ia?0=gb
%MOD256:ia?1=gb%DIV256:ia?2=gb%DIV&FFFF:
?fa=(1+?ga+?ha)DIV9:?ea=t%MOD256:ea?1=t%
DIV256:IFo%THEN?ja=q%MOD256:ja?1=q%DIV25
6
1860PTR#v%=24:xa%=TIME:CALLba%:PROCla("
Save "+h$+" "+STR$÷t%+" +"+STR$÷gb%+" "+
STR$÷eb%+" "+STR$÷db%):xa%=TIME-xa%:IFxa
%=0THENxa%=1:
1920ya%=PTR#v%::PRINT'"Bytes read: ";
CHR$131;"&";RIGHT$("000000"+STR$÷ya%,6):
PRINT"Bytes written:";CHR$131;"&";RIGHT$
("000000"+STR$÷gb%,6):ab%=xa%DIV360000:b
b%=(xa%-ab%*360000)DIV6000:cb%=(xa%-ab%*
360000-bb%*6000)DIV100:PRINT'"Time taken
: ";CHR$131;ab%;":";RIGHT$("00"+S
TR$(bb%),2);":";RIGHT$("00"+STR$(cb%),2)
1990PRINT"Speed: ";CHR$131;
(100*ya%)DIVxa%;" bytes/second":PRINT"In
put/output ratio:";CHR$131;ya%*100DIVgb%
;"%":CLOSE#v%:ENDPROC
2040DEFFNi:PRINT'"Decompress another fi
le? (Y/N)";:=FNva
2080DEFFNva:LOCALhb$:*FX21
2110REPEAT:hb$=CHR$(GETAND&DF):UNTILhb$
="Y"ORhb$="N":=(hb$="Y")
2160DEFFNg(bb%,s%,ib%):LOCALg$,hb$:g$="
":*FX21
2200PROCu:REPEAT:REPEAT:hb$=GET$:UNTIL(
hb$>="0"ANDhb$<="9")OR(NOTib%ANDhb$>=" "
ANDhb$<="÷")ORhb$=CHR$13ORhb$=CHR$127:IF
hb$<>CHR$13ANDhb$<>CHR$127ANDLEN(g$)<s%T
HENg$=g$+hb$:PRINThb$;
2260IFhb$=CHR$127ANDg$<>""THENg$=LEFT$(
g$,LEN(g$)-1):VDU127
2270UNTILLEN(g$)>=bb%ANDLEN(g$)<=s%ANDh
b$=CHR$13:PROCa:=g$