gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Tile data differences between 16 and 256 color tiles

#43805 - jarobi - Thu May 26, 2005 10:21 pm

I'm making a map editor for the gba and I'm a little bit confused about the difference in structure between 16 color tile data and 256 color tile data. I know that in 256 color tile data that each value is an index into the background palette for text backgrounds. However, I do not know how this works with 16 color tiles. I don't know whether 16 color palettes are indexed in this way:
0, 1, 2, 3, ..., 15
16, 17, 18, ..., 31
...253, 254, 255

or in this way:
0, 1, 2, ..., 15
0, 1, 2, ..., 15
...
0, 1, 2, ..., 15

I therefore do not know what to put into 16 color tile data so that I do not get a bunch of garbage when I export it to a header file. If the 16 color palettes are indexed like the second example, then that would leave me to believe that identical numbers in tile data can correspond to different colors depending on which palette is used to generate the color.

By the way, the map editor that I am working on is written in Java.
_________________
Nihongo o hanasemasen!

#43817 - MrD - Fri May 27, 2005 12:17 am

Quote:
or in this way:
0, 1, 2, ..., 15
0, 1, 2, ..., 15
...
0, 1, 2, ..., 15

If the 16 color palettes are indexed like the second example, then that would leave me to believe that identical numbers in tile data can correspond to different colors depending on which palette is used to generate the color.


Bingo!

When bit7 in REG_BGxCNT is unset, the background will be based on 16 colour tiles. Each sub-pallete then acts as a seperate source of 16 colours and when the tile-map is filled with map entries, you specify the Sub-Palette for each tile to use. You can see this effect if you open a game in Visual Boy Advance and look at the tile viewer, you can preview each tile in memory is any of the 16 palettes.

Each actual tile will therefore simply be a list of 64 4-bit numbers referring to the colour within the sub-palette to use. This allows you to use the same tile graphics again except using different colours.

http://user.chem.tue.nl/jakvijn/tonc/regbg.htm#map_reg contains a better explanation of tiled backgrounds and their map entries.

#43926 - jarobi - Sat May 28, 2005 7:53 am

Thanks for the info!
_________________
Nihongo o hanasemasen!