10
20
30 :
40 READ fn$:in%=OPENIN(fn$):IF in%=0:PRINT"Not found"
50 ext%=EXT#in%:CLOSE#in%:in%=0
60 DIM mem% ext%+24:OSCLI"LOAD "+fn$+" "+STR$~mem%
70 dw%=FNrev(mem%?0):mode%=FNrev(mem%?1) AND 7
80 stp%=FNrev(mem%?10):cw%=FNrev(mem%?11)
90 num%=256*EVAL("&"+MID$("5050504028282004",mode%*2+1,2))
100 IFdw%=0 OR dw%>8 OR cw%=0 OR cw%>8 OR stp%>8:PRINT"Doesn't look like LDPIC file":END
110 PRINT"MODE ";mode%;" dw=";dw%;" cw%=";cw%
120 PRINT"Scanning";
130 bits%=0:data%=0:ptr%=12:REPEAT
140 IF FNbit:cnt%=FNget(cw%) ELSE cnt%=1
150 dat%=FNget(dw%):num%=num%-cnt%:UNTIL num%<1
160 PRINTCHR$13;"End at ";~ptr%
170 IFptr%<ext%-32 OR ptr%>ext%:PRINT"Doesn't look like LDPIC file":END
180 :
190 FOR col%=1 TO 8
200 READ R,G,B:R=FNrev(R):G=FNrev(G):B=FNrev(B)
210 mem%?(ptr%+0)=R+G/16:mem%?(ptr%+1)=B
220 READ R,G,B:R=FNrev(R):G=FNrev(G):B=FNrev(B)
230 mem%?(ptr%+1)=mem%?(ptr%+1)+R/16:mem%?(ptr%+2)=G+B/16
240 ptr%=ptr%+3:NEXT:PRINT"Saving ";fn$;
250 OSCLI "SAVE "+fn$+" "+STR$~mem%+"+"+STR$~ptr%+" 0 FFFFFD00"
260 PRINT:END
270 :
280 DEFFNb0(A%,N%):LOCAL A$,B$,L%:B$="0":IFA%<0:B$="1":A%=A%AND&7FFFFFFF
290 REPEATA$=STR$(A%AND1)+A$:A%=A%DIV2:L%=L%+1:UNTILL%>30:=RIGHT$(B$+A$,N%)
300 DEFFNrev(A%):=FNr(A%DIV16)+16*FNr(A%AND15)
310 DEFFNr(A%):=VALMID$("00080412021006140109051303110715",A%*2+1,2)
320 DEFFNbit:IFbits%=0:data%=mem%?ptr%:ptr%=ptr%+1:bits%=8
330 data%=data%*2:bits%=bits%-1:=data%AND256
340 DEFFNget(N%):LOCALA%,B%:FORB%=1TON%:A%=(A%DIV2)ORFNbit:NEXT
350 REPEATA%=A%DIV2:N%=N%+1:UNTILN%>8:=A%
360 :
370
380 DATA JARRE
390 :
400
410 DATA 15,15,15 , 15,15, 0
420 DATA 15, 0,15 , 0, 5,15
430 DATA 15,10, 0 , 0,15, 0
440 DATA 15, 5, 5 , 0, 0, 0
450 DATA 15,15,15 , 15,15, 0
460 DATA 15, 0,15 , 0, 5,15
470 DATA 15,10, 0 , 0,15, 0
480 DATA 15, 5, 5 , 0, 0, 0