📄 gpeaccel.cpp
字号:
{
//
// Its what the spec says to do if xDiff == yDiff
//
*GRAPHICS_LINEINC = 4095 | (4095 << LINEINC_YINC_SHIFT);
//
// Calculate the ending physical address. The real ending address commented out.
// We just need to know the ending byte inside of the word. Since stride is always
// on a word boundary we can get rid of the term.
//
ulPhysEnd = ulPhysStart + cPels * BytesPerPixel * iXdir + cPels * stride * iYdir ;
ulRight = cPels * BytesPerPixel * iXdir;
}
else
{
switch(iDir)
{
//
// (xDiff > yDiff)
//
case 0:
case 3:
case 4:
case 7:
//
// Its what the spec says to do if xDiff > yDiff
//
*GRAPHICS_LINEINC = 4095 |
(((dN * 4095) / dM) << LINEINC_YINC_SHIFT);
//
// The real address
//
ulPhysEnd = ulPhysStart + cPels * (iXdir * BytesPerPixel + iYdir *stride * dN / dM);
ulRight = cPels * iXdir * BytesPerPixel;
break;
//
// (yDiff > xDiff)
//
case 1:
case 2:
case 5:
case 6:
//
// Its what the spec says to do if xDiff < yDiff
//
*GRAPHICS_LINEINC = (((dN * 4095) / dM) << LINEINC_XINC_SHIFT) |
(4095 << LINEINC_YINC_SHIFT);
ulPhysEnd = ulPhysStart + iYdir * cPels * stride + ( (iXdir * BytesPerPixel * cPels * dN) / dM);
ulRight = ( (iXdir * BytesPerPixel * cPels * dN) / dM);
break;
}
}
//
// BLKDESTWIDTH = xDiff % 4096
//
*GRAPHICS_BLKDESTWIDTH = cPels & 0xfff;
//
// BLKDESTHEIGT = xDiff / 4096
//
*GRAPHICS_BLKDESTHEIGHT = cPels >> 12;
*GRAPHICS_BLKDESTSTRT = ulPhysStart;
*GRAPHICS_DESTPIXELSTRT = ((ulPhysStart & 0x3) << 3) |
//((ulPhysEnd & 0x3) << (DESTPIXELSTRT_EPEL_SHIFT + 3));
(((ulRight-BytesPerPixel) & 0x3) << (DESTPIXELSTRT_EPEL_SHIFT + 3));
//
// The number of words in a scan line.
//
*GRAPHICS_DESTLINELENGTH = (stride>>2);
*GRAPHICS_BLKSRCSTRT = 0;
*GRAPHICS_SRCPIXELSTRT = 0;
*GRAPHICS_BLKSRCWIDTH = 0;
*GRAPHICS_SRCLINELENGTH = 0;
*GRAPHICS_LINEINIT = 2048 |
(2048 << LINEINIT_YINIT_SHIFT);
*GRAPHICS_LINEPATTRN = (lineParameters->style & LINEPATTRN_PTRN_MASK) |
( 0xF << LINEPATTRN_CNT_SHIFT);
*GRAPHICS_TRANSPATTRN = 0;
*GRAPHICS_BACKGROUND = lineParameters->solidColor;
*GRAPHICS_BLOCKMASK = lineParameters->solidColor;
//
// I don't think that this is ever necessary.
//
//if (sLine->BackgroundEn)
//{
// Control |= BLOCKCTRL_BACKGROUNDG;
//}
*GRAPHICS_BLOCKCTRL = ulControl |= BLOCKCTRL_BG | BLOCKCTRL_LINE | (BytesPerPixel << (BLOCKCTRL_PIXEL_SHIFT + 1));
*GRAPHICS_BLOCKCTRL = ulControl | BLOCKCTRL_ENABLE;
return S_OK;
}
//****************************************************************************
// GPEAccel::Line
//****************************************************************************
//
//
SCODE GPEAccel::Line
(
GPELineParms *lineParameters,
EGPEPhase phase
)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::Line\r\n")));
//
// Don't start another GDI operation until the last has finished.
//
if (phase == gpeSingle || phase == gpePrepare)
{
if (( lineParameters->pDst->InVideoMemory()) &&
( (lineParameters->style & 0xFFFF) == (lineParameters->style>>16)) &&
( lineParameters->mix == 0x0d0d ))
{
lineParameters->pLine = (SCODE (GPE::*)(struct GPELineParms *)) &GPEAccel::AcceleratedLine;
}
else
{
WaitForNotBusy();
lineParameters->pLine = &GPE::EmulatedLine;
}
}
return S_OK;
}
//****************************************************************************
// GPEAccel::BltPrepare
//****************************************************************************
//
SCODE GPEAccel::BltPrepare(GPEBltParms *pBltParms)
{
// RECTL rectl;
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEAccel::BltPrepare\r\n")));
BOOL bTryAccelSoft = TRUE;
#ifdef BSP_EP93XX_DISPLAY_ROTATION
//
if ( pBltParms->pDst == m_pPrimarySurface || pBltParms->pSrc == m_pPrimarySurface ){
pBltParms->pBlt = (SCODE (GPE::*)(GPEBltParms *))&GPEAccel::EmulatedBltRotate; // catch all
}
else
#endif
{
pBltParms->pBlt = &GPE::EmulatedBlt; // catch all
}
//return S_OK;
// Don't start another GDI operation until the last has finished.
//
//
// Can only hardware accel if Destination is in video memory and
// if the graphics is not performing another operation.
//
if (pBltParms->pDst->InVideoMemory() )
{
switch (pBltParms->rop4)
{
case 0x0000: // BLACKNESS
pBltParms->solidColor = 0x0;
pBltParms->pBlt = (SCODE (GPE::*) (struct GPEBltParms *)) &GPEAccel::AcceleratedFillRect;
bTryAccelSoft = FALSE;
break;
case 0xFFFF: // WHITENESS
pBltParms->solidColor = 0xffffff;
pBltParms->pBlt = (SCODE (GPE::*) (struct GPEBltParms *)) &GPEAccel::AcceleratedFillRect;
bTryAccelSoft = FALSE;
break;
case 0xF0F0: // PATCOPY
if(pBltParms->solidColor != -1)
{
pBltParms->pBlt = (SCODE (GPE::*) (struct GPEBltParms *)) &GPEAccel::AcceleratedFillRect;
bTryAccelSoft = FALSE;
}
break;
#ifndef BSP_EP93XX_DISPLAY_ROTATION
case 0x6666: // SRCINVERT
case 0x8888: // SRCAND
case 0xEEEE: // SRCPAINT
case 0xCCCC: // SRCCOPY
if( ( !pBltParms->pSrc->InVideoMemory() ) || // Only Accelerate For Source In Memory
( pBltParms->pLookup ) || // Emulate if color conversion required
( pBltParms->pConvert ) || // Emulate if color conversion required
( pBltParms->bltFlags & BLT_STRETCH ) || // Emulate if Stretching required
( pBltParms->bltFlags & BLT_TRANSPARENT ) ) // Emulate if transparent
{
break;
}
pBltParms->pBlt = (SCODE (GPE::*) (struct GPEBltParms *)) &GPEAccel::AcceleratedSrcCopyBlt;
bTryAccelSoft = FALSE;
break;
case 0x3333: // NOTSRCCOPY
if( ( !pBltParms->pSrc->InVideoMemory() ) || // Only Accelerate For Source In Memory
( pBltParms->pLookup ) || // Emulate if color conversion required
( pBltParms->pConvert ) || // Emulate if color conversion required
( pBltParms->bltFlags & BLT_STRETCH ) || // Emulate if Stretching required
( pBltParms->bltFlags & BLT_TRANSPARENT ) ) // Emulate if transparent
{
break;
}
pBltParms->pBlt = (SCODE (GPE::*) (struct GPEBltParms *)) &GPEAccel::AcceleratedSrcCopyBlt;
bTryAccelSoft = FALSE;
break;
#endif
default:
break;
}
}
//
// If we don't use the Hardware ROP, try to find a software blit if one is
// available.
//
if(bTryAccelSoft)
{
//
// EmulatedBlt will select proper optimized software blits available or cleartype
// or antialiased blts available.
//
WaitForNotBusy();
}
return S_OK;
}
//****************************************************************************
// GPEAccel::BltComplete
//****************************************************************************
//
SCODE GPEAccel::BltComplete(GPEBltParms *blitParameters)
{
return S_OK;
}
//****************************************************************************
// GPEAccel::InVBlank
//****************************************************************************
// We don't have to worry about blanking.
//
INT GPEAccel::InVBlank(void)
{
static BOOL value = FALSE;
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::InVBlank\r\n")));
value = !value;
return value;
}
//****************************************************************************
// PrintPalette
//****************************************************************************
// Debug routine to print out the current palette
//
//
void PrintPalette()
{
#ifdef DEBUG
ULONG ulEntry;
DEBUGMSG (GPE_ZONE_LINE, (L"GPEAccel: Current Palette, "));
//
// If the print Palette zone is enabled print out the palette whenever
// we open the palette.
//
if(GPE_ZONE_PALETTE)
{
for(ulEntry = 0; ulEntry < 256 ; ulEntry+=4)
{
RETAILMSG
(
1,
(
L"Entry 0x%03x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
ulEntry,
RASTER_COLOR_LUT[ulEntry],
RASTER_COLOR_LUT[ulEntry + 1],
RASTER_COLOR_LUT[ulEntry + 2],
RASTER_COLOR_LUT[ulEntry + 3]
)
);
}
}
#endif //DEBUG
}
//****************************************************************************
// GPEAccel::SetPalette
//****************************************************************************
// Set up the Color Look up table. There are two LUT's in hardware.
// the lookup table that is visible is not the one that is accessable.
//
//
SCODE GPEAccel::SetPalette
(
const PALETTEENTRY *source,
USHORT firstEntry,
USHORT numEntries
)
{
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::SetPalette\r\n")));
ULONG ulEntry;
ULONG ulCount;
if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
{
DEBUGMSG (GPE_ZONE_LINE,(TEXT("SetPalette invalid arguments\r\n")));
return E_INVALIDARG;
}
//
// Copy into our palette.
//
memcpy((void *)&m_Palette[firstEntry], source, sizeof(PALETTEENTRY) * numEntries);
//
// I would do a memory copy but the red and blue
// palette entries are reversed.
//
for(ulEntry = firstEntry ; ulEntry < numEntries; ulEntry++)
{
unsigned char red, green, blue;
//
// Get the values for Red, Green and Blue.
//
red = source[ulEntry].peRed ;
green = source[ulEntry].peGreen;
blue = source[ulEntry].peBlue;
//
// Program up the Color lookup table.
//
RASTER_COLOR_LUT[ulEntry] = ((ULONG)red<< 16) + ((ULONG)green << 8) + (ULONG)blue;
}
//
// Switch to the other LUT and program the same values.
//
*RASTER_LUTCONT ^= LUTCONT_SWTCH;
//
// Wait until a palette switch occurs at the end of the frame.
//
for(ulCount = 0 ;; ulCount++)
{
//
// Put a small delay to wait for the change.
//
Sleep(1);
//
// Has the switch occured.
//
if(((*RASTER_LUTCONT & LUTCONT_SSTAT) && (*RASTER_LUTCONT &LUTCONT_SWTCH)) ||
(!(*RASTER_LUTCONT & LUTCONT_SSTAT) && !(*RASTER_LUTCONT & LUTCONT_SWTCH)))
{
break;
}
if(ulCount > 100)
{
DEBUGMSG (GPE_ZONE_LINE, (TEXT("ERROR: Palette switch never occured.\n")));
}
}
//
// I would do a memory copy but the red and blue
// palette entries are reversed.
//
for(ulEntry = firstEntry ; ulEntry < numEntries; ulEntry++)
{
unsigned char red, green, blue;
//
// Get the values for Red, Green and Blue.
//
red = source[ulEntry].peRed ;
green = source[ulEntry].peGreen;
blue = source[ulEntry].peBlue;
//
// Program up the Color lookup table.
//
RASTER_COLOR_LUT[ulEntry] = ((ULONG)red<< 16) + ((ULONG)green << 8) + (ULONG)blue;
}
//
// Print out the palette to the debugger if the debug zone is enabled.
//
PrintPalette();
return S_OK;
}
//****************************************************************************
// GPEAccel::GetGraphicsCaps
//****************************************************************************
//
//
ULONG GPEAccel::GetGraphicsCaps()
{
DEBUGMSG (GPE_ZONE_LINE, (TEXT("GPEAccel::GetGraphicsCaps\r\n")));
ULONG ret = 0;
if (m_pMode)
{
//
// if in 16bpp mode, return GCAPS_GRAY16 to denote that we support
// anti-aliased fonts
if (m_pMode->Bpp == 16)
{
ret = GCAPS_GRAY16;
}
}
ret = ret | GCAPS_CLEARTYPE;
return ret;
}
//****************************************************************************
// RegisterDDHALAPI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -