Struct Emulator

Source
pub struct Emulator { /* private fields */ }

Implementations§

Source§

impl Emulator

Source

pub fn create(core_path: &Path, rom_path: &Path) -> Emulator

§Panics

If the platform is not Windows, Mac, or Linux; if the dylib fails to load successfully; if any Emulator has been created on this thread but not yet dropped.

Source

pub fn get_library(&mut self) -> &Library

Source

pub fn get_symbol<'a, T>(&'a self, symbol: &[u8]) -> Option<Symbol<'a, T>>

Source

pub fn run(&mut self, inputs: [Buttons; 2])

Source

pub fn reset(&mut self)

Source

pub fn get_video_ram_size(&self) -> usize

Source

pub fn get_system_ram_size(&self) -> usize

Source

pub fn get_save_ram_size(&self) -> usize

Source

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

Source

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

Source

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

Source

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

Source

pub fn memory_regions(&self) -> Vec<MemoryRegion>

Source

pub fn memory_ref(&self, start: usize) -> Result<&[u8], RetroRsError>

§Errors

RetroRsError::RAMCopyNotMappedIntoMemoryRegionError: Returns an error if the desired address is not mapped into memory regions

Source

pub fn memory_ref_mut( &self, mr: &MemoryRegion, start: usize, ) -> Result<&mut [u8], RetroRsError>

§Errors

RetroRsError::RAMMapOutOfRangeError: The desired address is out of mapped range RetroRsError::RAMCopySrcOutOfBoundsError: The desired range is not in the requested region

Source

pub fn pixel_format(&self) -> retro_pixel_format

Source

pub fn framebuffer_size(&self) -> (usize, usize)

Source

pub fn framebuffer_pitch(&self) -> usize

Source

pub fn peek_audio_sample<AudioPeek, AudioPeekRet>( &self, f: AudioPeek, ) -> AudioPeekRet
where AudioPeek: FnOnce(&[i16]) -> AudioPeekRet,

Source

pub fn get_audio_sample_rate(&self) -> f64

Source

pub fn get_video_fps(&self) -> f64

Source

pub fn save(&self, bytes: &mut [u8]) -> bool

Source

pub fn load(&mut self, bytes: &[u8]) -> bool

Source

pub fn save_size(&self) -> usize

Source

pub fn clear_cheats(&mut self)

Source

pub fn set_cheat(&mut self, index: usize, enabled: bool, code: &str)

§Panics

May panic if code can’t be converted to a CString

Source

pub fn get_pixel( &self, x: usize, y: usize, ) -> Result<(u8, u8, u8), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Source

pub fn for_each_pixel( &self, f: impl FnMut(usize, usize, u8, u8, u8), ) -> Result<(), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Source

pub fn copy_framebuffer_rgb888( &self, slice: &mut [u8], ) -> Result<(), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Source

pub fn copy_framebuffer_rgba8888( &self, slice: &mut [u8], ) -> Result<(), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Source

pub fn copy_framebuffer_rgb332( &self, slice: &mut [u8], ) -> Result<(), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Source

pub fn copy_framebuffer_argb32( &self, slice: &mut [u32], ) -> Result<(), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Source

pub fn copy_framebuffer_rgba32( &self, slice: &mut [u32], ) -> Result<(), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Source

pub fn copy_framebuffer_rgba_f32x4( &self, slice: &mut [f32], ) -> Result<(), RetroRsError>

§Panics

Panics if the pixel format used by the core is not supported for reads.

§Errors

RetroRsError::NoFramebufferError: Emulator has not created a framebuffer.

Trait Implementations§

Source§

impl Drop for Emulator

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl FramebufferToImageBuffer for Emulator

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.