[−][src]Struct olympia_engine::gameboy::GameBoy
Primary struct for an emulated gameboy.
Example usage:
// let cartridge_data: Vec<u8> = read_from_fs("my.rom"); let cartridge = Cartridge::from_data(cartridge_data).unwrap(); let mut gb = GameBoy::new(cartridge, GameBoyModel::GameBoy); // in your event loop or elsewhere, at a 4mhz interval gb.step();
Fields
events: Rc<EventEmitter<Event>>
Implementations
impl GameBoy
[src]
pub fn new(cartridge: Cartridge, model: GameBoyModel) -> GameBoy
[src]
Creates a new gameboy.
Arguments
cartridge
is the currently inserted Cartridgemodel
is the model of gameboy this should represent. Note this should be set to the actual hardware type desired, not it's target mode. For a Game Boy Color in Game Boy mode, this should be set toGameBoyModel::GameBoyColor
. The actual emulated mode is detected based on whether the ROM declares itself to be Game Boy Color enhanced or exclusive.
pub fn add_exec_time(&mut self, time: f64)
[src]
pub fn read_memory_u8<A: Into<LiteralAddress>>(
&self,
addr: A
) -> MemoryResult<u8>
[src]
&self,
addr: A
) -> MemoryResult<u8>
Read a value from the given memory address.
pub fn write_memory_u8<A: Into<LiteralAddress>>(
&mut self,
addr: A,
val: u8
) -> MemoryResult<()>
[src]
&mut self,
addr: A,
val: u8
) -> MemoryResult<()>
Write a value to the given memory address.
pub fn read_memory_i8<A: Into<LiteralAddress>>(
&self,
addr: A
) -> MemoryResult<i8>
[src]
&self,
addr: A
) -> MemoryResult<i8>
Read an value at the given memory address as a signed integer.
This is primarily useful for reading the target of a JR instruction.
pub fn read_memory_u16<A: Into<LiteralAddress>>(
&self,
target: A
) -> MemoryResult<u16>
[src]
&self,
target: A
) -> MemoryResult<u16>
Read a 16-bit value from the address at target
Note that the value is read in little endian format.
This means that given 0xC000
= 0x12
and 0xC001
= 0x45
,
the value read will be 0x4512
pub fn write_memory_u16<A: Into<LiteralAddress>>(
&mut self,
target: A,
value: u16
) -> MemoryResult<()>
[src]
&mut self,
target: A,
value: u16
) -> MemoryResult<()>
Write a 16-bit value to the address at target
Note that the value is written in little endian format.
This means that given value of 0xABCD
and target
of 0xC000
then 0xC000
will be set to 0xCD
and 0xC001
will be set to 0xAB
pub fn read_register_u16(&self, reg: WordRegister) -> u16
[src]
Read a value from the given 16-bit CPU register
pub fn write_register_u16(&mut self, reg: WordRegister, val: u16)
[src]
Write a value to a given 16-bit CPU register
pub fn read_register_u8(&self, reg: ByteRegister) -> u8
[src]
Read a value from the given 8-bit CPU register
pub fn write_register_u8(&mut self, reg: ByteRegister, val: u8)
[src]
Write a value to the given 8-bit CPU register
pub fn power_saving_mode(&self) -> PowerSavingMode
[src]
pub fn set_power_saving_mode(&mut self, mode: PowerSavingMode)
[src]
pub fn read_flag(&self, flag: Flag) -> bool
[src]
pub fn set_flag_to(&mut self, flag: Flag, value: bool)
[src]
pub fn step(&mut self) -> StepResult<()>
[src]
Runs a single instruction.
Note that this instruction may take multiple machine cycles to
execute. All components of the gameboy will run for this many machine
cycles. To find out how many clocks elapsed, use GameBoy::clocks_elapsed
.
pub fn current_instruction(&self) -> StepResult<Box<dyn RuntimeInstruction>>
[src]
Returns the instruction at the current PC.
pub fn clocks_elapsed(&self) -> u64
[src]
Query how many CPU clocks have elapsed since the emulator started
pub fn cycles_elapsed(&self) -> u64
[src]
Query how many machine cycles have elapsed since the emulator started
Each machine cycle represents 4 CPU clocks.
pub fn time_elapsed(&self) -> f64
[src]
Query much clock time has been spent emulating
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,