  A. General Information
  ----------------------
    The NES supports a myriad of input devices, including joypads, Zappers
    (light guns), and four-player devices.

    Joypad #1 and #2 are accessed via $4016 and $4017, respectively.

    The joypads are reset via a strobing-method: writing 1, then 0, to
    $4016. See Subsection H for information regarding "half-strobing."

    On a full strobe, the joypad's button status will be returned in a
    single-bit stream (D0). Multiple reads need to be made to read all the
    information about the controller.

      1 = A          9 = Ignored   17 = +--+
      2 = B         10 = Ignored   18 =    +-- Signature
      3 = SELECT    11 = Ignored   19 =    |
      4 = START     12 = Ignored   20 = +--+
      5 = UP        13 = Ignored   21 = 0
      6 = DOWN      14 = Ignored   22 = 0
      7 = LEFT      15 = Ignored   23 = 0
      8 = RIGHT     16 = Ignored   24 = 0

    See Subsection G for information about Signatures.


  B. The Zapper
  -------------
    The Zapper (otherwise known as the "Light Gun") simply uses bits
    within $4016 and $4017, described in Section 8. See bits D4, D3, and
    D0.

    It is possible to have two Zapper units connected to both joypad
    ports simultaneously.


  C. Four-player devices
  ----------------------
    Some NES games allow the use of a four-player adapter, extending the
    number of usable joypads from two (2) to four (4). Carts which use
    the quad-player device are Tengen's "Gauntlet II," and Nintendo's
    "RC Pro Am 2."

    All four (4) controllers read their status-bits from D0 of $4016 or
    $4017, as Subsection A states.

    For register $4016, reads #1-8 control joypad #1, and reads #9-16
    control joypad #3. For $4017, it is respective for joypad #2 and #4.

    The following is a list of read #s and their results.

      1 = A          9 = A         17 = +--+
      2 = B         10 = B         18 =    +-- Signature
      3 = SELECT    11 = SELECT    19 =    |
      4 = START     12 = START     20 = +--+
      5 = UP        13 = UP        21 = 0
      6 = DOWN      14 = DOWN      22 = 0
      7 = LEFT      15 = LEFT      23 = 0
      8 = RIGHT     16 = RIGHT     24 = 0

    See Subsection G for information about Signatures.


  D. Paddles
  ----------
    Taito's "Arkanoid"  uses a paddle as it's primary controller.

    The paddle position is read via D1 of $4017; the read data is inverted
    (0=1, 1=0). The first value read is the MSB, and the 8th value read is
    (obviously) the LSB. Valid value ranges are 98 to 242, where 98 rep-
    resents the paddle being turned completely counter-clockwise.

    For example, if %01101011 is read, the value would be NOT'd, making
    %10010100 which is 146.

    The paddle also contains one button, which is read via D1 of $4016. A
    value of 1 specifies that the button is being pressed.


  E. Power Pad
  ------------
    No information is currently available.


  F. R.O.B. (Robot Operated Buddy)
  --------------------------------
    No information is currently available.


  G. Signatures
  -------------
    A signature allows the programmer to detect if a device is connected
    to one of the four (4) ports or not, and if so, what type of device it
    is. Valid/known signatures are:

      %0000 = Disconnected
      %0001 = Joypad ($4016 only)
      %0010 = Joypad ($4017 only)


  H. Expansion ports
  ------------------
    The joypad strobing process requires dual writes: 1, then 0. If the
    strobing process is not completed, or occurs in a non-standard order,
    the joypads are no longer the item of communication: the expansion
    port is.

    For NES users, the expansion port is located on the bottom of the unit,
    covered by a small grey piece of plastic. Famicom users have a limited
    expansion port on the front of their unit, which was commonly used for
    joypads or turbo-joypads.

    Such an example of communicating with the expansion port would be the
    following code:

      LDA #%00000001
      STA $4016
      STA $4017           ; Begin read mode of expansion port
      LDA #%00000011      ; Write %110 to the expansion port
      STA $4016

    I have yet to encounter a cart which actually uses this method of
    communication.
