Early PPU dev: Background tile wrongly displayed

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Early PPU dev: Background tile wrongly displayed
by on (#150353)
Hi guys,

I'm working in implementing the PPU of my emulator. CPU is already tested and it works good (according to the nestest.nes log, and Blargg's official/unofficial instructions tests).

I managed to get VBlank and NMI up and running, so now i'm working on getting some background displayed in the screen. The problem is that i don't know why these couple of tiles (screenshot attached) are displayed wrong :S. As you will be able to see, the title screen and the screen before donkey starts moving are displayed perfectly. But when the animation starts, the tile is wrong.

I checked my name table mirroring and seems to be right. I have implemented registers just as in loopy's scrolling doc. No attribute tables or sprites implemented yet. Also, checked with a couple of other games, and the tiles are displayed OK.

Can you guys point me to the right direction based on your vast experience :).

Thanks in advance.
Re: Early PPU dev: Background tile suddenly wrongly diplayed
by on (#150373)
Make sure you have the increment mode (1 byte vs 32 bytes) correct, I guess.
Re: Early PPU dev: Background tile suddenly wrongly diplayed
by on (#150904)
It seems that I had timed my frames wrongly. Substraction of odd frames' last cycle when render is enabled was done wrong, and because of that my frame was way shorter than normal:

Instead of making only the last scan line shorter, I was substracting last cycle from every scan line when rendering enabled (Duh!).

I fixed it and the issue appears to be gone.

I also double checked my 2006h/2007h accesses to vRam, and they look OK.
Thank you Dwedit.
Re: Early PPU dev: Background tile suddenly wrongly diplayed
by on (#151307)
Fumarumota wrote:
Substraction of odd frames' last cycle when render is enabled was done wrong

That's strange, in the first versions of my PPU the odd cycle was simply ignored and nothing like this happened.
Re: Early PPU dev: Background tile suddenly wrongly diplayed
by on (#151313)
Petruza wrote:
That's strange, in the first versions of my PPU the odd cycle was simply ignored and nothing like this happened.

This means your emulator was off by only 1 cycle, while his was subtracting 1 cycle from every scanline, for a total error of 240 cycles. That's a significant difference.
Re: Early PPU dev: Background tile wrongly displayed
by on (#151338)
Oh right, every scanline, ok.