/* JOYBITS2.C ---- Polls and displays bits of port 201h.
 * by Gary Neal, Jr. -- garyneal@geocities.com
 */

#include   /* Console specific I/O */

int main(void)
{
    int joyState, bitMask;

    clrscr();                        /* Blank the screen */
    _setcursortype(_NOCURSOR);       /* Specific to Turbo C, okay to delete */
    gotoxy(10, 7);                   /* Set screen position */
    cputs("Port 201h status bits:");
    gotoxy(15, 9);                   /* Set screen position */
    cputs("7 6 5 4 3 2 1 0");
    gotoxy(15, 13);                  /* Set screen position */
    cputs("^ ^ ^ ^ ^ ^ ^ ^");
    gotoxy(15, 14);                  /* Set screen position */
    cputs("| | | | | | | +--- Capacitor state for Joystick A X-axis");
    gotoxy(15, 15);                  /* Set screen position */
    cputs("| | | | | | +----- Capacitor state for Joystick A Y-axis");
    gotoxy(15, 16);                  /* Set screen position */
    cputs("| | | | | +------- Capacitor state for Joystick B X-axis");
    gotoxy(15, 17);                  /* Set screen position */
    cputs("| | | | +--------- Capacitor state for Joystick B Y-axis");
    gotoxy(15, 18);                  /* Set screen position */
    cputs("| | | +----------- Switch state for Joystick A Button 1");
    gotoxy(15, 19);                  /* Set screen position */
    cputs("| | +------------- Switch state for Joystick A Button 2");
    gotoxy(15, 20);                  /* Set screen position */
    cputs("| +--------------- Switch state for Joystick B Button 1");
    gotoxy(15, 21);                  /* Set screen position */
    cputs("+----------------- Switch state for Joystick B Button 2");

    while (kbhit()) getch();         /* Clear the keyboard */

    while (!kbhit()) {
        joyState = inp(0x201);       /* Read the joystick port */
        gotoxy(15, 11);              /* Screen position for bits */
        for (bitMask = 0x80; bitMask; bitMask >>= 1) {
            if (joyState & bitMask)  /* Mask bit and display it */
                putch('1');
            else
                putch('0');
            putch(' ');
        }
    }

    while (kbhit()) getch();         /* Clear the keyboard */
    _setcursortype(_NORMALCURSOR);   /* Restore the cursor */
    return 0;
}

    Source: geocities.com/garyneal_71/GameLib/download

               ( geocities.com/garyneal_71/GameLib)                   ( geocities.com/garyneal_71)