diff options
author | Determinant <[email protected]> | 2017-11-15 19:39:51 -0500 |
---|---|---|
committer | Determinant <[email protected]> | 2017-11-15 19:39:51 -0500 |
commit | 9de33f8af72240546d9af2d65731a5d64340209d (patch) | |
tree | f9e1c54ad65c82f07ac612e745b5acf26ac4d109 | |
parent | 7ced09699636956fe1c0e4bc9748d482c1b40239 (diff) |
...
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | src/ppu.rs | 7 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index c53068b..ca6219f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -228,9 +228,6 @@ fn main() { cpu.step(); //println!("cpu at 0x{:04x}", cpu.get_pc()); while cpu.cycle > 0 { - if ppu.tick() || ppu.tick() || ppu.tick() { - cpu.trigger_nmi(); - } cnt += 1; if cnt >= CYC_PER_FRAME { win.render(); @@ -239,13 +236,17 @@ fn main() { if duration_per_frame > e { let diff = duration_per_frame - e; sleep(diff); - //println!("{} faster", diff.subsec_nanos() as f64 / 1e6); + println!("{} faster", diff.subsec_nanos() as f64 / 1e6); } else { - //println!("{} slower", (e - duration_per_frame).subsec_nanos() as f64 / 1e6); + println!("{} slower", (e - duration_per_frame).subsec_nanos() as f64 / 1e6); } timer = Instant::now(); cnt -= CYC_PER_FRAME; } + + if ppu.tick() || ppu.tick() || ppu.tick() { + cpu.trigger_nmi(); + } cpu.cycle -= 1; } } @@ -89,7 +89,6 @@ impl<'a> PPU<'a> { #[inline] pub fn write_oamdata(&mut self, data: u8) { self.reg = data; - if self.rendering { return } unsafe { let oam_raw = transmute::<&mut[Sprite; 64], &mut[u8; 256]>(&mut self.oam); oam_raw[self.oamaddr as usize] = data; @@ -109,6 +108,9 @@ impl<'a> PPU<'a> { pub fn write_scroll(&mut self, data: u8) { self.reg = data; let data = data as u16; + if !(!(self.get_show_bg() || self.get_show_sp()) || self.get_flag_vblank()) { + println!("writing to scroll {} {}", self.scanline, self.cycle); + } match self.w { false => { self.t = (self.t & 0x7fe0) | (data >> 3); @@ -491,8 +493,7 @@ impl<'a> PPU<'a> { } let visible_line = self.scanline < 240; let pre_line = self.scanline == 261; - self.rendering = pre_line || visible_line; - if self.rendering && (self.get_show_bg() || self.get_show_sp()) { + if (pre_line || visible_line) && (self.get_show_bg() || self.get_show_sp()) { if pre_line && 279 < cycle && cycle < 305 { self.reset_y(); } else { |