vdp_pal question

SGDK only sub forum

Moderator: Stef

Post Reply
zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

vdp_pal question

Post by zhengyaxin_8bit » Sun May 27, 2012 7:51 pm

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

zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

Post by zhengyaxin_8bit » Sun May 27, 2012 7:54 pm


zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

Post by zhengyaxin_8bit » Sun May 27, 2012 8:16 pm

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.

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

Post by Stef » Sun May 27, 2012 10:56 pm

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 :)

zhengyaxin_8bit
Very interested
Posts: 101
Joined: Thu Sep 04, 2008 2:57 am
Location: China

Post by zhengyaxin_8bit » Mon May 28, 2012 2:10 am

stef! Can you show your code for fixed it to here? I think the code you writed is better than me.

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

Post by Stef » Mon May 28, 2012 7:58 am

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.

sega16
Very interested
Posts: 251
Joined: Sat Jan 29, 2011 3:16 pm
Location: U.S.A.

Post by sega16 » Mon May 28, 2012 3:24 pm

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,
};

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

Post by Stef » Mon May 28, 2012 9:23 pm

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.

Manveru
Very interested
Posts: 85
Joined: Wed Sep 05, 2012 3:30 pm

Post by Manveru » Wed Jun 05, 2013 6:49 pm

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.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

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

Post by Stef » Wed Jun 05, 2013 8:31 pm

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.

Manveru
Very interested
Posts: 85
Joined: Wed Sep 05, 2012 3:30 pm

Post by Manveru » Wed Jun 05, 2013 9:20 pm

Oh oks thanks Stef, i thought all the functions need a 64 colour palette. Now it works.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

Manveru
Very interested
Posts: 85
Joined: Wed Sep 05, 2012 3:30 pm

Post by Manveru » Sat Jun 08, 2013 3:21 am

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.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

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

Post by Stef » Sat Jun 08, 2013 9:37 am

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);

Manveru
Very interested
Posts: 85
Joined: Wed Sep 05, 2012 3:30 pm

Post by Manveru » Sat Jun 08, 2013 5:54 pm

Ok thanks Stef, it looks fine.
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC

Post Reply