Palette change and SYS_setHIntCallback

SGDK only sub forum

Moderator: Stef

Post Reply
cloudstrifer
Very interested
Posts: 118
Joined: Mon Feb 19, 2018 7:31 pm

Palette change and SYS_setHIntCallback

Post by cloudstrifer » Thu Apr 23, 2020 3:32 am

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
...
Last edited by cloudstrifer on Thu Apr 23, 2020 1:22 pm, edited 2 times in total.

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

Re: Palette change and SYS_setHIntCallback

Post by Stef » Thu Apr 23, 2020 7:25 am

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.

cloudstrifer
Very interested
Posts: 118
Joined: Mon Feb 19, 2018 7:31 pm

Re: Palette change and SYS_setHIntCallback

Post by cloudstrifer » Thu Apr 23, 2020 5:18 pm

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.

Post Reply