NES tile format

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

Moderator: Moderators

nintendo8
Posts: 54
Joined: Tue Jul 10, 2012 1:37 pm

NES tile format

Post by nintendo8 »

Hello Everyone,
I am making a tile editor and tile map editor that currently only supports the sega genesis.
The way it works is it stores a true color tile and it will automatically reduce it to the selected palette (There will be a choice of dithering algorithms or no dithering at all right now it only supports floyd steiburg).
I do not know of any editors that are able to do this and I was thinking about just how useful this technology is and I realized that this should not be limited to just one platform.
Alot of retro game systems use a tile and a palette so I would not have to re-invent the wheel.
Another advantage is when making a cross platform game there would be no need to rework the graphics
and speaking of not having to redo graphics another advantage of this is if you need to add a last minute tile and there are no good color to use all you would have to do is add the tile and the palette can automatically adjust it's self (it will be able to automatically find an optimal palette for the tiles).
Sorry if this ended up as an advertisement I was trying to describe the program it will be free and open source.
So I was just wondering how the NES stores the palette and tiles and what are the RGB values for the palette on the sega genesis they are simply in steps of 36.
As you can tell I am much more familiar with the sega genesis hardware than the NES hardware.
Also plane mapping is plane mapping a byte or a word that stores what each tile goes where and nothing else? On the sega genesis plane mapping has a few flags like which palette row to use and if the tile is flipped either vertically or horizontally or both and a priority bit.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NES tile format

Post by tepples »

The "correct NES palette" is a very complex problem for people used to RGB. The video signal is generated directly in the composite domain, with hue in steps of 30 degrees in the YUV plane and four predefined brightnesses per hue. Different TVs decode them differently (which is also a problem with RGB VDPs, but composite encoding and decoding have historically been glossed over on most of those systems). This topic should get you started on what's involved.

The tile format itself is a lot simpler, but it's planar, not packed. If you've ever looked at Game Boy or SMS tiles, you should have no trouble figuring out planar. The palette consists of one background color, four sets of three colors for the background, and four sets of three colors for the sprites. Each background color set is assigned to a 16x16 pixel (2x2 tile) area, not an individual 8x8 pixel tile like on the Genesis, Super NES, GBC, and GBA, so tiles have to be reassigned to color sets on a 16x16 pixel basis, not 8x8, which is why so many NES games had background objects the size of the Image blocks in Super Mario Bros. series.
nintendo8
Posts: 54
Joined: Tue Jul 10, 2012 1:37 pm

Re: NES tile format

Post by nintendo8 »

Thank you It seems like it should not be too hard to add support for the NES. Hope to finish my program soon.
Edit: I was browsing the wiki and you call them name tables I called them plane mapping in my post sorry about that. Well either way thanks for the helpful link I am reading more about the PPU right now.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NES tile format

Post by tokumaru »

The name tables (plane mapping) have 1 byte per tile, so they hold just tile indexes and nothing more. There's no priority control for background tiles and they can't be flipped, but a separate table (the attribute table) is used to specify what palettes are used for which tiles. Each byte in the attribute table selects 4 palettes for an area of 4x4 tiles, where each 2x2 tiles uses the same palette. There's one mapper though, the MMC5 (it's very complex and was used in very few games), which has a special mode that allows individual tiles to use any of the 4 palettes. Maybe you want to consider supporting that mapper in your application.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: NES tile format

Post by zzo38 »

There is also 8tools and Famitile. You can make your own if you don't like these other ones much (that is why I wrote Famitile so you can write another one if you dislike 8tools and Famitile), but these others are also free and open source software. I may include the feature of automatically reducing and finding optimal palette in my program too if I know best algorithm so thank you.

(About RGB palettes: Famitile has the default palette of VirtuaNES built-in, although perhaps it would be a good idea to allow RGB palettes to be loaded as well. I do not know if the 8tools nametable editor supports this, but the 8tools tile editor you can enter any RGB colors you want to. My suggestion for your program is perhaps include a default palette for NES and also allow loading custom RGB palettes.)
(Free Hero Mesh - FOSS puzzle game engine)
nintendo8
Posts: 54
Joined: Tue Jul 10, 2012 1:37 pm

Re: NES tile format

Post by nintendo8 »

I am glad to hear that you are adding that feature to famitile I do not want to reinvert the wheel but you editor seems to be totally different then mine.
My program is GUI based and written using c++ and FLTK (good gui library) for the gui stuff
Image
You can either edit the tile directly by clicking on the palette bar and click on the tile (right) or select an rgb value and click on the left tile and then the right tile will update. I picked a color that would caused alot of dithering artifacts on purpose even with all the artifacts it looks good when zoomed out all the way. Also thank you for the advice on how to work with an NES palette I never thought about using a palette file I thought about calculating the rgb values real time but using a file does seem like the better option. How would that work? How would my program know how to convert NES palette values to rgb values to the correct palette entry from the file?
Last edited by nintendo8 on Wed Aug 15, 2012 3:55 pm, edited 1 time in total.
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: NES tile format

Post by zzo38 »

nintendo8 wrote:I am glad to hear that you are adding that feature to famitile I do not want to reinvert the wheel but you editor seems to be totally different then mine. I did not understand what was going on.
My program is GUI based and written using c++ and FLTK (good gui library) for the gui stuff
And that is the same reason I suggest that we can both make up the program, and there can be other programs with similar features; to use whatever is preferred by a different user! (At least the file formats are common enough.) Yours is a proper GUI, mine is more like vi
Also thank you for the advice on how to work with an NES palette I never thought about using a palette file I thought about calculating the rgb values real time but using a file does seem like the better option. How would that work? How would my program know how to convert NES palette values to rgb values to the correct palette entry from the file?
What I did is just import the palette (in the format described on the wiki under .pal) from VirtuaNES and converted it into a C header file, although it ought to allow external files to be loaded to (I will add it and you should probably add feature like that too).

So basically, you have the NES palette with sixteen entries (actual NES requires entry 0, 4, 8, and 12 to be the same as each other), and then select whether you are using 0/1/2/3, 4/5/6/7, 8/9/10/11, or 12/13/14/15 for editing so still only four colors per tile and thirteen colors per screen.

You should support at least standard NES nametables, although you can add support for MMC5 nametables as well if you want to (Famitile does support both standard and MMC5 nametables; 8tools appears to support only standard nametables but tepples can reply if I am wrong about this).
(Free Hero Mesh - FOSS puzzle game engine)
nintendo8
Posts: 54
Joined: Tue Jul 10, 2012 1:37 pm

Re: NES tile format

Post by nintendo8 »

So it seems that the palette is more complicated then I thought I used the code from the link posted earlier viewtopic.php?f=3&t=8209
and here is what I got
Image
I am aware that the NES only does 4 colors per row I just wanted to see what all the colors look like at the same time I will fix it soon.
This All the colors of the NES without setting the emphasis bits my program does support emphasis bits I hope people will understand that when they save the palette and use it in a NES program that the emphasis bits won't be set and it has nothing do with the palette file. They need to set them manually as emphasis bits is global.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NES tile format

Post by tepples »

It appears you have the hues out of order.
nintendo8
Posts: 54
Joined: Tue Jul 10, 2012 1:37 pm

Re: NES tile format

Post by nintendo8 »

Ok I fixed that hues glitch now on to add tiles support.
User avatar
usr_share
Posts: 6
Joined: Fri Dec 30, 2011 8:37 am
Location: Moscow, Russia

Re: NES tile format

Post by usr_share »

nintendo8 wrote: I am aware that the NES only does 4 colors per row I just wanted to see what all the colors look like at the same time I will fix it soon.
This All the colors of the NES without setting the emphasis bits my program does support emphasis bits I hope people will understand that when they save the palette and use it in a NES program that the emphasis bits won't be set and it has nothing do with the palette file. They need to set them manually as emphasis bits is global.
Why is the "emphasis bits" a slider? Shouldn't it be arranged as four checkboxes instead? (sort of [ ] B/W [ ] Red [ ] Green [ ] Blue)
User avatar
Grumskiz
Posts: 79
Joined: Sat Mar 26, 2011 1:06 pm
Location: Germany

Re: NES tile format

Post by Grumskiz »

usr_share wrote: Why is the "emphasis bits" a slider? Shouldn't it be arranged as four checkboxes instead? (sort of [ ] B/W [ ] Red [ ] Green [ ] Blue)
Edit: This next part is total bogus
From what I know the emphasis bits cannot be combined on the NES, so checkboxes could confuse people into thinking that this can be done. On a slider you can only have one option selected at a time. However I would recommend making a drop down menu for the color emphasis and a checkbox for the monochrome option like this:

Code: Select all

Color emphasis: 
> Red
> Green
> Blue

Monochrome Mode []
Of course when Monochrome Mode is selected the drop down menu for the color emphasis needs to be inactive.
Edit2: At least that would make sense, if the NES PPU didn't behave differently. Thanks to thefox and usr_share for the reminder!
Last edited by Grumskiz on Wed Aug 22, 2012 7:10 am, edited 2 times in total.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: NES tile format

Post by thefox »

Grumskiz wrote:From what I know the emphasis bits cannot be combined on the NES, so checkboxes could confuse people into thinking that this can be done.
Not true, they can be combined just fine. (FYI: FCEUX doesn't emulate this part right, it only allows one of the emphasis bits to affect the output.)
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
usr_share
Posts: 6
Joined: Fri Dec 30, 2011 8:37 am
Location: Moscow, Russia

Re: NES tile format

Post by usr_share »

Grumskiz wrote: From what I know the emphasis bits cannot be combined on the NES, so checkboxes could confuse people into thinking that this can be done.
They can. In fact, some developers have their games set all the emphasis bits -- this makes the colors quite a bit darker.
Of course when Monochrome Mode is selected the drop down menu for the color emphasis needs to be inactive.
They don't. Quoting the wiki's "PPU registers" page,
In either case, the tint bits are applied after grayscale, which means they still tint the gray image.
-- that is, the tint bits can be enabled (and will make sense) even in grayscale mode.
LocalH
Posts: 186
Joined: Thu Mar 02, 2006 12:30 pm

Re: NES tile format

Post by LocalH »

Also remember that the emphasis bits on RGB PPUs shoot that color component up to 100%.
Post Reply