Joystick / Game Port (201h) ------- Port at 201h used with Joysticks 0 joystick a, x coord (0 = timing active) 1 joystick a, y coord (0 = timing active) 2 joystick b, x coord (0 = timing active) 3 joystick b, y coord (0 = timing active) 4 joystick a, button 1 (0=pressed) 5 joystick a, button 2 (0=pressed) 6 joystick b, button 1 (0=pressed) 7 joystick b, button 2 (0=pressed) - accessed through port 201h - bits 3-0 are resistive inputs with the length of the pulse determined by 0-100K ohm resistive load. Use this formula: time = 24.2 + ( 0.011 * resistance ) or resistance = ( time - 24.2 ) / 0.011 - a read should be immediately preceded by a write (any data) to start timing for the resistive values. INT 15,84 - Joy-Stick Support AH = 84h DX = 0 to read the current switch settings = 1 to read the joystick position (resistive inputs) on return (DX=0, read switch setting): CF = 0 if successful = 1 if error AH = 80h error code if CF set on PC = 86h error code if CF set on XT before 11/8/82 AL = switch settings in bits 7-4 (if read switch function) on return (DX=1, read joystick position): AX = A(X) BX = A(Y) CX = B(X) DX = B(Y) ------------------------------------------------------------------------- The GamePort of the IBM PC ========================== First, the pinout: 1 XY1 (+5v) 2 Switch 1 3 X1 4 Switch 1 (GND) 5 Switch 2 (GND) 6 Y1 7 Switch 2 8 N.C. 9 XY2 (+5v) 10 Switch 4 11 X2 12 Switch 3&4 (GND) 13 Y2 14 Switch 3 15 N.C. You can call BIOS interrupt 15h, subfunction 84h to obtain the button setting and the joystick position. I've cut these lines from Ralf Brown's interrupt list release 31. --------8<--------8<--------8<--------8<--------8<--------8<--------8<-------- INT 15 - BIOS - JOYSTICK SUPPORT (XT after 11/8/82,AT,XT286,PS) AH = 84h DX = subfunction 0000h read joystick switches Return: AL bits 7-4 = switch settings 0001h read positions of joysticks Return: AX = X position of joystick A BX = Y position of joystick A CX = X position of joystick B DX = Y position of joystick B Return: CF set on error AH = status 80h invalid command (PC,PCjr) 86h function not supported (other) CF clear if successful Notes: if no game port is installed, subfunction 0000h returns AL=00h (all switches open) and subfunction 0001h returns AX=BX=CX=DX=0000h a 250kOhm joystick typically returns 0000h-01A0h --------------------------------------------------------------- From: ard@siva.bris.ac.uk (PDP11 Hacker .....) Subject: Re: PC game port - raw input question Date: Thu, 11 Nov 1993 13:32:00 GMT >>Can someone tell me briefly how to read the PC game (joystick) port hardware? >>I would like to use the potentiometer inputs to monitor some things. >>I know that there is at least one register at 0x201, but I can't find >>any specifics. Yes, 1 I/O port, at hex 201 only. Write to port 201 to start the timers. Read port 201 for the status - the bits are : 7 - 4 Digital inputs (MSB = button 3 etc) 3 - 0 Outputs of the timers (3 = Y2, 2 = X2, 1 = Y1, 0 = X1) Writing to port 201 will set the timer outputs to logic 1. They then go back to logic 0 after a time determined by the value of pot. >Just to clarify, I am planning on writing a Unix device driver. So I >will not have access to any DOS bios routines. >I am really just looking for a description of where to write to start the pot >timers, where to read them back, and what kind of times would be involved. Write to port 201 to start the timers. Read them back at the same port. Pots are normally 0-150k variable resistors (0-100k sometimes), and according to the IBM techref, the time is given by Time = 24.2e-6s + 0.011e-6s * R/Ohms (NOTE!! very different than first formula for time!) -tony