Code:
ppu.reg[6] += 0x20;
Remember that the tile is gotten by doing
Code:
tile = ppu.p_nt[(ppu.reg[6] & 0xC00) >> 10]\
[ppu.reg[6] & 0x3FF];
So basically the ppu.reg[6] += 0x20 is done at the end of the scanline to move to the next 32 batch of tiles. Since 32 tiles represents 256 pixels which is one scanline.
So to sum up the Y Scroll ( ppu.reg[6] += 0x20; )
increment the pointer so it can fetch the tiles for the next 8 scanline since one tile handles up to 8 scanlines.. It increments by 0x20 (32) every time because as the scanline is progressing, the X scroll is going up by 1 up until 32 and then resets, so it needs some more bits to get the other tiles, which is basically what the Y Scroll is. It keep track of what scanline you are on. The Y Offset (Fine Y)
Code:
else //inc fine y
ppu.reg[6] += 0x1000;
What this does is part of the tiles in the scanline. Since the tiles are 8x8 pixels EACH, and
Code:
pat_addr = (tile << 4) | (ppu.reg[6] >> 12) |
ppu.bg_addr;
You scan see from there that the tiles can only go up in multiples of 16. So basically what the Y Offset is is it allows the PPU to access it in smaller increments. Think of it as
tile * 16 + y_offset where y_offset is incremented up until 8 (Which is 8 pixels high, the size of ONE tile)
Hopefully that helps, if not, I am out of ways of explaining it