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

Method renderPixel

nes/ppu.go:535–567  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

533}
534
535func (ppu *PPU) renderPixel() {
536 x := ppu.Cycle - 1
537 y := ppu.ScanLine
538 background := ppu.backgroundPixel()
539 i, sprite := ppu.spritePixel()
540 if x < 8 && ppu.flagShowLeftBackground == 0 {
541 background = 0
542 }
543 if x < 8 && ppu.flagShowLeftSprites == 0 {
544 sprite = 0
545 }
546 b := background%4 != 0
547 s := sprite%4 != 0
548 var color byte
549 if !b && !s {
550 color = 0
551 } else if !b && s {
552 color = sprite | 0x10
553 } else if b && !s {
554 color = background
555 } else {
556 if ppu.spriteIndexes[i] == 0 && x < 255 {
557 ppu.flagSpriteZeroHit = 1
558 }
559 if ppu.spritePriorities[i] == 0 {
560 color = sprite | 0x10
561 } else {
562 color = background
563 }
564 }
565 c := Palette[ppu.readPalette(uint16(color))%64]
566 ppu.back.SetRGBA(x, y, c)
567}
568
569func (ppu *PPU) fetchSpritePattern(i, row int) uint32 {
570 tile := ppu.oamData[i*4+1]

Callers 1

StepMethod · 0.95

Calls 3

backgroundPixelMethod · 0.95
spritePixelMethod · 0.95
readPaletteMethod · 0.95

Tested by

no test coverage detected