I'm trying to switch palettes quickly on PLAN_B.
But for some reason only the last palette of the sequence of 4 is set.
It skips over 3 palettes.
How do i update the backround palette quickly enough so that the palette change could be seen?
How to update a switced palette on background
Moderator: Stef
Re: How to update a switced palette on background
There is no reason to skip palettes other than a programming mistake. The first thing comes to mind is to check vpd increment counter value.
There are two ways:
a) Change the palettes values themselves
b) Change tiles palette number
If for some reason you are going for B, you can do it in a single frame but only just. A tile table is 4KB in size*, but you only need to change every other byte, so with a clever programming you only need to change 2KB. Is doable but not easy: think carefully.
An advice: do it in vblank, avoid display period because it becomes really slow, and 2KB is quite a big chunk. As the game grows and you use more and more cpu you will notice an slow down.
* It could be bigger but it's completely unnecessary
There are two ways:
a) Change the palettes values themselves
b) Change tiles palette number
If for some reason you are going for B, you can do it in a single frame but only just. A tile table is 4KB in size*, but you only need to change every other byte, so with a clever programming you only need to change 2KB. Is doable but not easy: think carefully.
An advice: do it in vblank, avoid display period because it becomes really slow, and 2KB is quite a big chunk. As the game grows and you use more and more cpu you will notice an slow down.
* It could be bigger but it's completely unnecessary
HELP. Spanish TVs are brain washing people to be hostile to me.
Re: How to update a switced palette on background
I just remember another option:
Stop the action, do the changes you need taking as much frames as you need, finally restart game as normal.
This technique was used a lot by Nintendo games on SNES which has a much slower bandwidth with the video chip. The only thing is you need to do it "beautiful", like a detailed animation sequence to be successful.
Stop the action, do the changes you need taking as much frames as you need, finally restart game as normal.
This technique was used a lot by Nintendo games on SNES which has a much slower bandwidth with the video chip. The only thing is you need to do it "beautiful", like a detailed animation sequence to be successful.
HELP. Spanish TVs are brain washing people to be hostile to me.
Re: How to update a switced palette on background
Right now i'm using VDP_setPaletteColors.
The problem i'm having is that when i call my function which contains a sequence of palette changes within a loop, Only the last change will be applied.
IE:
I also tried doing it without a loop
But only the last palette change gets executed and shows on screen, All the other palette changes happen in between frames and don't get a chance to be applied and displayed.
EDIT:
I got it working with VDP_waitVsync.
However, i still have a problem.
I'm trying to change the PLAN_B image in the background while the palette change happends.
Knowing that there's a small delay when changing background images i tried to load the new image while the palette change is happening(Which takes a couple frames).
However, Calling the VDP draw image after calling the palette change function, causes the loading to start after the whole palette scroll sequence is over.
Is there any way to initiate the VDP_drawImage loading while the palette scrolling function is working and then immediately changing the BG layer to that image once the palette change is done?
The problem i'm having is that when i call my function which contains a sequence of palette changes within a loop, Only the last change will be applied.
IE:
Code: Select all
void ScrollPalettes
{
for(blabla = 0; blabla < NumOfDefinedPalettes; blabla ++)
{
VDP_setPaletteColors(0,arrayOfPalettes[blabla],16);
}
}
Code: Select all
void ScrollPalettes
{
VDP_setPaletteColors(0, predefinedpalette0, 16);
VDP_setPaletteColors(0, predefinedpalette1, 16);
VDP_setPaletteColors(0, predefinedpalette2, 16);
VDP_setPaletteColors(0, predefinedpalette3, 16);
}
EDIT:
I got it working with VDP_waitVsync.
However, i still have a problem.
I'm trying to change the PLAN_B image in the background while the palette change happends.
Knowing that there's a small delay when changing background images i tried to load the new image while the palette change is happening(Which takes a couple frames).
However, Calling the VDP draw image after calling the palette change function, causes the loading to start after the whole palette scroll sequence is over.
Is there any way to initiate the VDP_drawImage loading while the palette scrolling function is working and then immediately changing the BG layer to that image once the palette change is done?