Background color

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Disch
Posts: 1848
Joined: Wed Nov 10, 2004 6:47 pm

Background color

Post by Disch »

While we're somewhat on the subject of Micro Machines... I'm noticing it relies on oddball bg color behavior to draw it's multicolored bars. If you just use palette[0], ugly black patches get placed in their stead.

I recall that games have to reset the palette address before using the PPU address. I've seen code like the following in several games:

Code: Select all

LDA #$3F
STA $2006
LDA #$00
STA $2006
STA $2006
STA $2006
I'm guessing the first address set resets something relating to the palette which specifies palette[0] to be used as the background color... and the second write moves the ppu address away from the palette so that further PPU action won't change the BG color.

Am I close? I've tried using varying background colors in attempts to get the bars showing up in Micro Machines. I've gotten close to correcting it with the following logic:

On the second $2006 write - set the BG color to (PPU_Address & 0x0C)
On writes to ppu $3F00-$3FFF (through $2007) - set the BG color to the same after the increment.

This gets the bars dispaying properly, but doesn't reset the BG color back to black like it should (messing up the BG color for later in the frame).

Anyway... I know I'm barking up the right tree with this. I've been tinkering with several ideas but I just can't seem to get it to work right. How exactly is the BG color determined?

Thanks in advance for any help any of you can give me.


EDIT ---


Thanks to some info by Hyde, I've been able to get it working! I'm using the methods above... along with the same implimentation on $2007 reads... but I'm only using that BG color when BG rendering is disabled. When BG rendering is enabled... I use $3F00 regardless. This seems to fix the problem.
Post Reply