tick updates Cycle, ScanLine and Frame counters
()
| 644 | |
| 645 | // tick updates Cycle, ScanLine and Frame counters |
| 646 | func (ppu *PPU) tick() { |
| 647 | if ppu.nmiDelay > 0 { |
| 648 | ppu.nmiDelay-- |
| 649 | if ppu.nmiDelay == 0 && ppu.nmiOutput && ppu.nmiOccurred { |
| 650 | ppu.console.CPU.triggerNMI() |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | if ppu.flagShowBackground != 0 || ppu.flagShowSprites != 0 { |
| 655 | if ppu.f == 1 && ppu.ScanLine == 261 && ppu.Cycle == 339 { |
| 656 | ppu.Cycle = 0 |
| 657 | ppu.ScanLine = 0 |
| 658 | ppu.Frame++ |
| 659 | ppu.f ^= 1 |
| 660 | return |
| 661 | } |
| 662 | } |
| 663 | ppu.Cycle++ |
| 664 | if ppu.Cycle > 340 { |
| 665 | ppu.Cycle = 0 |
| 666 | ppu.ScanLine++ |
| 667 | if ppu.ScanLine > 261 { |
| 668 | ppu.ScanLine = 0 |
| 669 | ppu.Frame++ |
| 670 | ppu.f ^= 1 |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | // Step executes a single PPU cycle |
| 676 | func (ppu *PPU) Step() { |