/* JOYBITS.C ---- Polls joystick status bits.
 * by Gary Neal, Jr. -- garyneal@geocities.com
 */

#include           /* Console input/output */

/* Joystick Pots */
#define Bit0 0x01           /* Joystick A X-axis */
#define Bit1 0x02           /* Joystick A Y-axis */
#define Bit2 0x04           /* Joystick B X-axis */
#define Bit3 0x08           /* Joystick B Y-axis */

/* Joystick Buttons */
#define Bit4 0x10           /* Joystick A Button 1 */
#define Bit5 0x20           /* Joystick A Button 2 */
#define Bit6 0x40           /* Joystick B Button 1 */
#define Bit7 0x80           /* Joystick B Button 2 */

int main(void)
{
    int joyState;           /* Port value */

    joyState = inp(0x201);  /* Read joystick port */

    /* Check joystick pot status */
    cprintf("Capacitor for Joystick A's X-axis is %s charged.\r\n",
            ((joyState & Bit0) ? "not" : "fully"));
    cprintf("Capacitor for Joystick A's Y-axis is %s charged.\r\n",
            ((joyState & Bit1) ? "not" : "fully"));
    cprintf("Capacitor for Joystick B's X-axis is %s charged.\r\n",
            ((joyState & Bit2) ? "not" : "fully"));
    cprintf("Capacitor for Joystick B's Y-axis is %s charged.\r\n",
            ((joyState & Bit3) ? "not" : "fully"));

    /* Check joystick buttons status */
    cprintf("\r\nButton 1 on Joystick A is %spressed.\r\n",
            ((joyState & Bit4) ? "not " : ""));
    cprintf("Button 2 on Joystick A is %spressed.\r\n",
            ((joyState & Bit5) ? "not " : ""));
    cprintf("Button 1 on Joystick B is %spressed.\r\n",
            ((joyState & Bit6) ? "not " : ""));
    cprintf("Button 2 on Joystick B is %spressed.\r\n",
            ((joyState & Bit7) ? "not " : ""));

    /* Finish up */
    return 0;
}

    Source: geocities.com/garyneal_71/GameLib/download

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