VDP_drawText - palette index colour

SGDK only sub forum

Moderator: Stef

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

VDP_drawText - palette index colour

Post by matteus » Mon Sep 21, 2015 10:42 am

I've not looked at this in great depth but is it possible to assign a different colour from a palette to text or is the function hardwired to use colour 0 in the palette you assign to it?

I'd like to make full use of a single palette for text colours :)

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Re: VDP_drawText - palette index colour

Post by Moon-Watcher » Mon Sep 21, 2015 11:05 am

Font is just usual tiles. Call VDP_setTextPalette() to use another palette. Also you can change the color/s used by the font with VDP_setPaletteColor() or similar functions

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: VDP_drawText - palette index colour

Post by Stef » Mon Sep 21, 2015 11:08 am

If you define your own font with characters using several color then it will display in several colors, that is what you mean ?
And as said Moon-Watcher you can change the palette currently used to display text :)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Mon Sep 21, 2015 1:35 pm

I gather the default uses positions 0 for forecolour and 15 for back colour. I want to use PAL0 and have it so different colours can be used for different sections of text: 0 15, 1 15, 2 15, etc

I can't swap palettes as my APLAN uses PAL0 for the text, PAL1 for the layout, PAL2 for the background scene on BPLAN and PAL3 for the sprites.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: VDP_drawText - palette index colour

Post by Stef » Mon Sep 21, 2015 4:02 pm

matteus wrote:I gather the default uses positions 0 for forecolour and 15 for back colour. I want to use PAL0 and have it so different colours can be used for different sections of text: 0 15, 1 15, 2 15, etc

I can't swap palettes as my APLAN uses PAL0 for the text, PAL1 for the layout, PAL2 for the background scene on BPLAN and PAL3 for the sprites.
Oh in this case no, you cannot do that unfortunately... at least 0 is always the "transparent" color and the font tiles are hardwired in SGDK so you cannot use severals font at same time. At best you can change font at some point but that is not what you want.

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Wed Oct 21, 2015 8:42 pm

Stef how do I go about changing the font? :)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: VDP_drawText - palette index colour

Post by Stef » Thu Oct 22, 2015 7:50 pm

You just need to replace the standard font by your own with :

Code: Select all

u16 VDP_loadFont(const TileSet *font, u8 use_dma)
where font is a TileSet, you can look into SGDK about how to declare it :
https://github.com/Stephane-D/SGDK/blob ... libres.res

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Thu Oct 22, 2015 10:09 pm

Ohhhh so I declare the image as a palette as well!!! :D

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Thu Oct 22, 2015 10:16 pm

How do I set the font's palette?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: VDP_drawText - palette index colour

Post by Stef » Fri Oct 23, 2015 8:35 am

If you declare your font as an image then you can use its TileSet to set the font with the method i introduced before.
For the palette you can change it as you want by using the VDP_setPalette(..) method so you can use the specific font palette (declared in the IMAGE resource) but you can also use any other you prefer.
By default drawText(..) method use palette 0 but you can change the palette index to use with VDP_setTextPalette(...) (as already mentioned by Moon-Watcher)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Fri Oct 23, 2015 2:44 pm

I can't get this to work!

VDP_loadFont(&font_lib, TRUE);

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Fri Oct 23, 2015 2:58 pm

I think I've got a problem :) do I need to set the palette of a PLAN before loading an image?

VDP_drawImageEx(BPLAN, image, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), STAGE_POSITION_X, STAGE_POSITION_Y, FALSE, TRUE);

This statement should load the image into BPLAN and load its palette into PAL2? Yes? or do I also have to set the PAL2 to the palette data of the image?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: VDP_drawText - palette index colour

Post by Stef » Fri Oct 23, 2015 3:00 pm

Just look into the SGDK source, i'm using :

Code: Select all

if (!VDP_loadFont(&font_lib, FALSE))
   ...
and it does work. Use emulator debugger to understand why your font is not loaded.
Just to be sure, did you named your variable 'font_lib' ? In which case it could conflict with the internal 'font_lib' variable ;)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Fri Oct 23, 2015 3:03 pm

Okay forgot the FLAG lol but seem to still have a problem! lol

It's this line that's the problem! VDP_fadeIn(32, 47, palette, 30, FALSE);

I thought this would only fade in 32 to 47 (pal2?) but it seems to clear all colours in palette 0 to black too?

Code: Select all

        
        VDP_setPaletteColors(32, BlackPalette, 47);
        VDP_drawImageEx(BPLAN, image, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), STAGE_POSITION_X, STAGE_POSITION_Y, FALSE, TRUE);
        VDP_fadeIn(32, 47, palette, 30, FALSE);

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: VDP_drawText - palette index colour

Post by matteus » Fri Oct 23, 2015 3:07 pm

Code: Select all

VDP_setPaletteColors(32, BlackPalette, 16);
This correction seemed to work? :) So from position 32 to 48? implement black... that's if i've understood correctly!

Post Reply