pub struct Gb<E: Executor = DirectExecutor> {
pub cpustate: Gbz80State,
pub mmu: Box<GbMmu>,
pub button_states: ButtonStates,
pub serial: SerialState,
pub timer: TimerState,
pub apu: ApuState,
pub ppu: PpuState,
/* private fields */
}Expand description
Represents a “real” gameboy, by explicitly using the GbMmu for memory.
Fields§
§cpustate: Gbz80StateState of the CPU in the system.
mmu: Box<GbMmu>MMU for the system.
Joypad button states
serial: SerialStateState of serial data transfer.
timer: TimerStateState of timer updates
apu: ApuStateState of audio rendering
ppu: PpuStateState of video rendering
Implementations§
Source§impl Gb<MicrocodeExecutor>
impl Gb<MicrocodeExecutor>
Sourcepub fn new_microcode(bios: BiosRom, cart: Cartridge) -> Self
pub fn new_microcode(bios: BiosRom, cart: Cartridge) -> Self
Create a Gb with the given bios and cartridge, using the microcode executor
Source§impl Gb<DirectExecutorV2>
impl Gb<DirectExecutorV2>
Source§impl Gb<SteppingExecutor>
impl Gb<SteppingExecutor>
Sourcepub fn new_stepping(bios: BiosRom, cart: Cartridge) -> Self
pub fn new_stepping(bios: BiosRom, cart: Cartridge) -> Self
Create a Gb with the given bios and cartridge, using the stepping executor
Source§impl<E> Gb<E>
impl<E> Gb<E>
Sourcepub fn for_executor(bios: BiosRom, cart: Cartridge) -> Self
pub fn for_executor(bios: BiosRom, cart: Cartridge) -> Self
Create a Gb with the given bios and cartridge, using the executor specified by
this type. Works for executors with state types that implement Default.
Source§impl<E: Executor> Gb<E>
impl<E: Executor> Gb<E>
Sourcepub fn for_config<C>(bios: BiosRom, cart: Cartridge, config: &C) -> Selfwhere
C: ExecutorConfig<Executor = E>,
pub fn for_config<C>(bios: BiosRom, cart: Cartridge, config: &C) -> Selfwhere
C: ExecutorConfig<Executor = E>,
Create a Gb with the given bios and cartridge, using the provided config to
create the initial state of the executor.
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Tick forward by one instruction, executing background and graphics processing operations as needed.
Sourcepub fn set_sample_rate(&mut self, sample_rate: u32)
pub fn set_sample_rate(&mut self, sample_rate: u32)
Set the sample rate for the APU.
Sourcepub fn display_ready(&self) -> bool
pub fn display_ready(&self) -> bool
Returns true if the PPU finished a frame this tick and the display is ready to be sent out.
Sourcepub fn get_ready_frame(&self) -> Option<&[(u8, u8, u8)]>
pub fn get_ready_frame(&self) -> Option<&[(u8, u8, u8)]>
If the display is ready, get a reference to the PPU frame buffer.
Sourcepub fn elapsed_mcycles(&self) -> u64
pub fn elapsed_mcycles(&self) -> u64
Get the total number of mcycles elapsed since emulator start.
Sourcepub fn elapsed_time(&self) -> Duration
pub fn elapsed_time(&self) -> Duration
Get the total duration since the emulator started (based on the number of m-cycles elapsed.