pub struct KonamiHyperShotState { /* private fields */ }Expand description
The Konami Hyper Shot overlay state (v1.3.0 Workstream F1).
A simple 4-button expansion controller (two players, each with a Run and a
Jump button) used by Hyper Olympic / Hyper Sports. Per the NESdev
“Konami Hyper Shot” page it is read in parallel on $4017 (no shift
register), with $4016 writes selecting which player’s buttons are
enabled:
$4016 write: $4017 read:
7 bit 0 7 bit 0
---- ---- ---- ----
xxxx xEFx xxxD CBAx
|| | |||
|+- 0 = enable P1 | ||+-- P1 Run
+-- 0 = enable P2 | |+--- P1 Jump
| +---- P2 Run
+------ P2 JumpThe Jump/Run bits for a player read 0 while that player’s enable bit
($4016 bit 1 for P1, bit 2 for P2) is set (i.e. disabled). Determinism
holds: the read is a pure function of the live button mask + the last write.
Implementations§
Source§impl KonamiHyperShotState
impl KonamiHyperShotState
Sourcepub const fn new() -> Self
pub const fn new() -> Self
New controller with no buttons held and both players enabled (the
power-on $4016 write has not happened yet; enable is active-low, so the
quiescent state matches a write of 0).
Sourcepub const fn set(&mut self, buttons: u8)
pub const fn set(&mut self, buttons: u8)
Set the live 4-button mask (bit 0 = P1 Run, 1 = P1 Jump, 2 = P2 Run, 3 = P2 Jump). Bits above 3 are ignored.
Sourcepub const fn write_strobe(&mut self, value: u8)
pub const fn write_strobe(&mut self, value: u8)
Handle a $4016 write: bit 1 = 0 enables P1, bit 2 = 0 enables P2
(active-low).
Sourcepub const fn read(&self) -> u8
pub const fn read(&self) -> u8
Read the device byte for a $4017 access. Bit 1 = P1 Run, bit 2 = P1
Jump, bit 3 = P2 Run, bit 4 = P2 Jump; a player’s bits read 0 while
disabled. The caller ORs in the open-bus upper bits.
Sourcepub const fn peek(&self) -> u8
pub const fn peek(&self) -> u8
Side-effect-free sample (debugger peek) — identical to Self::read.
Sourcepub const fn from_parts(buttons: u8, p1_enabled: bool, p2_enabled: bool) -> Self
pub const fn from_parts(buttons: u8, p1_enabled: bool, p2_enabled: bool) -> Self
Reconstruct from save-state parts.
Raw button mask (save-state).
Sourcepub const fn p1_enabled_raw(&self) -> bool
pub const fn p1_enabled_raw(&self) -> bool
Raw P1-enable (save-state).
Sourcepub const fn p2_enabled_raw(&self) -> bool
pub const fn p2_enabled_raw(&self) -> bool
Raw P2-enable (save-state).
Trait Implementations§
Source§impl Clone for KonamiHyperShotState
impl Clone for KonamiHyperShotState
Source§fn clone(&self) -> KonamiHyperShotState
fn clone(&self) -> KonamiHyperShotState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more