›; FILESEL.ACT››; MyDOS File Selector v.0.4››; By Bill Kendrick›; New Breed Software 1996››; Update: January 13, 1996›; Added:›; PC Mirror directory change puts›; cursor back at top of listing›; More reliable PC Mirror directory›; change›; LF's removed during ASCII CR›; translation›; Page-up ability to text reader›; Top-of-file ability to text›; reader›; Reformatted (justified) documents›; 38-columned most of source code›; Defaults ("FILESEL.DAT") are›; reloaded when "." directory is›; selected›; Better status line displays›; Really long paths are fit to 40›; columns››; In the file "D:FILESEL.DAT" (all›; blank lines ignored), the following›; 'commands' are valid and the data in›; the next nonblank line following›; them are interpreted as:››; BACK---Background color (hue*16+lum)›; FORE---Foreground lum›; BORD---Border color (hue*16+lum)›; TBACK--Status line background color›; (hue*16+lum)›; TFORE--Status line foreground lum›; TBORD--Status line border hue›; TITLE--Screen title (ie, "Games")›; MASK---Extension filter mask (ie,›; "COMEXEOBJDOCTXT") "?" wild-›; card supported, any commas›; ignored›; SORT---Sort listing by:›; NAME or EXT (descending) or›; !NAME or !EXT (ascending)›; FONT---Sets screen font (ie,›; "TIMES.FNT")››INCLUDE "D:RUNTIME.ACT"›››; Entries for "reload" and "previous"›; (aka [<] or [BKSP] keys) directories››Char Array RELOAD=":. "›Char Array PREVDIR=":.. "›››; Global variables/buffers››Char Array Path(128),File(128),› Mask(128),Title(40),› Names(800),FN(128)›Byte Array OldX(100),OldY(100),› OldSDLst(8),Buf(2048)›Byte Back,Fore,Bord,NumFiles,Stack,› Sort,NEXTX,NEXTY,AnError=[0],› SortDir,InARoot,TBack,TFore,› TBord,ChSet›Card OError,Ch›Byte Key=764,VCount=$D40B,WSync=$D40A,› NMIEn=$D40E,ColPF1=$D017,› ColPF2=$D018,ColPF4=$D01A,› ChBas=$D409›Card VDSLst=$200,SDLst=$230,OldVec›››; Block I/O››Proc CIO=$E456(Byte AReg,XReg)››Card Func Burst(Byte Chan,Mode,› Card Addr,BufLen)› Type IOCB=[Byte ID,Num,Cmd,Stat› Card BAdr,PAdr,BLen› Byte A1,A2,A3,A4,A5,A6]›› IOCB Pointer IPtr›› Chan==&$07› IPtr=$340+(Chan LSH 4)› IPtr.Cmd=Mode› IPtr.BLen=BufLen› IPtr.BAdr=Addr› CIO(0,Chan LSH 4)›Return(IPtr.BLen)››Card Func BGet(Byte Chan› Card Addr,Len)› Card Temp›› Temp=Burst(Chan,7,Addr,Len)›Return(Temp)›››; Fits a string into a certain size›; (if too big, put first part, then›; "...", then last 13 characters›; (enough for a full filename))››Proc FitString(Char Array Src, Dest› Byte Max)› Byte A,L›› L=Src(0)›› If L<=Max Then› SCopy(Dest,Src)› Else› For A=1 To Max-16 Do› Dest(A)=Src(A)› Od› For A=Max-15 To Max-13 Do› Dest(A)='.› Od› For A=0 To 12 Do› Dest(Max-A)=Src(L-A)› Od› Dest(0)=Max› Fi›Return›››; DLI routine››Proc DLI()›[$48 $98 $48 $8A $48]›› If VCount<16 Then›› ; Fade from dark to bright above› ; title›› WSync=0› ColPF4=TBord+2› WSync=0› ColPF4=TBord+4› WSync=0› ColPF4=TBord+6› WSync=0› ColPF4=TBord+8› WSync=0› ColPF4=TBord+12› WSync=0› ColPF4=TBord+14› ColPF1=TFore› ColPF2=TBack› Else›› ; Fade from bright to dark below› ; title›› ChBas=ChSet› WSync=0› ColPF4=TBord+14› WSync=0› ColPF4=TBord+12› WSync=0› ColPF4=TBord+10› WSync=0› ColPF4=TBord+8› WSync=0› ColPF4=TBord+4› WSync=0› ColPF4=TBord+2›› ; ...and then set the menu area's› ; color›› WSync=0› ColPF1=Fore› ColPF2=Back› ColPF4=Bord› Fi›[$68 $AA $68 $A8 $68 $40]›››; DLI setup››Proc StartDLI()› Card SC›› NMIEn=$40 ; Disable DLI› OldVec=VDSLst› VDSLst=DLI› Poke(SDLst,$F0)› Poke(SDLst+1,$70)› Poke(SDLst+2,$42)› SC=PeekC(88)› PokeC(SDLst+3,SC)› Poke(SDLst+5,$82)› Poke(SDLst+6,$70)› NMIEn=$C0 ; Enable DLI›Return›››; Stop the DLI››Proc StopDLI()› NMIEn=$40 ; Disable DLI› MoveBlock(SDLst,OldSDLst,7)› VDSLst=OldVec›Return›››; String concatination››Proc SCat(Char Array D, S) › Byte A,L›› L=D(0)› For A=1 To S(0) Do› D(L+A)=S(A)› Od› D(0)=L+S(0)›Return›››; Error "trappers"››Proc Ignore()› Error=OError› Close(1)› AnError=1›Return››Proc APEIgnore()›Return›››; Load defaults from "D:FILESEL.DAT"››Proc GetDefaults()› Byte A,L› Char Array St(40)› Char Array St2(40)› Char Array File(120)›› Position(0,23)› Print("          Çåôôéîç äåæáõìôó®®®          ")›› ; Normal defaults›› Back=0› Fore=15› Bord=0› TBack=128› TFore=14› TBord=144›› SCopy(Mask,"")› SCopy(Title,"File Selector v.0.4")› Sort=0›› ; Look for file›› Error=Ignore› AnError=0›› ChSet=224›› StopDLI()› Close(1)› SCopy(File,Path)› SCat(File,"FILESEL.DAT")› Open(1,File,4,0)›› ; Found it? Execute it›› If AnError=0 Then› Do› ; Read lines (allowing for› ; blanks)›› Do› InputSD(1,St)› Until St(0)>0 Or EOF(1)<>0 Od› Do› InputSD(1,St2)› Until St2(0)>0 Or EOF(1)<>0 Od›› If SCompare(St,"BACK")=0 Then› Back=ValB(St2)› ElseIf SCompare(St,"FORE")=0 Then› Fore=ValB(St2)&15› ElseIf SCompare(St,"BORD")=0 Then› Bord=ValB(St2)› ElseIf SCompare(St,"TBACK")=0 Then› TBack=ValB(St2)› ElseIf SCompare(St,"TFORE")=0 Then› TFore=ValB(St2)&15› ElseIf SCompare(St,"TBORD")=0 Then› TBord=ValB(St2)&240› ElseIf SCompare(St,"MASK")=0 Then›› ; Copy 2nd line into Mask,› ; ignoring any commas›› L=0› For A=1 To St2(0) Do› If St2(A)<>', Then› L=L+1› Mask(L)=St2(A)› Fi› Od› Mask(0)=L› ElseIf SCompare(St,"TITLE")=0 Then› SCopy(Title,St2)› ElseIf SCompare(St,"SORT")=0 Then› If SCompare(St2,"NAME")=0 Then› Sort=1› SortDir=1› ElseIf SCompare(St2,"EXT")=0 Then› Sort=2› SortDir=1› ElseIf SCompare(St2,"!NAME")=0 Then› Sort=1› SortDir=0› ElseIf SCompare(St2,"!EXT")=0 Then› Sort=2› SortDir=0› Fi› ElseIf SCompare(St,"FONT")=0 Then›› ; Add our path if no literal› ; path ("D:" or "Dx:") is› ; given›› If (St2(0)>2 And St2(1)='D And› St2(2)=':) Or› (St2(0)>3 And St2(1)='D And› St2(3)=':) Then› SCopy(File,St2)› Else› SCopy(File,Path)› SCat(File,St2)› Fi›› ; Open and load font›› Error=Ignore› StopDLI()› Close(2)› Open(2,File,4,0)› If AnError=0 Then› BGet(2,Ch,1024)› ChSet=Ch/256› Fi› Error=OError› Close(2)› StartDLI()› Fi› Until St(0)=0 Od› Fi› Close(1)› StartDLI()›Return›››; Program/screen setup››Proc Setup()› Graphics(0)› PokeC(82,9984)› Poke(752,1)›› OError=Error›› Ch=(((Buf)/1024)+1)*1024›› ; Title:›› Print("}        ÍùÄÏÓ Æéìå Óåìåãôïò ö°®´        ")› Print("Âù Âéìì Ëåîäòéãë Îå÷ Âòååä Óïæô÷áòå ±¹¹¶")›› ; Starting point›› MoveBlock(OldSDLst,SDLst,7)› SCopy(Path,"D1:")› GetDefaults()›› Stack=0› NEXTX=0› NEXTY=2›› StartDLI()›Return›››; Get a directory list››Proc GetList()› Byte Done,A,B,C,Ok,FINALB› Char Array St(40)›› Position(0,23)› Print("          Òåáäéîç äéòåãôïòù®®®         ")›› Error=Ignore› AnError=0› SCopy(FN,Path)›› ; Add "." entry›› For A=1 To 12 Do› Names(A)=RELOAD(A)› Od› NumFiles=1›› ; If in root, don't add ".." entry›› If FN(0)>3 Then› InARoot=0› For A=1 To 12 Do› Names(12+A)=PREVDIR(A)› Od› NumFiles=2› Else› InARoot=1› Fi›› ; Open directory...›› StopDLI()› SCat(FN,"*.*")› Close(1)› Open(1,FN,6,0)› Done=0›› If AnError=0 Then› Do› InputSD(1,St)›› ; FREE SECTORS line?›› If St(0)>=1 And St(1)>='0 And› St(1)<='9 Then› Done=1› Else›› ; Is it in our filter mask?›› Ok=0› If Mask(0)<>0 Then› For B=1 To Mask(0)/3 Do› If (St(11)=Mask(B*3-2) Or› Mask(B*3-2)='?) And› (St(12)=Mask(B*3-1) Or› Mask(B*3-1)='?) And› (St(13)=Mask(B*3) Or› Mask(B*3)='?) Then› Ok=1› Fi› Od› Else› Ok=1› Fi›› ; Add it›› If Ok=1 Or St(2)=': Then› For A=1 To 12 Do› Names(NumFiles*12+A)=St(A+1)› Od› NumFiles=NumFiles+1› Fi› Fi› Until Done=1 Od› Fi› Close(1)› StartDLI()›› ; Sort it›› If Sort<>0 Then› Position(0,23)› Print("               Óïòôéîç®®®              ")›› ; Do this until we can sort no› ; more›› Do›› ; (Skip our first one or two› ; entries (".", and if ".." is› ; there))›› Done=1› For A=2-InARoot To NumFiles-2 Do›› ; Where to start? Filename or› ; extension?›› Ok=255› B=1› FINALB=13› If Sort=2 Then› B=10› FINALB=10› Fi›› ; Go through string and› ; compare it with one after› ; it›› Do› ; Same? Keep going...›› If Names(A*12+12+B)=Names(A*12+B) Then› B=B+1› If B>12 Then› B=1› Fi›› ; Difference!›› ; 1st character is ":" or " "› ; unfortunately in a bad› ; order. We want directories› ; ABOVE files. Notice patch›› ElseIf Names(A*12+12+B)1 Then› Ok=1› Else› Ok=0› Fi› Else› If B>1 Then› Ok=0› Else› Ok=1› Fi› Fi› Until Ok<>255 Or B=FINALB Od›› ; If they're not in the order› ; (dir(ection)) we want, swap› ; them›› If Ok=SortDir Then› For B=1 To 12 Do› C=Names(A*12+12+B)› Names(A*12+12+B)=Names(A*12+B)› Names(A*12+B)=C› Done=0› Od› Fi› Od› Until Done=1 Od› Position(0,23)› Put('œ)› Fi›Return›››; Display list on screen››Proc ShowList()› Byte A,B,X,Y› Char Array St(40),FN2(40)›› Put(125)› Poke(559,0)›› ; Title and path›› Position(20-Title(0)/2,0)› Print(Title)›› ; If path is too long, end it with› ; "..."›› FitString(FN,FN2,39)› Position(20-FN2(0)/2,1)› Print(FN2)›› ; Display in columns›› X=0› Y=2› For A=1 To NumFiles Do› Position(X,Y)› St(0)=12› For B=1 To 12 Do› St(B)=Names(A*12-12+B)› Od› Print(St)› Y=Y+1› If Y>23 Then› Y=2› X=X+13› Fi› Od›› Poke(559,34)›Return›››; Read a text file››Proc Read(Char Array File Byte X,Y)› Char Array FType(20),File40(40)› Byte Array NBs(256)› Card Array NCs(256)› Byte A,C,EOL,Abort,NB,Screens› Card NC›› ; Open it›› StopDLI()› Error=Ignore› AnError=0› Close(1)› Open(1,File,4,0)›› FitString(File,File40,35)›› ; Find the EOL type› ; (ASCII/Unix/Atari)›› EOL=0› For A=0 To 100 Do› C=GetD(1)› If (C=155 Or C=10 Or C=13)› And EOL=0 Then› EOL=C› Fi› Od›› If EOL=0 Then› EOL=155› Fi›› If EOL=155 Then› SCopy(FType,"Atari Text File:")› ElseIf EOL=10 Then› SCopy(FType,"Unix Text File:")› ElseIf EOL=13 Then› SCopy(FType,"ASCII Text File:")› Fi›› ; Title lines›› Put(125)› Position(20-FType(0)/2,0)› PrintE(FType)› Position(35,0)› Print("Page")› Position(17-File40(0)/2,1)› PrintE(File40)› Position(36,1)› PrintBE(1)›› Poke(766,1)› Key=255›› ; Reopen it (since we read some)›› Close(1)› Open(1,File,4,0)›› ; Find position of first screenful›› Note(1,@NC,@NB) › NCs(0)=NC› NBs(0)=NB› Screens=1› › Abort=0› Poke(559,0)›› Do› ; Read/convert/check End Of File›› C=GetD(1)›› If C=EOL Then› C=155› Fi›› If EOF(1)=0 Then› If C<>10 Or EOL<>13 Then› Put(C)› Fi› Fi›› ; Check "E:"ditor's cursor pos.› ; If it's low, say "press a› ; key" and wait›› If Peek(84)>=22 Then› StartDLI()› Poke(559,34)› Position(12,23)› Print("- Press a key -")›› Key=255› Do› Until Key<255 Or Strig(0)=0 Or Stick(0)=14 Or Stick(0)=13 Or Stick(0)=11 Od›› ; Page-up?› › If Key=14 Or Key=142 Or Stick(0)=14 Then› If Screens>1 Then› Screens=Screens-2› NC=NCs(Screens)› NB=NBs(Screens)› Point(1,NC,NB)› Fi› Fi›› ; Top-of-file?›› If Key=45 Then› Screens=0› NC=NCs(0)› NB=NBs(0)› Point(1,NC,NB)› Fi›› ; Abort?›› If Key=28 Or Stick(0)=11 Then› Abort=1› Fi›› Key=255› › ; Retitle›› Poke(766,0)› Put(125)› Position(20-FType(0)/2,0)› PrintE(FType)› Position(35,0)› Print("Page")› Position(20-File40(0)/2,1)› PrintE(File40)› Position(36,1)› PrintBE(Screens+1)›› ; Find position of this› ; screenful›› Note(1,@NC,@NB) › NCs(Screens)=NC› NBs(Screens)=NB› Screens=Screens+1›› Poke(766,1)› Poke(559,0)› StopDLI()› Fi› Until EOF(1)<>0 Or Abort=1 Od›› ; Wait for final keypress›› StartDLI()› Poke(559,34)›› ; Eat stick entry until they quit› ; it›› Do› Until Strig(0)=1 And Stick(0)=15 Od› Key=255›› If Abort=0 Then› Position(9,23)› Print("- DONE Press a key -")›› Do› Until Key<255 Or Strig(0)=0 Or Stick(0)<>15 Od› Key=255› Fi›› NEXTX=X› NEXTY=Y›› Key=255› Poke(766,0)› Close(1)›Return››; Deal with APE PC Mirror change› ›Proc APE()› Card C› Byte D›› Position(0,23)› Print("               ÁÐÅ Ãèáîçå              ")›› ; Get stuff from APE›› Error=APEIgnore› Close(1)›; Open(1,File,4,0)›;›; For C=0 To 1023 Do›; D=GetD(1) PUT(D)›; Od›; Close(1)›› ; Pause a moment for APE dir› ; change›› StartDLI()›› For C=0 To 50000 Do Od›› NEXTX=0› NEXTY=2›› GetDefaults()›Return››; Main selection / command procedure!››Byte Func SelectOne()› Byte Ex,A,B,N,Found,L,S› Int X,Y,OX,OY› Char Array St(20),St2(20)› Card Count›› X=NEXTX› Y=NEXTY› Ex=255›› ; We want "K:"eyboard input›› Close(2)› Open(2,"K:",4,0)›› Do› ; Print highlighted string› ; (or blank)›› A=(X/13)*22+Y-1› If A<=NumFiles Then› St(0)=12› For B=1 To 12 Do› St(B)=Names(A*12-12+B)+128› Od› Else› SCopy(St,"            ")› Fi› Position(X,Y)› Print(St)›› ; Get input›› Do› ; Joystick acts as keyboard›› N=0› S=Stick(0)› If S=11 Then N='+ Fi› If S=7 Then N='* Fi› If S=14 Then N='- Fi› If S=13 Then N='= Fi› If Strig(0)=0 Then N=155 Fi›› ; Click and pause emulation›› If N<>0 Then› Key=0› S=GetD(2)› For Count=0 To 2500 Do Od› Fi›› ; Keyboard obviously acts as› ; keyboard, too!›› If Key<255 Then› N=GetD(2)› Fi› Until N<>0 Od›› ; Unhighlight›› A=(X/13)*22+Y-1› If A<=NumFiles Then› St(0)=12› For B=1 To 12 Do› St(B)=Names(A*12-12+B)› Od› Else› SCopy(St," ")› Fi› Position(X,Y)› Print(St)›› ; Movement›› If N=' Or N='- Then› Y=Y-1› If Y<2 Then Y=23 Fi› ElseIf N='_ Then› Y=2› ElseIf N=' Or N='= Then› Y=Y+1› If Y>23 Then Y=2 Fi› ElseIf N='| Then› Y=23› ElseIf N=' Or N='+ Then› X=X-13› If X<0 Then X=0 Fi› ElseIf N='\ Then› X=0› ElseIf N=' Or N='* Then› X=X+13› If X>26 Then X=26 Fi› ElseIf N='^ Then› X=26›› ; Quit›› ElseIf N=' Then› Ex=2›› ; Execute/read/enter›› ElseIf (N=155 And St(2)<>32)› Or (N='> And St(1)=':) Then›› ; Directory entry?›› If St(1)=': Then›› ; Reload and previous are› ; special cases›› If SCompare(St,RELOAD)=0 Then› Ex=0› GetDefaults()› ElseIf SCompare(St,PREVDIR)=0 Then› N='<› Else› OldX(Stack)=X› OldY(Stack)=Y› Stack=Stack+1› SCopy(St2,"")› L=0› For A=2 To 9 Do› If St(A)<>32 Then› L=L+1› St2(L)=St(A)› Fi› Od› If St(10)<>32 Then› L=L+1› St2(L)='.› For A=10 To 12 Do› If St(A)<>32 Then› L=L+1› St2(L)=St(A)› Fi› Od› Fi› Fi› If SCompare(St,RELOAD)<>0 And› SCompare(St,PREVDIR)<>0 Then› L=L+1› St2(L)=':› Ex=0› St2(0)=L› SCat(Path,St2)› NEXTX=0› NEXTY=2› GetDefaults()› Fi›› ; Program or text file (other)›› Else›› ; Figure out full path›› SCopy(File,Path)› L=File(0)› For A=2 To 9 Do› If St(A)<>32 Then› L=L+1› File(L)=St(A)› Fi› Od› If St(10)<>32 Then› L=L+1› File(L)='.› For A=10 To 12 Do› If St(A)<>32 Then› L=L+1› File(L)=St(A)› Fi› Od› Fi› File(0)=L›› ; Open it›› StopDLI()› AnError=0› Error=Ignore› Close(1)› Open(1,File,4,0)›› If AnError=0 Then› ; Check it›› A=GetD(1)› B=GetD(1)›› Close(1)› StartDLI()›› ; Executable or other?›› If A=255 And B=255 Then› Ex=1› Else› Read(File,X,Y)› Ex=0› Fi› Else› ; Do APE stuff› › APE()› Ex=0› Fi› Fi›› ; Drive selection›› ElseIf N>='1 And N<='9 Then› SCopy(Path,"D1:")› Path(2)=N› Ex=0› NEXTX=0› NEXTY=2› Stack=0› GetDefaults()› Fi›› ; Back out of directory›› If N='< Or N='~ Then› If Path(0)>3 Then› B=0› For A=3 To Path(0)-1 Do› If Path(A)=': Then› B=A› Fi› Od›› ; Get old X/Y position›› If B<>0 Then› Path(0)=B› Ex=0› Stack=Stack-1› NEXTX=OldX(Stack)› NEXTY=OldY(Stack)› Fi›› GetDefaults()› Fi›› ; By-first-letter file selection›› ElseIf N>='A And N<='Z Then› OX=X› OY=Y› Found=0›› ; Go through, up->down,› ; left->right›› Do› Y=Y+1› If Y>23 Then› Y=2› X=X+13› If X>26 Then› X=0› Fi› Fi› A=(X/13)*22+Y-1› If A<=NumFiles Then› If Names(A*12-10)=N Then› Found=1› Fi› Fi› Until Found=1 Or (X=OX And Y=OY) Od› Fi› Until Ex<>255 Od› Close(2)›Return(Ex)›››; Jump to DOS››Proc Go_DOS()› [$6C$0A$00]›››; Load executable››Proc Load(Char Array FN)› Graphics(0)› Poke(752,1)› Put(125)› Position(16,11)› PrintE("Loading:")› Position(20-FN(0)/2,12)› PrintE(FN)›› ; Set current path›› If Path(0)>3 Then ; remove ":"?› Path(0)=Path(0)-1› Fi› XIO(1,0,41,0,0,Path)›› XIO(1,0,39,4,0,FN)›Return›››; Main››Proc Main()› Byte Done›› Setup()› Do› GetList()› ShowList()› Done=SelectOne()› Until Done<>0 Od›› If Done=1 Then› Load(File)› Fi›› StopDLI()› Poke(752,0)› Put(125)› Go_DOS()›Return››