// Program to test working with pad // Counts -ve when pad held left; +ve when held right // Counts back to zero when pad released // Outputs count to siocons terminal // Authors: Scott Campbell and Dave MacDonald #include #include "pad.h" #define Max_Tilt_Frames 5 #define Select_Pressed 99 volatile u_char *padBufP1, *padBufP2; unsigned long int ReadPad1(); void main() { int tiltCount=0; unsigned long int padValue; GetPadBuf(&padBufP1, &padBufP2); padValue = ReadPad1(); while(!(padValue & PADselect)) { printf(" \r"); printf("Tilt: %i\r",tiltCount); if(padValue & PADLleft) { if(tiltCount != -Max_Tilt_Frames) tiltCount--; } else if(padValue & PADLright) { if(tiltCount != Max_Tilt_Frames) tiltCount++; } else { if(tiltCount < 0) tiltCount++; else if(tiltCount > 0) tiltCount--; } VSync(0); padValue = ReadPad1(); } } unsigned long int ReadPad1() // Returns value from pad 1 { return (~(*(padBufP1+3) | *(padBufP1+2) << 8 | *(padBufP1+3) << 16 | *(padBufP1+2) << 24)); }