10
20
30 :
40 A%=0:X%=1:os%=((USR&FFF4)AND&FF00)DIV256
50 DIM ctrl% 31,name% 80,mem% 255:X%=ctrl%:Y%=X%DIV256
60 in%=0:out%=0:INPUT"Snapshot file: "f$
70 in%=OPENIN(f$):IF in%=0:PRINT"'"f$"' not found":END
80 INPUT"Source screen address &"A$:IF A$="":A$="4000"
90 addr%=EVAL("&"+A$) :base%=&100+addr%-&4000
100 IF((EXT#in%)AND&FF)=&1B:base%=&1B+addr%-&4000
110 INPUT"Output screen file: "out$
120 out%=OPENOUT(out$)
130 ON ERROR IF FNerr:PRINTERL:END
140 FOR ptr%=&40-&40 TO &5A-&40
150 PROCf_gbpb(3,in%,mem%,256,base%+ptr%*256)
160 PROCf_gbpb(1,out%,mem%,256,ptr%*256)
170 NEXT ptr%
180 CLOSE#out%:out%=0
190 CLOSE#in% :in%=0
200 X%!2=&34000:A%=FNfile(out$,2)
210 X%!6=&34000:A%=FNfile(out$,3)
220 END
230 :
240 DEFFNerr:REPORT:IFin%:A%=in%:in%=0:CLOSE#A%
250 IFout%:A%=out%:out%=0:CLOSE#A%
260 PRINT:=TRUE
270 :
280 DEFFNfile(A$,A%):IFPAGE<&FFFFF:$name%=A$:?X%=name%:X%?1=name%DIV256:=(USR&FFDD)AND&FF
290 =0
300 :
310 DEFPROCf_gbpb(A%,chn%,addr%,num%,ptr%)
320 ?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:IFPAGE<&FFFFF:CALL &FFD1:ENDPROC
330 IFA%=1ORA%=3:PTR#?X%=X%!9
340 REPEAT:IFA%=1ORA%=2:BPUT#?X%,?X%!1 ELSE IFA%=3ORA%=4:?X%!1=BGET#?X%
350 X%!1=X%!1+1:X%!5=X%!5-1:UNTIL(EOF#?X% AND A%>2)OR X%!5<1:ENDPROC
360 :