;*******************************************************************************
; Title:	TestCtrl
; Author:	Original by Unknown
; Copyright:	(C) Philip Ludlam and Fred Graute 2006
; Version:	1.04, Sunday the 7th of May, 2006
;
; Changes:	Modified by Philip Ludlam
;		Corrected by Fred Graute
;		Updated for the A9home by Fred Graute
;
;*******************************************************************************
; This program is free software; you can redistribute it and/or modify it
; under the terms of the GNU General Public License as published by the Free
; Software Foundation; either version 2 of the License, or (at your option)
; any later version.
;
; This program is distributed in the hope that it will be useful, but WITHOUT
; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
; FITNESS FOR APARTICULAR PURPOSE. See the GNU General Public License for more
; details.
;
; You should have received a copy of the GNU General Public License along with
; this program; if not, write to the Free Software Foundation, Inc., 59 Temple
; Place - Suite 330, Boston, MA 02111-1307, USA
;
;*******************************************************************************

		TTL	> TestCtrl

		GET	OSLib:oslib.hdr.types
		GET	OSLib:oslib.hdr.OS
		GET	OSLib:oslib.hdr.OSByte
		GET	AsmLib2:hdr.RegsBoth

		AREA	|main|, CODE, READONLY

		ENTRY

;-------------------------------------------------------------------------------
Start		B	Entry			; Entry instruction
		DCD	&79766748		; Magic value 1
		DCD	&216C6776		; Magic value 2
		DCD	End-Start		; Read only size
		DCD	0			; Read/write size
		DCD	32			; 26 or 32 bit build

Entry		MOV	r0, #&79		; reason = &79 => scan keyboard
		MOV	r1, #&87		; &86 => just scan right ctrl
		SWI	XOS_Byte		; returns &FF if pressed, else 0
		AND	r3, r1, #2		; b1 set if pressed, else clear
		MOV	r1, #&84		; &83 => just scan left ctrl
		SWI	XOS_Byte		; returns &FF if pressed, else 0
		ORR	r3, r3, r1,LSR #7	; b0 set if pressed, else clear
		STR	r3, [r12, #0]		; store value to set variable to
		ADR	r0, VarName		; -> var name = "Ctrl$Pressed"
		ADD	r1, r12, #0		; -> value to set variable to
		MOV	r2, #4			; size of value, 4 since integer
		MOV	r3, #0			; 0 => no name pointer
		MOV	r4, #1			; 1 => variable is an integer
		SWI	XOS_SetVarVal		; assign value to variable
		MOV	pc, lr			; return

VarName		DCB	"Ctrl$Pressed", 0

Licence		DCB	" PJL/FJG, 2006. Licence: GPL."

		ALIGN

End
		END

