Palette color > $3f

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

Moderator: Moderators

Post Reply
proteal
Posts: 5
Joined: Wed Apr 16, 2014 2:01 pm

Palette color > $3f

Post by proteal » Fri Jul 04, 2014 8:26 am

I noticed that Mike Tyson's Punch-Out writes a value of $8f into the background palette ($3f00). I assume this value should be masked by $3f and thus displayed as color $0f.

But now I'm wondering, if the value is read back through $2007, do you get $8f or $0f?

User avatar
Bregalad
Posts: 7951
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Palette color > $3f

Post by Bregalad » Fri Jul 04, 2014 8:41 am

You get $0f.
The high 2 bits aren't even stored anywhere.

Also palette read-back in general is somewhat un-reliable.

proteal
Posts: 5
Joined: Wed Apr 16, 2014 2:01 pm

Re: Palette color > $3f

Post by proteal » Fri Jul 04, 2014 9:01 am

All right, thanks much.

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

Re: Palette color > $3f

Post by tepples » Fri Jul 04, 2014 9:02 am

I thought palette readback was fine (due to use of SRAM) and OAM readback was unreliable (due to a half-@$$ed DRAM controller). Is there a test ROM?

Anyway, assuming that palette readback is reliable: Because palette reads come from inside the PPU, they aren't subject to the 1-byte delay for video memory readback. Bits 5-0 of the read palette value come from CGRAM (the palette memory inside the PPU), and I seem to remember that bits 7 and 6 of the read palette value come from open bus, which is the last value on the data bus (which in this case is $20, the high byte of the address).

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Palette color > $3f

Post by thefox » Fri Jul 04, 2014 9:12 am

From my experience making the PowerPak save state mappers, palette readback doesn't seem to work on all PPU revisions. It does work on PAL PPU.

Here's a relevant post: viewtopic.php?p=64340#p64340

BTW, the post refers to Famicom Titler, which uses the RGB PPU, but I'm pretty sure I've had problems with palette readback on some NTSC composite PPUs also.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

proteal
Posts: 5
Joined: Wed Apr 16, 2014 2:01 pm

Re: Palette color > $3f

Post by proteal » Fri Jul 04, 2014 9:22 am

Interesting. Palette read is tested in Blargg's palette_ram.nes, so I had assumed it was reliable.

User avatar
Quietust
Posts: 1603
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Palette color > $3f

Post by Quietust » Sat Jul 05, 2014 7:01 am

tepples wrote:I seem to remember that bits 7 and 6 of the read palette value come from open bus, which is the last value on the data bus (which in this case is $20, the high byte of the address).
"Open bus" for the PPU is different from the CPU - as I recall, what you actually get for bits 6 and 7 is the last value asserted on the PPU I/O data pins, just like when you read any write-only register.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

Post Reply