> FileToTAP 1.05  (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: P$ :CloseAll:" at line ";: Z; ctrl% 31,name% 80,mem% 255:X%=ctrl%:Y%=X%256:spec%= d' "Enter output TAP filename: "out$ n@in%=0:out%=(out$): out%=0:"Can't open '"out$"'":"Exec": xb IFFNuc(RIGHT$(out$,4))="/SPT":spec%=TRUE ELSE IFFNuc(RIGHT$(out$,4))="/TAP":spec%=FALSE ELSE M "(T)apefile or (S)peculator file? "A$:A$=A$,1): A$="S"A$="s":spec%= +"Outputting ";: spec%:"Speculator "; "tapefile" $ spec%:"SetType "+out$+" 11D" & spec% :"SetType "+out$+" 701" 5 "Enter input filenames, terminated with RETURN" $ :CloseAll:" at line ";: :   "File: "in$  in$<>"":Store in$="" #out%:out%=0  :  Store " in$,1)="*": in$: ,'type%=file(in$,5):type%=1:File: 6"Dir "+in$ @0i%=0::gbpb(8,0,name%,1,i%):i%=X%!9:r%=X%!5 JQr%=0:name%?(1+?name%)=13:in$=$(name%+1):type%=file(in$,5):in$=in$+",":File T r%<>0: ^: h File r0load%=X%!2:exec%=X%!6:len%=X%!10:attr%=X%!14 |PA%=in$,","):A%::SpName$=in$,A%+1):in$=in$,A%-1) "Store as: "SpName$  SpName$="":SpName$=in$ * type%<>1:"File '"in$"' not found": , len%>&10000:"File '"in$"' too long": ( len%=0:"File '"in$"' too short": J(load%&FFFF0000)=&FFF20000:load%=&FFFF0000+(load%&FF00):exec%=load% .in%=(in$): in%=0:"Can't open '"in$"'": #SpType%=(load% &30000)&10000 SpStart%=(load% &FFFF) SpExtra%=(exec% &FFFF) SpLen%=len% !SpName$=SpName$+10," "),10) j 11;(10+ SpName$);13;11;~SpType%;" "SpName$" "h0(SpStart%,4)" "h0(SpExtra%,4)" "h0(SpLen%,4); : 3#out%,&13+2*(spec%):#out%,0: Length of block 3SpChk%=0:Out(0) : Header block :Out(SpType%) : Basic/Char/Num/Code & A%=1 10 0%Out( SpName$,A%,1)) : Name : D/Out(SpLen%):Out(SpLen%256) : Length NIOut(SpStart%):Out(SpStart%256) : Basic autoline/Code exec address XPOut(SpExtra%):Out(SpExtra%256) : Code load address/Basic length/var name b spec%:#out%,SpChk% l: vD Zero-length files confuse Spectrum, it thinks they're 64k long 0 Spectrum also confused by files &FFxx long 0 So only 'valid' lengths are &0001 to &FEFF 3 SpLen%=0: 4,8);h0(SpLen%,4):#in%:in%=0: K#out%,SpLen%+2+2*spec%:#out%,(SpLen%+2+2*spec%)256: Length of block 8SpChk%=0:Out(&FF) : Data block Len%=SpLen%  SpLen%>255: A%=0 SpLen%256-1:gbpb(3,in%,mem%,256,A%*256):Chk(256):gbpb(2,out%,mem%,256,#out%): 4,8);h0(SpLen%-A%*256,4);: hA%=SpLen%255: A%:gbpb(3,in%,mem%,A%,(SpLen%&FF00)):Chk(SpLen%255):gbpb(2,out%,mem%,A%,#out%)  spec%:#out%,SpChk%  4,8);h0(SpLen%,4) #in%:in%=0  : 3Chk(N%): B%=0N%-1:SpChk%=SpChk%mem%?B%::  *Out(A%):SpChk%=SpChk%A%:#out%,A%: :  CloseAll:*Exec *#in%=in%: in%:A%=in%:in%=0:#A% 4(out%=out%: out%:A%=out%:out%=0:#A% > H: R#ݤh0(A%,N%)="0000000"+~A%,N%) \Cݤfile(A$,A%):$name%=A$:X%?0=name%:X%?1=name%256:=(&FFDD)&FF f#gbpb(A%,chn%,addr%,num%,ptr%) p5!X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%: &FFD1: zݤuc(A$): A$="":="" H A%=1 A$: A$,A%,1)>"_":A$=A$,A%-1)+( A$,A%,1)-32)+A$,A%+1)  :=A$