Struct GameBoy

Source
pub struct GameBoy { /* private fields */ }
Expand description

The GameBoy is the main interface to the emulator.

Everything regarding emulation can be controlled from here.

Implementations§

Source§

impl GameBoy

Source

pub fn builder<RomP: AsRef<Path>>(rom_file: RomP) -> GameBoyBuilder

Initiate a builder object with a cartridge file.

Source

pub fn clock_for_frame(&mut self)

Clocks the Gameboy clock for the duration of one PPU frame.

This is good for timing emulation, you can call this function once and then render it.

Source

pub fn game_title(&self) -> &str

Return the game title string extracted from the cartridge.

Source

pub fn file_path(&self) -> &Path

The cartridge file path.

Source

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

Return the pixels buffer of the PPU at the current state.

The format of the pixel buffer is RGB, i.e. 3 bytes per pixel.

Source

pub fn audio_buffers(&mut self) -> AudioBuffers<'_>

Return the audio buffer of the APU at the current state.

We use &mut as it will also reset the buffers after using them

Source

pub fn press_joypad(&mut self, button: JoypadButton)

Change the state of the joypad button to pressed.

Source

pub fn release_joypad(&mut self, button: JoypadButton)

Change the state of the joypad button to released.

Source

pub fn connect_device(&mut self, device: Rc<RefCell<dyn SerialDevice>>)

Connect a serial device to the Gameboy.

Currently the gameboy can only be master, so the other device must be implemented as slave.

Source

pub fn disconnect_device(&mut self)

Disconnects the serial device if any is connected, else, nothing is done

Source

pub fn save_state<W: Write>(&self, writer: W) -> Result<(), SaveError>

Saves the whole current state of the emulator.

Source

pub fn load_state<R: Read + Seek>(&mut self, reader: R) -> Result<(), SaveError>

Loads the whole state of the emulator, if an error happened in the middle the emulator will keep functioning like normal, as it stores a backup recovery state before loading the new state.

Auto Trait Implementations§

§

impl Freeze for GameBoy

§

impl !RefUnwindSafe for GameBoy

§

impl !Send for GameBoy

§

impl !Sync for GameBoy

§

impl Unpin for GameBoy

§

impl !UnwindSafe for GameBoy

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> Same for T

Source§

type Output = T

Should always be Self
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.