|
|
|
@@ -141,34 +141,27 @@ int nes_ppu_run(nes_ppu* ppu, int cycles) { |
|
|
|
|
|
|
|
ppu->cycle += cycles; |
|
|
|
|
|
|
|
if ( 0 != ppu->hit_line && |
|
|
|
ppu->scanline > ppu->hit_line && |
|
|
|
ppu->cycle > ppu->hit_dot) { |
|
|
|
ppu->status |= ppu_Status_Hit; |
|
|
|
} |
|
|
|
|
|
|
|
while (ppu->cycle >= nes_ppu_dots) { |
|
|
|
ppu->cycle -= nes_ppu_dots; |
|
|
|
if ( ppu->scanline <= nes_ppu_prerender && |
|
|
|
if ( ppu->scanline < nes_ppu_prerender && |
|
|
|
(ppu->frame & 1)) { |
|
|
|
// Prerender line is one dot shorter in odd frames |
|
|
|
// Fake it by incrementing the cycle in this case |
|
|
|
// TODO: Only if actually rendering |
|
|
|
ppu->cycle++; |
|
|
|
} |
|
|
|
|
|
|
|
ppu->scanline++; |
|
|
|
if (ppu->scanline >= nes_ppu_prerender + |
|
|
|
nes_ppu_height + |
|
|
|
nes_ppu_postrender + |
|
|
|
nes_ppu_vblank) { |
|
|
|
|
|
|
|
if (ppu->scanline >= nes_ppu_frame) { |
|
|
|
ppu->status &= ~(ppu_Status_VBlank | ppu_Status_Hit); |
|
|
|
ppu->hit_line = 0; |
|
|
|
ppu->hit_dot = 0; |
|
|
|
ppu->scanline = 0; |
|
|
|
ppu->scanline -= nes_ppu_frame; |
|
|
|
ppu->frame++; |
|
|
|
// TODO: Render callback if vblank was previously set |
|
|
|
} else if (ppu->scanline >= nes_ppu_prerender + |
|
|
|
nes_ppu_height + |
|
|
|
nes_ppu_postrender) { |
|
|
|
// TODO: Render callback if vblank was previously set? |
|
|
|
|
|
|
|
} else if (ppu->scanline >= nes_ppu_active) { |
|
|
|
ppu->status |= ppu_Status_VBlank; |
|
|
|
if (ppu->control & ppu_Control_VBlank) { |
|
|
|
vblank = 1; |
|
|
|
@@ -176,6 +169,12 @@ int nes_ppu_run(nes_ppu* ppu, int cycles) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ( 0 != ppu->hit_line && |
|
|
|
ppu->scanline > ppu->hit_line && |
|
|
|
ppu->cycle > ppu->hit_dot) { |
|
|
|
ppu->status |= ppu_Status_Hit; |
|
|
|
} |
|
|
|
|
|
|
|
return vblank; |
|
|
|
} |
|
|
|
|
|
|
|
|