Questions about NES Graphics Limitations

A place for your artistic side. Discuss techniques and tools for pixel art on the NES, GBC, or similar platforms.

Moderator: Moderators

User avatar
Okk
Posts: 23
Joined: Thu Dec 19, 2013 9:29 pm

Re: Questions about NES Graphics Limitations

Post by Okk »

tepples wrote:What would happen if you use your water palette for the mountain in the back? In the real world, the reason bodies of water appear blue is that they reflect the blue sky. Nor do clouds move anything like that. And are the tree stumps higher in the back?
Ah, that isn't exactly what I meant. Switching palette colors would compromise one of my scanlines with a rainbow of colors; I was wondering just what that would look like.
But Super Mario Bros 3 doesn't do that, then? Were mid-screen palette changes done in many commercial games?
I might be better off assuming one of my background palettes is globally dedicated to the status bar. Especially if I chose colors for it that were also useful in drawing scenery.
Denine
Posts: 397
Joined: Wed Feb 17, 2010 5:42 pm

Re: Questions about NES Graphics Limitations

Post by Denine »

Okk wrote:Were mid-screen palette changes done in many commercial games?
For example, the following games changes palette for status bar:
-Wizard & Warriors.
-Fantastic Adventurers of Dizzy.
-Dizzy the adventurer.
-Tom and Jerry.

And I'm sure there's are other games that do that too.

As for SMB3- It do not do that, not for Status bar, at least.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Questions about NES Graphics Limitations

Post by lidnariq »

Okk wrote:Switching palette colors would compromise one of my scanlines with a rainbow of colors; I was wondering just what that would look like.
I think you should be able to update up to 6 palette entries without any visible rainbow of colors.

If you want to see what the spray of colors looks like, in its most extreme form, the demo Tepples mentioned by ccovell (Sayoonara!) is here. But as tepples also mentioned, it's mostly invisible because ccovell uses the greyscale bit in the NES, which converts all 54 colors to one of three greys.

edit: grammar
Last edited by lidnariq on Sun Dec 22, 2013 6:38 pm, edited 4 times in total.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Questions about NES Graphics Limitations

Post by tokumaru »

lidnariq wrote:I think you should be able to update up to 6 palette entries without any visible rainbow of colors.
Yeah, if you don't need to restore the scroll then you can change a few colors per scanline without visible glitches. The real problem is when you want to do this in the middle of the picture and can't afford any blank lines between the areas with different palettes.
User avatar
Okk
Posts: 23
Joined: Thu Dec 19, 2013 9:29 pm

Re: Questions about NES Graphics Limitations

Post by Okk »

Thanks a lot for all your help, guys. I'm making a lot of progress, and I've learned a lot from this thread:
-Some games have four-direction scrolling without artifacts by adding extra memory.
-Pixel aspect ratio is 8:7.
-Scrolling can be changed between scanlines
-Color emphasis can be changed between scanlines. Incidentally, I've discovered that I can imitate color emphasis almost perfectly in my game by applying some combination of pure red, green or blue to my image, each at 25% opacity in the Darken blending mode.
-While background tiles are 8x8, tile palettes apply to 16x16 areas (without special hardware.)
-Sprites can be partially dropped when the sprites per scanline limit is exceeded.
-The color limit in sprite palettes can be circumvented by stacking sprites on top of each other. While I noticed this in Mega Man a while back, I hadn't known if it was a common practice. Alternatively, the top half of a character can use a different palette than the bottom half, like in Final Fantasy 1.

Unfortunately, I think I'm still a little fuzzy on changing tilesets. Apologies for my confusion on the topic. You guys have told me a lot about it, but I'm still kind of cunclear (it doesn't really help that I'm not entirely familiar with all of the technical terms.) If I'm understanding correctly, I could normally swap out up to 64 tiles at a time. Is this between scanlines, or just between frames? Are there other limitations on what tiles I can swap out or swap in? Other mappers would allow for more flexibility... do those involve special hardware? Of course, if lidnariq's raster display is any indication, I could draw pretty much whatever I want, hypothetically...

I'm also concerned about my status bar still. For the status bar I need to change tilesets, palettes AND scrolling, all between scanlines and at the same time. Is that plausible? Lidnariq indicated that I might be able to keep the multicolor artifacts from palette changing offscreen, as I'm only changing four colors. As it stands, the first scanline of my status bar would require two color changes, the second would require a third and the fourth color change wouldn't be needed until the third scanline, if it makes a difference. Also, sometimes the upper screen would scroll vertically instead of horizontally.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: Questions about NES Graphics Limitations

Post by lidnariq »

Okk wrote:If I'm understanding correctly, I could normally swap out up to 64 tiles at a time. Is this between scanlines, or just between frames?
Between scanlines.
Are there other limitations on what tiles I can swap out or swap in?
Effectively, no.
For the status bar I need to change tilesets, palettes AND scrolling, all between scanlines and at the same time. Is that plausible?
You have enough time to change 6 things invisibly per scanline; after that it'll start happening during the visible portion. Specifically in the case of palette changes, the first and last three are lost to overhead. Fortunately, those last three writes involve a coarse scroll change, so setting scrolling after a palette change is mostly free. Therefore, rendering has to be disabled for a palette change, so any tileset changes or fine scrolling changes done during this blank time will be invisible and so don't count against the limit.
As it stands, the first scanline of my status bar would require two color changes, the second would require a third and the fourth color change wouldn't be needed until the third scanline, if it makes a difference. Also, sometimes the upper screen would scroll vertically instead of horizontally.
The overhead involved in changing a color is large enough that it's best to change them all at the same time, and regardless you will need a blank line in which to do so.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Questions about NES Graphics Limitations

Post by tokumaru »

Okk wrote:-Some games have four-direction scrolling without artifacts by adding extra memory.
It's also possible to get rid of these artifacts without extra memory, but that usually involves some sort of sacrifice (e.g. a column of sprites at the right of the screen - which wastes sprites and effectively drops the sprites-per-scanline limit to 7 - or a total of 16 blanked scanlines distributed between the top and bottom of the screen). I guess it's probably better for you to go with the extra memory explanation. =)
If I'm understanding correctly, I could normally swap out up to 64 tiles at a time. Is this between scanlines, or just between frames?
That's perfectly safe to do between scanlines.
Are there other limitations on what tiles I can swap out or swap in? Other mappers would allow for more flexibility... do those involve special hardware?
The only real limitation is that the finest chunks an existing mapper can swap are 1KB (i.e. 64 tiles). If you don't want to change 64 tiles at once, you'll have to repeat the tiles you don't want to change across different 1KB chunks, wasting memory. Also, since the registers are 8-bit, they can only index 256 1KB chunks, so you're limited to 16384 tiles for the entire game. Technically this could be circumvented by wrapping the mapper with a second mapper (many pirate games do this), and then you could pick different sets of 16384 tiles, but that wouldn't be very typical.
For the status bar I need to change tilesets, palettes AND scrolling, all between scanlines and at the same time. Is that plausible?
Tilesets and scrolling could easily be done from one scanline to the next without any glitches, but palettes aren't so simple. If you can afford a few blank scanlines (2 or 3 should do it) between the status bar and the game window, you could pretend to be spreading the color updates across multiple HBlanks, which would make the color changes more plausible.
Also, sometimes the upper screen would scroll vertically instead of horizontally.
That's always tough when a status bar is present. There are software-only solutions to fix this though (which involve dynamically relocating the status bar in the name tables according to the vertical scroll) so it's certainly plausible. A bit annoying to code, but you don't have to worry about that, right?
User avatar
Okk
Posts: 23
Joined: Thu Dec 19, 2013 9:29 pm

Re: Questions about NES Graphics Limitations

Post by Okk »

tokumaru wrote:The only real limitation is that the finest chunks an existing mapper can swap are 1KB (i.e. 64 tiles). If you don't want to change 64 tiles at once, you'll have to repeat the tiles you don't want to change across different 1KB chunks, wasting memory.
So if I grab one tile from the rom, I have to grab the next 63 tiles along with it. Now I finally understand why Mario 3 always loaded that jellyfish. Can I start swapping in tiles at any point in the tile memory? Or should I think of that as being divided up into eight sections?
Also, since the registers are 8-bit, they can only index 256 1KB chunks, so you're limited to 16384 tiles for the entire game.
That should be plenty, but I'll start keeping track.

If I can switch 64 tiles between scanlines, then could I hypothetically switch all of the tiles between frames? Or would that impede on other important processes? Also, I think I read that I don't have to dedicate half of my tile memory to background tiles and the other to sprites, but that they are interchangeable; could I pick and choose which is which at my leisure?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Questions about NES Graphics Limitations

Post by tepples »

Okk wrote:Or should I think of that as being divided up into eight sections?
Yes. The FME-7 mapper divides the pattern table into eight windows.
If I can switch 64 tiles between scanlines, then could I hypothetically switch all of the tiles between frames?
Yes.
Or would that impede on other important processes? Also, I think I read that I don't have to dedicate half of my tile memory to background tiles and the other to sprites, but that they are interchangeable; could I pick and choose which is which at my leisure?
You can swap any tile data you want into the four background tile windows or the four sprite tile windows.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Questions about NES Graphics Limitations

Post by tokumaru »

Okk wrote:Now I finally understand why Mario 3 always loaded that jellyfish.
It was common for games to group CHR-ROM animations in the same banks to avoid wasting space, so when you look at the pattern tables in a debugger you often see tiles that are never used in the level you're in.
If I can switch 64 tiles between scanlines, then could I hypothetically switch all of the tiles between frames? Or would that impede on other important processes?
When using CHR-ROM, switching tiles is practically instantaneous. You just need to make a mapper write for each switch and the mapper will take care of making the CHR chunk you selected visible in the window you requested. It's pretty quick. CHR-RAM on the other hand requires the program itself to send each byte of CHR data to VRAM, so the amount of tiles you can change from frame to frame is very modest. You should probably stick to faking CHR-ROM and switching as many tiles as you want.
Also, I think I read that I don't have to dedicate half of my tile memory to background tiles and the other to sprites, but that they are interchangeable; could I pick and choose which is which at my leisure?
When sprites are set to the size of 8x16 pixels they can use any of the 512 tiles, but the top tile is always even and the bottom one is always the odd one following that. The background can't possibly address more than 256 tiles (unless the "rare" MMC5 mapper is used, then you can address 16384 tiles in the same frame), but you can change which half of the pattern tables is used for what at any time during the frame (you can even use the same 256 tiles for both sprites and background, while the other 256 are left unused), or you can bankswitch new background tiles halfway across the screen to simulate having more than 256 background tiles.
User avatar
Okk
Posts: 23
Joined: Thu Dec 19, 2013 9:29 pm

Re: Questions about NES Graphics Limitations

Post by Okk »

tepples wrote:You can swap any tile data you want into the four background tile windows or the four sprite tile windows.
Are those windows dedicated to their purpose, though? Could I take tiles in my background windows and use them to draw a sprite?

Another question that's come up: Does the NES have drawing functions other than placing its tiles? Could it, for example, draw a filled rectangle of arbitrary dimensions somewhere on the screen?
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Questions about NES Graphics Limitations

Post by rainwarrior »

The NES cannot do arbitrary graphics, but there are many attempts to do things like this by various means. You can use some combination of tiles and sprites to produce shapes that you couldn't do with tiles alone.

If you wanted an arbitrary rectangle with tiles alone, you need somewhere between 0-9 extra tiles for the edges of the rectangle and 1 tile for the interior.

There are two sets of 256 tiles. Sprites or the background can each chose which of those two pages to draw from individually. So yes, you can use background tiles for your sprites, if you want. This is a global setting so the sprites will only come from one tile set or the other for an entire screen (or you could split them per-scanline if you get fussy with it). There is also a mode that uses 8x16 sprites instead of 8x8 sprites, and this mode turns the two sets of tiles into a single set of 256 8x16 tiles that can be used by sprites only. (The background is always 8x8 tiles.)
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Questions about NES Graphics Limitations

Post by tokumaru »

Okk wrote:Are those windows dedicated to their purpose, though?
Yes. There are 4 windows on the sprite side and for windows on the background side.
Could I take tiles in my background windows and use them to draw a sprite?
Like I said in my last message, if you use 8x16 sprites you can have access to all 512 tiles. The opposite is not possible, the background can't access more than 256 tiles, unless you use the MMC5 (a somewhat uncommon mapper that has a special graphics mode that gives you access to 16384 tiles) or bankswitch halfway down the screen to load new tiles into the background windows.
Does the NES have drawing functions other than placing its tiles? Could it, for example, draw a filled rectangle of arbitrary dimensions somewhere on the screen?
NES graphics are exclusively composed of tiles, but if you use CHR-RAM you can simulate a traditional pixel array. With a few bankswitches you can have the screen display 960 unique tiles from CHR-RAM, and since it's RAM these tiles can be modified at will. I's a slow process though, and it would take several frames to update a whole screen, and palette attributes would still be limited to 16x16-pixel areas, so you wouldn't be able to color all pixels freely.

I can name a couple of NES games that do this, in case you want to see how it works: Videomation and Color A Dinosaur. Notice how they don't even bother trying to give you more than 4 colors to work with? A regular person just wanting to draw/color something would never understand the 16x16-pixel attribute area thing. Pictionary is different, it has a set of primitive lines and shapes that can be combined to create limited drawings.
User avatar
Okk
Posts: 23
Joined: Thu Dec 19, 2013 9:29 pm

Re: Questions about NES Graphics Limitations

Post by Okk »

Sorry, tokumaru. I missed that earlier post somehow.
Right now I only have thirteen animated tiles, and I think I've been assuming I'd simulate CHR-RAM for that, but I may need to reconsider.

I've included an image of my status bar. The icons for the NES buttons have been replaced with icons for keyboard controls (my game's control scheme uses the same number of buttons as the NES controller.) More relevantly, I've adjusted it a bit so that the topmost line is entirely black (or should it be a different color?) If this isn't enough to change four background palette colors, scrolling and a set of background tiles, I could conceivably add another blanked scanline on top, eating one scanline from the play area. Blanking scanlines like this doesn't change the position of the tiles below, does it?

Under my status bar is a set of tiles to be swapped in. But you might notice that it doesn't contain the skill icons present on the status bar. There will probably be quite a few icons, so the status bar could actually require up to three sets of tiles to be swapped in. Would I have to do each one on a different scanline? One set could be changed before the status bar, and then the second after the blank scanline, but by the second scanline the tiles for the icons have started being drawn. If I'm not mistaken, there would need to be an update to the nametable, is that right? (Either that or sacrifice as many as three tiles from any set that I might be swapping out at the time.)
Attachments
status.png
status.png (5.45 KiB) Viewed 4239 times
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Questions about NES Graphics Limitations

Post by tepples »

Swapping tile sets in tile windows can be done in the scanlines that you're already blanking for the palette change.

About use of Z and X: German and French keyboards move Z far from X, and a lot of people prefer to play using a USB joystick. You'll want to make keys configurable.
Post Reply