, > MkMap 1.05 - 21-Nov-2016 J.G.Harston @ Create a free space map from examining directory structure : (mapsz%=2048*(1-(>&FFFF)) 2;7:"Build a free space map from directory"'"structure" "":secmax%=("&"+A$)-1 ; A%=0 mapsz%-1 4:map%!A%=0::disp%=:23,1;0;0;0;0 >sec%=2:num%=secmax%-sec%+1:mapadd: Add whole disk to FSM =fs%=8 :sec%=2 :num%=5:maprem : Remove root directory Efs%=16:sec%=70:num%=4:maprem : Remove FSM and root directory :scan::*INFO $ ":maplist:23,1,1;0;0;0;:: U'"(W)rite new free space map to disk"'"(S)ave free space map as a file"'"(Q)uit" 3:13;8;13;":";:A$=(&DF):"WSQ",A$):13 A$="W":"Writing"; A$="W":fs%=8 :mapwriteA A$="W":fs%=16:mapwriteH A$="S":"Saving";:mapsave A$="Q":"Quit": :  scan ">idx%,ret%:f$=gbpb8(idx%):idx%=X%!9:ret%=f$:ret%:file , ret%=0: 6: @ file J(-1):=32:disp%=disp% T:fs%=8 disp%:30:"INFO @."+f$:vpos%=:vpos%<2:39 ^, HADFS has 'read sector start' command: hOfs%=16:dir%=file("@."+f$,&FD)=2:sec%=X%!14 &FFFFFF:num%=X%!11 &7FFFFF r5 With ADFS need to peek output of *INFO command: |*fs%=8:11,0);:dir%=byte(135,0,0)=68 `fs%=8:10-10*(vpos%=1),vpos%-1);:A$="":num%=16:A$=A$+byte(135,0,0):9::sec%=("&"+A$) nfs%=8:num%=5:dir%:0,1);:A$="":num%=18:A$=A$+byte(135,0,0):9::num%=("&"+A$):num%=(num%+255)256 "0,3);:maprem:disp%maplist dir%:fs%=16:links %dir%:"Dir @."+f$:scan:"Dir ^"  :  links link%=sec%: /err(hadfs(fsm%,&80,drive%,link%,1),link%) >link%=fsm%!14 &FFFF:fsm%?12>127:link%=fsm%!24 &FFFFFF $link%:sec%=link%:num%=3:maprem  link%=0  : maprem:num%=0: &ptr%=-8:ptr%=ptr%+8 0"map%!ptr%=0 map%!ptr%>=sec% :*ptr%>mapsz%-9:0,2);"FSM too full": DXmap%!ptr%=sec%:map%!ptr%=map%!ptr%+num%:map%!(ptr%+4)=map%!(ptr%+4)-num%:maprem2: NRmap%!ptr%+map%!(ptr%+4)=sec%+num%:map%!(ptr%+4)=map%!(ptr%+4)-num%:maprem2: X'A%=ptr%:A%=A%+8:map%!A%=0:A%=A%+8 b- A%=A% ptr% -4:map%!A%=map%!(A%-8): l$map%!(ptr%-4)=sec%-map%!(ptr%-8) v5map%!(ptr%+4)=map%!ptr%+map%!(ptr%+4)-(sec%+num%) map%!(ptr%+0)=sec%+num%  maprem2  :  maprem2 ]map%!(ptr%+4)=0:A%=ptr%:map%!A%=map%!(A%+8):map%!(A%+4)=map%!(A%+12):A%=A%+8:map%!A%=0  : mapadd:num%=0: ptr%=-8:ptr%=ptr%+8 Amap%!ptr%=0 map%!ptr%>=sec% map%!ptr%+map%!(ptr%+4)=sec% *ptr%>mapsz%-9:0,2);"FSM too full": =map%!ptr%=0:map%!ptr%=sec%:map%!(ptr%+4)=num%:mapadd2:  mapadd2 H6map%!ptr%+map%!(ptr%+4)=map%!(ptr%+8):ptr%=ptr%+8 Rptr%<>0:map%!(ptr%-8)+map%!(ptr%-4)=map%!ptr%:map%!(ptr%-4)=map%!(ptr%-4)+map%!(ptr%+4): A%=ptr% mapsz%-1 4:map%!A%=map%!(A%+8):: \ f: p maplist zptr%=-8:ptr%=ptr%+8 ;h0(map%!ptr%,6);"+";h0(map%!(ptr%+4),5);(1-(>35)); map%!ptr%=0 =24:12;  :=ptr% :  mapsave H"File to save: "A$:A$<>"":"SAVE "+A$+" "+~map%+"+200 0 FFFFFD0"  A$="": : #ݤadfs_sum(mem%):sum%:sum%=255  A%=254 0 -1 sum%>255:sum%=(sum%+1)255 !sum%=sum%+mem%?A%::=sum%255 : mapwriteA ptr%8>82:"FSM too big": $err(scsi(fsm%,8,drive%,0,2),0) $src%=0:dst%=0: .fsm%!dst%=map%!src% 8!fsm%!(dst%+256)=map%!(src%+4) Bsrc%=src%+8:dst%=dst%+3 Lmap%!(src%-8)=0 Vfsm%?&1FE=dst%-3 `8fsm%!dst%=0:fsm%!(dst%+256)=0:dst%=dst%+3:dst%>&FB jfsm%!&0FC=secmax%+1 tfsm%?&0FF=adfs_sum(fsm%) ~"fsm%?&1FF=adfs_sum(fsm%+&100) %err(scsi(fsm%,10,drive%,0,2),0) "MOUNT "+drive%  : mapwriteH ptr%8>35:"FSM too big": +err(hadfs(fsm%,&80,drive%,&47,1),&47) dskid%=fsm%!16 &FFFF +err(hadfs(fsm%,&80,drive%,&46,1),&46) %fsm%?24=dskid%:fsm%?25=dskid%256 Esecmax%<&10000:fsm%!28=(secmax%+1)(fsm%!28 &7FFF0000):size%=2 Osecmax%>&FFFF :fsm%!28=(secmax%+1)(fsm%!28 &7F000000)&80000000:size%=3 src%=0:dst%=&20:  fsm%!dst%=map%!src% #fsm%!(dst%+size%)=map%!(src%+4) !src%=src%+8:dst%=dst%+size%*2 (map%!(src%-8)=0 2+err(hadfs(fsm%,&81,drive%,&46,1),&46) <'"MOUNT "+(48+drive%-7*(drive%>9)) F P: Z+ݤscsi(addr%,cmd%,drv%,sect%,num%):fs% dfs%=fs:fs%<>8:*FADFS nDX%?0=0:X%!1=addr%:X%?5=cmd%:X%?6=drv%*32+((sect%&1F0000)65536) x9X%?7=((sect%&FF00)256):X%?8=sect%:X%!9=num%:X%!11=0 2A%=&72:&FFF1:A%=?X%:fs%<>8:"FX143,18,"+fs% =A% : Bݤhadfs(addr%,cmd%,drv%,sect%,num%):fs%: &80=read, &81=write WX%!0=&600:X%!2=addr%:X%!6=sect%:X%?9=drv%:X%?10=num%:X%?11=cmd%:A%=90:&FFF1:=X%?11 : err(A%,S%):A%=0: -"Disk error &"h0(A%,2)" at "h0(S%,8):  : )ݤbyte(A%,X%,Y%)=((&FFF4)&FF00)256  ݤfs:A%,Y%,E%:=(&FFDA)&FF Bݤfile(A$,A%):$name%=A$:?X%=name%:X%?1=name%256:=(&FFDD)&FF Yݤgbpb(A%):X%!1=name%:&FFD1:A%=name%+((1+?name%)((A%-2)=6)):A%?(1+?A%)=13:=$(A%+1) Eݤgbpb8(ptr%):X%!1=name%:X%!5=1:X%!9=ptr%:A%=8:&FFD1:X%!5=1:="" 7A%=name%+1:A%!(A%?-1)=&D20:A%?($A%," ")-1)=13:=$A% "#ݤh0(A%,N%)="0000000"+~A%,N%) ,3ݤargs(A%,Y%,ptr%):X%,E%:?(P-3)=0:E%=Y%:Y%=0 6.<&FFFF:!&70:X%=&70:!X%=ptr%:&FFDA:=!X% @'ș"OS_Args",A%,Y%,ptr%,,ptr%:=ptr%