Starting to code PPU

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
blanham
Posts: 7
Joined: Thu Jun 04, 2009 3:19 pm

Starting to code PPU

Post by blanham » Thu Jun 18, 2009 1:41 pm

I've been working on an NES emulator and have almost completed the cpu core and so have started thinking about ppu emulation. The problem is that I am at a loss as to where to begin. Any hints on what I should implement first? I'm planning to use SDL.

tepples
Posts: 22277
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Thu Jun 18, 2009 7:10 pm

First implement the PPU's dot clock (3 dots every CPU cycle on NTSC), the horizontal sequence (341 dots = 1 line), and the vertical sequence (240+1+20+1 lines = 1 frame on NTSC). Then expose the vertical sequence through the NMI bit of PPUCTRL ($2000) and the vblank state bit of PPUSTATUS ($2002). That will at least get games to start booting.

blanham
Posts: 7
Joined: Thu Jun 04, 2009 3:19 pm

Post by blanham » Fri Jul 03, 2009 7:02 pm

Okay, It's been a while, and I now have the various clocks implemented. I decided after some research to use 15/16 Master cycles. I see the nametable being written, but now I'm stuck. What is the best way of actually rendering the screen? I figured that going scanline by scanline would be the best way to go, but I'm also not sure how to actually convert the name table, palette, and other information into each individual pixel.

User avatar
MottZilla
Posts: 2835
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Fri Jul 03, 2009 7:19 pm

There's nothing wrong with drawing the screen pixel by pixel. It's slower but modern PCs won't have any trouble with it. When I wrote my NES emulator I started out with a tiled renderer, then went to a scanline renderer, and finally to a pixel by pixel renderer.

Post Reply