PPU Emulation O_O

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
PPU Emulation O_O
by on (#179552)
Hi people, I'm writting an nes emu in Golang. The CPU already works nice; but I'm facing some problems to test the PPU emulation. Actually I wrote a basic ppu code trying to make the minium enough to have tiles in scren (no scrolling, no attributes) just background tiles with 4 colors (pattern A + pattern B) (ignoring the color palette).

Now, I just have some static "noise" on screen; I expected to have some dynamic titles (even wrong). The 0x2000 (PPUCTRL) is never called by ROM with NMI_OUTPUT on, so there are no NMI interruptions during VBLANK.

Well, you know more than I how hard it's debug an emulator. I reached in a point that I can't understand whats going on.

Can you guys look my code and try to figure out what I'm doing wrong? This is the repository: https://github.com/jonathandasilvasanto ... rc/zerojnt

The most important files are: cpu.go, ppu.go, ioports.go

Thank you. I'm looking forward any tips or suggestions :)

This is the github repository:
Re: PPU Emulation O_O
by on (#179555)
Obvious tests including logging the output of writes to $2006 and $2007.

Feel free to skip the "real" renderer altogether, and just display the contents of PPU memory.
Re: PPU Emulation O_O
by on (#179560)
Thank you. Your answer help me to realize that 2007 and 2006 are never called :( The problem is something before it.

At this moment the unique registers accessed are 2000 (once) and 2002 (many times)
Re: PPU Emulation O_O
by on (#179562)
Most games have a delay loop at the beginning, waiting for [$2002] & $80 to be set twice before anything else happens.

(This is because the PPU rejects all writes to most registers after /RESET has been released until 262 total scanlines have been rendered by it)
Re: PPU Emulation O_O
by on (#179572)
zerojnt wrote:
At this moment the unique registers accessed are 2000 (once) and 2002 (many times)

The $2000 write is probably turning rendering off, and the $2002 reads are waiting for the vblank flag to get set. All NES programs are supposed to wait a couple of frames before using the PPU. If you don't set this flag, the game will be such in this loop forever.
Re: PPU Emulation O_O
by on (#179585)
Spot-on! You're right :) The problem was the NMI_OCCURRED update. :)

Now I have new problems, but I'm not blocked :)

Thank you.