> MkTAP 1.20  (C) J.G.Harston B Make a TAP file from Spectrum files with load/exec addresses (. v1.03 Asks or determines output filetype 2 v1.04 Uses 256-byte buffer < v1.05 Scans directories F" v1.06 Command line interface PH v1.07 Updated ProgEnv library for BB4Wv6+Brandy, added TZX support ZO v1.15 Avoids OSCLI to set filetype, cleans source name, defaults to Basic d3 v1.20 Renamed to MkTAP and updated parameters n: x! :Close_All::exit(): < ctrl% 31,name% 80,mem% 255,type$(3):X%=ctrl%:Y%=X%256 )A$=OS_GetEnv+" ":os%>31:Win_TextIO Gtype$(0)="Basic":type$(1)="Num ":type$(2)="Char ":type$(3)="Bytes" |A$=" ": "Source file/dir: "in$: "Destination file: "out$: "Options/flags: "A$:A$=nul(out$)+" "+nul(in$)+" "+A$ Japnd%=cl("-a",0):spec%=cl("-s",0):tzx%=cl("-t",0):embd%=cl("-e",0) 7 CmdLine bugfix requires space before final option A$=A$+" ":vb%=cl("-v",0) 'out$=cl("",1):out$="""""":out$="" $in$=cl("",1):in$="""""":in$="" ;nm$=cl("",1):ld$=cl("",1):ex$=cl("",1):tp$=cl("",1) %ld%=-1:ex%=-1:tp%=-1:in%=0:out%=0 !ld$<>"":ld%=("&"+ld$):tp%=0 !ex$<>"":ex%=("&"+ex$):tp%=3 tp$<>"":tp%=("&"+tp$) :out$=("-?")out$="":syntax:exit(220 (out$<>0)): : "Cin$<>"":A%=file(in$,5):(A%1):in%=f_openin(in$):in%=0:A%=0 ,9in$<>"":A%=0:"File '"in$"' not found":exit(214): 63apnd%:out%=f_openup(out$):out%:#out%=#out% @!out%=0:out%=f_openout(out$) JBout%=0:"Couldn't open file '"out$"'":Close_All:exit(192): TOos%<8:A%=file(out$,5):X%?5=&FF:spec%:X%?4=&F7:X%?3=1 X%?4=&F1:X%?3=&1D ^os%<8:A%=file(out$,1) hok%=: ok%= r6os%<8:ok%:"SetType "+out$+" 11D":"Stamp "+out$ |: ! :Close_All::exit(): 8in%:A%=file(in$,5):File in$="":Enter Store #out%:out%=0:exit(0): :  Enter 5 "Enter input filenames, terminated with RETURN" : "File: "in$ "":"Store as: "nm$:Store  in$="": :  Store (file(in$,5)1):File: -"Dir "+in$:i%=0::in$=gbpb8(i%):i%=X%!9 1in$<>"":A%=file(in$,5):(A%1):nm$="":File  in$="": : & File 00load%=X%!2:exec%=X%!6:len%=X%!10:attr%=X%!14 :O(load%&FFFFFF00)=&FFF70000:load%=&30000:exec%=load%: Speculator ROM file DV(load%&FFFF0000)=&FFF20000:load%=(load%&FFFF)&30000:exec%=load%: Z80Tube file N*len%>&EFFF:"File '"in$"' too long": X+len%=0 :"File '"in$"' too short": b@in%=0:in%=f_openin(in$):in%=0:"File '"in$"' not found": l_embd%:ld%=0:ex%=0:len%>3:#in%=len%-4:ld%=#in%+256*#in%:ex%=#in%+256*#in%:len%=len%-4 vld%<>-1:load%=&30000+ld% 1ex%<>-1:exec%=&30000+ex% tp%=0:exec%=len% nm$="":nm$=fn_unbbc(in$) : SpName$ =pad(nm$,10) SpStart%=(load%&FFFF) SpExtra%=(exec%&FFFF) "SpType% =(load%&30000)&10000 tp%<>-1:SpType%=tp% : Svb%: SpName$" ";:SpType%<4: type$(SpType%); vb%: " &"h0(SpType%,2)" "; Fvb%: " "h0(len%,4)" "h0(SpStart%,4)" "h0(SpExtra%,4);10,8); : Gtzx%:#out%=0:$mem%="ZXTape!":mem%!7=26:f_gbpb(2,out%,mem%,10,0) tzx%:#out%,&10   A%=tzx% 0 8#out%,&13+2*(spec%):#out%,0 : Length of block   *:SpChk%=0:Out(0) : Header block 4AOut(SpType%) : Basic/Char/Num/Code > A%=1 10 H'Out( SpName$,A%,1)): : Name R/Out(len%):Out(len%256) : Length \IOut(SpStart%):Out(SpStart%256) : Basic autoline/Code exec address fPOut(SpExtra%):Out(SpExtra%256) : Code load address/Basic length/var name pspec%:#out%,SpChk% z: tzx%:#out%,&10  A%=tzx% 0 #out%,len%+2+2*spec% 9#out%,(len%+2+2*spec%)256 : Length of block  8SpChk%=0:Out(&FF) : Data block len%>255: A%=0 len%256-1:f_gbpb(3,in%,mem%,256,A%*256):Chk(256):f_gbpb(2,out%,mem%,256,#out%):vb%: 4,8);h0(len%-A%*256,4); len%>255: eA%=len%255:A%:f_gbpb(3,in%,mem%,A%,(len%&FF00)):Chk(len%255):f_gbpb(2,out%,mem%,A%,#out%) spec%:#out%,SpChk% : vb%: 4,8);h0(len%,4) #in%:in%=0  : 3Chk(N%): B%=0N%-1:SpChk%=SpChk%mem%?B%:: $*Out(A%):SpChk%=SpChk%A%:#out%,A%: .: 8csyntax:"Usage: MkTAP outfile infile -append -embed -spec -tzx [name [load [exec [type]]]]": B: L ݤnul(A$):A$:=A$ ="""""" V-ݤpad(A$,L%):A$=A$,L%):=A$+L%- A$," ") `%ݤfn_unbbc(A$):A$="" os%>7:="" j7A%=1A$:A$,A%,1)="/":A$=A$,A%-1)+"."+A$,A%+1) t :=A$ ~#ݤh0(A%,N%)="0000000"+~A%,N%) : Close_All:*EXEC "in%=in%:in%:A%=in%:in%=0:#A% 'out%=out%:out%:A%=out%:out%=0:#A%  : Lݤfile(A$,A%):<&FFFFF:$name%=A$:?X%=name%:X%?1=name%256:=(&FFDD)&FF JA$=f_name(A$):A%=255 A%=5:X%!14=(A$):X%!14:X%!10=#X%!14:#X%!14 1A%=255:X%?6=0:"LOAD """+A$+""" "+~X%!2:=1 A%=5:X%!14:=1 A%=5:=0 FA%=0:"SAVE """+A$+""" "+~X%!10+" "+~X%!14:X%!10=X%!14-X%!10:=1 BA%=7:"SAVE """+A$+""" "+~+"+"+~X%!10:X%!10=X%!14-X%!10:=1  A%=8   : :=2 "MKDIR "+A$:=2  (=0 2: 31:A%,B%:B%=A%:A%=A$,"\",A%+1):A%=0:A$,".",B%)=0:A$=A$+"." d=A$ n: x%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: : ݤgbpb8(ptr%):>&FFFFF:="" 7X%!1=name%:X%!5=1:X%!9=ptr%:A%=8:&FFD1:X%!5=1:="" #A%=name%:A%?(1+?A%)=13:=$(A%+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$ 6/ݤs(A$):A$,1)=" ":A$=A$,2):A$,1)<>" " @+A$,1)=" ":A$=A$,A$-1):A$,1)<>" " J=A$ T: ^BݤOS_GetEnv:A%,X%,Y%,P%,A$:X%=1:os%=((&FFF4)&FF00)256:X% hd!=&D7C1C7C5:run$=ARGV$(0):ARGC:A%=1ARGC:A$=A$+ARGV$(A%)+" "::=A$,A$-1)!=&D7C1C7C5:="" r_>&FFFFF:X%256:A$=@cmd$:ș"GetModuleFileName",0,X%,255:run$=$$X%:Y%=@lib$,@tmp$)=0:P%= |P%=0:>&FFFF:run$=$&8100:ș"OS_GetEnv"A$,,A%:ș"OS_WriteEnv","",A%:A$=A$,1+A$+" "," ",1+A$," "))):P%=:Y%=:A$," ")=0:A$=run$+" " P%=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: &: