Stephane-D / SGDK

SGDK - A free and open development kit for the Sega Mega Drive
https://www.patreon.com/SGDK
MIT License
1.77k stars 189 forks source link

Problems with palette fading process #362

Closed saintienn closed 1 week ago

saintienn commented 4 weeks ago

Hi Stef, I've been having some issues since the commit: I simplified/improved the palette fading process a bit to avoid transferring the palette out of the vblank

I use memcpy to do fadeIn/fadeout effects and after this commit all the palette colors remain black.

My code: memcpy( & stage_pallete[16], startscreen_pal.data, 32); memcpy( & stage_pallete[32], startscreen_pal.data, 32);

map = MAP_create( & startscreen_map, BG_A, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind)); VDP_loadTileSet( & startscreen_tileset, ind, CPU);

VDP_setScrollingMode(HSCROLL_PLANE, VSCROLL_PLANE); MAP_scrollToEx(map, 1, 1,FALSE); PAL_fadeIn(0, 63, stage_pallete, 50, 1);

So I saw the changes in pal.c and tried to fix the problem by changing line 375 in the NO_INLINE PAL_doFadeStep(void) function

From this: PAL_setColors(fadeInd, fadeCurrentPal, fadeSize, DMA_QUEUE); To this: PAL_setColors(fadeInd, fadeCurrentPal, fadeSize, (fadeSize > 16) ? DMA:CPU);

And Cha-Ching! the fades are back. But I'm confused, what could be happening?

Stephane-D commented 1 week ago

Should be fixed now :-)