Don't recalculate vblank time on every step.

This commit is contained in:
Seth Morabito 2018-12-27 09:34:20 -08:00
parent 2da0a49574
commit 91c8817585
2 changed files with 6 additions and 8 deletions

View File

@ -307,10 +307,10 @@ fn dmd_set_nvram(nvram: &[u8; 8192]) -> c_int {
}
#[no_mangle]
fn dmd_get_nvram(nvram: &mut [u8]) -> c_int {
fn dmd_get_nvram(nvram: &mut [u8; 8192]) -> c_int {
match DMD.lock() {
Ok(dmd) => {
nvram.clone_from_slice(&dmd.get_nvram());
nvram.clone_from_slice(dmd.get_nvram());
SUCCESS
}
Err(_) => ERROR

View File

@ -142,7 +142,7 @@ pub struct Duart {
istat: u8,
imr: u8,
ivec: u8,
last_vblank: Instant,
next_vblank: Instant
}
impl Default for Duart {
@ -165,15 +165,13 @@ impl Duart {
istat: 0,
imr: 0,
ivec: 0,
last_vblank: Instant::now(),
next_vblank: Instant::now() + Duration::new(0, VERTICAL_BLANK_DELAY),
}
}
pub fn get_interrupt(&mut self) -> Option<u8> {
let new_vblank_time: Instant = self.last_vblank + Duration::new(0, VERTICAL_BLANK_DELAY);
if Instant::now() > new_vblank_time {
self.last_vblank = Instant::now();
if Instant::now() > self.next_vblank {
self.next_vblank = Instant::now() + Duration::new(0, VERTICAL_BLANK_DELAY);
self.vertical_blank();
}