UWORD *POTGOR;
UBYTE *DDRAV,*SDRV,*PDRAAV;


UBYTE ReadKey(void)
{
UBYTE Val1;
    *DDRAV = 3;
	Val1 = *SDRV;
	if (Val1) *SDRV = 0;
	return(Val1);

}

UBYTE ReadLB(void)
{
UBYTE Val1;
	Val1 = *PDRAAV;
	return(Val1);

}

UWORD ReadRB(void)
{
UWORD Value;
	Value = *POTGOR;
	return(Value);
}


/* Note that the following check is made before any calls to GetMsg
are made.  If the Right-Amiga has not been pressed, and the left or
right mouse buttons have not been pressed, then no call will be made
to GetMsg.  Note that a call to GetMsg (or an IntuiMessage and the
retrieval of the Message->Code and Message->Class, along with ReplyMsg)
takes about 1.3 microseconds when compiled for 68K, but about 367
microseconds when compiled for WarpOS.  I assume it would be much longer
for the Phase 5 version, for which task switching is longer.  The
corresponding call to InputCheck takes about 5.7 microseconds.  That's
with the initializing of SDRV, DDRAV, PDRAAV, and POTGOR done in main
rather than in InputCheck. */


BOOL InputCheck(void)
{
UWORD RBVal;
UBYTE Val1,Val2;
	SDRV =	(UBYTE *)0xbfec01;
	DDRAV =	(UBYTE *)0xbfe201;
	PDRAAV = (UBYTE *)0xbfe001;
	POTGOR = (UWORD *)0xdff016;
	Val1 = ReadKey();
	Val2 = ReadLB();
	RBVal = ReadRB();
	if (Val1 == 0x31) return(TRUE);
	if (!(Val2 & 0x40)) return(TRUE);
	RBVal = RBVal & 0x400;
	if (RBVal != 0x400) return(TRUE);
	return(FALSE);
}
