pub struct Chip8 { /* private fields */ }Expand description
Struct representing the Chip-8 virtual machine.
Implementations§
Source§impl Chip8
impl Chip8
Sourcepub fn new(seed: u32) -> Self
pub fn new(seed: u32) -> Self
Creates a new Chip-8 virtual machine. We use a seed to initialize the random number generator for portability across environments.
Sourcepub fn frame_width(&self) -> u32
pub fn frame_width(&self) -> u32
Returns the width of the frame in pixels.
Sourcepub fn frame_height(&self) -> u32
pub fn frame_height(&self) -> u32
Returns the height of the frame in pixels.
Sourcepub fn speed(&self) -> u32
pub fn speed(&self) -> u32
Returns the speed of the virtual machine in instructions per second.
Sourcepub fn set_speed(&mut self, instructions_per_second: u32)
pub fn set_speed(&mut self, instructions_per_second: u32)
Sets the speed of the virtual machine in instructions per second.
Sourcepub fn update(&mut self, time_delta: u32)
pub fn update(&mut self, time_delta: u32)
This will progress the virtual machine by the given time delta. It takes into account any accumulated time from previous calls that were less than a full cycle. The time delta given is in microseconds.
Sourcepub fn frame(&self) -> FrameBuffer
pub fn frame(&self) -> FrameBuffer
Returns a copy of the frame buffer.
Sourcepub fn set_registers(&mut self, registers: Registers)
pub fn set_registers(&mut self, registers: Registers)
Sets the registers.
Sourcepub fn handle_key_event(&mut self, key: Key, state: KeyState)
pub fn handle_key_event(&mut self, key: Key, state: KeyState)
Passes a key event to the virtual machine.
Auto Trait Implementations§
impl Freeze for Chip8
impl RefUnwindSafe for Chip8
impl Send for Chip8
impl Sync for Chip8
impl Unpin for Chip8
impl UnwindSafe for Chip8
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more