source/src/graphics.c
//set the fade flag to fade in or not and increase the fadecounter to startvalue
set the fade flag to fade in or not and increase the fadecounter to startvalue
set the fade flag to fade in or not and increase the fadecounter to startvalue
void startfade(uint8_t afadein, uint8_t ForTitle)
{
    #ifdef NINTENDO
    if((_cpu == CGB_TYPE) || sgb_enabled)
    {
    #endif
        #ifdef NINTENDO
        fadeSteps = 5;
        if(_cpu == CGB_TYPE)
        {
            startFade = 7;
        }
        else
        {
            startFade = 3;
        }
        #endif
        #ifdef GAMEGEAR
        fadeSteps = 4;
        startFade = 8;
        #endif
        #ifdef MASTERSYSTEM
        fadeSteps = 2;
        startFade = 10;
        #endif
        fadeCounter = 1;
        fadeStep = 0;
    #ifdef NINTENDO
    }
    else
    {
        fadeStep = 6;
        fadeSteps = 4;
        startFade = fadeSteps * fadeStep;
        fadeCounter = startFade;
    }
    #endif
    fadein = afadein;
    uint8_t sgbpal;
    sgbpal = 0;
    #ifdef SEGA
    sgbpal = 1;
    #endif
    sgbpal = sgbpal | sgb_enabled;
    if (ForTitle)
    {
        if (sgbpal)
        {
            memcpy(toPallette, bkgSgbPaletteTitle, sizeof(toPallette));
        }
        else
        {
            memcpy(toPallette, bkgPaletteTitle, sizeof(toPallette));
        }
    }
    else
    {
        if (sgbpal)
        {
            memcpy(toPallette, bkgSgbPaletteGame, sizeof(toPallette));
        }
        else
        {
            memcpy(toPallette, bkgPaletteGame, sizeof(toPallette));
        }
    }
}
void startfade ( uint8_t afadein , uint8_t ForTitle ) { #ifdef NINTENDO if ( ( _cpu == CGB_TYPE ) || sgb_enabled ) { #endif 
        #ifdef NINTENDO fadeSteps = 5 ; if ( _cpu == CGB_TYPE ) { startFade = 7 ; } else { startFade = 3 ; } #endif 
        #ifdef GAMEGEAR fadeSteps = 4 ; startFade = 8 ; #endif 
        #ifdef MASTERSYSTEM fadeSteps = 2 ; startFade = 10 ; #endif 
        fadeCounter = 1; fadeStep = 0 ; #ifdef NINTENDO } else { fadeStep = 6 ; fadeSteps = 4 ; startFade = fadeSteps * fadeStep ; fadeCounter = startFade ; } #endif fadein = afadein ; uint8_t sgbpal ; sgbpal = 0 ; #ifdef SEGA sgbpal = 1 ; #endif sgbpal = sgbpal | sgb_enabled ; if ( ForTitle ) { if ( sgbpal ) { memcpy ( toPallette , bkgSgbPaletteTitle , sizeof ( toPallette ) ) ; } else { memcpy ( toPallette , bkgPaletteTitle , sizeof ( toPallette ) ) ; } } else { if ( sgbpal ) { memcpy ( toPallette , bkgSgbPaletteGame , sizeof ( toPallette ) ) ; } else { memcpy ( toPallette , bkgPaletteGame , sizeof ( toPallette ) ) ; } } }
set the fade flag to fade in or not and increase the fadecounter to startvalue
set the fade flag to fade in or not and increase the fadecounter to startvalue


        //6 steps on color gameboy to go from default pallete to black and vice versa (goes from 0 to fadesteps) //skips per fadestep to prolong fade effect //skips per fadestep to prolong fade effect //skips per fadestep to prolong fade effect 

        //counts from 1 to startfade above then increases fadestep  //fade step we are at (will go until fadestep > fadesteps) //how long takes each step //4 steps on dmg gameboy to go from default pallete to black and vice versa //set temporary palette based on title or gameplay (screen is only faded on 2 places)