pub struct Controller { /* private fields */ }Expand description
One standard NES controller plugged into $4016 (player 1) or $4017
(player 2).
Implementations§
Source§impl Controller
impl Controller
Set the current button state. Takes effect on the next strobe edge (or immediately, while strobe is held high).
Get the current button state.
Sourcepub const fn write_strobe(&mut self, value: u8)
pub const fn write_strobe(&mut self, value: u8)
Handle a write to $4016. Only bit 0 matters for the standard
controller. While strobe is held high the shift register continuously
reloads from the live button state.
Sourcepub const fn read(&mut self, continues_run: bool) -> u8
pub const fn read(&mut self, continues_run: bool) -> u8
Handle a read of $4016 / $4017. Returns the LSB of the shift
register and shifts. While strobe is held high, the LSB is always
the A button (bit 0 of buttons).
Per the wiki, when the shift register has been emptied subsequent
reads return 1.
continues_run is true when the immediately preceding CPU cycle was
also a read of this same port — the case an absolute-indexed
read-modify-write (SLO $4016,X) and a DMC-DMA-interrupted read both
produce. CLK stays low across such a run, so the register does not
advance between the reads and both see the same bit.
Trait Implementations§
Source§impl Clone for Controller
impl Clone for Controller
Source§fn clone(&self) -> Controller
fn clone(&self) -> Controller
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more