About the standard controller regs

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
About the standard controller regs
by on (#95198)
The wiki shows registers $4016/17 in two different ways.

1 -link-
Code:
Input ($4016 write)
7  bit  0
---- ----
xxxx xxxS
        |
        +- Controller shift register strobe

Output ($4016/$4017 read)
7  bit  0
---- ----
xxxx xxxD
        |
        +- Serial controller data


2 -link-
Code:
$4016 (R)    ---4.3--0    Read data from controller port #1.


- After all, how does $4016/17 work exactly, specially on reads? Could someone clarify it?

by on (#95199)
A write to 4016 with bit 0000 0001 latches controller data from all controllers. Reads then come through 4016 with data being at positions 000* *00*, unless you include the expansion port which has some other bits. But the normal controller uses 0 to return data, while the zapper and vaus use the other bits in the middle of $4016 for their data.

by on (#95206)
The first link specifies how a specific peripheral sends its data, the second link describes the generic interface.

by on (#95225)
Nobody saw schematic diagram?
Image
As you can see, joypad port uses 3 bits of data bus: D0, D3 and D4. D0 for joypad buttons state, D3 and D4 for zapper state (as already told). But there are to additional bits which can be read: D1 and D2. But they are on extension connector. So, actually you can read 5 bits at once from extension connector or 3 bits from joypad connector. Question is how you will interpret those bits.