Created
September 12, 2012 04:10
-
-
Save scottferg/3704238 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (p *Ppu) renderTileRow() { | |
// 32 total loops for 32 tiles, 1 pixel of each | |
for x := 0; x < 32; x++ { | |
// for i := a; i < a+0x20; i++ { | |
attrAddr := 0x23C0 | (p.VramAddress & 0xC00) | int(p.AttributeLocation[p.VramAddress&0x3FF]) | |
shift := p.AttributeShift[p.VramAddress&0x3FF] | |
attr := ((p.Vram[attrAddr] >> shift) & 0x03) << 2 | |
ntAddress := p.selectNametable((p.VramAddress & 0xC00) >> 10) | |
t := p.bgPatternTableAddress(p.Vram[(p.VramAddress&0x3FF)+ntAddress]) | |
tile := p.Vram[t : t+16] | |
p.decodePatternTile([]Word{tile[p.TilerowCounter], tile[p.TilerowCounter+8]}, x*8, p.Scanline, p.bgPaletteEntry(attr), nil) | |
// Flip bit 10 on wraparound | |
if p.VramAddress&0x1F == 0x1F { | |
// If rendering is enabled, at the end of a scanline | |
// copy bits 10 and 4-0 from VRAM latch into VRAMADDR | |
p.VramAddress = p.VramAddress ^ (p.VramLatch & 0x41F) | |
} else { | |
p.VramAddress++ | |
} | |
} | |
p.TilerowCounter++ | |
if p.TilerowCounter == 8 { | |
p.TilerowCounter = 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment