📄 gpeaccel.cpp
字号:
//
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::SetPointerShape Invalid Cursor Width, cX = 0%08x\r\n"), cX));
return S_FALSE;
}
if( bSizeChanged ) {
if( m_ucCusorValue)
delete m_ucCusorValue;
m_ucCusorValue= new UCHAR[cX*cY];
if( !m_ucCusorValue )
return S_FALSE;
}
//
// Store size and hotspot for new cursor
//
m_CursorSize.x = cX;
m_CursorSize.y = cY;
m_CursorHotspot.x = xHot;
m_CursorHotspot.y = yHot;
//
// Disable the cursor if the size has changed.
//
if(m_bCursorEnabled && bSizeChanged)
{
*RASTER_CURSORXYLOC &= ~CURSORXYLOC_CEN;
//
// Program in the cursor size register.
//
*RASTER_CURSORSIZE = ulCursorSize | ((cY - 1)<<CURSORSIZE_CLINS_SHIFT);
}
int pos=0;
UCHAR ucTemp;
UCHAR * pValue=m_ucCusorValue;
//
// store OR and AND mask for new cursor
//
andPtr = (UCHAR*)pMask->Buffer();
for (row = 0; row < cY; row++)
{
xorPtr = andPtr + (cY * pMask->Stride());
for (col = 0; col < cX / 8; col++)
{
bAnd = ~andPtr[row * pMask->Stride() + col];
bXor = xorPtr[row * pMask->Stride() + col];
usMask = 0;
//following two loops invert the two bytes and the bits in the two bytes.
for ( i = 0; i < 4; i++)
{
ucTemp= (bAnd &(0x1<<i) ) ? 0x02 :0;
ucTemp|= (bXor &(0x1<<i) ) ? 0x01 :0;
pValue[4+pos + 3 -i]=ucTemp;
}
for ( i = 0; i < 4; i++)
{
ucTemp= (bAnd &(0x1<<(4+i) ) ) ? 0x02 :0;
ucTemp|= (bXor &(0x1<<(4+i) ) ) ? 0x01 :0;
pValue[pos+ 3- i]=ucTemp;
}
pos+=8;
}
}
return FlushPointer( cX, cY ,bSizeChanged);
}
//****************************************************************************
// GPEAccel::FlushPointer
//****************************************************************************
//
SCODE GPEAccel::FlushPointer( INT cX, INT cY ,BOOL bSizeChanged )
{
ULONG ulXYLOC;
UCHAR usMask;
int pos=0;
int row;
int col;
int iCursorBit=0;
int iMaxCol=cX/4;
int i;
UCHAR * pValue=m_ucCusorValue;
#ifdef BSP_EP93XX_DISPLAY_ROTATION
UCHAR * ucTempCursor= new UCHAR[cX*cY];
if( (!ucTempCursor) ){
if(ucTempCursor)
delete ucTempCursor;
return S_FALSE;
}
//Rotate the matrix:
switch( m_iRotate ) {
case DMDO_180:
for( row=0; row< cY; row++ ){
for (col = 0; col < cX ; col++) {
//ucTempCursor[row][col]=m_ucCusorValue[cY-1-row][cX-1-col];
ucTempCursor[row*cX + col]=m_ucCusorValue[(cY-1-row)*cX + (cX-1-col)];
}
}
//Since the data has been copied to m_ucCusorValue, the next line is useless.
pValue=ucTempCursor;
break;
case DMDO_90:
{
for( row=0; row< cY; row++ ){
for (col = 0; col < cX ; col++) {
//ucTempCursor[row][col]=m_ucCusorValue[col][cY-1-row];
ucTempCursor[row*cX+col]=m_ucCusorValue[col*cX +( cY-1-row ) ];
}
}
pValue=ucTempCursor;
}
break;
case DMDO_270:
{
for( row=0; row< cY; row++ ){
for (col = 0; col < cX ; col++) {
//ucTempCursor[row][col]=m_ucCusorValue[cX-1-col][row];
ucTempCursor[row*cX+col]=m_ucCusorValue[(cX-1-col)*cX + row];
}
}
pValue=ucTempCursor;
}
break;
default:
break;
}
#endif
pos=0;
for (row = 0; row < cY; row++) {
for (col = 0; col < iMaxCol; col++) {
usMask=0;
for( i=0; i< 4; i++){
usMask|= (pValue[pos++] << (6-2*i) );
}
((PUCHAR)m_pCursor)[iCursorBit++ ] = (UCHAR)usMask;
}
}
//
// Cursor has been initialized.
//
m_bCursorHasShape = TRUE;
//
// Enable the cursor and display the new cursor.
//
if(m_bCursorEnabled)
{
//
// Compute new cursor rect
//
m_CursorRect.left = m_xPosition - m_CursorHotspot.x;
//m_CursorRect.right = m_CursorRect.left + m_CursorSize.x;
m_CursorRect.top = m_yPosition - m_CursorHotspot.y;
//m_CursorRect.bottom = m_CursorRect.top + m_CursorSize.y;
ulXYLOC = CURSORXYLOC_XMASK & ((m_StartStop.ulHActiveStart - m_CursorRect.left)<<CURSORXYLOC_XSHIFT);
ulXYLOC |= CURSORXYLOC_YMASK & ((m_StartStop.ulVActiveStart - m_CursorRect.top)<<CURSORXYLOC_YSHIFT);
// ulXYLOC |= m_bCursorEnabled? CURSORXYLOC_CEN: 0;
ulXYLOC |= CURSORXYLOC_CEN;
//
// Write the New XY Cursor value.
//
*RASTER_CURSORXYLOC = ulXYLOC;
}
//
// Renable the cursor if the size has changed.
//
if(m_bCursorEnabled && bSizeChanged)
{
*RASTER_CURSORXYLOC |= CURSORXYLOC_CEN;
}
#ifdef BSP_EP93XX_DISPLAY_ROTATION
if(ucTempCursor)
delete ucTempCursor;
#endif
return S_OK;
}
//****************************************************************************
// GPEAccel::MovePointer
//****************************************************************************
//
SCODE GPEAccel::MovePointer(INT xPosition, INT yPosition)
{
ULONG ulXYLOC;
static INT iLastRotate=0;
if (xPosition != -1 || yPosition != -1)
{
// Compute new cursor rect
m_CursorRect.left = xPosition- m_CursorHotspot.x;
m_CursorRect.top = yPosition - m_CursorHotspot.y;
m_CursorRect.right = m_CursorRect.left + m_CursorSize.x;
m_CursorRect.bottom = m_CursorRect.top + m_CursorSize.y;
#ifdef BSP_EP93XX_DISPLAY_ROTATION
RotateRectl( &m_CursorRect );
if( iLastRotate != m_iRotate ){
FlushPointer( m_CursorSize.x, m_CursorSize.y ,TRUE);
//yPosition=-1;
iLastRotate=m_iRotate;
}
#endif
m_xPosition = m_CursorRect.left;
m_yPosition = m_CursorRect.top;
if(m_bCursorHasShape)
{
ulXYLOC = CURSORXYLOC_XMASK & ((m_StartStop.ulHActiveStart - m_CursorRect.left)<<CURSORXYLOC_XSHIFT);
ulXYLOC |= CURSORXYLOC_YMASK & ((m_StartStop.ulVActiveStart - m_CursorRect.top)<<CURSORXYLOC_YSHIFT);
ulXYLOC |= CURSORXYLOC_CEN;
}
m_bCursorEnabled = TRUE;
}
else
{
ulXYLOC = 0;
m_bCursorEnabled = FALSE;
}
//
// Write the New XY Cursor value.
//
*RASTER_CURSORXYLOC = ulXYLOC;
return S_OK;
}
//****************************************************************************
// GPEAccel::WaitForNotBusy
//****************************************************************************
// In the EP9312 Video is never busy.
//
void GPEAccel::WaitForNotBusy(void)
{
//
// TODO TODO TODO this should have a timeout.
//
#if 0
int i;
for(i=0; i<500 & (*GRAPHICS_BLOCKCTRL & BLOCKCTRL_ENABLE); i++)
{}
#else
while(*GRAPHICS_BLOCKCTRL & BLOCKCTRL_ENABLE);
#endif
return;
}
//****************************************************************************
// GPEAccel::IsBusy
//****************************************************************************
// In the EP9312 Video is never busy.
//
int GPEAccel::IsBusy(void)
{
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::IsBusy\r\n")));
return (*GRAPHICS_BLOCKCTRL & BLOCKCTRL_ENABLE)? TRUE:FALSE;
}
//****************************************************************************
// GPEAccel::GetPhysicalVideoMemory
//****************************************************************************
// Get the Physical memory base and video memory size.
//
void GPEAccel::GetPhysicalVideoMemory
(
unsigned long *physicalMemoryBase,
unsigned long *videoMemorySize
)
{
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::GetPhysicalVideoMemory\r\n")));
*physicalMemoryBase = m_pvFlatFrameBuffer;
*videoMemorySize = m_cbScanLineLength * m_cyPhysicalScreen;
}
#ifdef DD_ENABLE
void GPEAccel::GetVirtualVideoMemory(unsigned long *virtualMemoryBase, unsigned long *videoMemorySize)
{
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::GetVirtualVideoMemory\r\n")));
*virtualMemoryBase = m_VirtualFrameBuffer;
*videoMemorySize = m_cbScanLineLength * m_cyPhysicalScreen;
}
#endif // DD_ENABLE
//****************************************************************************
// GPEAccel::WrappedEmulatedLine
//****************************************************************************
//
//
SCODE GPEAccel::WrappedEmulatedLine (GPELineParms *lineParameters)
{
SCODE retval;
// do emulated line
retval = EmulatedLine (lineParameters);
return retval;
}
//****************************************************************************
// GPEAccel::AcceleratedLine
//****************************************************************************
// Performs a hardware accelerate line draw.
//
//
SCODE GPEAccel::AcceleratedLine (GPELineParms *lineParameters)
{
ULONG ulControl = 0;
int iDir = lineParameters->iDir;
ULONG dN = lineParameters->dN;
ULONG dM = lineParameters->dM;
int cPels = lineParameters->cPels;
int xStart = lineParameters->xStart;
int yStart = lineParameters->yStart;
int iXdir;
int iYdir;
ULONG ulPhysStart;
ULONG ulPhysEnd;
GPESurf *pDst = lineParameters->pDst;
ULONG ulRight;
// RETAILMSG(1, (TEXT("AcceleratedLine xStart %d yStart %d cPels %d style 0x%08x\r\n"), xStart, yStart, cPels, lineParameters->style));
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::AcceleratedLine")));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" xStart = %d"),xStart ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" yStart = %d"),yStart ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" cPels = %d"),cPels ));
/*
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" xStart = %d"),xStart ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" yStart = %d"),yStart ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" cPels = %d"),cPels ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" iDir = %d"),iDir ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" style = 0x%08x"),lineParameters->style ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" dN = %d"),dN ));
DEBUGMSG (GPE_ZONE_LINE, (TEXT(" dM = %d\r\n"),dM ));
*/
int BytesPerPixel = EGPEFormatToBpp[pDst->Format()] >> 3;
int stride = pDst->Stride();
// Line drawing in negative X direction is not supported.
if( lineParameters->iDir == 2 || lineParameters->iDir == 3 ||
lineParameters->iDir == 4 || lineParameters->iDir == 5 )
return EmulatedLine(lineParameters);
if( dN != 0 ) // Accelerate only horizontal and vertical lines.
return EmulatedLine(lineParameters);
//
// Check to see if cPels is negative.
//
if(cPels < 0)
{
cPels = -1 * cPels;
iDir = (iDir + 4) & 7 ;
}
//
// omit the end points
//
if(cPels > 0) cPels--;
//
// Figure out which direction the line is going.
//
switch(iDir)
{
case 0:
case 1:
ulControl = 0;
iXdir = 1;
iYdir = 1;
break;
case 2:
case 3:
ulControl = BLOCKCTRL_DXDIR;
iXdir = -1;
iYdir = 1;
break;
case 4:
case 5:
ulControl = BLOCKCTRL_DXDIR | BLOCKCTRL_DYDIR;
iXdir = -1;
iYdir = -1;
break;
case 6:
case 7:
ulControl = BLOCKCTRL_DYDIR;
iXdir = 1;
iYdir = -1;
break;
default:
DEBUGMSG (GPE_ZONE_LINE,(TEXT("Invalid direction: %d\r\n"), lineParameters->iDir));
return E_INVALIDARG;
}
//
// Start of the Physical buffer.
//
ulPhysStart = yStart * stride + xStart * BytesPerPixel + pDst->OffsetInVideoMemory() + FRAMEBUF_PHYSICAL_MEMORY;
//
// Wait until the last possible moment to wait for the graphics engine to be finished.
//
#ifdef DD_ENABLE
//FlushDCache();
CacheRangeFlush(NULL, 0, CACHE_SYNC_DISCARD );
#endif
WaitForNotBusy();
if(dN == dM)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -