;Amiga function key reader and loader
;Using the DOS, EXECUTE command.
;(C)1990 A.M.BRIMBLE


Openlib=-408
Closelib=-414
Execbase=4
Execute=-222
IoErr=-132
skeys=$bfec01

run:

	bsr	init		;Open libs

loop:
	cmp.b	#$5F,skeys	;F1 pressed ?
	beq	function1	;If so, execute function1
	cmp.b	#$5D,skeys	;Else F2 pressed ?
	beq	function2	;If so, execute function2
	cmp.b	#$5B,skeys	;etc .....
	beq	function3
	cmp.b	#$59,skeys
	beq	function4
	cmp.b	#$57,skeys
	beq	function5
	cmp.b	#$55,skeys
	beq	function6
	cmp.b	#$53,skeys
	beq	function7
	cmp.b	#$51,skeys
	beq	function8
	cmp.b	#$4f,skeys
	beq	function9
	cmp.b	#$4d,skeys
	beq	function10
	cmp.b	#$3f,skeys
	beq	function11
	cmp.b	#$3d,skeys
	beq	function12
	jmp	loop		;Loop again
	
init:
	move.l	execbase,a6	;Exec base address into a6
	lea	dosname(pc),a1
	moveq	#0,d0
	jsr	openlib(a6)     ;Attempt to open dos.library
	move.l	d0,dosbase
	beq	error		;End if unsuccesful 
	rts

error:
	move.l	dosbase,a6
	jsr	IoErr(a6)
	move.l	d0,d5
	move.l	#-1,d7

qu:
	move.l	dosbase,a1
	move.l	execbase,a6
	jsr	closelib(a6)
	rts

function1:
	move.l	dosbase,a6	;Get DOS base address
	move.l	#command1,d1	;Get CLI command to execute
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)	;Execute CLI command for F1
	jmp 	loop

function2:
	move.l	dosbase,a6
	move.l	#command2,d1
	clr.l	d2
	clr.l	d3
	jsr 	execute(a6)
	jmp	 loop

function3:
	move.l	dosbase,a6
	move.l	#command3,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp 	loop

function4:
	move.l	dosbase,a6
	move.l	#command4,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp 	loop

function5:
	move.l	dosbase,a6
	move.l	#command5,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp	loop

function6:
	move.l	dosbase,a6
	move.l	#command6,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp 	loop

function7:
	move.l	dosbase,a6
	move.l	#command7,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp 	loop

function8:
	move.l	dosbase,a6
	move.l	#command8,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp 	loop

function9:
	move.l	dosbase,a6
	move.l	#command9,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp	loop

function10:
	move.l	dosbase,a6
	move.l	#command10,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp	loop

function11:
	move.l	dosbase,a6
	move.l	#command11,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp	loop

function12:
	move.l	dosbase,a6
	move.l	#command12,d1
	clr.l	d2
	clr.l	d3
	jsr	execute(a6)
	jmp	loop

dosname:	dc.b "dos.library",0,0
		even
dosbase:	dc.l 0
		even

;Enter commands to be executed here.
command1:	dc.b	"TOCCATAREMIX",0 
command2:	dc.b	"GAPULUS",0
command3:	dc.b	"CREATION2",0
command4:	dc.b	"RENDEZVOUS2",0
command5:	dc.b	"OXYGENE2",0
command6:	dc.b	"AMIGAFORMAT",0
command7:	dc.b	"PHANTOM1",0
command8:	dc.b	"EQUINOXE4",0
command9:	dc.b	"BACH80sMIX",0
command10:	dc.b	"CRAZYCOMETS",0
command11:	dc.b	"BACHTOWN",0
command12:	dc.b	"GREEN",0


;Here is a new function key reader that works even when
;the CLI is not active !. Also there is no keyboard
;buffer, so even if you press the function keys like
;mad only 1 command will be run.
;To use the routine, Enter your fkey definitions by
;the labels command1,command2 etc and assemble.
;Make sure that the RUN command is present when you
;use the routine.
~
