Casio PV-1000/Controller
The Casio PV-1000 Joystick is a 2-axis, 4-button joystick. Pictures are available here: https://commons.wikimedia.org/wiki/Category:Casio_PV-1000_accessories
Reading its status is much like one how one reads the buttons on a Game Boy.
Input (port $FD write)
7 bit 0 ---- ---- xxxx ABCD |||| |||+-- 1: include information about joysticks' "Attack" buttons ||+--- 1: include information about joysticks' up and left directions |+---- 1: include information about joysticks' down and right directions +----- 1: include information about joysticks' start and select buttons
Output (port $FD read)
7 bit 0 ---- ---- xxxx ABCD |||| |||+-- 1: if Player 1 "Attack", left, down, or select was pressed, depending on above ||+--- 1: if Player 1 "Attack", up, right, or start was pressed |+---- 1: if Player 2 "Attack", left, down, or select +----- 1: if Player 2 "Attack", up, right, or start
A 2-position-2-pole switch on the controller lets each player swap the two "Attack" buttons, so there is no consistent mapping of "button at tip of joystick" vs "button above start and select buttons" to which bit above.
Hardware
The values written to port $FD appear on the pins of the ULA. The voltages are then current-limited by four 10kΩ resistors, where they go to the joystick ports, through diodes in the joystick, and if the relevant button is pressed, back to the joystick port to a 330pF capacitor and then back to the ULA.
This means that it takes approximately 12 T-states after the selection is written before a pressed button can be detected. Since a Z80 IN instruction takes 11-12 T states all by itself, this is not a timing constraint.
However if a button is not pressed, the 330pF capacitor is instead discharged by a 56kΩ resistor on the mainboard. This means it takes approximately 56 T-states after the selection is made before an unpressed button can be detected.
ULA----10kΩ----jack----|>|----button----jack----+----+----10kΩ----ULA 330pF 56kΩ | | gnd gnd