aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 11 insertions, 3 deletions
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;