Input devices: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
(→‎Usage of port pins by hardware type: significant revision to table)
Line 52: Line 52:
== Usage of port pins by hardware type ==
== Usage of port pins by hardware type ==
{| class="wikitable"
{| class="wikitable"
!Device                     
|-
!<span style="font-size:60%">$4016</span><br/>D4
!rowspan="2" style="text-align: right;" valign="bottom"|signal
!<span style="font-size:60%">$4016</span><br/>D3
!colspan="3" style="border-left: 2px solid black;"|output
!<span style="font-size:60%">$4016</span><br/>D2
!colspan="6" style="border-left: 2px solid black;"|Joypad 1
!<span style="font-size:60%">$4016</span><br/>D1
!colspan="6" style="border-left: 2px solid black;"|Joypad 2
!<span style="font-size:60%">$4016</span><br/>D0
!style="border-left: 2px solid black;"|audio output
!<span style="font-size:60%">$4016</span><br/>CLK
|-
!<span style="font-size:60%">$4017</span><br/>D4
!style="border-left: 2px solid black;"|OUT2
!<span style="font-size:60%">$4017</span><br/>D3
!<span style="font-size:60%">$4017</span><br/>D2
!<span style="font-size:60%">$4017</span><br/>D1
!<span style="font-size:60%">$4017</span><br/>D0
!<span style="font-size:60%">$4017</span><br/>CLK
!OUT2
!OUT1
!OUT1
!OUT0
!OUT0
!/IRQ
!style="border-left: 2px solid black;"|/OE1
! AUDIO
!style="border-left: 2px solid gray;"|D4
! Note
!D3
 
!D2
!D1
!D0
!style="border-left: 2px solid black;"|/OE2
!style="border-left: 2px solid gray;"|D4
!D3
!D2
!D1
!D0
!style="border-left: 2px solid black;"|AUDIO
|-
|access method
|colspan="3" style="text-align: center; border-left: 2px solid black;"|write $4016
|style="border-left: 2px solid black;"|<ref>/OE1 is activated by reading $4016</ref>
|colspan="5" style="text-align: center; border-left: 2px solid gray;"|read $4016
|style="border-left: 2px solid black;"|<ref>/OE2 is activated by reading $4017</ref>
|colspan="5" style="text-align: center; border-left: 2px solid gray;"|read $4017
|style="border-left: 2px solid black;"|
|-
!style="text-align: left;"|available at
!colspan="3" style="border-left: 2px solid black;"|
!style="border-left: 2px solid black;"|
!colspan="5" style="border-left: 2px solid gray;"|
!style="border-left: 2px solid black;"|
!colspan="5" style="border-left: 2px solid gray;"|
!style="border-left: 2px solid black;"|
|-
|NES [[Controller port pinout|controller port]] 1
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|yes
|yes
|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|-
|Famicom controller 1 internal connection
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|-
|AV Famicom controller port 1
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|-
|NES [[Controller port pinout|controller port]] 2
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|yes
|yes
|
|
|yes
|style="border-left: 2px solid black;"|
|-
|Famicom controller 2 internal connection
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|yes
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|-
|AV Famicom controller port 2
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|-
|NES [[Expansion port#NES|expansion port]]
|style="border-left: 2px solid black;"|yes
|yes
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|yes
|yes
|yes
|yes
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|yes
|yes
|yes
|yes
|yes
|style="border-left: 2px solid black;"|yes
|-
|Famicom [[Expansion port#Famicom|expansion port]]
|style="border-left: 2px solid black;"|yes
|yes
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|yes
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|yes
|yes
|yes
|yes
|yes
|style="border-left: 2px solid black;"|yes
|-
!style="text-align: left;"|used by
!colspan="3" style="border-left: 2px solid black;"|
!style="border-left: 2px solid black;"|
!colspan="5" style="border-left: 2px solid gray;"|
!style="border-left: 2px solid black;"|
!colspan="5" style="border-left: 2px solid gray;"|
!style="border-left: 2px solid black;"|
|-
|[[Standard controller|Controller]] 1
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|-
|[[Standard controller|Controller]] 2
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|<ref>$4016 D2 is used by Famicom controller 2 for microphone input.</ref>
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|-
|Famicom expansion [[Standard controller|controller]] 1
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|yes
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|<ref>A Famicom expansion controller may connect the audio output signal to a headphone jack (for example: IQ502 joypad).</ref>
|-
|Famicom expansion [[Standard controller|controller]] 2
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|yes
|
|style="border-left: 2px solid black;"|
|-
|NES [[Four Score]] controller 1 & 3
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|-
|NES [[Four Score]] controller 2 & 4
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|
|yes
|style="border-left: 2px solid black;"|
|-
|[[Four Score|Hori 4 Players Adapter]] controller 1 & 3
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|yes
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|-
|[[Four Score|Hori 4 Players Adapter]] controller 2 & 4
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|yes
|
|style="border-left: 2px solid black;"|
|-
|NES [[Zapper]] in port 2
|style="border-left: 2px solid black;"|
|
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|yes
|yes
|
|
|
|style="border-left: 2px solid black;"|
|-
|Famicom [[Zapper]]
|style="border-left: 2px solid black;"|
|
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|yes
|yes
|
|
|
|style="border-left: 2px solid black;"|<ref>A Famicom zapper may use the audio output signal to emit gunshot sounds (for example: Casel Zapper).</ref>
|-
|NES [[Power Pad]] in port 2
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|yes
|yes
|
|
|
|style="border-left: 2px solid black;"|
|-
|[[Power Pad#Family Trainer Mat|Family Trainer Mat]]
|style="border-left: 2px solid black;"|yes
|yes
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|yes
|yes
|yes
|yes
|
|style="border-left: 2px solid black;"|
|-
|NES [[Arkanoid controller]] in port 2
|style="border-left: 2px solid black;"|
|
|yes
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|yes
|yes
|
|
|
|style="border-left: 2px solid black;"|
|-
|Famicom [[Arkanoid controller]]
|style="border-left: 2px solid black;"|
|yes
|
|style="border-left: 2px solid black;"|
|style="border-left: 2px solid gray;"|
|
|
|yes
|
|style="border-left: 2px solid black;"|yes
|style="border-left: 2px solid gray;"|
|
|
|yes
|
|style="border-left: 2px solid black;"|
|-
|-
<!-- Device                                                          !!4!!3!!2!!1!!0!!C!!4!!3!!2!!1!!0!!C!!2!!1!!0!!I!!A!! Note-->
|[[Family BASIC Keyboard]]
|[[Controller port pinout|Joypad1]]<br/>(NES Four Score Joypad 1 & 3) || || || || ||x||x|| || || || || || || || ||x|| || ||rowspan=4|<ref>AUDIO line can be used for pad which has audio jack to plug in headphones (for example: IQ502 joypad)</ref><ref>$4016 D2 can be uses as microphone input</ref>
|style="border-left: 2px solid black;"|yes
|-
|yes
|[[Controller port pinout|Joypad2]]<br/>(NES Four Score Joypad 2 & 4) || || ||FC|| || || || || || || ||x||x|| || ||x|| ||  
|yes
|-  
|style="border-left: 2px solid black;"|  
|[[Controller port pinout|Joypad3]]<br/>(Famicom)                    || || || ||x|| ||x|| || || || || || || || ||x|| ||  
|style="border-left: 2px solid gray;"|  
|  
|  
|  
|  
|style="border-left: 2px solid black;"|  
|style="border-left: 2px solid gray;"|yes
|yes
|yes
|yes
|  
|style="border-left: 2px solid black;"|  
|-
|-
|[[Controller port pinout|Joypad4]]<br/>(Famicom)                    || || || || || || || || || ||x|| ||x|| || ||x|| ||  
|[[Famicom 3D glasses]]
|-                                                                    
|style="border-left: 2px solid black;"|  
|Lightgun [[Zapper]]<br/>(NES P2/Famicom)                            || || || || || || ||x||x|| || || || || || || || || ||rowspan=2|<ref>AUDIO line can be used for emiting bullet shoot sounds (for example: Casel Zapper)</ref>
|yes
|-                                                                   
|  
|Lightgun [[Zapper]]<br/>(NES P1)                                    ||x||x|| || || || || || || || || || || || || || ||  
|style="border-left: 2px solid black;"|
|-                                                                   
|style="border-left: 2px solid gray;"|  
|[[Family BASIC Keyboard]]/Subor Keyboard                            || || || || || || ||x||x||x||x|| || ||x||x||x|| ||  
|  
|-                                                                    
|  
|[[Arkanoid controller]]<br/>(NES P2)                                || || || || || || ||x||x|| || || || || || ||x|| ||  
|  
|-                                                                    
|  
|[[Arkanoid controller]]<br/>(Famicom)                                || || || || || || || || || ||x|| || || ||x|| || ||  
|style="border-left: 2px solid black;"|  
|-                                                                   
|style="border-left: 2px solid gray;"|  
|Exercise Mat [[Power Pad]]<br/>(NES P2)                              || || || || ||x|| ||x||x|| || || || || || || || ||  
|  
|-                                                                   
|  
|Exercise Mat [[Power Pad]]<br/>(Famicom)                            || || ||x||x||x|| ||x||x||x||x|| || || || || || ||  
|  
|-                                                                  
|  
|[[Famicom 3D glasses]]                                              || || || || || || || || || || || || || ||x|| || ||  
|style="border-left: 2px solid black;"|  
|}
|}


<references/>
<references/>

Revision as of 14:01, 10 February 2022

The NES has two general-purpose controller ports on the front of the console, as well as a (rarely used) 48-pin expansion port underneath.

The Famicom's standard controllers are hardwired to the front of the unit, and a special 15-pin expansion port is commonly used for third-party controllers. The AV Famicom, however, features detachable controllers using the same ports as the NES.

The NES and Famicom have a set of I/O ports used for controllers and other peripherals, consisting of the following:

  • One output port, 3 bits wide, accessible by writing the bottom 3 bits of $4016.
    • The values latched by $4016/write appear on the OUT0-OUT2 output pins of the 2A03/07, where OUT0 is routed to the controller ports and OUT0-OUT2 to the expansion port on the NES.
  • Two input ports, each 5 bits wide, accessible by reading the bottom 5 bits of $4016 and $4017. Reading $4016 and $4017 activates the /OE1 and /OE2 signals, respectively, which are routed to the controller ports and the expansion port.
    • On the NES, only D0, D3, and D4 are connected to both controller ports, while all of D0-D4 are connected to the expansion port.
    • On the original Famicom, the two ports differ: $4016 D0 and D2 and $4017 D0 are permanently connected to both controllers, while $4016 D1 and all of $4017's D0-D4 are connected to the expansion port.
    • On the AV Famicom, only D0 is connected to the controller ports. The expansion port is unchanged.

Programmer's reference

Hardware

Other I/O devices

Usage of port pins by hardware type

signal output Joypad 1 Joypad 2 audio output
OUT2 OUT1 OUT0 /OE1 D4 D3 D2 D1 D0 /OE2 D4 D3 D2 D1 D0 AUDIO
access method write $4016 [1] read $4016 [2] read $4017
available at
NES controller port 1 yes yes yes yes yes
Famicom controller 1 internal connection yes yes yes
AV Famicom controller port 1 yes yes yes
NES controller port 2 yes yes yes yes yes
Famicom controller 2 internal connection yes yes yes yes
AV Famicom controller port 2 yes yes yes
NES expansion port yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes yes
Famicom expansion port yes yes yes yes yes yes yes yes yes yes yes yes
used by
Controller 1 yes yes yes
Controller 2 yes [3] yes yes
Famicom expansion controller 1 yes yes yes [4]
Famicom expansion controller 2 yes yes yes
NES Four Score controller 1 & 3 yes yes yes
NES Four Score controller 2 & 4 yes yes yes
Hori 4 Players Adapter controller 1 & 3 yes yes yes
Hori 4 Players Adapter controller 2 & 4 yes yes yes
NES Zapper in port 2 yes yes
Famicom Zapper yes yes [5]
NES Power Pad in port 2 yes yes yes yes
Family Trainer Mat yes yes yes yes yes yes yes
NES Arkanoid controller in port 2 yes yes yes yes
Famicom Arkanoid controller yes yes yes yes
Family BASIC Keyboard yes yes yes yes yes yes yes
Famicom 3D glasses yes
  1. /OE1 is activated by reading $4016
  2. /OE2 is activated by reading $4017
  3. $4016 D2 is used by Famicom controller 2 for microphone input.
  4. A Famicom expansion controller may connect the audio output signal to a headphone jack (for example: IQ502 joypad).
  5. A Famicom zapper may use the audio output signal to emit gunshot sounds (for example: Casel Zapper).