wrapbpp.cpp

来自「老外的一个开源项目」· C++ 代码 · 共 716 行 · 第 1/3 页

CPP
716
字号
}

void Wrapbpp::GetPhysicalVideoMemory
(
	unsigned long *pPhysicalMemoryBase,
	unsigned long *pVideoMemorySize
)
{
	*pPhysicalMemoryBase = (ULONG)DispDrvrPhysicalFrameBuffer;
	*pVideoMemorySize = DispDrvr_cdwStride * DispDrvr_cyScreen / 4;
}


SCODE Wrapbpp::AllocSurface(
	GPESurf **ppSurf,
	INT width,
	INT height,
	EGPEFormat format,
	INT surfaceFlags )
{
	if (surfaceFlags & GPE_REQUIRE_VIDEO_MEMORY) 
	{
        // Can't allocate video-memory surfaces in the Wrapbpp environment
		return E_OUTOFMEMORY;
	}
	// Allocate from system memory
	DEBUGMSG(GPE_ZONE_CREATE,(TEXT("Creating a GPESurf in system memory. EGPEFormat = %d\r\n"), (int)format ));
	*ppSurf = new GPESurf( width, height, format );
	if( *ppSurf )
	{
		// check we allocated bits succesfully
		if( !((*ppSurf)->Buffer()) )
			delete *ppSurf;	// and then return E_OUTOFMEMORY
		else
			return S_OK;
	}
	return E_OUTOFMEMORY;
}


SCODE Wrapbpp::WrappedEmulatedLine( GPELineParms *pParms )
{		
	SCODE sc = EmulatedLine(pParms);	// Draw to the backup framebuffer	

	if(FAILED(sc))
	{
		return sc;
	}
	
	// Now, calculate the dirty-rect to refresh to the actual hardware
	RECT bounds;

	int N_plus_1;			// Minor length of bounding rect + 1

	if( pParms->dN)			// The line has a diagonal component (we'll refresh the bounding rect)
	{
		N_plus_1 = 2 + ((pParms->cPels * pParms->dN) / pParms->dM);
	}
	else
	{
		N_plus_1 = 1;
	}

	switch(pParms->iDir) 
	{
		case 0:
			bounds.left   = pParms->xStart;
			bounds.top    = pParms->yStart;
			bounds.right  = pParms->xStart + pParms->cPels + 1;
			bounds.bottom = bounds.top     + N_plus_1;
			break;
		case 1:
			bounds.left   = pParms->xStart;
			bounds.top    = pParms->yStart;
			bounds.bottom = pParms->yStart + pParms->cPels + 1;
			bounds.right  = bounds.left    + N_plus_1;
			break;
		case 2:
			bounds.right  = pParms->xStart + 1;
			bounds.top    = pParms->yStart;
			bounds.bottom = pParms->yStart + pParms->cPels + 1;
			bounds.left   = bounds.right   - N_plus_1;
			break;
		case 3:
			bounds.right  = pParms->xStart + 1;
			bounds.top    = pParms->yStart;
			bounds.left   = pParms->xStart - pParms->cPels;
			bounds.bottom = bounds.top + N_plus_1;
			break;
		case 4:
			bounds.right  = pParms->xStart + 1;
			bounds.bottom = pParms->yStart + 1;
			bounds.left   = pParms->xStart - pParms->cPels;
			bounds.top    = bounds.bottom  - N_plus_1;
			break;
		case 5:
			bounds.right   = pParms->xStart + 1;
			bounds.bottom  = pParms->yStart + 1;
			bounds.top     = pParms->yStart - pParms->cPels;
			bounds.left    = bounds.right   - N_plus_1;
			break;
		case 6:
			bounds.left    = pParms->xStart;
			bounds.bottom  = pParms->yStart + 1;
			bounds.top     = pParms->yStart - pParms->cPels;
			bounds.right   = bounds.left    + N_plus_1;
			break;
		case 7:
			bounds.left    = pParms->xStart;
			bounds.bottom  = pParms->yStart + 1;
			bounds.right   = pParms->xStart + pParms->cPels + 1;
			bounds.top     = bounds.bottom  - N_plus_1;
			break;
		default:
			DEBUGMSG(GPE_ZONE_ERROR,(TEXT("Invalid direction: %d\r\n"),pParms->iDir));
			return E_INVALIDARG;
	}

	DispDrvrDirtyRectDump((LPRECT)&bounds);

	return sc;
}
   
			  
SCODE Wrapbpp::Line(
	GPELineParms *pLineParms,
	EGPEPhase phase	)
{
	DEBUGMSG(GPE_ZONE_LINE,(TEXT("Wrapbpp::Line\r\n")));

	if(phase == gpeSingle || phase == gpePrepare) 
	{
		if((pLineParms->pDst != m_pPrimarySurface) || (DispDrvrPhysicalFrameBuffer != NULL))
		{
            pLineParms->pLine = &GPE::EmulatedLine;
		}
		else
		{
            pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms *))&Wrapbpp::WrappedEmulatedLine;
		}
	}
	return S_OK;
}

#undef SWAP
#define SWAP(type,a,b) { type tmp; tmp=a; a=b; b=tmp; }

SCODE Wrapbpp::WrappedEmulatedBlt( GPEBltParms *pParms )
{
	SCODE sc = EmulatedBlt(pParms);	// Draw to the backup framebuffer

	if( FAILED(sc))
		return sc;

	// Now, calculate the dirty-rect to refresh to the actual hardware
	RECT bounds;

	bounds.left		= pParms->prclDst->left;
	bounds.top		= pParms->prclDst->top;
	bounds.right	= pParms->prclDst->right;
	bounds.bottom	= pParms->prclDst->bottom;

	if(bounds.left > bounds.right) 
	{
		SWAP(int,bounds.left,bounds.right)
	}
	if( bounds.top > bounds.bottom) 
	{
		SWAP(int,bounds.top,bounds.bottom)
	}

	DispDrvrDirtyRectDump((LPRECT)&bounds);

	return sc;
}

SCODE Wrapbpp::BltPrepare(
	GPEBltParms *pBltParms )
{
	DEBUGMSG(GPE_ZONE_LINE,(TEXT("Wrapbpp::BltPrepare\r\n")));

	if((pBltParms->pDst != m_pPrimarySurface) || (DispDrvrPhysicalFrameBuffer != NULL))
	{
        pBltParms->pBlt = &GPE::EmulatedBlt;
	}
	else
	{
        pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))&Wrapbpp::WrappedEmulatedBlt;
	}
	return S_OK;
}


SCODE Wrapbpp::BltComplete( GPEBltParms *pBltParms	)
{
	return S_OK;
}

int Wrapbpp::InVBlank(void)
{
	return 0;
}


SCODE Wrapbpp::SetPalette
(
    const PALETTEENTRY *source,
    unsigned short firstEntry,
    unsigned short numEntries
)
{
	return S_OK;
}

void 
RegisterDDHALAPI()
{
        ;       // No DDHAL support in wrapper
}

ULONG *APIENTRY DrvGetMasks(
	DHPDEV dhpdev)
{
	switch ((DispDrvr_cdwStride * 32)/DispDrvr_cxScreen)
	{ // Bpp
		case 2:
		    return BitMasks2bpp;
			break;
		case 8:
		case 16:
			return BitMasks8bpp;
			break;
		default:
			return NULL;
			break;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?