Struct VFrameTsCounter

Source
pub struct VFrameTsCounter<V, C> {
    pub vts: VFrameTs<V>,
    pub contention: C,
}
Expand description

A generic VFrameTs<V> based T-states counter.

Implements Clock for counting cycles when code is being executed by z80emu::Cpu.

Inserts additional T-states according to the contention model specified by generic parameters: V: VideoFrame and C: MemoryContention.

Fields§

§vts: VFrameTs<V>

The current value of the counter.

§contention: C

An instance implementing a MemoryContention trait.

Implementations§

Source§

impl<V, C> VFrameTsCounter<V, C>

Source

pub fn new(vc: Ts, hc: Ts, contention: C) -> Self

Constructs a new and normalized VFrameTsCounter from the given vertical and horizontal counter values.

§Panics

Panics when the given values lead to an overflow of the capacity of VideoTs.

Source

pub fn from_tstates(ts: FTs, contention: C) -> Self

Builds a normalized VFrameTsCounter from the given count of T-states.

§Panics

Panics when the given ts overflows the capacity of VideoTs.

Source

pub fn from_video_ts(vts: VideoTs, contention: C) -> Self

Builds a normalized VFrameTsCounter from the given count of T-states.

§Panics

Panics when the given ts overflows the capacity of VideoTs.

Source

pub fn from_vframe_ts(vfts: VFrameTs<V>, contention: C) -> Self

Builds a normalized VFrameTsCounter from the given count of T-states.

§Panics

Panics when the given ts overflows the capacity of VideoTs.

Source

pub fn is_contended_address(self, address: u16) -> bool

Methods from Deref<Target = VFrameTs<V>>§

Source

pub const EOF: VFrameTs<V>

Source

pub fn wrap_frame(&mut self)

Ensures the vertical counter is in the range: (-VSL_COUNT, VSL_COUNT) by calculating a remainder of the division of the vertical counter by VideoFrame::VSL_COUNT.

Trait Implementations§

Source§

impl<V: VideoFrame, C> AddAssign<u32> for VFrameTsCounter<V, C>

Source§

fn add_assign(&mut self, delta: u32)

Performs the += operation. Read more
Source§

impl<V: VideoFrame, C: MemoryContention> Clock for VFrameTsCounter<V, C>

Source§

type Limit = i16

This type is being used for an arbitrary representation of the limit argument when executing instructions. See Cpu::execute_with_limit for an explanation.
Source§

type Timestamp = VideoTs

This type is being used for timestamping the interactions between Cpu, Io and Memory implementations. Read more
Source§

fn is_past_limit(&self, limit: Self::Limit) -> bool

Should return true if the Clock has reached the given limit otherwise should return false.
Source§

fn add_irq(&mut self, _pc: u16) -> Self::Timestamp

This method should increase the counter by at least IRQ_ACK_CYCLE_TS 6 T-states. The method should return the timestamp that may be passed to Io::irq_data. It’s being used at the beginning of the maskable interrupt request/acknowledge cycle. The pc is a value of the program counter when the interrupt was accepted.
Source§

fn add_no_mreq(&mut self, address: u16, add_ts: NonZeroU8)

This method should increase the counter by at least the value given in add_ts. It’s being used by internal operations of the Cpu without any external access. The address given here is whatever was put on the address bus before.
Source§

fn add_m1(&mut self, address: u16) -> Self::Timestamp

This method should increase the counter by at least M1_CYCLE_TS 4 and should return the timestamp that may be passed to Memory::read_opcode. This method is also being used when the non-maskable interrupt is being accepted and while the Cpu is wasting cycles in the halted state.
Source§

fn add_mreq(&mut self, address: u16) -> Self::Timestamp

This method should increase the counter by at least the value given in MEMRW_CYCLE_TS 3 and should return the timestamp that may be passed to Memory::read_mem,
Source§

fn add_io(&mut self, port: u16) -> Self::Timestamp

This method should increase the counter by at least IO_CYCLE_TS 4 T-states and should return the timestamp that may be passed to Io::read_io or Io::write_io.
Source§

fn add_wait_states(&mut self, _bus: u16, wait_states: NonZeroU16)

This method should increase the counter by the value given in wait_states. A call to one of Io::read_io, Io::write_io or Io::irq_data may request such additional number of wait states to be added.
Source§

fn as_timestamp(&self) -> Self::Timestamp

Should return the current state of the Clock as a timestamp.
Source§

impl<V: Clone, C: Clone> Clone for VFrameTsCounter<V, C>

Source§

fn clone(&self) -> VFrameTsCounter<V, C>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug, C: Debug> Debug for VFrameTsCounter<V, C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V, C> Deref for VFrameTsCounter<V, C>

Source§

type Target = VFrameTs<V>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<V, C> DerefMut for VFrameTsCounter<V, C>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<V, C> From<VFrameTsCounter<V, C>> for VFrameTs<V>

Source§

fn from(vftsc: VFrameTsCounter<V, C>) -> VFrameTs<V>

Converts to this type from the input type.
Source§

impl<V, C> From<VFrameTsCounter<V, C>> for VideoTs

Source§

fn from(vftsc: VFrameTsCounter<V, C>) -> VideoTs

Converts to this type from the input type.
Source§

impl<V: Hash, C: Hash> Hash for VFrameTsCounter<V, C>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<V: Ord, C: Ord> Ord for VFrameTsCounter<V, C>

Source§

fn cmp(&self, other: &VFrameTsCounter<V, C>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<V: PartialEq, C: PartialEq> PartialEq for VFrameTsCounter<V, C>

Source§

fn eq(&self, other: &VFrameTsCounter<V, C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: PartialOrd, C: PartialOrd> PartialOrd for VFrameTsCounter<V, C>

Source§

fn partial_cmp(&self, other: &VFrameTsCounter<V, C>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<V: VideoFrame, C> SubAssign<u32> for VFrameTsCounter<V, C>

Source§

fn sub_assign(&mut self, delta: u32)

Performs the -= operation. Read more
Source§

impl<V: Copy, C: Copy> Copy for VFrameTsCounter<V, C>

Source§

impl<V: Eq, C: Eq> Eq for VFrameTsCounter<V, C>

Source§

impl<V, C> StructuralPartialEq for VFrameTsCounter<V, C>

Auto Trait Implementations§

§

impl<V, C> Freeze for VFrameTsCounter<V, C>
where C: Freeze,

§

impl<V, C> RefUnwindSafe for VFrameTsCounter<V, C>

§

impl<V, C> Send for VFrameTsCounter<V, C>
where C: Send, V: Send,

§

impl<V, C> Sync for VFrameTsCounter<V, C>
where C: Sync, V: Sync,

§

impl<V, C> Unpin for VFrameTsCounter<V, C>
where C: Unpin, V: Unpin,

§

impl<V, C> UnwindSafe for VFrameTsCounter<V, C>
where C: UnwindSafe, V: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<S, T> IntoSample<S> for T
where S: FromSample<T>,

Source§

fn into_sample(self) -> S

Convert to S a sample type from self.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.