📄 ddgpe.cpp
字号:
return BltPrepare( &(pddgpeBltParms->gpeBltParms) );
}
SCODE DDGPE::PerformBlt(
DDGPEBltParms* pddgpeBltParms
)
{
SCODE rc = S_OK;
if (pddgpeBltParms == NULL)
{
return E_INVALIDARG;
}
rc = BltPrepare( pddgpeBltParms );
if( FAILED(rc) )
return rc;
/*DEBUGMSG(1, (TEXT("DDRAW Dest Info:\n\r") ));
DEBUGMSG(1, (TEXT(" left = %d\n\r"), parms.prclDst->left ));
DEBUGMSG(1, (TEXT(" top = %d\n\r"), parms.prclDst->top ));
DEBUGMSG(1, (TEXT(" right = %d\n\r"), parms.prclDst->right ));
DEBUGMSG(1, (TEXT(" bottom = %d\n\r"), parms.prclDst->bottom ));
if (pSrc != NULL)
{
DEBUGMSG(1, (TEXT("DDRAW Src Info:\n\r") ));
DEBUGMSG(1, (TEXT(" left = %d\n\r"), parms.prclSrc->left ));
DEBUGMSG(1, (TEXT(" top = %d\n\r"), parms.prclSrc->top ));
DEBUGMSG(1, (TEXT(" right = %d\n\r"), parms.prclSrc->right ));
DEBUGMSG(1, (TEXT(" bottom = %d\n\r"), parms.prclSrc->bottom ));
}*/
//rc = (PGPE(pGPE)->*(parms.pBlt))( &parms ); // old way
rc = (this->*(pddgpeBltParms->gpeBltParms.pBlt))( &(pddgpeBltParms->gpeBltParms) );
if( FAILED(rc) )
return rc;
return BltComplete( &(pddgpeBltParms->gpeBltParms) );
}
SCODE DDGPE::BltExpanded
(DDGPESurf* pDst,
DDGPESurf* pSrc,
DDGPESurf* pPattern,
DDGPESurf* pMask,
CLIPOBJ* pco,
XLATEOBJ* pxlo,
CONST RECT * prclDst,
CONST RECT * prclSrc,
ULONG solidColor,
ULONG bltFlags,
ROP4 rop4
)
{
SCODE sc = NOERROR;
DDGPEDriverData* pDriverData = NULL;
DDGPEBltParms ddgpeBltParms;
// if( pGPE->SurfaceBusyFlipping( pDst ) )
// {
// if( bltFlags & 0x100 ) // TBD: Review, - need const
// pGPE->WaitForVBlank();
// else
// return DDERR_WASSTILLDRAWING;
// }
pDriverData = GetDriverData();
memset( (void *)&ddgpeBltParms, 0, sizeof(ddgpeBltParms) );
ddgpeBltParms.dwVersion = DDGPEBLTPARMS_CURRENTVERSION;
if ((pDriverData != NULL) && (pDriverData->dwSize > 0))
{
ddgpeBltParms.dwDriverSignature = pDriverData->dwDriverSignature;
}
ddgpeBltParms.gpeBltParms.pDst = pDst;
ddgpeBltParms.gpeBltParms.pSrc = pSrc;
ddgpeBltParms.gpeBltParms.pMask = (GPESurf *)NULL;
ddgpeBltParms.gpeBltParms.pBrush = pPattern;
ddgpeBltParms.gpeBltParms.prclDst = (RECTL *)prclDst;
ddgpeBltParms.gpeBltParms.prclSrc = (RECTL *)prclSrc;
// ddgpeBltParms.gpeBltParms.prclClip = (RECTL *)NULL;
ddgpeBltParms.gpeBltParms.solidColor = solidColor;
ddgpeBltParms.gpeBltParms.bltFlags = bltFlags;
ddgpeBltParms.gpeBltParms.rop4 = rop4;
// ddgpeBltParms.gpeBltParms.prclMask = (RECTL *)NULL;
// ddgpeBltParms.gpeBltParms.pptlBrush = (POINTL *)NULL;
// ddgpeBltParms.gpeBltParms.pLookup = (unsigned long *)NULL;
// ddgpeBltParms.gpeBltParms.pConvert = (ColorConverter::*)(unsigned long)NULL;
// ddgpeBltParms.gpeBltParms.pColorConverter = (ColorConverter *)NULL;
ddgpeBltParms.gpeBltParms.xPositive = 1;
ddgpeBltParms.gpeBltParms.yPositive = 1;
if( (pSrc != NULL) && ((GPESurf *)(pDst) == (GPESurf *)(pSrc)) ) // <-- Won't happen on stretch Blts
{
// Check for overlap since source and dest surfaces are the same
if( prclSrc->bottom > prclDst->top
&& prclSrc->top < prclDst->bottom
&& prclSrc->right > prclDst->left
&& prclSrc->left < prclDst->right )
{
if( prclSrc->top == prclDst->top )
{
// Horizontal blt, just set xPositive appropriately
ddgpeBltParms.gpeBltParms.xPositive = (prclSrc->left >= prclDst->left);
}
else
{
// Non horizontal blts, just set yPositive appropriately
ddgpeBltParms.gpeBltParms.yPositive = (prclSrc->top >= prclDst->top);
}
// In case we enumerate cliprects - determine the order to use
/*if( prclSrc->top > prclTrg->top )
{
iDir = ( prclSrc->left > prclTrg->left ) ? CD_RIGHTDOWN : CD_LEFTDOWN;
}
else
{
iDir = ( prclSrc->left > prclTrg->left ) ? CD_RIGHTUP : CD_LEFTUP;
}*/
}
}
sc = PerformBlt(&ddgpeBltParms);
return sc;
}
SCODE DDGPE::BltExpanded
(DDGPESurf* pDst,
DDGPESurf* pSrc,
DDGPESurf* pPattern,
CONST RECT * prclDst,
CONST RECT * prclSrc,
ULONG solidColor,
ULONG bltFlags,
ROP4 rop4
)
{
SCODE sc = NOERROR;
sc = BltExpanded(
pDst,
pSrc,
pPattern,
NULL, //pMask,
NULL, //pco,
NULL, //pxlo,
prclDst,
prclSrc,
solidColor,
bltFlags,
rop4
);
return sc;
}
void DDGPE::SetVisibleSurface(
GPESurf* pSurf,
DWORD dwData,
BOOL bWaitForVBlank/* = FALSE*/
)
{
// driver should override this function to use the dwData parameter
SetVisibleSurface(pSurf, bWaitForVBlank);
}
void DDGPE::SetVisibleSurface(
GPESurf* pSurf,
BOOL bWaitForVBlank/* = FALSE*/
)
{
if (bWaitForVBlank)
{
while (InVBlank()) {}
while (!InVBlank()) {}
}
GPE::SetVisibleSurface(pSurf);
}
// returns DD_OK for OK otherwise error code
// populates *pFormat, and *pPixelFormat
SCODE DDGPE::DetectPixelFormat(
DWORD dwCaps, // in: DDSCAPS_xxx flags
DDPIXELFORMAT* pDDPF, // in: Explicit pixel format or current mode
EGPEFormat* pFormat,
EDDGPEPixelFormat* pPixelFormat
)
{
//DebugBreak();
if( pDDPF->dwFlags & DDPF_RGB )
{
if( !(pDDPF->dwFlags & DDPF_ALPHAPIXELS) )
{
pDDPF->dwRGBAlphaBitMask = 0;
}
if( pDDPF->dwRGBBitCount == 4 )
{
*pPixelFormat = ddgpePixelFormat_4bpp;
}
else if( pDDPF->dwRGBBitCount == 8 )
{
*pPixelFormat = ddgpePixelFormat_8bpp;
}
else if (( pDDPF->dwRGBBitCount == 16 ) ||
( pDDPF->dwRGBBitCount == 15 ))
{
//if( pDDPF->dwRGBAlphaBitMask == 0x0000 && pDDPF->dwRBitMask == 0xF800 )
if (IsRGB565(pDDPF))
{
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("565 surface detected\r\n") ));
*pPixelFormat = ddgpePixelFormat_565;
}
//else if( pDDPF->dwRGBAlphaBitMask == 0x8000 && pDDPF->dwRBitMask == 0x7C00 )
else if (IsRGB1555(pDDPF))
{
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("1555 surface detected\r\n") ));
*pPixelFormat = ddgpePixelFormat_5551;
}
//else if( pDDPF->dwRGBAlphaBitMask == 0xF000 && pDDPF->dwRBitMask == 0x0F00 )
else if (IsRGB4444(pDDPF))
{
*pPixelFormat = ddgpePixelFormat_4444;
}
//else if( pDDPF->dwRGBAlphaBitMask == 0x0000 && pDDPF->dwRBitMask == 0x7C00 )
else if (IsRGB0555(pDDPF))
{
*pPixelFormat = ddgpePixelFormat_5550;
}
else
{
return DDERR_INVALIDPIXELFORMAT;
}
}
else if( pDDPF->dwRGBBitCount == 24 )
{
//if( pDDPF->dwRGBAlphaBitMask == 0x000000 && pDDPF->dwRBitMask == 0xFF0000 )
if (IsRGB0888(pDDPF))
{
*pPixelFormat = ddgpePixelFormat_8880;
}
else
{
return DDERR_INVALIDPIXELFORMAT;
}
}
else if( pDDPF->dwRGBBitCount == 32 )
{
//if( pDDPF->dwRGBAlphaBitMask == 0xFF000000 && pDDPF->dwRBitMask == 0x00FF0000 )
if (IsRGB8888(pDDPF))
{
*pPixelFormat = ddgpePixelFormat_8888;
}
else
{
return DDERR_INVALIDPIXELFORMAT;
}
}
else
{
return DDERR_INVALIDPIXELFORMAT;
}
}
else if( pDDPF->dwFlags & DDPF_ZBUFFER )
{
//*pPixelFormat = ddgpePixelFormat_raw;
return DDERR_UNSUPPORTEDFORMAT;
}
else if( pDDPF->dwFlags & DDPF_FOURCC )
{
if( pDDPF->dwFourCC == FOURCC_YUYV422 )
{
*pPixelFormat = ddgpePixelFormat_YUYV422;
}
else if( pDDPF->dwFourCC == FOURCC_UYVY422 )
{
*pPixelFormat = ddgpePixelFormat_UYVY422;
}
else if( pDDPF->dwFourCC == FOURCC_YUY2422 )
{
*pPixelFormat = ddgpePixelFormat_YUY2422;
}
else
{
return DDERR_UNSUPPORTEDFORMAT;
}
}
else
{
return DDERR_INVALIDPIXELFORMAT;
}
*pFormat = EDDGPEPixelFormatToEGPEFormat[*pPixelFormat];
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("Detected surface pixelFormat, format = %d, %d\r\n"), *pPixelFormat, *pFormat));
return DD_OK;
}
SCODE DDGPE::DetectMode
(DWORD* dwModeID,
DWORD dwWidth,
DWORD dwHeight,
EGPEFormat format,
EDDGPEPixelFormat pixelFormat,
DDPIXELFORMAT* pDDPF/* = NULL*/ // in: Explicit pixel format or current mode
)
{
// we can ignore the pDDPF, because we've looked at it as much as possible
// already to figure out the pixelFormat
// anyone who wants to do more than this function offers must override this in the
// subclassed DDGPE
// to find an appropriate mode, index through all the modes
// and check the parameters set for that mode.
// we require an exact match
DWORD dwNumModes = 0;
SCODE sc = S_OK;
GPEMode modeInfo;
GPEModeEx modeInfoEx;
DWORD dwCurrentMode = 0;
memset(&modeInfoEx, 0, sizeof(modeInfoEx));
dwNumModes = NumModes();
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("DetectMode: There are 0x%d modes\r\n"), dwNumModes));
for (dwCurrentMode = 0; dwCurrentMode < dwNumModes; dwCurrentMode++)
{
sc = g_pGPE->GetModeInfo(&modeInfo, dwCurrentMode);
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("DetectMode: Getting info on mode %d.\r\n"), dwCurrentMode));
if (SUCCEEDED(sc))
{
sc = g_pGPE->GetModeInfoEx(&modeInfoEx, dwCurrentMode);
if (FAILED(sc))
{
// function probably wasn't supported by the driver
modeInfoEx.ePixelFormat = EGPEFormatToEDDGPEPixelFormat[modeInfo.format];
sc = S_OK;
}
else
{
//pixelFormat = modeInfoEx.ePixelFormat;
}
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("DetectMode: Mode Info\r\n") ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode width = %d\r\n"), modeInfo.width ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode height = %d\r\n"), modeInfo.height ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode format = %d\r\n"), modeInfo.format ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode pixel format = %d\r\n"), modeInfoEx.ePixelFormat ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT("DetectMode: Requested\r\n") ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode width = %d\r\n"), dwWidth ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode height = %d\r\n"), dwHeight ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode format = %d\r\n"), format ));
DEBUGMSG(GPE_ZONE_CREATE, (TEXT(" mode pixel format = %d\r\n"), pixelFormat ));
if ( ((DWORD)modeInfo.width == dwWidth) &&
((DWORD)modeInfo.height == dwHeight) &&
(modeInfo.format == format) &&
(modeInfoEx.ePixelFormat == pixelFormat) &&
(1)) // kinda strange but added here so commenting out various lines in this if.. is easy
{
*dwModeID = dwCurrentMode;
break;
}
}
else
{
DEBUGMSG(GPE_ZONE_CREATE | GPE_ZONE_ERROR, (TEXT("DetectMode: Info on mode %d FAILED 0x%08x\r\n"), dwCurrentMode, sc));
}
}
return sc;
}
////
// Stub functions
////
int DDGPE::InDisplay(void)
{
return 0;
}
////
// Stub functions to mark as unsupported
////
SCODE
DDGPE::GetModeInfoEx(GPEModeEx *pModeEx, int modeNo)
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDGPE::GetModeInfoEx Unsupported\r\n")));
return E_NOTIMPL;
}
SCODE DDGPE::SetMode(
int modeNo,
HPALETTE * pPalette,
BOOL bChangeGDISurfaceMode
)
{
DEBUGMSG(GPE_ZONE_WARNING, (TEXT("DDGPE::SetMode() is Not Implemented by DDI\r\n") ));
return E_NOTIMPL;
}
//////////////////////////////////////////////////////////////////////////////////////////////
void RegisterDDHALAPI(VOID)
{
; // DDHAL wrapper not required for new-style DDI/DDHAL
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -