Unit key;
var
/*

	KEYS
	
		BIT	7	6	5	4	3	2	1	0
			---	---	---	---	---	---	---	---
	ROW7 =	F7	Hme	-	0	8	6	4	2
	ROW6 = 	F5	UAr	@	O	U	T	E	Q
	ROW5 =	F3	=	:	K	H	F	S	C=
	ROW4 = 	F1	RSh	.	M	B	C	Z	Spc
	ROW3 = 	CDo	/	,	N	V	X	LSh	RSt
	ROW2 = 	CRi	;	L	J	G	D	A	Ctl
	ROW1 = 	Ret	*	P	I	Y	R	W	LAr
	ROW0 =	Del	Pnd	+	9	7	5	3	1

*/


const ROW7: byte = %01111111;const ROW6: byte = %10111111;
const ROW5: byte = %11011111;const ROW4: byte = %11101111;
const ROW3: byte = %11110111;const ROW2: byte = %11111011;
const ROW1: byte = %11111101;const ROW0: byte = %11111110;
	
const BIT7: byte = %10000000;const BIT6: byte = %01000000;
const BIT5: byte = %00100000;const BIT4: byte = %00010000;
const BIT3: byte = %00001000;const BIT2: byte = %00000100;
const BIT1: byte = %00000010;const BIT0: byte = %00000001;

// Params are used as global references in Macros so do not really occupy memory
	const INPUT_PARAMS: address	= $02a1;		// Put params here just in case
	pa, pb, pc: byte at INPUT_PARAMS;			// parameters for methods


// Read a key row
// 
// PARAMS: 		pa = ROW value
// RETURNS:		BYTE bit mask for keys pressed on selected ROW
//
// Use constants ROW0 through ROW7 as the parameter to test for
// a specific row on the keyboard.
// See table in header for where keys can be found in
// the ROWS and BITS
//
// Example usage:
// key := key::ReadKeyRow( key::ROW7 );
procedure ReadKeyRow( pa: global pure_number byte ) inline;
begin

	poke( ^$9120, 0, pa );
	peek( ^$9121, 0 );
	
end;

end.
