PPU Emulation O_O

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
zerojnt
Posts: 13
Joined: Wed Sep 14, 2016 1:21 pm

PPU Emulation O_O

Post by zerojnt »

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:
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: PPU Emulation O_O

Post by lidnariq »

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.
zerojnt
Posts: 13
Joined: Wed Sep 14, 2016 1:21 pm

Re: PPU Emulation O_O

Post by zerojnt »

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)
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: PPU Emulation O_O

Post by lidnariq »

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)
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: PPU Emulation O_O

Post by tokumaru »

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.
zerojnt
Posts: 13
Joined: Wed Sep 14, 2016 1:21 pm

Re: PPU Emulation O_O

Post by zerojnt »

Spot-on! You're right :) The problem was the NMI_OCCURRED update. :)

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

Thank you.
Post Reply