Reimplemented sleep for 60 FPS.

This commit is contained in:
Josh W 2023-11-26 20:25:19 -05:00
parent c1515b2bb9
commit f7de75a276

View file

@ -36,7 +36,7 @@ const TOTAL_GLYPH_ATLASES: u8 = 16 * 8;
// Total screen blocks = GLYPH_COLUMNS * GLYPH_ROWS // Total screen blocks = GLYPH_COLUMNS * GLYPH_ROWS
const TOTAL_SCREEN_BLOCKS: usize = 2000; const TOTAL_SCREEN_BLOCKS: usize = 2000;
const FPS_60_HERTZ: u32 = 1_000_000_000u32 / 60; const REFRESH_RATE: u32 = 1_000_000_000u32 / 60;
const BLINK_RATE: u128 = 266666666; const BLINK_RATE: u128 = 266666666;
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
@ -257,8 +257,11 @@ pub fn main() {
blink_tick += elapsed; blink_tick += elapsed;
} }
if (elapsed as u32) < REFRESH_RATE {
sleep(Duration::new(0, REFRESH_RATE - elapsed as u32));
}
render(&mut canvas, &atlases, &dos_screen, &blink_state); render(&mut canvas, &atlases, &dos_screen, &blink_state);
//sleep(Duration::new(0, FPS_60_HERTZ));
prev_tick = curr_tick; prev_tick = curr_tick;
} }