VDP_drawText - palette index colour

SGDK only sub forum

Moderator: Stef

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 10:44 pm

matteus wrote: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);
Actually this code should work and indeed apply fade in only on palette 2 (color index 32 to 47).
If it really does not work then there is a issue in my code !

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

Re: VDP_drawText - palette index colour

Post by matteus » Sat Oct 24, 2015 6:47 pm

There may well be an issue in your code then lol as my alteration worked! :)

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 » Sun Oct 25, 2015 10:05 pm

I will investigate :D

Hik
Very interested
Posts: 68
Joined: Thu Jul 30, 2015 11:39 pm
Location: Iceland

Re: VDP_drawText - palette index colour

Post by Hik » Sun Oct 02, 2016 3:54 pm

I just ran into this issue with my code. I was doing a fade in but the text disappeared.
Disabling the fade in made the text reappear. I think it did work before I added a sprite.

Anyway ,I don't really need the fade in for that part but I'm bringing this up as a reminder
that fading in text and doing other things on the same screen can make things tricky.

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 » Sun Oct 02, 2016 5:26 pm

Given the date of the previous post i think the VDP palette bug has been resolved (hopefully).
In your case, are you sure you are on the last SGDK version ? i added interrupts protection which may explain the palette corruption when a sprite is added.

Hik
Very interested
Posts: 68
Joined: Thu Jul 30, 2015 11:39 pm
Location: Iceland

Re: VDP_drawText - palette index colour

Post by Hik » Sun Oct 02, 2016 5:51 pm

I'm using SGDK 1.21

Here's the code;

Code: Select all

// ...code...
	SYS_disableInts();
    VDP_resetScreen();
        // reset palettes
      //VDP_setTextPalette(0);
    //VDP_setPaletteColors(0, palette_black, 64); // <------Enable Fade in
    // Load images
    VDP_drawImageEx(PLAN_A, &title_image, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), 7, 2, FALSE, TRUE);
    ind += title_image.tileset->numTile;

    //VDP_setTextPalette(0);
    //VDP_setTextPlan(PLAN_A);

    //VDP process done - re-enable interrupts
    SYS_enableInts();

    // Prepare palettes
    memcpy(&palette[16], title_image.palette->data, 16 * 2);
    VDP_setPalette(1, title_image.palette->data);
/*
	// fade in
    VDP_fadeIn(0, (4 * 16) - 1, palette, 32, FALSE); // <----Fade in ends
	
	while(counter <= 300) //Fade in
    {
		//Wait for screen refresh
        VDP_waitVSync();
		counter++;
    }
*/
    VDP_drawText("Start", 17, 22);
    VDP_drawText("Options", 17, 24);

    //Initialize joypad
    JOY_init();
    JOY_setEventHandler( &handleInput );

	while(1)
    {
		//Wait for screen refresh
        handleSprite();
        SPR_update();
        VDP_waitVSync();
    }
    return 0;
What happened was that when running it with the fade in ,the title image faded in correctly but the text wasn't there.
I had another function draw in text to test something out which worked before but when I added the sprite it stopped working.
The sprite worked like it should. Maybe I just wasn't using the fade in correctly? I'm just starting out so I might have made a mistake.

So I commented out the fade in and used VDP_setPalette() for the image instead to get the right palette without using the fade in.
That made the text appear again and everything except the fade in (which I commented out) is now working fine.

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: VDP_drawText - palette index colour

Post by cero » Mon Oct 03, 2016 9:31 am

What's in your palette[15]? You're fading everything into that, which is different from this thread's issue.

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 Oct 03, 2016 10:34 am

As Cero said, you are fading all palette color entries (0 to 63) with this method :

Code: Select all

   VDP_fadeIn(0, (4 * 16) - 1, palette, 32, FALSE); // <----Fade in ends
So you need to have correct 'palette' initialization or you need to limit fading to only wanted palette entries.
Also i saw you made you own passive loop to wait for fading, normally you don't require that as you used FALSE on last parameter of VDP_fadeIn(..)

Post Reply