framecounter improvement

This commit is contained in:
kirjavascript 2022-10-03 23:52:31 +01:00
parent 6f7f18e049
commit 965bdcf73c
2 changed files with 11 additions and 2 deletions

View file

@ -12,6 +12,13 @@ use gfx::Gfx;
// TODO: composit layers in gfx istead of multiple buffers
// just draw directly to layers
// just have two layers
// set version?? store in core
// or just have a parser to get the version
//
pub struct Megadrive {
pub core: ConfiguredCore<AutoInterruptController, mem::Mem>,

View file

@ -46,6 +46,7 @@ impl Default for FrameCounter {
}
impl FrameCounter {
/// returns frames to render
pub fn tick(&mut self) -> u64 {
let diff = Instant::now().duration_since(self.epoch);
let frames = (diff.as_millis() as f64 * 0.05992274) as u64; // TODO: PAL
@ -54,8 +55,9 @@ impl FrameCounter {
self.frames = frames;
self.frames_to_render
}
pub fn frames_to_render(&self) -> u64 {
self.frames_to_render
/// for unpausing
pub fn reset_epoch(&mut self) {
self.epoch = Instant::now();
}
}