Page 1 of 1

Palette change and SYS_setHIntCallback

Posted: Thu Apr 23, 2020 3:32 am
by cloudstrifer
Hi, I'm trying to change palette on SYS_setHIntCallback but it's flickering a lot.
I want to change the 1st palette.
Can someone help me?

Thank you!

Code: Select all

...
void doPaletteSwap()
{	
  DMA_doDma(DMA_CRAM, (void*) palette2, 0, 16, 2);
  DMA_waitCompletion(); //?????
}

void doDefaultPalette()
{	
  DMA_doDma(DMA_CRAM, palette, 0, 16, -1);	
}
...

...
SYS_setHIntCallback(doPaletteSwap);	
VDP_setHIntCounter(160);
SYS_setVIntCallback(doDefaultPalette);
...
while true
...

Re: Palette change and SYS_setHIntCallback

Posted: Thu Apr 23, 2020 7:25 am
by Stef
You can't expect updating a complete palette in a single scanline to work like that (afaik it's possible at the cost of half of the sprite but you have to really prepare and optimize it). Usually game tend to update about 2 to 4 colors per scanline, and it's better to do it during hblank... So at best you will spent 1 scaline to sync on next hblank, then use 4 scanlines at best to update the whole palette.

Re: Palette change and SYS_setHIntCallback

Posted: Thu Apr 23, 2020 5:18 pm
by cloudstrifer
I don't know how to do it. :oops:

I'm reading about this, trying to understand about palette color change and hblank.
I don't want to ask too much, but can you show me an example?

Thank you.