//=================================================================
//
// Copyright (c) Microsoft Corporation 1999 - All Rights Reserved.
//
//=================================================================

//-----------------------------------------------------------------------------
//
// _STEPEDGE_FN_NAME_   Name of the step edge function (must be left edge)
// _GOURAUD_  Define this to interpolate the intensity along the edge.
// _AFFINE_                 Define this to use affine texture mapping along the edge.
// _PERSPECTIVE_            Define this to use perspective texture mapping along the edge.
// _ZBUFFER_                Define this to interpolate the z-values along the edge.
// _FOG_                    Define this to interpolate fog intensity along the edge.
//
//-----------------------------------------------------------------------------

void _STEPEDGE_FN_NAME_(void)
{
    GRFEDGE *pgeEdge = &g_grdRenderData.geEdge;

   	pgeEdge->x += pgeEdge->xStep;
    pgeEdge->y++;

	pgeEdge->xError += pgeEdge->xNum;
	if(pgeEdge->xError >= 0)
    {
		pgeEdge->x++;
		pgeEdge->xError -= pgeEdge->xDenom;

#if defined(_AFFINE_)
        pgeEdge->u += pgeEdge->uStepExtra;
        pgeEdge->v += pgeEdge->vStepExtra;
#endif

#if defined(_PERSPECTIVE_)
   		pgeEdge->oow += pgeEdge->oowStepExtra;
		pgeEdge->uow += pgeEdge->uowStepExtra;
        pgeEdge->vow += pgeEdge->vowStepExtra;
#endif

#if defined(_ZBUFFER_)
   		pgeEdge->Z += pgeEdge->ZStepExtra;
#endif

#if defined(_GOURAUD_)
        pgeEdge->f16Blue += pgeEdge->f16BlueStepExtra;

        if (!(g_grdRenderData.dwState & STATE_SHADEI))
        {
            pgeEdge->f16Green += pgeEdge->f16GreenStepExtra;
            pgeEdge->f16Red += pgeEdge->f16RedStepExtra;
        }

        if (g_grdRenderData.dwState & STATE_SHADEALPHA)
        {
            pgeEdge->f16Alpha += pgeEdge->f16AlphaStepExtra;
        }
#endif

#if defined(_FOG_)
        if (!g_grdRenderData.fFogIsFlat)
        {
            pgeEdge->f16Fog += pgeEdge->f16FogStepExtra;
        }
#endif
	}
	else
	{
#if defined(_AFFINE_)
		pgeEdge->u += pgeEdge->uStep;
		pgeEdge->v += pgeEdge->vStep;
#endif

#if defined(_PERSPECTIVE_)
   		pgeEdge->oow += pgeEdge->oowStep;
		pgeEdge->uow += pgeEdge->uowStep;
		pgeEdge->vow += pgeEdge->vowStep;
#endif

#if defined(_ZBUFFER_)
		pgeEdge->Z += pgeEdge->ZStep;
#endif

#if defined(_GOURAUD_)
        pgeEdge->f16Blue += pgeEdge->f16BlueStep;

        if (!(g_grdRenderData.dwState & STATE_SHADEI))
        {
            pgeEdge->f16Green += pgeEdge->f16GreenStep;
            pgeEdge->f16Red += pgeEdge->f16RedStep;
        }

        if (g_grdRenderData.dwState & STATE_SHADEALPHA)
        {
            pgeEdge->f16Alpha += pgeEdge->f16AlphaStep;
        }
#endif

#if defined(_FOG_)
        if (!g_grdRenderData.fFogIsFlat)
        {
            pgeEdge->f16Fog += pgeEdge->f16FogStep;
        }
#endif
	}
}

