From dfdeb66b10c1c1af8243c475bca69839e2bdd6e8 Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 14 Nov 2017 12:30:05 -0500 Subject: ... --- src/main.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 54885ca..cef6d4c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -186,6 +186,7 @@ fn main() { mem.init(&mut cpu, &mut ppu); let mut cnt = 0; let mut cnt2 = 0; + let mut flag = false; loop { if win.poll() {break} cpu.step(); @@ -196,9 +197,16 @@ fn main() { if ppu.tick() { println!("triggering nmi"); cpu.trigger_nmi(); - println!("{} cpu {} ppu per frame", cnt, cnt2); - cnt2 = 0; - cnt = 0; + } + if ppu.get_flag_vblank() { + if !flag { + println!("{} cpu {} ppu per frame", cnt, cnt2); + cnt2 = 0; + cnt = 0; + flag = true; + } + } else { + flag = false; } } cpu.cycle -= 1; -- cgit v1.2.3-70-g09d2