> MkUnix v0.03 & Creates blank 16-bit Unix images 9 Block numbers in free block lists ordered downwards (: 2 :CloseAll::exit() <* "Make a blank PDP11 Unix disk image" F "Image file: "out$ P5 "Image size: "fsize$: fsize$="":fsize$="720K" Z3 "16bit/24bit: "bitsz$: bitsz$="":bitsz$="16" d. "Disk title: "title$:title$=title$,20) n: x8bitsz%=(bitsz$): bitsz%<>16: bitsz%<>24:bitsz%=16 fsize%=(fsize$) 1 fsize$,"K") fsize$,"k"):fsize%=fsize%*2  11,11,11 . 13,9);fsize%;" blocks, ";fsize%2;"K "  13,9);bitsz%;" "  ' : >super% =1 : Superblock always block 1 :itable%=2 : Start block of itable ;isize% =fsize% (43+(fsize% 1000)) : Size of itable Broot% =itable%+isize% : Start block of root directory =cfree% =root%+1 : Start of disk data space : :n1% =fsize%-cfree% : Number of data blocks Qlsize% =n1% 100 : Number of data blocks used to hold free blocks @nfree% =(n1% 100)+1 : Number of in-core free blocks "Elfree% =cfree%+nfree%-1 : Start of on-disk free block list ,>bfree% =lfree%+lsize% : Start of free disk blocks 64dfree% =fsize%-bfree%+nfree% : Disk free space @4dused% =fsize%-dfree% : Disk used space J/today% =swap(today) : Today's date T: ^"fsize: ";fsize% h3"itable: ";h0(itable%,4);" + ";h0(isize%,4) r"root: ";h0(root% ,4) |3"cfree: ";h0(cfree% ,4);" + ";h0(nfree%,4) 3"lfree: ";h0(lfree% ,4);" + ";h0(lsize%,4) 5"bfree: ";h0(bfree% ,4);" - ";h0(fsize%-1,4) 1"dfree: ";h0(dfree% ,4);", ";dfree%2;"K" 1"dused: ";h0(dused% ,4);", ";dused%2;"K" 1"dsize: ";h0(fsize% ,4);", ";fsize%2;"K" < bitsz%<>16:"Can only do 16-bit at the mo.":exit(126) 8 isize%<1:"Error: disk image too small":exit(127) 1 out$="":"No disk image file name":exit(0) :  mem% 512 =out%=(out$): out%=0:"Can't create '"out$"'":exit(192)  wr%=2 :  Boot block at &0000  ------------------- clr &gbpb(wr%,out%,mem%,512,0) 0: : Superblock at &0001 D ------------------- Nmem%!&000=isize% Xmem%!&002=fsize% bmem%!&004=nfree% l4 A%=1 nfree%:mem%!(4+A%*2)=cfree%+nfree%-A%: vQmem%!&0CE=0 : No in-code free inodes, first save will fetch free blocks %mem%!&19C=today% : Creation date -$(mem%+&1DC)=title$:mem%?(&1DC+title$)=0 'gbpb(wr%,out%,mem%,512,super%*512) :  itable at &0002  --------------- clr : inode 1 &mem%!00=&C1FF : mode =dwrxwrxwrx mem%?02=&02 : links=2 %mem%!03=&0000 : user=0, group=0 &mem%?05=&00 : size DIV 65536=0 4mem%!06=&20 : size=32, two directory entries 3mem%!08=root% : first block of root directory !mem%!24=today% : access time  !mem%!28=today% : modify time (gbpb(wr%,out%,mem%,512,itable%*512)  : * rest of itable 4 -------------- >clr HV isize%>1: blk%=itable%+1 itable%+isize%-1:gbpb(wr%,out%,mem%,512,blk%*512): R: \ root directory f -------------- p%mem%!00=&0001:mem%!02=&002E: "." z&mem%!16=&0001:mem%!18=&2E2E: ".." &gbpb(wr%,out%,mem%,512,root%*512) :  core free blocks  ---------------- clr R nfree%>1: blk%=cfree% cfree%+nfree%-2:gbpb(wr%,out%,mem%,512,blk%*512): : * linked list of blocks of free blocks * ------------------------------------ 3 Each block will always start with 100 entries # blk%=lfree% lfree%+lsize%-1 clr mem%!0=100 3 blk%=lfree%+lsize%-1:mem%!2=0 mem%!2=blk%+1 , A%=2 100:mem%!(A%*2)=bfree%+100-A%: bfree%=bfree%+99 $%gbpb(wr%,out%,mem%,512,blk%*512) . blk% 8: B#out%:out%=0 Lexit(0): V: `: j(clr: A%=0 511 4:mem%!A%=0:: t ݤtoday ~9A$=$:dy%=A$,5):yr%=A$,12): yr%<1970:yr%=yr%+100 ;mn%="JanFebMarAprMayJunJulAugSepOctNovDec",A$,8,3))3 ?dy%="000031059090120151181212243273304334",mn%*3+1,3)+dy%  (yr%4)=0:mn%>1:dy%=dy%+1 "=((yr%-1970)*365.25+dy%)*86400 : CloseAll "in%=in%:in%:A%=in%:in%=0:#A% 'out%=out%:out%:A%=out%:out%=0:#A%  5exit(A%):"FX1,"+(A%255): >&FFFFF:Ș A%  #ݤh0(A%,N%)="0000000"+~A%,N%) 9gbpb(A%,chn%,adr%,num%,ptr%):#chn%=ptr%: num%=0:  3#chn%,?adr%:adr%=adr%+1:num%=num%-1:num%<1: +ݤswap(N%): A%-1:A%!0=N%:A%!4=N%:=A%!2