SGDK - Fading issues
Posted: Wed May 29, 2013 11:43 am
Hey Guys,
I'm getting closer to understanding how this thing works
I attempted to fade an image in and then out again.
The fading in part works, but when I start fading out, it's palette colours swap to white and then fade to black.
Can anyone help me explain why?
Here's the code I am using (I pasted the full thing, just so you can see what's going on).
Hope someone can help me again!
regards,
Dennis
I'm getting closer to understanding how this thing works

I attempted to fade an image in and then out again.
The fading in part works, but when I start fading out, it's palette colours swap to white and then fade to black.
Can anyone help me explain why?
Here's the code I am using (I pasted the full thing, just so you can see what's going on).
Code: Select all
#include <genesis.h>
extern GenResTiles FRBackground;
extern GenResTiles FRLogo;
#define TILEPRIO 0
int main()
{
// Set game to PAL format
VDP_setScreenHeight240();
// Load Data for background
VDP_setPalette(PAL1, FRBackground.pal); // this palette needs to fade
// load tiles in VRAM
// arg0 = tiles data
// arg1 = index for first destination tile
// arg2 = number of tiles to load
// arg3 = use DMA (1) or not (0)
VDP_loadTileData(FRBackground.tiles, TILE_USERINDEX, FRBackground.width*FRBackground.height, 0);
// VDP_loadTileData(FRLogo.tiles, TILE_USERINDEX, FRLogo.width*FRLogo.height, 0);
VDP_fadePalIn(PAL1, FRBackground.pal, 60, 1); // start fading in (before we draw the map, so it doesnt "pop" for a frame)
// Draw images on screen
// arg0 = draw plane (APLAN | BPLAN)
// arg1 = tile data
// arg0 = pallette to use
// arg1 = priority
// arg2 = flip
// arg3 = flip
// arg4 = index
// arg2 = X position
// arg3 = Y position
// arg4 = width (in tiles)
// arg5 = height (in tiles)
VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(PAL1, TILEPRIO, 0, 0, TILE_USERINDEX), 0, 0, FRBackground.width, FRBackground.height);
// VDP_fillTileMapRectInc(BPLAN, TILE_ATTR_FULL(PAL2, TILEPRIO, 0, 0, TILE_USERINDEX + tilesLoaded), 0, 0, FRLogo.width, FRLogo.height);
// "Menu" text
VDP_drawTextBG(BPLAN, "Press start to continue ", TILE_ATTR(PAL0, 1, 0, 0), 8, 24);
// fading
VDP_waitFadeCompletion(); // wait til fade has completed
VDP_setPalette(PAL1, FRBackground.pal); // update palette (after fading, the colours still looked a tint darker)
waitTick(TICKPERSECOND * 2); // wait for 2 seconds
VDP_clearTextBG(BPLAN, 8, 24, 24); // remove text
VDP_fadePalOut(PAL1, 60, 0); // Fade image out
VDP_waitFadeCompletion(); // wait til fade has completed
while(1)
{
//read input
//move sprite
//update score
//draw current screen (logo, start screen, settings, game, gameover, credits...)
//wait for screen refresh
VDP_waitVSync();
}
return (0);
}
regards,
Dennis