Expand description
Fixed-timestep game clock shared by every PSoXide game.
Game logic runs in fixed ticks of a whole number of VBlanks; rendering runs
as often as the frame cost allows and shows the latest tick (optionally
interpolated with FixedClock::phase_q12). Logic speed then never
depends on how long a frame takes to draw.
Each game picks its own TickConfig (tick rate and catch-up policy);
the functions are the same everywhere, so behaviour and the
TickStats consistency counters mean the same thing in every game.
The clock never reads hardware. Callers pass the current VBlank count
(psx_rt::interrupts::vblank_count() on the console), which keeps every
rule host-testable.
use psx_tick::{FixedClock, TickConfig, TickRate};
let now = 100;
let mut clock = FixedClock::new(TickConfig::new(TickRate::HZ60), now);
// A frame that took three VBlanks owes three ticks.
let mut ran = 0;
while clock.due(now + 2) {
ran += 1; // simulate one tick
}
clock.end_frame();
assert_eq!(ran, 3);Structs§
- Fixed
Clock - Fixed-timestep clock. See the crate docs.
- Tick
Config - A game’s clock settings.
- Tick
Rate - Tick length in VBlanks: 1 is 60 Hz on NTSC, 2 is 30 Hz, 3 is 20 Hz.
- Tick
Stats - Frame-consistency counters since construction or
FixedClock::reset_stats.
Enums§
- CatchUp
- What to do when a frame falls further behind than the game allows.
Constants§
- TICK_
HISTOGRAM_ BUCKETS - Buckets in
TickStats::ticks_per_frame; the last one collects every frame with that many ticks or more.