#define X 1
#define Y 2
#define Z 4 //now powers of 2
#define W 8 //I.E bit values
unsigned short SWITCH = 0;
unsigned char Previous;
void Interrupt()
unsigned char Edges,Pins;
{
if(INTCON.INTF)
{
SWITCH |= W;
PORTA.F1 = 1;
INTCON.INTF = 0;
}
if(INTCON.RBIF)
{
Pins=PORTB; //read the inputs
Pins=~Pins; //invert so active low
Edges=Pins^[B]Previous[/B]; //find bits that have changed
Edges&=Pins; //and are now high
Previous=Pins; //keep copy for next time
INTCON.RBIF = 0;