#include "JoyPad.h" static volatile unsigned char *padA, *padB; static unsigned short snapshot; // Status pof the Jo-Pad of ineteres static int wasstop; // Needed for one event only per push static int wasselect; static int wasleft; static int wasright; void InitializePads() { GetPadBuf(&padA,&padB); wasstop=0; wasselect=0; wasleft=0; wasright=0; } void RequestPads() { snapshot=((padA[2]<<8)+padA[3]); // Get the two relevant bytes snapshot=~snapshot; } int Right() { return (snapshot&(1<<13)); } int Left() { return (snapshot&(1<<15)); } int Up() { return (snapshot&(1<<12)); } int Down() { return (snapshot&(1<<14)); } int Circle() { return (snapshot&(1<<5)); } int Square() { return (snapshot&(1<<7)); } int Triangle() { return (snapshot&(1<<4)); } int Cross() { return (snapshot&(1<<6)); } // L1 and L2 parallel int LeftBlock() { return ((snapshot&1)||(snapshot&(1<<2))); } // R1 and R2 parallel int RightBlock() { return ((snapshot&(1<<1))||(snapshot&(1<<3))); } int Stop() { int isstop; int result; isstop=(snapshot&(1<<8)); if (isstop) { if (wasstop==0) { result=1; wasstop=1; } else result=0; } else { result=0; wasstop=0; } return result; } int Select() { int isselect; int result; isselect=(snapshot&(1<<11)); if (isselect) { if (wasselect==0) { result=1; wasselect=1; } else result=0; } else { result=0; wasselect=0; } return result; } int BuffLeft() { int isleft; int result; isleft=(snapshot&(1<<15)); if (isleft) { if (wasleft==0) { result=1; wasleft=1; } else result=0; } else { result=0; wasleft=0; } return result; } int BuffRight() { int isright; int result; isright=(snapshot&(1<<13)); if (isright) { if (wasright==0) { result=1; wasright=1; } else result=0; } else { result=0; wasright=0; } return result; }