pub struct SpeedrunTimer { /* private fields */ }Expand description
The timer. Feed it Self::observe once per frame, after the frame.
Implementations§
Source§impl SpeedrunTimer
impl SpeedrunTimer
Sourcepub const fn new(def: SplitsDefinition, region: Region) -> Self
pub const fn new(def: SplitsDefinition, region: Region) -> Self
A timer for def, timing in region’s master clock.
Sourcepub const fn definition(&self) -> &SplitsDefinition
pub const fn definition(&self) -> &SplitsDefinition
The definition being timed.
Sourcepub const fn state(&self) -> TimerState
pub const fn state(&self) -> TimerState
The current state.
Sourcepub const fn start_clock(&self) -> u64
pub const fn start_clock(&self) -> u64
The master clock the run started at (meaningful once started).
Sourcepub fn elapsed(&self) -> u64
pub fn elapsed(&self) -> u64
Cycles since the start: live while running, the final time once finished, 0 when idle.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Return to idle and clear every hit count, as if just created (the operand history is kept: time did not jump).
Sourcepub fn observe(
&mut self,
master_clock: u64,
frame: u64,
read: impl FnMut(u32) -> u8,
) -> Option<TimerEvent>
pub fn observe( &mut self, master_clock: u64, frame: u64, read: impl FnMut(u32) -> u8, ) -> Option<TimerEvent>
Observe the end of a frame: master_clock and frame are the
console’s counters now (on crate::Nes, cpu().master_clock() and
frame()), and read peeks a RetroAchievements flat address
(unmapped addresses should read 0; Self::observe_nes does this).
Sourcepub fn observe_nes(&mut self, nes: &mut Nes) -> Option<TimerEvent>
pub fn observe_nes(&mut self, nes: &mut Nes) -> Option<TimerEvent>
Self::observe against a live console, after its frame.
Trait Implementations§
Source§impl Clone for SpeedrunTimer
impl Clone for SpeedrunTimer
Auto Trait Implementations§
impl Freeze for SpeedrunTimer
impl RefUnwindSafe for SpeedrunTimer
impl Send for SpeedrunTimer
impl Sync for SpeedrunTimer
impl Unpin for SpeedrunTimer
impl UnsafeUnpin for SpeedrunTimer
impl UnwindSafe for SpeedrunTimer
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