This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Ppu palettes

Ppu palettes
by on (#134054)
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...
Re: Ppu palettes
by on (#134057)
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.
Re: Ppu palettes
by on (#134089)
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.