Ppu palettes

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
Choz
Posts: 10
Joined: Tue Jul 30, 2013 10:35 am

Ppu palettes

Post by Choz » Fri Sep 19, 2014 5:42 pm

I am programming an emulator and my colours are wrong. After a lot of searching, I think that I haven't fully understood how the palettes works.
From the explanation on NesDev, the background palettes are arranged like this:
$3F01-$3F03 Background palette 0
$3F05-$3F07 Background palette 1
$3F09-$3F0B Background palette 2
$3F0D-$3F0F Background palette 3

For my RGB palettes, I got 64 colours. When I am building up the bits from the pattern table and the attribute table, I am taking the 2 upper bits from the attribute table and the 2 lowers from the pattern table (1st bit from the first address, 2nd bit from the address + 8). Then, this gives me a number from 0 to 15 (0xf). So, I take this number and I add it to 3F00 to get the correct address. For example, let's say that the value is 5 so, the address is 3F05. Then I read the value in this address (3F05) and I use this value as the index one of the 64 colours in the palettes.

Is it right? I am trying to run balloon fight, but the background is always gray : RGB(128,128,128), like the 0 index palette entry.
I feel that there is probably another pointer that I am not aware of...

User avatar
tokumaru
Posts: 11991
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Ppu palettes

Post by tokumaru » Fri Sep 19, 2014 7:18 pm

Some games, like SMB1, are known to use mirrors of the palette addresses... I don't know if Balloon Fight does something like this.

Anyway, have you verified that the game does in fact run and fill the name tables with data? This could possibly not be related to palettes at all.

Choz
Posts: 10
Joined: Tue Jul 30, 2013 10:35 am

Re: Ppu palettes

Post by Choz » Sat Sep 20, 2014 7:37 am

The game is running. But yesterday, I found that if I disable transparency, the background becomes black as it should. I will try to compare my palettes with the one from fceux.

I don't think that the problem is mirroring because I support it. But maybe that the problem lies into the 6502 emulation, because the game end up crashing after 30 seconds.

Post Reply