pub struct Z80<Q: Flavour> {
pub flavour: Q,
/* private fields */
}
Expand description
Emulates a Zilog’s Z80 CPU
in various “flavours” via the Cpu trait.
Fields§
§flavour: Q
Exposes an instance of the Flavour implementation.
Implementations§
source§impl<Q: Flavour> Z80<Q>
impl<Q: Flavour> Z80<Q>
sourcepub fn get_memptr(&self) -> u16
pub fn get_memptr(&self) -> u16
Retrieves the internal state of the MEMPTR register.
sourcepub fn set_memptr(&mut self, memptr: u16)
pub fn set_memptr(&mut self, memptr: u16)
Changes the internal state of the MEMPTR register.
sourcepub fn normalize_r(&mut self)
pub fn normalize_r(&mut self)
The content of the R
register is lazy evaluated when its value is being set or retrieved.
This method normalizes the internal state of the R
register, so e.g. two instances of
Z80 can be compared if they represent the same CPU
state.
sourcepub fn into_flavour<F>(self) -> Z80<F>
pub fn into_flavour<F>(self) -> Z80<F>
Trait Implementations§
source§impl<Q: Flavour> Cpu for Z80<Q>
impl<Q: Flavour> Cpu for Z80<Q>
source§fn add_r(&mut self, delta: i32)
fn add_r(&mut self, delta: i32)
Adds the arbitrary value to the memory refresh counter.
This can be used to emulate the Cpu in the HALT state without executing the busy loop.
source§fn halt(&mut self)
fn halt(&mut self)
Forces Cpu to enter the HALT state. This doesn’t involve Clock and happens instantly.
This also can be done by executing
HALT
instruction with Cpu::execute_instruction.source§fn get_im(&self) -> InterruptMode
fn get_im(&self) -> InterruptMode
Returns the current interrupt mode.
source§fn set_im(&mut self, im: InterruptMode)
fn set_im(&mut self, im: InterruptMode)
Sets the interrupt mode.
source§fn exx(&mut self)
fn exx(&mut self)
Swaps the
BC
, DE
and HL
registers with their alternative counterparts BC'
, DE'
and HL'
.source§fn get_reg(&self, reg: Reg8, prefix: Option<Prefix>) -> u8
fn get_reg(&self, reg: Reg8, prefix: Option<Prefix>) -> u8
Returns the content of the selected 8-bit register. Read more
source§fn set_reg(&mut self, dst: Reg8, prefix: Option<Prefix>, val: u8)
fn set_reg(&mut self, dst: Reg8, prefix: Option<Prefix>, val: u8)
Sets the content of the selected 8-bit register. Read more
source§fn get_reg2(&self, src: StkReg16) -> (u8, u8)
fn get_reg2(&self, src: StkReg16) -> (u8, u8)
Returns the content of the selected pair of registers as a tuple of 8-bit unsigned integers. Read more
source§fn get_alt_reg2(&self, src: StkReg16) -> (u8, u8)
fn get_alt_reg2(&self, src: StkReg16) -> (u8, u8)
Returns the content of the selected pair of alternative registers as a tuple of 8-bit unsigned integers. Read more
source§fn get_reg16(&self, src: StkReg16) -> u16
fn get_reg16(&self, src: StkReg16) -> u16
Returns the content of the selected pair of registers as an unsigned 16-bit integer.
source§fn get_alt_reg16(&self, src: StkReg16) -> u16
fn get_alt_reg16(&self, src: StkReg16) -> u16
Returns the content of the selected pair of alternative registers as an unsigned 16-bit integer.
source§fn set_reg2(&mut self, src: StkReg16, hi: u8, lo: u8)
fn set_reg2(&mut self, src: StkReg16, hi: u8, lo: u8)
Sets the content of the selected pair of registers. Read more
source§fn set_reg16(&mut self, src: StkReg16, val: u16)
fn set_reg16(&mut self, src: StkReg16, val: u16)
Sets the content of the selected pair of registers as an unsigned 16-bit integer.
source§fn get_index2(&self, prefix: Prefix) -> (u8, u8)
fn get_index2(&self, prefix: Prefix) -> (u8, u8)
Returns the content of one of the index registers as a tuple of 8-bit unsigned integers. Read more
source§fn get_index16(&self, prefix: Prefix) -> u16
fn get_index16(&self, prefix: Prefix) -> u16
Returns the content of one of the index registers as a 16-bit unsigned integer. Read more
source§fn set_index2(&mut self, prefix: Prefix, hi: u8, lo: u8)
fn set_index2(&mut self, prefix: Prefix, hi: u8, lo: u8)
Sets the content of one of the index registers. Read more
source§fn set_index16(&mut self, prefix: Prefix, val: u16)
fn set_index16(&mut self, prefix: Prefix, val: u16)
Sets the content of one of the index registers as a 16-bit unsigned integer. Read more
source§fn is_irq_allowed(&self) -> bool
fn is_irq_allowed(&self) -> bool
Returns true if the Cpu will accept the interrupt request before executing the next opcode.
source§fn is_nmi_allowed(&self) -> bool
fn is_nmi_allowed(&self) -> bool
Returns true if the Cpu will accept the non-maskable interrupt before executing the next opcode.
source§fn restore_iff1(&mut self)
fn restore_iff1(&mut self)
Restores the content of the
interrupt flip-flop 1
from the content of the interrupt flip-flop 2
.
This is what RETN
instruction usually does.source§fn disable_interrupts(&mut self)
fn disable_interrupts(&mut self)
Disables the maskable interrupts by resetting both
interrupt flip-flops
to Off. Read moresource§fn enable_interrupts(&mut self)
fn enable_interrupts(&mut self)
Enabes the maskable interrupts by setting both
interrupt flip-flops
to On. Read moresource§fn is_after_ei(&self) -> bool
fn is_after_ei(&self) -> bool
Returns
true
if the last command executed was EI
.source§fn is_after_prefix(&self) -> bool
fn is_after_prefix(&self) -> bool
source§fn get_prefix(&self) -> Option<Prefix>
fn get_prefix(&self) -> Option<Prefix>
Returns the prefix value after executing the last command. Read more
source§fn irq<M, T, F>(
&mut self,
control: &mut M,
tsc: &mut T,
debug: Option<F>
) -> Option<Result<M::WrIoBreak, M::RetiBreak>>
fn irq<M, T, F>( &mut self, control: &mut M, tsc: &mut T, debug: Option<F> ) -> Option<Result<M::WrIoBreak, M::RetiBreak>>
Requests a maskable interrupt. Read more
source§fn nmi<M, T>(&mut self, control: &mut M, tsc: &mut T) -> bool
fn nmi<M, T>(&mut self, control: &mut M, tsc: &mut T) -> bool
Attempts to trigger a non-maskable interrupt. Read more
source§fn execute_instruction<M, T, F>(
&mut self,
control: &mut M,
tsc: &mut T,
debug: Option<F>,
code: u8
) -> Result<M::WrIoBreak, M::RetiBreak>
fn execute_instruction<M, T, F>( &mut self, control: &mut M, tsc: &mut T, debug: Option<F>, code: u8 ) -> Result<M::WrIoBreak, M::RetiBreak>
Executes a single instruction given as
code
. If the instruction is a first byte of the multi-byte
instruction the rest of the instruction body will be fetched via calls to Memory::read_opcode. Read moresource§fn execute_next<M, T, F>(
&mut self,
control: &mut M,
tsc: &mut T,
debug: Option<F>
) -> Result<M::WrIoBreak, M::RetiBreak>
fn execute_next<M, T, F>( &mut self, control: &mut M, tsc: &mut T, debug: Option<F> ) -> Result<M::WrIoBreak, M::RetiBreak>
Executes the next instruction present in the Memory at the program counter fetched via Memory::read_opcode. Read more
source§impl<'de, Q> Deserialize<'de> for Z80<Q>where
Q: Flavour + Deserialize<'de>,
impl<'de, Q> Deserialize<'de> for Z80<Q>where
Q: Flavour + Deserialize<'de>,
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
source§impl<Q: PartialEq + Flavour> PartialEq for Z80<Q>
impl<Q: PartialEq + Flavour> PartialEq for Z80<Q>
impl<Q: Eq + Flavour> Eq for Z80<Q>
impl<Q: Flavour> StructuralPartialEq for Z80<Q>
Auto Trait Implementations§
impl<Q> RefUnwindSafe for Z80<Q>where
Q: RefUnwindSafe,
impl<Q> Send for Z80<Q>where
Q: Send,
impl<Q> Sync for Z80<Q>where
Q: Sync,
impl<Q> Unpin for Z80<Q>where
Q: Unpin,
impl<Q> UnwindSafe for Z80<Q>where
Q: UnwindSafe,
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