📄 specialobject.c
字号:
IMG_UINT32 ui32NumVerts;
IMG_FLOAT afVertdata[12];
IMG_UINT32 ui32ISPTSPWord, ui32TSPObjectWord, ui32TempBlockHeader, ui323DControlWord;
IMG_UINT32 ui32RegionClip, ui32FPControlWord;
ui32FPControlWord = MBX1_TAFPFORMAT_TYPEIEEEFLOAT;
if(psRect)
{
if(psRect->i32X == gc->sLastDrawMask.i32X &&
psRect->i32Y == gc->sLastDrawMask.i32Y &&
psRect->ui32Width == gc->sLastDrawMask.ui32Width &&
psRect->ui32Height == gc->sLastDrawMask.ui32Height)
{
return;
}
if(bIsEnable)
{
/* Do fullscreen disable first */
afVertdata[0] = 0.0f;
afVertdata[1] = 0.0f;
afVertdata[2] = 1.0f;
afVertdata[3] = 2.0f * psDrawParams->ui32Width;
afVertdata[4] = 0.0f;
afVertdata[5] = 1.0f;
afVertdata[6] = 0.0f;
afVertdata[7] = 2.0f * psDrawParams->ui32Height;
afVertdata[8] = 1.0f;
ui323DControlWord = MBX1_TAOBJTYPE_STATE |
MBX1_TASTATEPRES_ISPCTL |
MBX1_TASTATEPRES_TSPCTL |
MBX1_TASTATEPRES_REGIONCLIP |
MBX1_TASTATEPRES_FP_INPUTFORMAT;
#ifndef FIX_HW_PRN_145
ui32ISPTSPWord = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_LOGICALOPDISABLE |
MBX1_ISPTSPCTL_CKDISABLE |
MBX1_ISPTSPCTL_OBJTYPE_VIEWPORT |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
MBX1_ISPTSPCTL_DWDISABLE |
MBX1_ISPTSPCTL_TAGWDISABLE;
#else
ui32ISPTSPWord = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_BLENDOPMODEFOGNONE |
MBX1_ISPTSPCTL_CKDISABLE |
MBX1_ISPTSPCTL_OBJTYPE_VIEWPORT |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
MBX1_ISPTSPCTL_DWDISABLE |
MBX1_ISPTSPCTL_TAGWDISABLE;
#endif
ui32TSPObjectWord = MBX1_TSPOBJ_ACMPMODEALWAYS;
ui32RegionClip = MBX1_TASTATERGNCLIP_CLIPNONE;
ui32TempBlockHeader = gc->sHWContext.ui32PrimitiveHeader;
EmitState(gc, &ui323DControlWord, 1);
EmitState(gc, &ui32ISPTSPWord, 1);
EmitState(gc, &ui32TSPObjectWord, 1);
EmitState(gc, &ui32RegionClip, 1);
EmitState(gc, &ui32FPControlWord, 1);
/* Preserve terminate word bit only */
gc->sHWContext.ui32PrimitiveHeader &= MBX1_TAPRIM_USE_TERMINATE_WORD;
gc->sHWContext.ui32PrimitiveHeader |= MBX1_TAPRIM_CULLMODENONE;
StartTriangleStrip(gc);
OutputVerticesSpecialObject(gc, afVertdata, 3, 3);
EndPrimitiveBlock(gc);
gc->sHWContext.ui32PrimitiveHeader = ui32TempBlockHeader;
}
else
{
DPF((DBG_ERROR,"What is a non-fullscreen disable for?"));
return;
}
/* Now do non-fullscreen enable */
/*
* The vertices are organised as a strip.
*
* [1] (X0, Y1) --- (X1, Y1) [3]
* | \ |
* [0] (X0, Y0) --- (X1, Y0) [2]
*/
afVertdata[0] = (IMG_FLOAT)psRect->i32X;
afVertdata[1] = (IMG_FLOAT)psRect->i32Y;
afVertdata[2] = 1.0f;
afVertdata[3] = (IMG_FLOAT)psRect->i32X;
afVertdata[4] = (IMG_FLOAT)(psRect->i32Y + psRect->ui32Height);
afVertdata[5] = 1.0f;
afVertdata[6] = (IMG_FLOAT)(psRect->i32X + psRect->ui32Width);
afVertdata[7] = (IMG_FLOAT)psRect->i32Y;
afVertdata[8] = 1.0f;
afVertdata[9] = (IMG_FLOAT)(psRect->i32X + psRect->ui32Width);
afVertdata[10] = (IMG_FLOAT)(psRect->i32Y + psRect->ui32Height);
afVertdata[11] = 1.0f;
ui32NumVerts = 4;
gc->sLastDrawMask = *psRect;
gc->bLastDrawMaskFullScreenEnable = IMG_FALSE;
ui32RegionClip = CalcRegionClip(gc, psRect);
}
else
{
/* Fullscreen */
if(gc->bLastDrawMaskFullScreenEnable && bIsEnable)
return;
afVertdata[0] = 0.0f;
afVertdata[1] = 0.0f;
afVertdata[2] = 1.0f;
afVertdata[3] = 2.0f * psDrawParams->ui32Width;
afVertdata[4] = 0.0f;
afVertdata[5] = 1.0f;
afVertdata[6] = 0.0f;
afVertdata[7] = 2.0f * psDrawParams->ui32Height;
afVertdata[8] = 1.0f;
ui32NumVerts = 3;
gc->sLastDrawMask.i32X = 0;
gc->sLastDrawMask.i32Y = 0;
gc->sLastDrawMask.ui32Width = psDrawParams->ui32Width;
gc->sLastDrawMask.ui32Width = psDrawParams->ui32Height;
gc->bLastDrawMaskFullScreenEnable = bIsEnable;
ui32RegionClip = MBX1_TASTATERGNCLIP_CLIPNONE;
}
ui323DControlWord = MBX1_TAOBJTYPE_STATE |
MBX1_TASTATEPRES_ISPCTL |
MBX1_TASTATEPRES_TSPCTL |
MBX1_TASTATEPRES_REGIONCLIP |
MBX1_TASTATEPRES_FP_INPUTFORMAT;
#ifndef FIX_HW_PRN_145
ui32ISPTSPWord = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_LOGICALOPDISABLE |
MBX1_ISPTSPCTL_CKDISABLE |
MBX1_ISPTSPCTL_OBJTYPE_VIEWPORT |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
MBX1_ISPTSPCTL_DWDISABLE |
MBX1_ISPTSPCTL_TAGWDISABLE |
(bIsEnable ? MBX1_ISPTSPCTL_VIEWPORTMASK : 0);
#else
ui32ISPTSPWord = MBX1_ISPTSPCTL_SRCBLENDONE |
MBX1_ISPTSPCTL_DESTBLENDZERO |
MBX1_ISPTSPCTL_BLENDOPMODEFOGNONE |
MBX1_ISPTSPCTL_CKDISABLE |
MBX1_ISPTSPCTL_OBJTYPE_VIEWPORT |
MBX1_ISPTSPCTL_DCMPMODEALWAYS |
MBX1_ISPTSPCTL_DWDISABLE |
MBX1_ISPTSPCTL_TAGWDISABLE |
(bIsEnable ? MBX1_ISPTSPCTL_VIEWPORTMASK : 0);
#endif
ui32TSPObjectWord = MBX1_TSPOBJ_ACMPMODEALWAYS;
ui32TempBlockHeader = gc->sHWContext.ui32PrimitiveHeader;
EmitState(gc, &ui323DControlWord, 1);
EmitState(gc, &ui32ISPTSPWord, 1);
EmitState(gc, &ui32TSPObjectWord, 1);
EmitState(gc, &ui32RegionClip, 1);
EmitState(gc, &ui32FPControlWord, 1);
/* Preserve terminate word bit only */
gc->sHWContext.ui32PrimitiveHeader &= MBX1_TAPRIM_USE_TERMINATE_WORD;
gc->sHWContext.ui32PrimitiveHeader |= MBX1_TAPRIM_CULLMODENONE;
StartTriangleStrip(gc);
OutputVerticesSpecialObject(gc, afVertdata, ui32NumVerts, 3);
EndPrimitiveBlock(gc);
gc->sHWContext.ui32PrimitiveHeader = ui32TempBlockHeader;
/* Need to mark these bits as dirty for re-emission. */
gc->sHWContext.ui32TAControland3DState |= (ui323DControlWord & ~MBX1_TASTATEPRES_REGIONCLIP);
}
#endif
/***********************************************************************************
Function Name : SendDrawMaskForPrimitive
Inputs : gc
Outputs : -
Returns : -
Description : Calculates the currently required drawmasks, combining scissor,
viewport and drawablePrivate information.
************************************************************************************/
IMG_VOID SendDrawMaskForPrimitive(GLESContext *gc)
{
/*
* Only do something if something has changed
*/
if (gc->bDrawMaskInvalid && gc->psRenderSurface->bInFrame)
{
GLESDrawMaskRect sScissor;
GLESDrawableParams *psDrawParams = &gc->sDrawableParams;
IMG_INT32 i32X1, i32Y1, i32X0, i32Y0;
gc->bDrawMaskInvalid = IMG_FALSE;
if ((gc->ui32FrameEnables & GLES_FS_SCISSOR_ENABLE) && !gc->bFullScreenScissor)
{
if(gc->sState.sScissor.ui32ScissorWidth == 0 || gc->sState.sScissor.ui32ScissorHeight == 0)
{
/*
* Full screen should be scissored here
* Do full screen disable.
*/
SendDrawMaskRect(gc, NULL, IMG_FALSE);
return;
}
switch(psDrawParams->eRotationAngle)
{
case ROTATE_0:
default:
i32X0 = gc->sState.sScissor.i32ScissorX;
i32Y0 = psDrawParams->ui32Height -
(gc->sState.sScissor.i32ScissorY + gc->sState.sScissor.ui32ScissorHeight);
break;
case ROTATE_90:
i32X0 = psDrawParams->ui32Width -
(gc->sState.sScissor.i32ScissorX + gc->sState.sScissor.ui32ScissorWidth);
i32Y0 = psDrawParams->ui32Height -
(gc->sState.sScissor.i32ScissorY + gc->sState.sScissor.ui32ScissorHeight);
break;
case ROTATE_180:
i32X0 = psDrawParams->ui32Width -
(gc->sState.sScissor.i32ScissorX + gc->sState.sScissor.ui32ScissorWidth);
i32Y0 = gc->sState.sScissor.i32ScissorY;
break;
case ROTATE_270:
i32X0 = gc->sState.sScissor.i32ScissorX;
i32Y0 = gc->sState.sScissor.i32ScissorY;
break;
}
i32X1 = i32X0 + gc->sState.sScissor.ui32ScissorWidth;
i32Y1 = i32Y0 + gc->sState.sScissor.ui32ScissorHeight;
if (!gc->bFullScreenViewport)
{
GLint nXV0, nYV0, nXV1, nYV1;
/* Work out a combination of the viewport and scissor */
switch(psDrawParams->eRotationAngle)
{
case ROTATE_0:
default:
nXV0 = gc->sState.sViewport.i32X;
nYV0 = psDrawParams->ui32Height - (gc->sState.sViewport.i32Y + gc->sState.sViewport.ui32Height);
break;
case ROTATE_90:
nXV0 = psDrawParams->ui32Width - (gc->sState.sViewport.i32X + gc->sState.sViewport.ui32Width);
nYV0 = psDrawParams->ui32Height - (gc->sState.sViewport.i32Y + gc->sState.sViewport.ui32Height);
break;
case ROTATE_180:
nXV0 = psDrawParams->ui32Width - (gc->sState.sViewport.i32X + gc->sState.sViewport.ui32Width);
nYV0 = gc->sState.sViewport.i32Y;
break;
case ROTATE_270:
nXV0 = gc->sState.sViewport.i32X;
nYV0 = gc->sState.sViewport.i32Y;
break;
}
nXV1 = nXV0 + gc->sState.sViewport.ui32Width;
nYV1 = nYV0 + gc->sState.sViewport.ui32Height;
if ((i32X1 < nXV0) || (i32Y1 < nYV0) || (i32X0 > nXV1) || (i32Y0 > nYV1))
{
/*
* Viewport and scissor don't overlap so scissor fullscreen
* Do full screen disable.
*/
SendDrawMaskRect(gc, NULL, IMG_FALSE);
return;
}
else
{
/*
* Determine overlapping rectangle
*/
i32X0 = MAX(i32X0, nXV0);
i32X1 = MIN(i32X1, nXV1);
i32Y0 = MAX(i32Y0, nYV0);
i32Y1 = MIN(i32Y1, nYV1);
}
}
}
else if (!gc->bFullScreenViewport)
{
/*
* If there's no scissor and the viewport isn't full screen,
* set clip to the current viewport
*/
switch(psDrawParams->eRotationAngle)
{
case ROTATE_0:
default:
i32X0 = gc->sState.sViewport.i32X;
i32Y0 = psDrawParams->ui32Height - (gc->sState.sViewport.i32Y + gc->sState.sViewport.ui32Height);
break;
case ROTATE_90:
i32X0 = psDrawParams->ui32Width - (gc->sState.sViewport.i32X + gc->sState.sViewport.ui32Width);
i32Y0 = psDrawParams->ui32Height - (gc->sState.sViewport.i32Y + gc->sState.sViewport.ui32Height);
break;
case ROTATE_180:
i32X0 = psDrawParams->ui32Width - (gc->sState.sViewport.i32X + gc->sState.sViewport.ui32Width);
i32Y0 = gc->sState.sViewport.i32Y;
break;
case ROTATE_270:
i32X0 = gc->sState.sViewport.i32X;
i32Y0 = gc->sState.sViewport.i32Y;
break;
}
i32X1 = i32X0 + gc->sState.sViewport.ui32Width;
i32Y1 = i32Y0 + gc->sState.sViewport.ui32Height;
}
else
{
/*
* No scissor, fullscreen viewport and not single buffered window
* = Fullscreen enable
*/
SendDrawMaskRect(gc, NULL, IMG_TRUE);
return;
}
/*
* Make sure the scissor/viewport hasn't any negative coordinates
*/
if (i32X0 < 0)
{
if (i32X1 < 0)
{
/*
* Viewport/scissor is off screen
* Do full screen disable.
*/
SendDrawMaskRect(gc, NULL, IMG_FALSE);
return;
}
else
{
i32X0 = 0;
}
}
if (i32Y0 < 0)
{
if (i32Y1 < 0)
{
/*
* Viewport/scissor is off screen
* Do full screen disable.
*/
SendDrawMaskRect(gc, NULL, IMG_FALSE);
return;
}
else
{
i32Y0 = 0;
}
}
/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -