Trait z80emu::z80::Flavour

source ·
pub trait Flavour: Clone + Copy + Default + PartialEq + Eq {
    const CONSTANT_OUT_DATA: u8;
    const ACCEPTING_INT_RESETS_IFF2_EARLY: bool;

    // Required methods
    fn tag() -> &'static str;
    fn memptr_mix(msb: u8, lsb: u8) -> (u8, u8);
    fn begin_instruction(&mut self);
    fn flags_modified(&mut self);
    fn get_q(&self, acc: u8, flags: CpuFlags) -> u8;
    fn cpu_into_any(cpu: Z80<Self>) -> Z80Any;
    fn unwrap_cpu_any(cpu_any: Z80Any) -> Z80<Self>;

    // Provided method
    fn reset(&mut self) { ... }
}
Expand description

A trait for implementing exceptions to the undocumented Z80 behaviour.

It’s been reported that depending on the CPU technology (NMOS, CMOS) and the manufacturer (Zilog, NEC, other clones) there are certain differences of undocumented behaviour and mainly affects the way the Flags’ undocumented bits 3 and 5 are being modified.

Required Associated Constants§

source

const CONSTANT_OUT_DATA: u8

The value being actually put on the data bus while executing the undocumented instruction OUT (C),(HL).

source

const ACCEPTING_INT_RESETS_IFF2_EARLY: bool

Should be true if the IFF2 is being reset early when accepting an interrupt, while an instruction is being executed, so LD A,I or LD A,R may report modified IFF2 value.

Required Methods§

source

fn tag() -> &'static str

Returns the string identifier of this flavour.

source

fn memptr_mix(msb: u8, lsb: u8) -> (u8, u8)

The way MEMPTR is being updated for: LD (nnnn),A, LD (BC),A, LD (DE),A and OUT (nn),A is being controlled by this function. The current Accumulator value is being passed as msb and the lower 8-bits of the current destination address is being provided as lsb. The function should return the (MSB, LSB) value to set the MEMPTR with.

source

fn begin_instruction(&mut self)

This method is being called each time before an instructions is being executed or an interrupt is being accepted, including NMI. It might modify some state and is being used together with Flavour::flags_modified and Flavour::get_q to prepare a value applied to bits 3 and 5 of the Flags for the SCF/CCF instructions.

source

fn flags_modified(&mut self)

This method is being called each time an instructions modifies the Flags register.

source

fn get_q(&self, acc: u8, flags: CpuFlags) -> u8

Bits 3 and 5 of the returned value will be copied to the Flags register.

source

fn cpu_into_any(cpu: Z80<Self>) -> Z80Any

Converts a Z80 struct of this flavour into an Z80Any enum.

source

fn unwrap_cpu_any(cpu_any: Z80Any) -> Z80<Self>

Returns the contained Z80<Self> value, consuming the cpu value.

§Panics

Panics if the cpu_any value is not a variant corresponding to this Flavour.

Provided Methods§

source

fn reset(&mut self)

Should reset the state. Called by crate::Cpu::reset. The default implementation resets the state to default.

Object Safety§

This trait is not object safe.

Implementors§