Page 1 of 1

vdp_pal question

Posted: Sun May 27, 2012 7:51 pm
by zhengyaxin_8bit
After call the following code:
VDP_fadeOutAll(20,1);
VDP_waitFadeCompletion();
while(1)
{
}
The palette just have 16 color is black.I want to all color to black.
Image

Posted: Sun May 27, 2012 7:54 pm
by zhengyaxin_8bit

Posted: Sun May 27, 2012 8:16 pm
by zhengyaxin_8bit
I modify vdp_pal.c

void VDP_fadeOutAll(u16 numframe, u8 async)
{
u16 tmp_pal[64];
u16 i;

for(i = 0; i < 64; i++) tmp_pal = 0;

// do the fade
VDP_fadeAllTo(tmp_pal, numframe, async);
// VDP_fadeTo(0, 63, palette_black, numframe, async);
}

void VDP_fadeInAll(const u16 *pal, u16 numframe, u8 async)
{
u16 tmp_pal[64];
u16 i;

for(i = 0; i < 64; i++) tmp_pal = 0;

// do the fade
VDP_fadeAll(tmp_pal, pal, numframe, async);

// VDP_fade(0, 63, palette_black, pal, numframe, async);
}

Now , I can do this.

Posted: Sun May 27, 2012 10:56 pm
by Stef
You're right there is a bug as the palette_black is only 16 entries.
I fixed the problem by using a palette_black_all which contains 64 blacks entries. Thanks for the report :)

Posted: Mon May 28, 2012 2:10 am
by zhengyaxin_8bit
stef! Can you show your code for fixed it to here? I think the code you writed is better than me.

Posted: Mon May 28, 2012 7:58 am
by Stef
It's very similar to want you did actually except i used a static black palette :

http://code.google.com/p/sgdk/source/br ... /vdp_pal.c

Keep the first 15th lines of your vdp_pal.c file as i did some others modifications which are not compatible with your version.

Posted: Mon May 28, 2012 3:24 pm
by sega16
I like zhengyaxin_8bit's method better personally becasue there is alot of redundant data and there is little speed gain in this case by using a table
doing:

Code: Select all

for(i = 0; i < 64; i++) tmp_pal[i] = 0;
see it takes up less memory in rom and either way you would have to have the 64 bytes of ram used.
is alot better than

Code: Select all

const u16 palette_black_all[64] =
{
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,

    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,

    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,

    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,

    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,

    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,

    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,

    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
    0x0000,
};

Posted: Mon May 28, 2012 9:23 pm
by Stef
sega16 wrote:I like zhengyaxin_8bit's method better personally becasue there is alot of redundant data and there is little speed gain in this case by using a table
doing:

Code: Select all

for(i = 0; i < 64; i++) tmp_pal[i] = 0;
see it takes up less memory in rom and either way you would have to have the 64 bytes of ram used.
is alot better than

Code: Select all

const u16 palette_black_all[64] =
{
....
    0x0000,
};

Afaik my method requires 2*16*4 = 128 bytes of supplementary rom but requires 128 less ram (not really important i admit) and the most important, you don't need to initialize data which is a waste of time. 128 bytes of rom is really nothing... compared to all others tables.

Posted: Wed Jun 05, 2013 6:49 pm
by Manveru
For the fading, you need a 64 black colours palette to turn screen black, but what is the other 64 colours palette you need to make the fadeout and make "visible" the screen? I tried with a 16 one but it does not work.

Posted: Wed Jun 05, 2013 8:31 pm
by Stef
Actually others colors come from your own palette.
You want to start black and goes to your palette.
You can do the "fade in" process on a specific palette (0 to 3), in this case the destination palette should have at least 16 entried.
If you do the "fade in" process on all palette you have to give a 64 colors destination palette.

Posted: Wed Jun 05, 2013 9:20 pm
by Manveru
Oh oks thanks Stef, i thought all the functions need a 64 colour palette. Now it works.

Posted: Sat Jun 08, 2013 3:21 am
by Manveru
If you don't mind i will use this topic for another question about fading palettes.

I have an image that i need to keep in screen but changing the palette. When i try to fade from one to another, the arriving image is not correct because the color changing stops before ending, before the right colours are reached. When i draw it as usually, it is drawn correctly with both palettes, but something is happening with de fading.

I have tried with PAL0 and PAL1 because of previous message that you wrote about an issue, but the same result with both.

The code is that simple:

Code: Select all

VDP_fadePal(0, myPal1, myPal2, 30, 1);
VDP_waitFadeCompletion();
When i try to fade from myPal2 to myPal1 the fading stop before ending too.

Posted: Sat Jun 08, 2013 9:37 am
by Stef
Manveru wrote:If you don't mind i will use this topic for another question about fading palettes.

I have an image that i need to keep in screen but changing the palette. When i try to fade from one to another, the arriving image is not correct because the color changing stops before ending, before the right colours are reached. When i draw it as usually, it is drawn correctly with both palettes, but something is happening with de fading.

I have tried with PAL0 and PAL1 because of previous message that you wrote about an issue, but the same result with both.

The code is that simple:

Code: Select all

VDP_fadePal(0, myPal1, myPal2, 30, 1);
VDP_waitFadeCompletion();
When i try to fade from myPal2 to myPal1 the fading stop before ending too.
Looks like there is a rounding bug in the palette fading method, but you can easily fix it by setting munally the destination palette after the fade effect :

Code: Select all

VDP_fadePal(0, myPal1, myPal2, 30, 1);
VDP_waitFadeCompletion();
VDP_setPalette(0, myPal2);

Posted: Sat Jun 08, 2013 5:54 pm
by Manveru
Ok thanks Stef, it looks fine.