timer consts
This commit is contained in:
parent
28fb90c8d6
commit
7ff06f151e
|
@ -40,10 +40,6 @@ pub struct Cpu {
|
|||
cycle_start: Instant,
|
||||
}
|
||||
|
||||
// Hz
|
||||
const CLOCK_SPEED: usize = 4194304;
|
||||
const SPEEDUP: f64 = 1.;
|
||||
|
||||
impl Cpu {
|
||||
pub fn new(
|
||||
mut memory: Memory,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use crate::{
|
||||
processor::{Cpu, CLOCK_SPEED, SPEEDUP},
|
||||
processor::Cpu,
|
||||
util::{get_bit, set_bit},
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,8 @@ impl Timers {
|
|||
}
|
||||
}
|
||||
|
||||
// Hz
|
||||
const CLOCK_SPEED: usize = 4194304;
|
||||
// this will need to change when cgb mode is implemented
|
||||
// as it uses bit 5 in double speed mode
|
||||
const AUDIO_BIT: u8 = 4;
|
||||
|
@ -68,7 +70,7 @@ impl Cpu {
|
|||
pub(super) fn sleep(&mut self, machine_cycles: u8) {
|
||||
let secs = ((machine_cycles as f64) * 4.) / CLOCK_SPEED as f64;
|
||||
if let Some(remaining) =
|
||||
Duration::from_secs_f64(secs / SPEEDUP).checked_sub(self.cycle_start.elapsed())
|
||||
Duration::from_secs_f64(secs).checked_sub(self.cycle_start.elapsed())
|
||||
{
|
||||
spin_sleep::sleep(remaining);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue