Port 201H is designated as the Game Adapter Port or Joystick Port.  It is
not supported by the PC/XT BIOS, but AT BIOS service INT 15H 84H provides
an easy-to-use interface for the adapter.

It is an analog-to-digital converter which can be used by scientific
measuring tools and other devices which present an analog (resistive)
input to the interface.  It accepts up to four digital inputs (on/off data
such as the press of a button) and up to four resistive inputs (such as an
X-ordinate of a joystick or a temperature value from an electronic
thermometer).

The value obtained by an IN from 201H is as diagrammed:

  7  6  5  4  3  2  1  0 
 B2 B1 A2 A1 By Bx Ay Ax 
                         
                          Coordinates (resistive, time-dependent inputs)
                     Buttons/Triggers (digital inputs)

You can read the buttons (digital inputs)  with:

mov   dx,201H
out   dx,al      ;initiate transaction; AL=anything
in    al,dx      ;read bits 4-7 for buttons: 0=pressed, 1=open

The joysticks, paddles, measuring devices (resistive inputs) are read by
tracking the time that an X or Y bit stays high (1) after an OUT 201,xxx.
To read an individual resistive input (e.g., joystick A, X ordinate):

mov   dx,201H
out   dx,al      ;initiate transaction  AL=anything
mov   cx,-1      ;set resistance counter for first loop
again: in    al,dx      ;read the settings
inc   cx         ;bump counter
test  al,1       ;has X-ordinate for joystick A gone low?
jnz   again      ;loop until it does (when bit=0, we're done)

The delay value accumulated in CX will indicate the X-ordinate position of
joystick A.  The resulting value is CPU-dependent.  To ensure accuracy, it
would be better to use a hardware timer, rather than a loop counter.

See Also: INT 15H 84H (joystick support)
- -

Game I/O Adapter Port