> DiskToImg v0.29 2::exit() <A$=OS_GetEnv+" ":fs%=fs F!cl("-?",0):syntax:exit(0) P"cl("-help",0):help:exit(0) Z ctrl% 31:X%=ctrl%:Y%=X%256 dfs(A$)="":"Source drive: "in$:"Output file: "out$:"Disk size (K): "sz$:A$=in$+" "+out$+" "+sz$ n]dbug%=cl("-d",0):auto%=cl("-a",0):verb%=cl("-v",0):size%=cl("-s",1):mix%=cl("-m",0) xCzero%=cl("-z",0):inv%=cl("-i",0):in$=cl("",0):out$=cl("",0) "size%=0:A$:size%=cl("",0) Msize%<50:size%=size%*100-40*(size%=6)-20*(size%=7size%=3)-40*(size%=14) in$>"@":in$=(in$-17) *drive%=in$:geom$=A$:geom$="":auto%= zdbug%:"in$ ='"in$"'"'"out$ ='"out$"'"'"geom$='"geom$"'"'"size%=";size%'"auto%=";auto%'"verb%=";verb%'"debug=";dbug% .diskrec% 255:logbps%=0:max%=0:parameters >size%=(sides%*tracks%*spt%*2^logbps%)/1024:auto%:size%=-1 geom:auto%:geom$="" *dbug%:" D:S:H:TK:Z:NM:S0"'"G:"geom$ !logbps%=0:syntax:exit(220) ?:"FX143,18,"+fs%:Close_All:Hour_Glass(-3)::exit() :out%=(out$):out%=0:"Can't open '"out$"'":exit(192) =verb%:"Create ";size%+"K ",size%>0);"image of ";geom >FDC_Init(diskrec%,logbps%,spt%,heads%,den%,tracks%,sec0%) /bps%=2^logbps%:bsz%=spt%*bps%:data% bsz%-1 "2drive%=drive%3:os%<6:den%=2:drive%=drive%4 ,diskread:finish 6exit(0): Jdiskread T"#out%=0:dstep%=(tracks%>63)+2 ^dseq%:head%=0sides%-1:track%=0tracks%-1:track(head%*tracks%*dstep%+track%):track%:head%: h[track%=0tracks%-1:head%=0sides%-1:track(track%*sides%*dstep%+head%):head%:track% r  finish  verb%: #out%:out%=0 8"SetType "+out$+" "+~imgtype(out$):"Stamp "+out$  exit(0)  track(offset%) verb%:=0:"----"; 0verb%:8;8;8;8;head%;":";d0(track%,2); 8auto%:autor%=diskop(1,data%,spt%):num%=spt%*bps% 2inv%:A%=0spt%*bps%-14:data%!A%=data%!A%: gbpb(2,out%,data%,num%,0)   auto &r%=diskop(1,data%,spt%) 0@r%=0:spt%*bps%>max%:max%=spt%*bps%:13:diskread:finish: :r%=0:pad:num%=max%: X#verb%:" Reading sector IDs:"; b4sec0%=0:sense:r%:verb%:" Can't sense track." lr%:num%=max%: v-logbps%=data%?3+7:sec0%=256:dup%=:A%=0: *data%?(A%+2)4:B%=0::dup%=(data%!B%=data%!A%):B%=B%+4:A%=B%dup% A%=A%+4:data%!A%=-1dup% !data%!(A%-4)=data%!8:A%=A%-4 !data%!(A%-4)=data%!4:A%=A%-4 !data%!(A%-4)=data%!0:A%=A%-4 3spt%=A%4:bps%=2^logbps%:mix%:spt%>10:spt%=10 (den%=4:seq%:seq%=:heads%=2:max%=0 Tverb%:" den:";den%;" sec0:"h0(sec0%,2)" spt:";spt%;" bps:";bps%;" tsz:";max%; +verb%:geom:A$=geom:A$,A$,"(")-1); :spt%*bps%>max%:max%=spt%*bps%:13:diskread:finish:  A%=0max%-14:data%!A%=-1: \FDC_Init(diskrec%,logbps%,spt%,heads%,den%,tracks%,sec0%):r%=diskop(1,data%,spt%):pad $r%:verb%:" Can't read track";  r%:read  verb%:  num%=max% * > read Hverb%:" Sec: "; Rsec%=0spt%-1 \%verb%:5,8);h0(sec0%+sec%,2); f&r%=diskop(1,data%+bps%*sec%,bps%) pverb%:" ";h0(r%,2); z   pad 8max%>spt%*bps%:A%=spt%*bps%max%-14:data%?A%=-1: max%<>2*spt%*bps%:  B%=spt%-10-1:A%=2520-4 Hdata%!(B%*bps%*2+A%+bps%)=-1:data%!(B%*bps%*2+A%)=data%!(B%*bps%+A%)  A%:B%   sense A%=02554:data%!A%=-1: fden%=1:FDC_Init(diskrec%,logbps%,spt%,heads%,den%,tracks%,sec0%):r%=diskop(3,data%,spt%):r%=0: fden%=2:FDC_Init(diskrec%,logbps%,spt%,heads%,den%,tracks%,sec0%):r%=diskop(3,data%,spt%):r%=0: fden%=4:FDC_Init(diskrec%,logbps%,spt%,heads%,den%,tracks%,sec0%):r%=diskop(3,data%,spt%):r%=0:  .parameters BAlogbps%=10:spt%=16:den%=2:-<20480:logbps%=8:spt%=16:den%=1 L8dstep%=:tracks%=80:sec0%=0:sides%=2:heads%=1:seq%= Vauto%:size%=0:size%=-1: ` auto%= ~1size%:A$="G:"+size(size%):A$="G:":geom$="" A$=geom$:geom$="" geom2$=geom$ %logbps%=8:spt%=10:den%=1:sides%=1  :A$=s(A$) A%=p("D"):A%<>:den%=A% A%=p("Q"):A%<>:seq%=A% A%=p("H"):A%<>:sides%=A%  A%=p("T"):A%<>:tracks%=A% "A%=p("S"):A%<>:logbps%=A%+7 (A%=p("B"):A%<>:logbps%=(A%)/(2)  A%=p("N"):A%<>:spt%=A% >A$,1)="Z"A$,1)="z":sec0%=("&"+A$,2)):A$=A$,2+~A%) A$,1)=":":A$=A$,2) (("DdQqHhTtSsBbNnZz",A$,1))=0A$="" 22A$,2)<>"G:"A$,2)<>"g:":geom:A$="G:"+geom$ P2A$,2)<>"G:":"Unknown geometry":exit(220): Z/den%=A$,3):seq%=A$,5)<>0:sides%=A$,7) dRheads%=sides%:tracks%=A$,9):logbps%=7+A$,12):logbps%>14:logbps%=logbps%-7 n(spt%=A$,14):sec0%=("&"+A$,17,2)) xA$=geom2$:geom2$="":A$="" seq%:heads%=2:heads%=1  ,ݤp(B$):A$,1)<>B$A$,1)<>(B$+32):= !A%=A$,2):A$=A$,2+A%):=A% ^syntax:"DiskToImg (-size ) () -a -m -z -v -help": 6help:syntax:$(+17)" (C)J.G.Harston 2008-2014" 7" -auto attempts to autosense source disk layout" )" -mix mixed-density Slogger disk" +" -zero track 0 starts with sector 0" " -inv invert data" " is:" F" G:::::::" " or any combination of:" ,H" D:Q:H:T:B:N:Z" 6 " known -size options are:" @A%=50160010 J9geom$=size(A%):geom$<>"":" -size ";A%;"K : ";geom T: hݤsize(size%) |"size%=200:="1:1:1:80:1:10:00" "size%=320:="2:1:1:80:1:16:00" "size%=400:="1:1:2:80:1:10:00" "size%=640:="2:1:2:80:1:16:00" "size%=720:="2:0:2:80:2:09:01" "size%=800:="2:0:2:80:3:05:00" #size%=1440:="4:0:2:80:2:18:01" #size%=1600:="4:0:2:80:3:10:00" "size%=100:="1:1:1:40:1:10:00" "size%=160:="2:1:1:40:1:16:00" "size%=360:="2:0:2:40:2:09:01" "size%=400:="2:1:2:40:2:10:01" "size%=070:="1:1:1:35:0:16:01" "size%=140:="1:1:2:35:0:16:01" "size%=280:="2:1:1:35:1:16:01" &="" : ݤgeom D geom$="":="autosensed disk" X>geom$="1:1:1:40:1:10:00":="1*40*10*256 FM disk (40T DFS)" b>geom$="2:1:1:40:1:16:00":="1*40*16*256 MFM disk (ADFS S)" l>geom$="1:1:1:80:1:10:00":="1*80*10*256 FM disk (80T DFS)" v>geom$="2:1:1:80:1:16:00":="1*80*16*256 MFM disk (ADFS M)" ]geom$="1:1:2:80:1:10:00":="2*80*10*256 FM disk (2xDFS, L2FS, AcornCPM, TorchCPN, HADFS)" igeom$="1:0:2:80:1:10:00":="80*2*10*256 FM disk (interleaved 2xDFS, L2FS, AcornCPM, TorchCPN, HADFS)" Ogeom$="2:1:2:80:1:16:00":="2*80*16*256 MFM disk (ADFS L, L3FS, Filestore)" [geom$="2:0:2:80:1:16:00":="80*2*16*256 MFM disk (interleaved ADFS L, L3FS, Filestore)" @geom$="2:0:2:80:2:09:01":="80*2*9*512 MFM disk (DOS 720K)" Pgeom$="2:0:2:80:3:05:00":="80*2*5*1024 MFM disk (MDFS, AcornDOS, ADFS D,E)" @geom$="2:0:2:80:3:05:01":="80*2*5*1024 MFM disk (AcornDOS)" Ageom$="4:0:2:80:2:18:01":="80*2*18*512 MFM disk (DOS 1440K)" ?geom$="4:0:2:80:3:10:00":="80*2*10*1024 MFM disk (ADFS F)" ?geom$="1:1:1:35:0:16:01":="1*35*16*128 FM disk (1xMZ-80K)" ?geom$="1:1:2:35:0:16:01":="2*35*16*128 FM disk (2xMZ-80K)" @geom$="2:1:1:35:1:16:01":="1*35*16*256 MFM disk (MZ-80A/B)" ?geom$="2:0:2:40:2:09:01":="40*2*9*512 MFM disk (360K DOS)"  Dgeom$="2:1:2:40:2:10:01":="2*40*10*512 MFM disk (MZ-80A/B CPM)"  Egeom$="2:1:2:80:2:10:00":="2*80*10*512 MFM disk (Slogger DDCPM)" *="G:"+geom$+" disk" > geom Hmgeom$=den%+":"+(seq%1)+":"+sides%+":"+tracks%+":"+(logbps%-7)+":"+"0"+spt%,2)+":"+"0"+~sec0%,2) R fݤimgtype(in$) pin%=(in$):in%=0:=-1 z'gbpb(4,in%,data%,16,0):#in%:in%=0 data%?11=13 $data%="Slogger CPM":=&1A6 $data%="SLOGGER CPM":=&1A6 data%?8=13 $data%="Acorn CP":=&1A6 $data%="ACORN CP":=&1A6 $(data%+5)="DOS":=&FC8  =&B22 7FDC_Init(dskrec%,bps%,spt%,hds%,den%,trks%,sec0%) i%:os%<>6: ?dskrec%?0=bps%:dskrec%?1=spt%:dskrec%?2=hds%:dskrec%?3=den% 2i%=4594:dskrec%!i%=0::dskrec%!64=&20000000 7dskrec%?8=sec0%:dskrec%!16=trks%*spt%*(2^bps%)*hds%  .ݤdiskop(op%,data%,spt%) 8hos%=6:ș"XADFS_DiscOp",0,op%+64+(diskrec%<<6),offset%*spt%*bps%+(drive%<<29),data%,spt%*bps%r%:=r% BJden%=1:op%=1:=disk(data%,&53,drive%+head%*2,track%,sec0%,spt%,den%) LJden%=1:op%=2:=disk(data%,&4B,drive%+head%*2,track%,sec0%,spt%,den%) VJden%=1:op%=3:=disk(data%,&5B,drive%+head%*2,track%,sec0%,spt%,den%) `Dden%=2:op%=1:=scsi(data%,&008,drive%,track%*16+head%*80,spt%) jDden%=2:op%=2:=scsi(data%,&10A,drive%,track%*16+head%*80,spt%) t=-1 Close_All "in%=in%:in%:A%=in%:in%=0:#A% 'out%=out%:out%:A%=out%:out%=0:#A%  #gbpb(A%,chn%,addr%,num%,ptr%) 4?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:&FFD1: #ݤh0(A%,N%)="0000000"+~A%,N%) #ݤd0(A%,N%)="00000000"+A%,N%) Hour_Glass(A%):os%<>6: A%=-1:ș"Hourglass_On": A%=-2:ș"Hourglass_Off":  A%=-3:ș"Hourglass_Smash": ș"Hourglass_Percentage",A% ( <:ݤOS_GetEnv:A$,A%:X%=1:os%=((&FFF4)&FF00)256:X%-1 FJos%=32:>&FFFF:ș"GetModuleFileName",0,X%,255:A$=$$X%:run$=A$:=@cmd$ Pos%=32:A$=$&100 Z{A$=0:>&7FFF:run$=$&8100:ș"OS_GetEnv"A$,,A%:ș"OS_WriteEnv","",A%:A$=A$,1+A$+" "," ",1+A$," "))):A$=0:A$=run$ d0A$=0:?(P-3):A$=$&600A$=0:A$=$(-&300) n7A%=A$+" "," "):run$=A$,A%-1):run$<>"":=A$,A%+1) xbY%=X%256:A%=9:?X%=0:X%!1=X%+16:X%!16=0:&FFD1:A%=X%+16:!A%?A%+A%?2<>8:A%?(A%+1)=13:=$(A%+1) ="" exit(A%):"FX1,"+A%:  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)<>" " +A$,1)=" ":A$=A$,A$-1):A$,1)<>" " "=A$ 64ݤdisk(addr%,cmd%,drv%,trk%,sec%,num%,den%):fs% @fs%=fs:fs%<>4:*FX143,18,4 J7X%?0=drv%+den%*24+8:X%!1=addr%:X%?5=3-7*(cmd%>127) T=X%?6=cmd%:X%?7=trk%:X%?8=sec%:X%?9=num%&20:A%=127:&FFF1 ^5A%=X%?(7+X%?5):A%<>&10:fs%<>4:"FX143,18,"+fs% h=A% |+ݤscsi(addr%,cmd%,drv%,sect%,num%):fs% fs%=fs:fs%<>8:*FADFS DX%?0=0:X%!1=addr%:X%?5=cmd%:X%?6=drv%*32+((sect%&1F0000)65536) 9X%?7=((sect%&FF00)256):X%?8=sect%:X%!9=num%:X%!11=0 IA%=&72:&FFF1:A%=?X%:fs%<>8:"DISMOUNT",cmd%>255):"FX143,18,"+fs% =A% ݤfs:A%,E%,Y%:=(&FFDA)&FF   A{   "  g{N{LQ%=PA.:CH."* BASIC f{Z{{{檤`T{T{`` g{,z0ȱQ{` ee  { {Q{쩏 `