/* ______ ___ ___ * /\ _ \ /\_ \ /\_ \ * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ * /\____/ * \_/__/ * * Joystick driver for N64 controllers. * * By Richard Davies, based on sample code by Earle F. Philhower, III. * * This driver supports upto four N64 controllers. The analog stick * calibrates itself when the controller is powered up (in hardware). * There is some autodetection code included, but it's unused as it's * unreliable. Care to take a look? * * This driver is for the N64 pad -> parallel port interface developed * by Stephan Hans and Simon Nield, supported by DirectPad Pro 4.9. * * See http://www.st-hans.de/N64.htm for interface information, and * See http://www.ziplabel.com for DirectPad Pro information. * * See readme.txt for copyright information. */ #include "allegro.h" #include "allegro/internal/aintern.h" #include "allegro/platform/aintdos.h" #ifndef ALLEGRO_DOS #error something is wrong with the makefile #endif #define LPT1_BASE 0x378 #define LPT2_BASE 0x278 #define LPT3_BASE 0x3bC #define D0 0x01 #define D1 0x02 #define D2 0x04 #define D3 0x08 #define D4 0x10 #define ACK 0x40 #define N64_HI 0xFF /* driver functions */ static int n64_init(void); static void n64p1_exit(void); static void n64p2_exit(void); static void n64p3_exit(void); static int n64p1_poll(void); static int n64p2_poll(void); static int n64p3_poll(void); static int n64_detect(int base, int joynum); JOYSTICK_DRIVER joystick_n641 = { JOY_TYPE_N64PAD_LPT1, NULL, NULL, "N64pad-LPT1", n64_init, n64p1_exit, n64p1_poll, NULL, NULL, NULL, NULL }; JOYSTICK_DRIVER joystick_n642 = { JOY_TYPE_N64PAD_LPT2, NULL, NULL, "N64pad-LPT2", n64_init, n64p2_exit, n64p2_poll, NULL, NULL, NULL, NULL }; JOYSTICK_DRIVER joystick_n643 = { JOY_TYPE_N64PAD_LPT3, NULL, NULL, "N64pad-LPT3", n64_init, n64p3_exit, n64p3_poll, NULL, NULL, NULL, NULL }; /* n64_init: * Initialiases the N64 joypad driver. */ static int n64_init(void) { int i; num_joysticks = 4; for (i=0; i 64); joy[joynum].stick[0].axis[1].d1 = (joy[joynum].stick[0].axis[1].pos < -64); joy[joynum].stick[0].axis[1].d2 = (joy[joynum].stick[0].axis[1].pos > 64); return 0; } /* n64p1_poll: * Input polling function. */ static int n64p1_poll(void) { int joynum; for (joynum=0; joynum