pub struct ControlDeck { /* private fields */ }
Expand description

Represents an NES Control Deck

Implementations§

source§

impl ControlDeck

source

pub fn new(ram_state: RamState) -> Self

Create a NES ControlDeck.

source

pub fn load_rom<S: ToString, F: Read>( &mut self, name: S, rom: &mut F ) -> NesResult<()>

Loads a ROM cartridge into memory

Errors

If there is any issue loading the ROM, then an error is returned.

source

pub fn load_cpu(&mut self, cpu: Cpu)

source

pub const fn loaded_rom(&self) -> &Option<String>

source

pub const fn cart_battery_backed(&self) -> bool

source

pub fn sram(&self) -> &[u8]

source

pub fn load_sram(&mut self, sram: Vec<u8>)

source

pub fn wram(&self) -> &[u8]

source

pub fn frame_buffer(&mut self) -> &[u8]

Get a frame worth of pixels.

source

pub const fn frame_number(&self) -> u32

Get the current frame number.

source

pub const fn sample_rate(&self) -> f32

Audio sample rate.

source

pub fn audio_samples(&self) -> &[f32]

Get audio samples.

source

pub fn clear_audio_samples(&mut self)

Clear audio samples.

source

pub fn clock_rate(&mut self) -> f32

source

pub fn clock_instr(&mut self) -> NesResult<ControlFlow<usize, usize>>

Steps the control deck one CPU clock.

Errors

If CPU encounteres an invalid opcode, an error is returned.

source

pub fn clock_seconds( &mut self, seconds: f32 ) -> NesResult<ControlFlow<usize, usize>>

Steps the control deck the number of seconds.

Errors

If CPU encounteres an invalid opcode, an error is returned.

source

pub fn clock_seconds_inspect<F>( &mut self, seconds: f32, inspect: F ) -> NesResult<ControlFlow<usize, usize>>
where F: FnMut(&mut Cpu),

Steps the control deck the number of seconds with an inspection function, executed on every CPU clock.

Errors

This function will return an error if .

source

pub fn clock_frame(&mut self) -> NesResult<ControlFlow<usize, usize>>

Steps the control deck an entire frame

Errors

If CPU encounteres an invalid opcode, an error is returned.

source

pub fn clock_scanline(&mut self) -> NesResult<ControlFlow<usize, usize>>

Steps the control deck a single scanline.

Errors

If CPU encounteres an invalid opcode, an error is returned.

source

pub const fn cpu_corrupted(&self) -> bool

Returns whether the CPU is corrupted or not.

source

pub const fn cpu(&self) -> &Cpu

source

pub fn cpu_mut(&mut self) -> &mut Cpu

source

pub const fn ppu(&self) -> &Ppu

source

pub fn ppu_mut(&mut self) -> &mut Ppu

source

pub const fn apu(&self) -> &Apu

source

pub const fn mapper(&self) -> &Mapper

source

pub fn mapper_mut(&mut self) -> &mut Mapper

source

pub const fn four_player(&self) -> FourPlayer

Returns whether Four Score is enabled.

source

pub fn set_four_player(&mut self, four_player: FourPlayer)

Enable/Disable Four Score for 4-player controllers.

source

pub fn set_cycle_accurate(&mut self, enabled: bool)

Enable/Disable cycle accurate mode

source

pub fn joypad_mut(&mut self, slot: Slot) -> &mut Joypad

Returns a mutable reference to a joypad.

source

pub const fn zapper_pos(&self) -> (i32, i32)

Returns the zapper aiming position for the given controller slot.

source

pub fn trigger_zapper(&mut self)

Trigger Zapper gun for a given controller slot.

source

pub fn aim_zapper(&mut self, x: i32, y: i32)

Aim Zapper gun for a given controller slot.

source

pub fn set_filter(&mut self, filter: VideoFilter)

Set the image filter for video output.

source

pub fn connect_zapper(&mut self, enabled: bool)

Enable Zapper gun.

source

pub fn add_genie_code(&mut self, genie_code: String) -> NesResult<()>

Add NES Game Genie codes.

Errors

If genie code is invalid, an error is returned.

source

pub fn remove_genie_code(&mut self, genie_code: &str)

source

pub const fn channel_enabled(&self, channel: Channel) -> bool

Returns whether a given API audio channel is enabled.

source

pub fn toggle_channel(&mut self, channel: Channel)

Toggle one of the APU audio channels.

source

pub const fn is_running(&self) -> bool

Is control deck running.

Trait Implementations§

source§

impl Clock for ControlDeck

source§

fn clock(&mut self) -> usize

Steps the control deck a single clock cycle.

source§

fn clock_to(&mut self, _clocks: u64)

source§

impl Clone for ControlDeck

source§

fn clone(&self) -> ControlDeck

Returns a copy 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 ControlDeck

source§

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

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

impl Default for ControlDeck

source§

fn default() -> Self

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

impl Regional for ControlDeck

source§

fn region(&self) -> NesRegion

Get the NES format for the emulation.

source§

fn set_region(&mut self, region: NesRegion)

Set the NES format for the emulation.

source§

impl Reset for ControlDeck

source§

fn reset(&mut self, kind: Kind)

Resets the console.

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> 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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V