pub struct ZapperState { /* private fields */ }Expand description
The NES Zapper light-gun overlay state.
Models the NES variant: bit 3 = light sensed (0 detected / 1 not), bit 4 =
trigger (1 pulled). Light detection samples the PPU framebuffer luminance at
the aim point once per frame (a frame-granular model — see light_seen).
Implementations§
Source§impl ZapperState
impl ZapperState
Sourcepub const fn set(&mut self, x: u16, y: u16, trigger: bool)
pub const fn set(&mut self, x: u16, y: u16, trigger: bool)
Update the live aim point + trigger state.
Sourcepub fn sample_light(&mut self, framebuffer: &[u8])
pub fn sample_light(&mut self, framebuffer: &[u8])
Sample the framebuffer luminance at the aim point, setting light_seen
if the pixel is bright enough. framebuffer is the PPU’s RGBA8 256x240
buffer. Called once per frame by the bus after the frame completes.
Sourcepub const fn read(&self) -> u8
pub const fn read(&self) -> u8
The device byte for a $4016/$4017 access. Bit 3 = light (0 detected /
1 not), bit 4 = trigger (1 pulled). Independent of the strobe (the
Zapper has no shift register). The caller ORs in the open-bus upper bits.
Sourcepub const fn from_parts(x: u16, y: u16, trigger: bool, light_seen: bool) -> Self
pub const fn from_parts(x: u16, y: u16, trigger: bool, light_seen: bool) -> Self
Reconstruct from save-state parts.
Sourcepub const fn trigger_raw(&self) -> bool
pub const fn trigger_raw(&self) -> bool
Raw trigger state (save-state).
Sourcepub const fn light_seen_raw(&self) -> bool
pub const fn light_seen_raw(&self) -> bool
Raw light-seen state (save-state).
Trait Implementations§
Source§impl Clone for ZapperState
impl Clone for ZapperState
Source§fn clone(&self) -> ZapperState
fn clone(&self) -> ZapperState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more