> MMCEdit 0.15  GoMMC Manipulation 7 v0.15 - Added Delete, Modify, Move, Sort, Compact (: 2,&87:ver$="0.15":init: err:end: < menu:end: F: PRinit:max%=512+(--4096): ctrl%31,ws%9,inf%63,mem%max%-1:X%=ctrl%:Y%=X%256 Z23;2,53;0;0;0: d: nݤerr:=17:CloseAll:=-1 x30,23);::CloseAll:" - press SPACE";:A%=:= : -CloseAll:in%=in%:in%:A%=in%:in%=0:#A% 'out%=out%:out%:A%=out%:out%=0:#A% "ch%=ch%:ch%:A%=ch%:ch%=0:#A%  : end: *QUIT  : ݤmenu:*FX229 Ctitle("GoMMC/GoSDC Editor"):_LINE:free%=mmc_Cat(mem%):_LINE U" (A)dd (D)elete (M)odify (L)oad (S)ave"'" (R)esort (C)ompact (*)command (Q)uit" ,_LINE:32:::A$=:A$>"`":A$=(A$-32) ="ADMCRLSQ*"+13,A$):13:A$="*":"*"A$:A$:A$="":":"; A$="A":Add:A$="*" "A$="D":Del:A$="*" ,A$="M":Mod:A$="*" 6A$="C":Comp:A$="*" @A$="R":Sort:A$="*" JA$="L":Load:A$="*" TA$="S":Save:A$="*" ^$A$="Q":" Quit? ";:笤yn:A$="*" hA$<>"":=A$="Q" r: | -----------------  Program functions  ----------------- : Add:" Add a GoMMC entry" GetInfo(0) C mmc_Add(name$,len%,type%,subt%,mem%)=0:" GoMMC full.";:A%=  : $Del:" Delete a GoMMC entry": Gnum%=GetName:" Delete '"name$"'? ";:A%=yn:A%:11;(20):11,11 A% O?mem%=0:mmc_(&4103,mem%,&1C0+64*num%,64) : Set catalog entry to 'deleted'  : "Mod:" Modify a GoMMC entry" %num%=GetName:11:39'39:11,11 &GetInfo(mem%) 0i add%<>mem%!4:38'38;13;11;" Move object to new address? ";: yn:Move(mem%!4,mem%!8,add%,len%) :Bmmc_(&4003,mem%,&1C0+64*num%,64) : Get catalog entry DX!mem%=type%:mem%!1=subt%:mem%!4=add%:mem%!8=len%:$(mem%+16)=name$:mem%?(16+name$)=0 NEmmc_(&4103,mem%,&1C0+64*num%,64) : Update catalog entry XEmmc_(&4103,mem%,add%-&200+16,64) : Update object header b'$mem%="GoMMCEnt":mem%!8=0:mem%!12=0 lBmmc_(&4103,mem%,add%-&200,16) : Add object header vGmmc_(&4003,mem%,20,4) : Read end of free space mem%!4=0:mem%!5=add%-&200  mem%!12" Filename:"'" Start:"'" Length:":11,11,11: H711,)name$:A%=-1:11,A%)name$(20-name$)0,A%) R911,)"&"add$:add%=h(add$):12,-1)h0(add%,6)" " \911,)"&"len$:len%=h(len$):12,-1)h0(len%,6)" " f6" Correct? ";:A%=yn:A%:11;(20):11,11,11,11 p?A%:out%=(name$):out%=0:" Can't open '"name$"'.";:A%=: z" Saving data ......";: =?ws%=0:ws%!1=add%:add%=!ws%:?ws%=0:ws%!1=len%:len%=!ws%: 76,8);h0(add%,8),6);:mmc_(&4003,mem%,add%,256) Egbpb(2,out%,mem%,256,#out%):add%=add%+256:len%=len%-256:len%<1 #out%:out%=0: : -Sort:" Sort GoMMC catalog? ";: yn: 7mmc_Sort(0,mem%)=0:" **No global catalog**":A%=  : -Comp:" Compact GoMMC data? ";: yn: #mem%!0=0:mmc_(&4003,mem%,0,32) Amem%?8=13:$mem%<>"GoMMCCat":" **No global catalog**":A%=: :csz%=mem%!16: csz%<1: : Catalog empty  *FX229,1 Cn%=0: : Remove deleted items @mmc_(&4003,inf%,&200+64*n%,64) : Get object info $~ inf%?0=0:mmc_(&4003,inf%,&1C0+64*csz%,64):mmc_(&4103,inf%,&200+64*n%,64):csz%=csz%-1:!mem%=csz%:mmc_(&4103,mem%,16,4) . n%=n%+1 8 n%>=csz%:*FX229 BJA%=mmc_Sort(4,mem%) : Sort catalog by address L>mmc_(&0201,0,0,0):mmcend%=X%!6-&2000 : Get card size V n%=0 csz%-1 `@mmc_(&4003,inf%,&200+64*n%,64) : Get object info jVlen%=inf%!8:add%=mmcend%-len% : Compacted object should start here t| inf%!4<>add%:Move(inf%!4,len%,add%,len%):inf%!4=add%:mmc_(&4103,inf%,&200+64*n%,64):mmc_(&4103,inf%,add%-512+16,64) ~mmcend%=mmcend%-len%-512  n% Bmem%!0=mmcend%:mmc_(&4103,mem%,20,4) : Update free space GA%=mmc_Sort(0,mem%) : Sort catalog by name  :  ------------  Subfunctions  ------------ : #ݤGetName:" Entry name:":11: /13,)""name$:13,-1);name$;(26-name$) Cnum%=mmc_Find(name$,mem%): num%=0:" Entry not found.":11,11  num%:=num%  : GetInfo(inf%) 6xp%=9:" Type:"'" Subt:":inf%:" Address:":xp%=10 (%" Length:"'" Name:"'xp%-5,11); 2*type%=0:subt%=0:add%=6:len%=0:name$="" "":type%=h(A$):xp%+1,-1)h0(type%,2)" "mmc_Type(type%) Cxp%,)"&"A$:A$<>"":subt%=h(A$):xp%+1,-1)h0(subt%,2)" " R xp%=10:xp%,)"&"A$:A$<>"":add%=h(A$)&FFFFFF:xp%+1,-1)h0(add%,6)" " Jxp%,)"&"A$:A$<>"":len%=h(A$)&FFFFFF:xp%+1,-1);h0(len%,6)" " =xp%,)A$:A$<>"":name$=A$:xp%,-1);name$;(20-name$)  inf%: add%<>(inf%!5 &FFFFFF) len%<>(inf%!9 &FFFFFF):'" **WARNING** Address/length changed."'" This may corrupt the catalog/data.":11,11,11 f" Correct? ";:A%=yn: A% len%=0 name$="" add%<6:A%=0:11;38'38'38'7,11);: inf%:11  A% b?ws%=0:ws%!1=add%:add%=!ws%:?ws%=0:ws%!1=len%:len%=!ws% : Multiply by 256 without overflowing  : 7Move(oldadd%,oldlen%,newadd%,newlen%): len%,dir% Snewadd%=newadd%-512:oldadd%=oldadd%-512:newlen%=newlen%+512:oldlen%=oldlen%+512 Emmc_(&4003,mem%,oldadd%+32,48):mem%?48=0:" Moving ";str0(mem%) 4 Work out direction to move without overlapping 2 oldadd%<0:newadd%<0:oldadd%>newadd%:dir%=1 3 oldadd%<0:newadd%<0:oldadd%0:oldadd%>newadd%:dir%=1 ,3 oldadd%>0:newadd%<0:oldadd%>newadd%:dir%=-1 62 oldadd%>0:newadd%>0:oldadd%>newadd%:dir%=1 @3 oldadd%>0:newadd%>0:oldadd%oldlen%:len%=oldlen% ^F dir%<0:newadd%=newadd%+oldlen%-len%:oldadd%=oldadd%+oldlen%-len% h *FX229,1 r |P13;" Read "h0(oldadd%,8),6)", "h0(oldlen%,8),6)" remaining";: A%=GET "mmc_(&4003,mem%,oldadd%,len%) P13;" Write "h0(newadd%,8),6)", "h0(oldlen%,8),6)" remaining";: A%=GET "mmc_(&4103,mem%,newadd%,len%) G dir%<0:oldlen%=oldlen%-len%:len%=max%: len%>oldlen%:len%=oldlen% oldadd%=oldadd%+len%*dir% newadd%=newadd%+len%*dir% G dir%>0:oldlen%=oldlen%-len%:len%=max%: len%>oldlen%:len%=oldlen%  oldlen%=0::*FX229  : : # > BLib.GoMMC 1.01 15-Feb-2005 # =============================  GoMMC access routines  --------------------- ' Depends: String: FNuc(), FNstr0() &: 0# PROCmmc - Issue GoMMC command :# ----------------------------- D action% - GoMMC action N" addr% - BBC memory address X mmc% - GoMMC address b# ----------------------------- l#mmc_(action%,addr%,mmc%,num%) vZ(-256&DB)=&53:action%=&0201:ch%=(@dir$+"GoMMC.dat"):ch%:X%!6=#ch%:#ch%:ch%=0: {(-256&DB)=&53:action%=&4003:ch%=(@dir$+"GoMMC.dat"):ch%:#ch%=mmc%: A%=0 num%-1:addr%?A%=#ch%::#ch%:ch%=0: {(-256&DB)=&53:action%=&4103:ch%=(@dir$+"GoMMC.dat"):ch%:#ch%=mmc%: A%=0 num%-1:#ch%,addr%?A%::#ch%:ch%=0: T!X%=&1212:X%!2=action%:X%?4=&01:X%!6=addr%:X%!10=mmc%:X%!14=num%:A%=&B0:&FFF1: : + FNmmc_Type - Return GoMMC object type + ------------------------------------- Lݤmmc_Type(A%):A%<4:="del FSIMTOOLDISK",A%*4+1,4) =" "+h0(A%,2)+" " : 1 FNmmc_Find - Find an entry in GoMMC catalog 1 ------------------------------------------- < name$ - onject name to add, can be terminated with '*' 1 mem% - 64 bytes of memory for object entry  % Returns: 0 - Object not found  5 <>0 - Object found, mem% contains info 1 -------------------------------------------  ݤmmc_Find(A$,mem%) * csz%,n%,l%,match% 4Dmem%!0=0:mmc_(&4003,mem%,0,64) : Read global catalog >Dmem%?8=13:$mem%<>"GoMMCCat":=0 : No global catalog H@csz%=mem%!16:csz%=0:=0 : Catalog empty R,A$=uc(A$):A$,1)="*":l%=A$-1 l%=255 \)n%=0::mmc_(&4003,mem%,512+64*n%,64) f+match%=uc(str0(mem%+16)),l%)=A$,l%) p.n%=n%+1:n%=csz% match%:match%:=n% =0 z: / FNmmc_Add - Add an entry to GoMMC catalog / -----------------------------------------  name$ - object name to add # size% - size of object to add  type% - object type  subt% - object subtype 1 mem% - 64 bytes of memory for object entry  6 Returns: 0 - No GoMMC catalog or catalog full 6 <>0 - GoMMC data address of new object 2 mem% - contains object catalog info / ----------------------------------------- +ݤmmc_Add(name$,size%,type%,subt%,mem%)  csz%,free%,add% size%=(size%+511)-512 Dmem%!0=0:mmc_(&4003,mem%,0,32) : Read global catalog $Dmem%?8=13:$mem%<>"GoMMCCat":=0 : No global catalog .'mem%?8=0:csz%=mem%!16:free%=mem%!20 8=add%=free%-size%:add%-512<&240+csz%*64:=0 : GoMMC full B?!mem%=type%:mem%?1=subt%:mem%!4=add%:mem%!8=size%:mem%!12=0 L'$(mem%+16)=name$:mem%?(16+name$)=0 VBmmc_(&4103,mem%,512+64*csz%,64) : Add catalog entry `Fmmc_(&4103,mem%,add%-512+16,64) : Add object entry copy j'$mem%="GoMMCEnt":mem%!8=0:mem%!12=0 tBmmc_(&4103,mem%,add%-512,16) : Add object header ~mmc_(&4003,mem%,16,8) Hmem%!0=csz%+1:mem%!4=add%-512 : Update catsize, free Emmc_(&4103,mem%,16,8) : Update global header ?!mem%=type%:mem%?1=subt%:mem%!4=add%:mem%!8=size%:mem%!12=0 -$(mem%+16)=name$:mem%?(16+name$)=0:=add% :  List the GoMMC catalogue  ------------------------ 9 mem% - 64 bytes of memory for reading object entry ! Returns: free space pointer / ----------------------------------------- ݤmmc_Cat(mem%)  free%,csz%,n% %" No Type Start Length Name" #mem%!0=0:mmc_(&4003,mem%,0,32) =mem%?8=13:$mem%<>"GoMMCCat":" **No global catalog**":=0 csz%=mem%!16:free%=mem%!20 (csz%:n%=0csz%-1:mmc_(&4003,mem%,512+64*n%,64):" "d(n%+1,2)" "mmc_Type(mem%?0)" "h0(mem%?1,2)" "h0(mem%!5,6)" "h0(mem%!9,6)" "str0(mem%+16),14)8: 2@!mem%=free%:mem%!4=(512+csz%*64+511)-512:!mem%=!mem%-mem%!4 <mmc_(&0201,0,0,0) FR PRINT SPC4FNh0(X%!7-32,6)SPC2FNh0(mem%!5+2,6)SPC1FNh0(mem%!1,6)" Free space" P312h0(mem%!5+2,6)1h0(mem%!1,6)" Free space" Z =free% d: n Sort the GoMMC catalogue x ------------------------ ? sort% - object word to sort by, or 0 to sort by type+name 1 mem% - 64 bytes of memory for object entry  & Returns: 0 - No GoMMC catalog / <>0 - Number of catalog entries / ----------------------------------------- ݤmmc_Sort(sort%,mem%)  swap%,diff%,csz%,n% #mem%!0=0:mmc_(&4003,mem%,0,32) #mem%?8=13:$mem%<>"GoMMCCat":=0 csz%=mem%!16:csz%<2:=1 *FX229,1 :swap%=0:n%=0csz%-2 Hmmc_(&4003,mem%+00,512+64*n%,64):mmc_(&4003,mem%+64,&240+64*n%,64) |diff%=0:sort%:diff%=mem%!(sort%+64)-mem%!sort% A%=0::diff%=mem%?A%-mem%?(A%+64):A%=A%+1:A%=A%-12*(A%=4):diff%A%=64 Ydiff%>0:mmc_(&4103,mem%+00,&240+64*n%,64):mmc_(&4103,mem%+64,512+64*n%,64):swap%=1 "n%:swap%=0:*FX229 , =csz% 6: @: J Library functions T ================= ^title(T$)::132;157;135;141;(16-T$/2);T$'132;157;135;141;(16-T$/2);T$'135;157;132;" (C)2004 J.G.Harston. Version ";ver$: h _LINE: 148;39,",");8: r: |Zݤyn:"(Y/N)";::A%= &DF: A%=89 A%=78: 5,8);: A%=89 "Yes ":= "No ":=0 %ݤstr(A%,N%):A%?N%:A%?N%=13:=$A% 5ݤstr0(A%):A$:A$=str(A%,254):=A$,A$+0,0)-1) ݤuc(A$):B$:A$="":="" 5B$=B$+(A$((A$<"@")&DF)):A$=A$,2):A$="":=B$ #ݤh0(A%,N%)="0000000"+~A%,N%) #ݤd(A%,N%)=" "+A%,N%) ݤh(A$)=("&"+uc(A$)) : #gbpb(A%,chn%,addr%,num%,ptr%) =?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:<&FFFF:&FFD1: A%=1A%=3:#?X%=X%!9 5:A%=1A%=2:#?X%,?X%!1 A%=3A%=4:?X%!1=#?X% 4X%!1=X%!1+1:X%!5=X%!5-1:(#?X% A%>2)X%!5<1: