PPU Nametables

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

User avatar
Elessar
Posts: 11
Joined: Tue Jun 14, 2011 6:42 pm

PPU Nametables

Post by Elessar »

I am in the process of implementing the PPU, but I am having problems trying to get the nametables to load properly. Here is a comparison of nametables for Donkey Kong on my emulator & FCEUXDSP.

Image

Would this be a result of improper initial PPU loading, or would it be changes to the nametables through PPUDATA?

I can provide more information and/or code if this is too obscure a problem to determine from the picture.
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

Are you certain the game is even running? It would also help if you had actual tile graphics showing.
User avatar
Elessar
Posts: 11
Joined: Tue Jun 14, 2011 6:42 pm

Post by Elessar »

Yes, the game is running (the debugger runs through the code).
It would also help if you had actual tile graphics showing.
Do you mean the tile sets? Here they are:
Image

I apologize if I misunderstood you, it's been a long day.
User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz »

can you post your code to draw the tile data?
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

Your windows are blank. I don't see Donkey Kong's graphics at all.

Again just because code is executing and not hitting a bad opcode doesn't mean the game is running. At the very least check that the contents of name table memory match what they are in FCEUX when the title screen is up. And infact if the game is running even without any input the nametable will change after awhile as the game will run an attract mode/demo. If this isn't happening then the game isn't actually running yet.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

Put a screen of the game running.
User avatar
Elessar
Posts: 11
Joined: Tue Jun 14, 2011 6:42 pm

Post by Elessar »

I realized that the tile set preview wasn't reading the bytes correctly. Here is a screenshot of the game running with the tile sets and name tables:

Image
User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz »

looks like you're reading the same row of tiles over and over... and i have no idea whats going on with your main display. again, if you can post the source code we can point out what's going wrong.
User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Post by cpow »

miker00lz wrote:looks like you're reading the same row of tiles over and over... and i have no idea whats going on with your main display. again, if you can post the source code we can point out what's going wrong.
The main emu window looks like it's just displaying uninitialized (garbage) video memory.
User avatar
Elessar
Posts: 11
Joined: Tue Jun 14, 2011 6:42 pm

Post by Elessar »

It looks like I had overlooked two essential items: NMI & DMA.

Here is what the system looks like now:
Image
Image

As you can see, the left side and some of the top is not showing correctly. What could be causing this?

(I don't have sprites implemented yet, just the background.)
User avatar
MottZilla
Posts: 2837
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla »

Your name table mirroring is broken. You shouldn't have 4 unique name tables unless the game is using "Four Screen Mirroring" whic is actually No Mirroring. If you fix name table mirroring you might fix those issues in the background.
User avatar
miker00lz
Posts: 235
Joined: Thu Sep 23, 2010 7:28 pm

Post by miker00lz »

MottZilla wrote:Your name table mirroring is broken. You shouldn't have 4 unique name tables unless the game is using "Four Screen Mirroring" whic is actually No Mirroring. If you fix name table mirroring you might fix those issues in the background.
yeah, exactly.

Elessar, there are four mirroring cases you need to account for on reads/writes to/from your PPU memory.


for horizontal mirroring:
on accesses to $2400 thru $27FF, subtract $400 from the address
on accesses to $2800 thru $2BFF, subtract $400 from the address
on accesses to $2C00 thru $2FFF, subtract $800 from the address

for vertical mirroring:
on accesses to $2800 thru $2FFF, subtract $800 from the address

for one screen mirroring:
on accesses anywhere from $2000 thru $2FFF, you get the new address by AND'ing the given address by $03FF, then OR'ing that result with $2000.

and like MottZilla said, for four screen mirroring just leave the address as it is.
User avatar
Elessar
Posts: 11
Joined: Tue Jun 14, 2011 6:42 pm

Post by Elessar »

I will start implementing mirroring now, but that should not be causing the glitches. I have verified that all the PPU memory accesses have stayed within the $2000 nametable, and the nametable viewer I wrote displays the nametable perfectly.

EDIT: I implemented mirroring, but the glitches still remain.
Image
Image

Is there anything else that could cause this?
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Memory initialization? The game probably isn't zeroing out the second nametable. If you're not initializing memory to anything, you could get glitchy areas on the second nametable.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

Dwedit wrote:Memory initialization? The game probably isn't zeroing out the second nametable. If you're not initializing memory to anything, you could get glitchy areas on the second nametable.
From experience, nametables should be initialized by the emulator with zeroes ($00), and not $FFs.
Last edited by Zepper on Sat Mar 10, 2012 10:48 am, edited 1 time in total.
Post Reply