Skip to main content

KonamiHyperShotState

Struct KonamiHyperShotState 

Source
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 Jump

The 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

Source

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).

Source

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.

Source

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).

Source

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.

Source

pub const fn peek(&self) -> u8

Side-effect-free sample (debugger peek) — identical to Self::read.

Source

pub const fn from_parts(buttons: u8, p1_enabled: bool, p2_enabled: bool) -> Self

Reconstruct from save-state parts.

Source

pub const fn buttons_raw(&self) -> u8

Raw button mask (save-state).

Source

pub const fn p1_enabled_raw(&self) -> bool

Raw P1-enable (save-state).

Source

pub const fn p2_enabled_raw(&self) -> bool

Raw P2-enable (save-state).

Trait Implementations§

Source§

impl Clone for KonamiHyperShotState

Source§

fn clone(&self) -> KonamiHyperShotState

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KonamiHyperShotState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for KonamiHyperShotState

Source§

fn default() -> KonamiHyperShotState

Returns the “default value” for a type. Read more
Source§

impl Copy for KonamiHyperShotState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.