vdp_pal question
Moderator: Stef
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
vdp_pal question
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.
VDP_fadeOutAll(20,1);
VDP_waitFadeCompletion();
while(1)
{
}
The palette just have 16 color is black.I want to all color to black.
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
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.
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.
-
- Very interested
- Posts: 101
- Joined: Thu Sep 04, 2008 2:57 am
- Location: China
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
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.
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.
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:
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
doing:
Code: Select all
for(i = 0; i < 64; i++) tmp_pal[i] = 0;
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,
};
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
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:see it takes up less memory in rom and either way you would have to have the 64 bytes of ram used.Code: Select all
for(i = 0; i < 64; i++) tmp_pal[i] = 0;
is alot better thanCode: 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.
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
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
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.
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.
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:
When i try to fade from myPal2 to myPal1 the fading stop before ending too.
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();
The man who moves a mountain begins by carrying away small stones. Confucius, 551-479 BC
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
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 :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:When i try to fade from myPal2 to myPal1 the fading stop before ending too.Code: Select all
VDP_fadePal(0, myPal1, myPal2, 30, 1); VDP_waitFadeCompletion();
Code: Select all
VDP_fadePal(0, myPal1, myPal2, 30, 1);
VDP_waitFadeCompletion();
VDP_setPalette(0, myPal2);