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.

Beginners > Setting a Background To Use a Specified 16-Colour Palette

#32862 - Celeryface - Tue Dec 28, 2004 9:36 pm

Hi there,

When loading/setting up your background how to do set the 16-colour palette number, as I've read you can use 16 16-colour palettes.

I have 2 256-colour backgrounds, and 1 background set to 16-colours so that I can use it for text support.

I want to use another palette for my text that uses palette index 0,1. I'm the using AGBTTY library and my palette for my backgrounds doesn't take up all 256 colours of the palette. Is it possible to tell the hardware to use a specific palette set just for the text?

Thanks in advance. :)

#32864 - tepples - Tue Dec 28, 2004 9:41 pm

Provided you have loaded an appropriate font into VRAM:
agbtty_textattr(0x0000) will use colors 1 through 15
agbtty_textattr(0x1000) will use colors 17 through 31
agbtty_textattr(0x2000) will use colors 33 through 47
...
agbtty_textattr(0xF000) will use colors 241 through 255
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.


Last edited by tepples on Tue Dec 28, 2004 9:51 pm; edited 1 time in total

#32868 - Celeryface - Tue Dec 28, 2004 9:49 pm

tepples wrote:
Provided you have loaded an appropriate font into VRAM:
agbtty_textattr(0x0000) will use colors 1 through 15
agbtty_textattr(0x1000) will use colors 17 through 31


Nice!
Is there one to use colours above 31? Specifically I'm looking to use 32 and 33.

Edit: agbtty_textattr(0x2000);

Thanks! :)

#32869 - tepples - Tue Dec 28, 2004 9:53 pm

Caught me in mid-edit.

You can't use colors 32 and 33, as color 32 is transparent in 16 color mode, but you can use 33 and 34. Are you trying to use two colors together in one glyph, or are you trying to make a glyph of one color and the same glyph of another color?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#32870 - Celeryface - Tue Dec 28, 2004 9:55 pm

tepples wrote:
Caught me in mid-edit.

You can't use colors 32 and 33, as color 32 is transparent in 16 color mode, but you can use 33 and 34. Are you trying to use two colors together in one glyph, or are you trying to make a glyph of one color and the same glyph of another color?


I'm using 32 for the transparent (black) colour, and 33 for the actual colour of the font. Is it possible to get an outline colour on the text?

What's a glyph? :)

#32875 - tepples - Tue Dec 28, 2004 10:40 pm

A glyph is an image, either vector or raster, that represents a character. For instance, there is only one character 'Latin capital letter A', but each font has its own distinct glyph for it. A relation from a set of characters to a set of glyphs is called a "font" over those characters, and a set of fonts with similar design characteristics is called a "typeface".

You can get an outline or a drop shadow by drawing a different font in a tile editor and then copying agbtty_init() and making it load your font, replacing the call to upcvt_4bit() with a DMA memcpy() or a call to whatever conversion or decompression function you prefer.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#32877 - Celeryface - Tue Dec 28, 2004 10:46 pm

Cool. Thanks for the info :)

What's the easiest way to import new fonts? I'm using the one from AGBTTY "text.chr" then I convert it to chr.h using the tool provided. I want to use the original NES font found in that link you provided.

Thanks :)


tepples wrote:
A glyph is an image, either vector or raster, that represents a character. For instance, there is only one character 'Latin capital letter A', but each font has its own distinct glyph for it. A relation from a set of characters to a set of glyphs is called a "font" over those characters, and a set of fonts with similar design characteristics is called a "typeface".

You can get an outline or a drop shadow by drawing a different font in a tile editor and then copying agbtty_init() and making it load your font, replacing the call to upcvt_4bit() with a DMA memcpy() or a call to whatever conversion or decompression function you prefer.


Last edited by Celeryface on Tue Dec 28, 2004 11:10 pm; edited 1 time in total

#32879 - tepples - Tue Dec 28, 2004 10:52 pm

Any bitmap to tile converter from gbadev.org will spit out tiles in various formats.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#32880 - Celeryface - Tue Dec 28, 2004 10:58 pm

tepples wrote:
Any bitmap to tile converter from gbadev.org will spit out tiles in various formats.


I'm pretty new at editing font bitmaps. What format does the bitmaps have to be in? Do I need to save it as a .chr file?

Thanks again :)

#32886 - tepples - Tue Dec 28, 2004 11:48 pm

Which image converter are you using? Perhaps it can output 16-color tiles as well.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#32888 - Celeryface - Tue Dec 28, 2004 11:57 pm

tepples wrote:
Which image converter are you using? Perhaps it can output 16-color tiles as well.


For backgrounds I use gfx2gba. For sprites I use pcx2sprite.

I'm unsure of how to create the actual bitmap and save it as a .chr file :)

#32901 - tepples - Wed Dec 29, 2004 2:36 am

Make sure that the bitmap has one glyph in each 8x8 space and that the glyphs are arranged in ASCII order, left to right and top to bottom. For example, you could cut a 128x32 or 128x48 pixel block out of any of the NES fonts I posted. Then convert the bitmap to indexed color and make sure the bitmap uses color 0 for transparency and any or all of colors 1 through 15 for everything else. Then use gfx2gba to convert it to a .chr file, but use a straight CPU or DMA memcpy() to put it in VRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#32928 - Celeryface - Wed Dec 29, 2004 8:11 am

tepples wrote:
Make sure that the bitmap has one glyph in each 8x8 space and that the glyphs are arranged in ASCII order, left to right and top to bottom. For example, you could cut a 128x32 or 128x48 pixel block out of any of the NES fonts I posted. Then convert the bitmap to indexed color and make sure the bitmap uses color 0 for transparency and any or all of colors 1 through 15 for everything else. Then use gfx2gba to convert it to a .chr file, but use a straight CPU or DMA memcpy() to put it in VRAM.


Okay, cool. I'll give that a try. :)

I didn't know gfx2gba could output .chr files.

Thanks!

#32961 - tepples - Wed Dec 29, 2004 6:20 pm

.chr files are just a generic term for raw tile data.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#33067 - Celeryface - Thu Dec 30, 2004 5:22 pm

Image

Is this bitmap in the correct format/layout to use in AGBTTY?

Also, what parameters should I use in gfx2gba for this?

Thanks again. :)