home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
451-475
/
apd459
/
amoscli.amos
/
amoscli.amosSourceCode
Wrap
AMOS Source Code
|
1994-01-01
|
12KB
|
359 lines
'*******************************************************************
'* A M O S C L I By Gary Fearn *
'*******************************************************************
'
'* Rename this program to CLI.Acc *
'
'* This Utility is most effective if assigned to the Help key *
'* to replace the Help.Acc. You can do this by using Config.Amos *
'* on the program disc. Select the < Help Accesory name > from the *
'* menu and change the two top strings to "CLI.Acc",and the last *
'* string to "Cannot find CLI.ACC". *
'*
'* Pressing return at prompt displays last command entered *
'* typing ? <return> displays all commands available *
'* typing a command with ? as a parameter displays command template*
'
'******************** 1/2 MEG MACHINES *****************************
'* At present this is a tight fit into memory. I suggest you edit out
'* some commands and mess about with set buffer and other memory
'* saving commands.
'********************************************************************
'
'
If Fast Free=0
Close Workbench : Close Editor
Screen Open 7,640,256,4,Hires
Else
Screen Open 7,640,256,8,Hires
End If
_INTRO
Wind Open 1,16,10,74,30,1
Palette $12,$34,$AF,$FF
Curs Off : Flash Off
COMMAND$="" : FIRST$=" " : SEC$=" " : COMNUM=18 : Rem COMNUM=number of commands
Dim COMNAME$(COMNUM)
Restore NAMES
For A=0 To COMNUM-1
Read COMNAME$(A)
Next A
Global COMMAND$,COMNAME$(),COMNUM,FIRST$,SEC$
Centre "A M O S C L I" : Print : Print
Print Pen$(2)+"Type ? <Return> for list of commands."
Print "Type the CommandName followed by a ? for the Template."
Print "Press Return at prompt to edit the last command."
Print : Print
'
BEGIN:
Do
Input "> ";COMMAND$
If COMMAND$="" Then Put Key KEYBUFF$
KEYBUFF$=COMMAND$
COMMAND$=Upper$(COMMAND$)
Proc PARSE
Loop
'
Procedure _INTRO
VERSION$="V1.2"
Wind Open 1,96,20,50,10,1
Curs Off : Flash Off
Palette $12,$34,$AF,$FF
Centre "Presenting the AMOS CLI" : Print
Print : Centre Pen$(0)+"By Gary Fearn" : Print
Print : Locate 17, : Print VERSION$+" 3-9-92"
Do
If Mouse Key<>0 Then Exit
If Inkey$<>"" Then Exit
Loop
Wind Close
End Proc
Procedure PARSE
If Len(COMMAND$)=0 Then Pop Proc
POS=Instr(COMMAND$," ")
If POS=0 Then FIRST$=COMMAND$ : SEC$="" : Goto MISSIT
FIRST$=Left$(COMMAND$,POS-1)
SEC$=Right$(COMMAND$,Len(COMMAND$)-POS)
MISSIT:
Proc CHECK_COMS
End Proc
Procedure CHECK_COMS
R=Match(COMNAME$(0),FIRST$)
If R=>0 Then Bell
If R<0 Then Pop Proc : Rem * Pop Proc if command not reconized
If R=0 Then Proc COM0
On R Proc COM1,COM2,COM3,COM4,COM5,COM6,COM7,COM8,COM9,COM10,COM11,COM12,COM13,COM14,COM15,COM16,COM17
End Proc
'
'************************
'** Command Procedures **
'************************
' * ? (Prints out list of commands)
Procedure COM0
For A=0 To COMNUM-1
Print COMNAME$(A)
Next A
End Proc
' * CD (CHANGE Directory)
Procedure COM1
If SEC$="" Then Print Dir$ : Pop Proc
If SEC$="/" Then Parent : Pop Proc
If SEC$="?" Then Print "CD | CD / | CD ? | CD <Pathname>" : Pop Proc
If Exist(SEC$)
Dir$=SEC$
Else
Print "Does not Exist !"
End If
End Proc
' * Cls ( clear the screen & cursor home)
Procedure COM2
If SEC$="?" Then Print "No Parameters" : Pop Proc
Clw : Home
End Proc
' * Copy (copies a file)
Procedure COM3
If SEC$="" Then Pop Proc
If SEC$="?" Then Print "Copy ? | Copy <filename> <filename> | copy <Path+filename> <Drive>" : Pop Proc
POS=Instr(SEC$," ")
If POS=0 Then Print "Invalid parameters" : Pop Proc
FIR$=Left$(SEC$,POS-1)
SEC$=Right$(SEC$,Len(SEC$)-POS)
If Exist(FIR$)
Open In 1,FIR$
FILELEN=Lof(1)
Close 1
Reserve As Work 6,FILELEN
Bload FIR$,6
If Len(SEC$)=4
POS=Instr(FIR$,":")
If POS<>0
FIR$=Right$(FIR$,Len(FIR$)-4)
End If
SEC$=SEC$+FIR$
End If
Print "copying ";FIR$;" as ";SEC$;"..."
Bsave SEC$,Start(6) To Start(6)+FILELEN
Erase 6
Else
Print FIR$;" does not exist."
End If
End Proc
' * Dfree (? remaining disk/mem space
Procedure COM4
If SEC$="?" Then Print "Dfree | Dfree MEM" : Pop Proc
If SEC$="" Then Print Dir$;" ";Dfree;" bytes remaining." : Pop Proc
If SEC$="MEM"
Print Chip Free;" bytes of chip ram available"
Print Fast Free;" bytes of fast ram available"
Print : Print "Total = ";Chip Free+Fast Free
End If
End Proc
' * Dir (Directory of files)
Procedure COM5
If SEC$="?" Then Print "Dir | Dir <Pathname>" : Pop Proc
If SEC$=""
Dir
Else
Dir SEC$
End If
End Proc
' * Exist (Checks if a file exists)
Procedure COM6
If SEC$="" Then Print "Do I Exist ?" : Pop Proc
If SEC$="?" Then Print "Exist <Filename>" : Pop Proc
If Exist(SEC$)
Print "Yes ";SEC$;" does exist"
Else
Print "No ";SEC$;" does not exist"
End If
End Proc
' * Ftype (Displays the type of files in a directory
Procedure COM7
If SEC$="?" Then Print "Ftype | Ftype <pathname> " : Pop Proc
If SEC$<>"" Then Dir$=SEC$
FILE$=Dir First$("")
While FILE$<>""
FTYPE[FILE$]
FILE$=Dir Next$
Wend
End Proc
' * IFF (Load an iff picture)
Procedure COM8
If SEC$="?" Then Print "IFF | IFF <filename>" : Pop Proc
If SEC$="" Then SEC$=Fsel$("","","Select a picture")
If SEC$="" Then Pop Proc
Open In 1,SEC$ : L=Lof(1) : E$=Input$(1,100) : Close 1
POS=Hunt(Varptr(E$) To Varptr(E$)+Len(E$),"Pac.Pic")
' Just to see if its a packed picture
If POS<>0
Print "Picture is in a packed format"
Reserve As Work 6,L
Load SEC$,6
Unpack 6 To 6
Erase 6
Else
Load Iff SEC$,6
End If
Flash Off : Curs Off : Hide
Do
A$=Inkey$
If Mouse Key<>0 Then Exit
If A$<>"" Then Exit
Loop
Show
Screen Close 6
End Proc
' * Kill (deletes a file)
Procedure COM9
If SEC$="?" Then Print "Kill | Kill <filename>" : Pop Proc
If SEC$="" Then SEC$=Fsel$("*.*","","Delete a file")
If SEC$="" Then Pop Proc
If Exist(SEC$)
Kill SEC$
Print SEC$;" Deleted ..."
Else
Print SEC$;" does not exist"
End If
End Proc
' * MKdir ( Make a directory)
Procedure COM10
If SEC$="?" Then Print "Mkdir <DirectoryName>" : Pop Proc
If SEC$="" Then Print "name required" : Pop Proc
Mkdir SEC$
End Proc
' * Music (Play Music in background)
Procedure COM11
If SEC$="?" Then Print "Music | Music <filename> | Music OFF" : Pop Proc
If SEC$="OFF" Then Music Off : Pop Proc
If SEC$="" Then SEC$=Fsel$("*.*","","Play a Music file")
If SEC$="" Then Pop Proc
Load SEC$
Music 1
End Proc
' * Quit ( Ends this program)
Procedure COM12
If SEC$="?" Then Print "Bye Bye " : Pop Proc
End
End Proc
' * Rename (Renames a file)
Procedure COM13
If SEC$="?" Then Print "Rename <filename1> <filename2>" : Pop Proc
POS=Instr(SEC$," ")
If POS=0 Then Print "Invalid parameters" : Pop Proc
FIR$=Left$(SEC$,POS-1)
SEC$=Right$(SEC$,Len(SEC$)-POS)
If Exist(FIR$)
Rename FIR$ To SEC$
End If
End Proc
' * Run ( Runs a program from disk/mem)
Procedure COM14
If SEC$="?" Then Print "Run | Run <Filename> | Run DISK " : Pop Proc
If SEC$="DISK"
F$=Fsel$("*.AMOS","","Run a file")
Run F$
End If
N$=Psel$("*.*",SEC$,"Run A FILE IN MEM")
If N$="" Then Pop Proc
Prun N$
Screen Open 7,640,256,8,Hires
Curs Off : Flash Off
Wind Open 1,16,10,74,30,1
End Proc
' * Sample (plays a sample bank)
Procedure COM15
If SEC$="?" Then Print "Sample | Sample <filename> | Sample BANK | (Use Cursor Keys)" : Pop Proc
If SEC$="" Then SEC$=Fsel$("*.abk","","Select a Sample bank ")
If SEC$="BANK" Then SNUM=Deek(Start(5)) : Goto SAMMAIN
If SEC$="" Then Pop Proc
Open In 1,SEC$ : L=Lof(1) : E$=Input$(1,24) : Close 1
POS=Hunt(Varptr(E$) To Varptr(E$)+Len(E$),"Samples")
If POS<>0
SNUM=Deek(Varptr(E$)+20) : Rem Snum= the amount of samples in bank
Load SEC$
SAMMAIN:
X=1 : Sam Play 1 : PLFLAG=0
While X=>1 and X<=SNUM
If PLFLAG=1 : Sam Play X : PLFLAG=0 : End If
Locate 30,Y Curs-1 : Print Using "##";X; : Print " "; : Print Using "##";SNUM
If Key State(79)=True : Dec X : PLFLAG=1 : Wait 10 : End If
If Key State(78)=True : Inc X : PLFLAG=1 : Wait 10 : End If
If Mouse Key=1 : Exit : End If
Wend
Erase 5
Else
Print "Sorry This is not a Sample Bank"
End If
End Proc
' * Scankey ( prints ASCII and scancode for keypresses
Procedure COM16
If SEC$="?" Then Print "No Parameters" : Pop Proc
Print "press mouse buttons to quit" : Print
While Mouse Key=0
A$=Inkey$
If A$<>"" Then Print "chr$ =";A$;" scancode =";Scancode;" ASCII =";Asc(A$)
Wend
End Proc
' * Sprite (displays sprites)
Procedure COM17
If SEC$="?" Then Print "Sprite | Sprite <filename> | Sprite BANK | (Use Cursor Keys)" : Pop Proc
If SEC$="" Then SEC$=Fsel$("*.abk","","Load a Sprite bank ")
If SEC$="" Then Pop Proc
If SEC$="BANK" Then Bgrab 1 : Goto NOLOAD
Load SEC$
NOLOAD:
Screen Open 6,320,256,16,Lowres
Curs Off : Flash Off : Hide
Get Sprite Palette
SLEN=Length(1) : X=1
While X=>1 and X<=SLEN
If Mouse Key<>0 Then Exit
Wait 10
Locate 20,0 : Print Using "##";X; : Print " "; : Print Using "##";SLEN
Sprite 8,X Mouse,Y Mouse,X
If Key State(79)=True Then Dec X
If Key State(78)=True Then Inc X
Wend
Sprite Off
Show
Screen Close 6
End Proc
'
'
'
'
'* Data for Command names must be uppercase and in alphabetical order *
NAMES:
Data "?","CD","CLS","COPY","DFREE","DIR","EXIST","FTYPE","IFF","KILL","MKDIR","MUSIC","QUIT"
Data "RENAME","RUN","SAMPLE","SCANKEY","SPRITE"
'
'*************************
'** External Procedures **
'*************************
'
Procedure FTYPE[FILE$]
If Left$(FILE$,1)="*" Then Print FILE$ : Pop Proc
FILE$=Right$(FILE$,Len(FILE$)-1)
POS=Instr(FILE$," ",1)
FILE$=Left$(FILE$,POS-1)
Open In 1,FILE$ : L=Lof(1) : FROM$=Input$(1,30) : Close 1
_GETSTR[FROM$,FILE$,"Samples"," (Sample Bank)"]
If Param=1 Then Pop Proc
_GETSTR[FROM$,FILE$,"AmSp"," (Sprite Bank)"]
If Param=1 Then Pop Proc
_GETSTR[FROM$,FILE$,"AMOS Basic"," (Basic program)"]
If Param=1 Then Pop Proc
_GETSTR[FROM$,FILE$,"FORM"," (IFF file)"]
If Param=1 Then Pop Proc
_GETSTR[FROM$,FILE$,"Pac.Pic"," (Packed file)"]
If Param=1 Then Pop Proc
_GETSTR[FROM$,FILE$,"Music"," (Music Bank)"]
If Param=1 Then Pop Proc
_GETSTR[FROM$,FILE$,"AmIc"," (Icons Bank)"]
If Param=1 Then Pop Proc
Print FILE$," (Unknown)"
End Proc
Procedure _GETSTR[FROM$,FILE$,LOOK$,MESSAGE$]
POS=Hunt(Varptr(FROM$) To Varptr(FROM$)+Len(FROM$),LOOK$)
If POS<>0 Then Print FILE$;" ";MESSAGE$ : YES=1
End Proc[YES]
'