// Analog pad tester. Useful for finding the typical null-zone ranges // to prevent unwanted movement in your games. // Type SIOCONS AUTO to load and run. // by James Shaughnessy james@manc.u-net.com // http://www.netyaroze-europe.com/~shaughnj #include #include "pad.h" #define OT_LENGTH (1) #define NUM_PACKETS (248000) #define CLx (80) // Box Centre coords #define CLy (200) #define CRx (240) #define CRy (200) // Global Variables u_char PAD1lh, PAD1lv, PAD1rh, PAD1rv; // Analog axis u_char PAD2lh, PAD2lv, PAD2rh, PAD2rv; // Analog axis GsBOXF box[2]; GsBOXF stick[2]; // Two Ordering Tables, one for each buffer GsOT WorldOT[2]; // Two Ordering Table Tags, one for each buffer GsOT_TAG OTTag[2][1<> 4) == 0x1) FntPrint("Mouse connected.\n\n"); else if ((*(bb0+1) >> 4) == 0x2) FntPrint("NeGcon connected.\n\n"); else if ((*(bb0+1) >> 4) == 0x4) FntPrint("Standard PAD connected.\n\n"); if ((*(bb0+1) >> 4) == 0x7) FntPrint("Analog PAD connected.\n\n"); else if ((*(bb0+1) >> 4) == 0x5) FntPrint("Joystick connected.\n\n"); else FntPrint("Please insert an analog\nPAD or Joystick in port 1\n\n"); if ( (*(bb0+1) >> 4) == 0x7 || (*(bb0+1) >> 4) == 0x5 ) { FntPrint("\n\nValues:\n\n Left: H = %3d V = %3d\n\nRight: H = %3d V = %3d\n", PAD1lh, PAD1lv, PAD1rh, PAD1rv); if (padStatus & PAD1i) { FntPrint("\n\nLEFT PRESS"); if (padStatus & PAD1j) FntPrint(" RIGHT PRESS\n"); } else if (padStatus & PAD1j) FntPrint("\n\n RIGHT PRESS\n"); stick[0].x = CLx - 25 + (44 * (PAD1lh)) / 255; stick[0].y = CLy - 25 + (44 * (PAD1lv)) / 255; stick[1].x = CRx - 25 + (44 * (PAD1rh)) / 255; stick[1].y = CRy - 25 + (44 * (PAD1rv)) / 255; for (i = 0; i < 2; ++i) { GsSortBoxFill(&stick[i], &WorldOT[activeBuff], 0); GsSortBoxFill(&box[i], &WorldOT[activeBuff], 0); } } FntFlush(-1); // Wait for end of drawing, a vertical blank then swap buffers DrawSync(0); hsyncs = VSync(0); GsSwapDispBuff(); // Register Clear in OT GsSortClear(0, 0, 0, &WorldOT[activeBuff]); // Draw the Ordering Table GsDrawOt(&WorldOT[activeBuff]); } // ****** PAD routines ****** // call once only in program initialisation void PadInit (void) { GetPadBuf(&bb0, &bb1); } // call once per VSync(0) // Note that in a game that doesn't use the analog pad these // assignments will take up valuable time. u_long PadRead(void) { // Get analog PAD positions PAD1rh = *(bb0+4); PAD1rv = *(bb0+5); PAD1lh = *(bb0+6); PAD1lv = *(bb0+7); PAD2rh = *(bb1+4); PAD2rv = *(bb1+5); PAD2lh = *(bb1+6); PAD2lv = *(bb1+7); return(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); }