MCPcopy
hub / github.com/fogleman/nes / tick

Method tick

nes/ppu.go:646–673  ·  view source on GitHub ↗

tick updates Cycle, ScanLine and Frame counters

()

Source from the content-addressed store, hash-verified

644
645// tick updates Cycle, ScanLine and Frame counters
646func (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
676func (ppu *PPU) Step() {

Callers 1

StepMethod · 0.95

Calls 1

triggerNMIMethod · 0.80

Tested by

no test coverage detected