> TAPtoBIN 1.15  (C) J.G.Harston " Extract files from TAP files (4 Needs to be able to recognise Speculator files 2" v1.11 - Uses CmdLine library 31:Win_TextIO n? ctrl% 31,name% 80,type$(3):X%=ctrl%:Y%=X%256:wr%=2:rd%=4 xGtype$(0)="Basic":type$(1)="Num ":type$(2)="Char ":type$(3)="Bytes" mA$=" ": "Source file: "in$: "Destination dir: "outd$: "Options/flags: "A$:A$=in$+" "+outd$+" "+A$ ro%=cl("-r",0) 7 CmdLine bugfix requires space before final option A$=A$+" ":vb%=cl("-v",0) Qin$=cl("",1):outd$=cl("",1):outd$<>"":outd$,1)=d$:outd$=outd$,outd$-1) Din$="-?":"Usage: TAPtoBIN () -v -ro":exit(0): in$="":exit(0): : Din%=f_openin(in$):in%=0:"File '"in$"' not found":exit(214): ,outd$<>"":f_cdir(outd$):outd$=outd$+d$ % A%-1:max%=-A%-2500: mem% max% (f_gbpb(rd%,in%,mem%,10,0):mem%?7=13 8tap%=(($mem%="ZXTape!"4))(((!mem%&FFFFFF)=&11)1) (tap%4)=0:#in%=0 : .vb%: "Filename Type Start Extr Len"; "*:(tap%4):#in%=&10:A%=#in%+#in% ,1num%=(#in%+256*#in%)-1+(tap%1):flag%=#in% 67flag%=&00:RdHeader flag%=&FF:RdData RdSkip @#in%:#in%:in%=0:vb%: Jexit(0): T: ^RdSkip:#in%=#in%+num%: h: rRdHeader |5num%>max%:RdSkip: : Header is too long ;f_gbpb(rd%,in%,mem%,num%,0) : Read header block SpType% =mem%?0 SpLen% =(mem%!11)&FFFF SpStart%=(mem%!13)&FFFF SpExtra%=(mem%!15)&FFFF  mem%?11=13:SpName$=$(mem%+1)  vb%: 8'fn_clean(SpName$);" ";:ro%:HeaderRO HeaderZX  : HeaderZX < SpType%<4: type$(SpType%); " &"h0(SpType%,2)" "; <" "h0(SpStart%,4)" "h0(SpExtra%,4)" "h0(SpLen%,4);  : HeaderRO &Uhi(SpType%);h0(SpStart%,4);" ";hi(SpType%);h0(SpExtra%,4);" ";h0(SpLen%,4); 0 :: D RdData NKnum%=num%-1+(tap%1):SpName$=s(SpName$):out$=outd$+fn_unspec(SpName$) X"len%=num%:len%>max%:len%=max% b f_gbpb(rd%,in%,mem%,len%,0) lp"Save "+f_name(out$)+" "+~mem%+"+"+~num%+" "+~(SpType%*&10000+SpExtra%)+" "+~(SpType%*&10000+SpStart%) v1num%=num%-len%:num%<1:(tap%1)=0:chk%=#in%  num%<1: $out%=f_openup(out$):#out%=len%  "len%=num%:len%>max%:len%=max%  f_gbpb(rd%,in%,mem%,len%,0) !f_gbpb(wr%,out%,mem%,len%,0) num%=num%-len%: num%<1 (tap%1)=0:chk%=#in% #out%:out%=0: : ݤfn_clean(A$): A$="":="" L A%=1 A$: A$,A%,1)<" " A$,A%,1)>"~":A$=A$,A%-1)+"_"+A$,A%+1)  :=A$ :  ݤfn_unspec(B$): B$="":="_" =B%,C$:A$="""#$%&:<>*.@[\]^{|}~":C$="'?S;+;()+/=(/)'(')'"  M(os%-24):A$=""":<>?*/\|":C$="';()#+..'":(os%-32):A$="""?*/":C$="'#+." *# A%=1 B$:B%=A$,B$,A%,1)) 4) B%:B$=B$,A%-1)+C$,B%,1)+B$,A%+1) >> B$,A%,1)<"!" B$,A%,1)>"~":B$=B$,A%-1)+"_"+B$,A%+1) H :=B$ R: \ ݤhi(A%) f!A%<3:=h0(A%,2) =h0(-1,2) p#ݤh0(A%,N%)="0000000"+~A%,N%) z/ݤs(A$):A$,1)=" ":A$=A$,2):A$,1)<>" " +A$,1)=" ":A$=A$,A$-1):A$,1)<>" " =A$ : Close_All:*Exec "in%=in%:in%:A%=in%:in%=0:#A% 'out%=out%:out%:A%=out%:out%=0:#A%  :  f_init 6d$=".":s$="/":os%40:d$="/":s$=".":os%>31:d$="\"  : !ݤf_openin(A$)=(f_name(A$)) "ݤf_openout(A$)=(f_name(A$)) !ݤf_openup(A$)=(f_name(A$)) Vݤf_name(A$):os%>31:A%,B%:B%=A%:A%=A$,"\",A%+1):A%=0:A$,".",B%)=0:A$=A$+"." $=A$ .: 8f_cdir(A$) B,(os%40):A$="mkdir "+A$ A$="cdir "+A$ L V A$: ` j : : tA$ ~ : %f_gbpb(A%,chn%,addr%,num%,ptr%) ??X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:<&FFFFF: &FFD1: A%=1A%=3:#?X%=X%!9 5:A%=1A%=2:#?X%,?X%!1 A%=3A%=4:?X%!1=#?X% 5X%!1=X%!1+1:X%!5=X%!5-1:(#?X% A%>2) X%!5<1: : cݤcl(l$,n%):l$="":A$=s(A$):A$=34:A%=A$+" "" ",""" ",2):l$=A$,2,A%-2):A$=s(A$,A%+1)):=l$ "":A%=A$,l$):A%:A$=s(A$,A%-1)+A$,A$," ",A%)+1))+" ":= n%=0:l$<>"":= %A%=" ",l$=32)+A$,l$):A%=0:="" 'A$=A$,A%-1)+s(A$,A$," ",A%)+1))  Cl$=32:l$=A$,A%):A$=A$,A%-1):=l$,1-(l$=34),l$+2*(l$=34)) PA$,A%,1)<>34:l$=A$,A%,A$+" "," ",A%)-A%):A$=A$,A%-1)+A$,A%+l$+1):=l$ Jl$=A$,A%+1,A$+""" ",""" ",A%+1)-A%-1):A$=A$,A%-1)+A$,A%+l$+3):=l$ (/ݤs(A$):A$,1)=" ":A$=A$,2):A$,1)<>" " 2+A$,1)=" ":A$=A$,A$-1):A$,1)<>" " <=A$ F: PBݤOS_GetEnv:A%,X%,Y%,P%,A$:X%=1:os%=((&FFF4)&FF00)256:X% Zd!=&D7C1C7C5:run$=ARGV$(0):ARGC:A%=1ARGC:A$=A$+ARGV$(A%)+" "::=A$,A$-1)!=&D7C1C7C5:="" d_>&FFFFF:X%256:A$=@cmd$:ș"GetModuleFileName",0,X%,255:run$=$$X%:Y%=@lib$,@tmp$)=0:P%= nP%=0:>&FFFF:run$=$&8100:ș"OS_GetEnv"A$,,A%:ș"OS_WriteEnv","",A%:A$=A$,1+A$+" "," ",1+A$," "))):P%=:Y%=:A$," ")=0:A$=run$+" " xP%=0:P%=X%:[OPT 0:NOP:]:P%=?X%:Y%=:P%=&EAP%=18:A$=$&600 P%=0:A$=$(-&300)P%=&A0:A$=$(^@%-256):Y%=?(-2)64P%=&90:A$=$&100:Y%=!&200 KA$=" "+A$:A$=A$,2):A$<>32:A$=34:A%=A$,"""",2)+1A%=A$+" "," ") (Y%:run$=A$,A%-1):A$=A$,A%+1):Y%=0 A$<>32:=A$ : &os(A$):A$=42:A$ A$<>"":A$  : Fexit(A%):"FX1,"+(A%255):quit$=quit$:A$=quit$:quit$="":os(A$) >&FFFFF:Ș A%  : Win_TextIO 0ș "GetStdHandle",-10 @hfile%(1):*INPUT 13 1ș "GetStdHandle",-11 @hfile%(2):*OUTPUT 14 &ș "SetConsoleMode",@hfile%(1),0: :