Change palette values per scanline in practical way

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

User avatar
greatkreator
Posts: 49
Joined: Wed Dec 09, 2015 2:18 pm

Re: Change palette values per scanline in practical way

Post by greatkreator »

It's not a problem for me at all. I am ready for that.

I just need to know about its theoretical possibilities.
Just not to be trying to get physically impossible things.
User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Re: Change palette values per scanline in practical way

Post by darryl.revok »

Just not to be trying to get physically impossible things.
I think you're getting to that ballpark with changing palettes on scanlines.

I started inquiring about it when I stated doing scanline stuff, and was pretty quickly convinced that doing this to get more than 4 palettes in the playfield was not possible.

If you blank out a line, your sprites blank out too, so you can't plan for a blank line in the background to cover it. So you have to have a part of the screen over which nothing will pass. That makes this good for status bars and almost nothing else.
User avatar
greatkreator
Posts: 49
Joined: Wed Dec 09, 2015 2:18 pm

Re: Change palette values per scanline in practical way

Post by greatkreator »

What's about skip odd lines in odd frames and skip even lines in even frames? To simulate some kind of "interlace".
It may work. At least on LCDs.
User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Re: Change palette values per scanline in practical way

Post by darryl.revok »

I'm not a hardware guy, BUT, I don't think you'll get the effect you want.

The resolution of NTSC is quite a bit greater than the resolution of the NES. Every scanline you blank will represent more than one blanked scanline on your screen.

I honestly do think you'll be better suited to push boundaries in other areas. That's what I'm doing. :)
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Change palette values per scanline in practical way

Post by tepples »

The NES composite signal is not a conforming NTSC signal but instead a 240p signal compatible with most NTSC monitors.

How well this palette technique will work depends on how your monitor responds to the RGB121 technique (images; demo ROM).
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Change palette values per scanline in practical way

Post by tokumaru »

But then you'll spend almost all your time manipulating the display, with nothing left for the game logic. You'd hardly get a consistent effect anyway, considering how differently each TV treats 240p analog signals. It would certainly look like crap (too much flicker) on CRTs and probably also on consoles modded for RGB and HDMI.

Also, correct me if I'm wrong, but I believe sprites won't show up as soon as you turn rendering back on, because sprites need an entire scanline of evaluation so they can be displayed on the NEXT scanline (this is why there are no sprites on scanline 0, they're being evaluated to show up on scanline 1), so every time you turn rendering off, you get at least 2 scanlines without sprites.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Change palette values per scanline in practical way

Post by dougeff »

Just to add a little more detail about those demo pictures...

He's got nametable #0 filled with the green elements of the picture, amd nametable #1 filled with the red and blue elements of the picture, and using timed code to change the H scroll (or is it, changing the nametable selection) at the end of every scanline.

Cool, but impractical for an actual game (except maybe a static title screen).
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Change palette values per scanline in practical way

Post by tokumaru »

If you want to change the palette in the middle of the gameplay area, I think this discussion is pretty much over. The way sprites work makes it completely impractical to rewrite the palette if they need to be present.

However, if this is for a status bar, a (spriteless) still image, or maybe even a video sequence, it may be possible to come up with a way to make this feasible. But you have to tell us where your going with this, otherwise we can't help.
User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Re: Change palette values per scanline in practical way

Post by darryl.revok »

Just gonna throw out there that if a bigger palette is one of your main goals, you might want to consider Sega Master System.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Change palette values per scanline in practical way

Post by dougeff »

If you want to do something impressive, try to do some raster effects...

http://www.zophar.net/pdroms/nes/raster ... grams.html
Attachments
RasterTest1.png
RasterTest1.png (3.2 KiB) Viewed 3904 times
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Change palette values per scanline in practical way

Post by tokumaru »

darryl.revok wrote:Just gonna throw out there that if a bigger palette is one of your main goals, you might want to consider Sega Master System.
Not only the palette is bigger (32 colors for the background), but you get to use 16 colors per tile! And you can flip tiles horizontally and vertically. Sprites are not as versatile though, since they all use only 1 of the 2 16-color palettes (but hey, it's still more than the total of 12 colors you get on the NES) and can't be flipped (ouch).

Normally I'm against suggesting a different platform when someone asks how to do something on a specific machine, but when they absolutely feel the need to bend such intrinsic aspects of the platform it should indeed be the time to ask oneself if that particular machine was the right choice for the project.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: Change palette values per scanline in practical way

Post by ccovell »

dougeff wrote:If you want to do something impressive, try to do some raster effects...
http://www.zophar.net/pdroms/nes/raster ... grams.html
Image

That probably drives certain TVs crazy, too. ;-D
psc
Posts: 41
Joined: Tue Dec 11, 2012 1:02 pm

Re: Change palette values per scanline in practical way

Post by psc »

I've already made a mid-frame palette update demo you can try here: viewtopic.php?f=2&t=12830

It is in fact possible to update a palette (single color) without destroying the sprites, HOWEVER, this only works on two precise spots of the screen.
But your question was "is it practical", and the answer is "not really."

Now that I think about it, I'm wondering if PPUMASK ($2001) has an influence on this. If the left column of sprites is enabled/disabled, maybe it can extend the window to update the palette without effecting the sprites. I'll look into this...
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Change palette values per scanline in practical way

Post by tokumaru »

psc wrote:If the left column of sprites is enabled/disabled, maybe it can extend the window to update the palette without effecting the sprites.
That shouldn't change anything... AFAIK, that setting only prevents the pixels from being displayed, it doesn't affect the sprite/background processing in any way.
Post Reply