📄 gpeflat.cpp
字号:
GPELineParms *lineParameters,
EGPEPhase phase
)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEFlat::Line\r\n")));
if (phase == gpeSingle || phase == gpePrepare)
{
if ((lineParameters->pDst != m_pPrimarySurface))
{
lineParameters->pLine = EmulatedLine;
}
else
{
lineParameters->pLine = (SCODE (GPE::*)(struct GPELineParms *)) WrappedEmulatedLine;
}
}
return S_OK;
}
//****************************************************************************
// GPEFlat::BltPrepare
//****************************************************************************
//
SCODE GPEFlat::BltPrepare(GPEBltParms *blitParameters)
{
RECTL rectl;
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEFlat::BltPrepare\r\n")));
//
// default to base EmulatedBlt routine
//
blitParameters->pBlt = EmulatedBlt;
//
// see if we need to deal with cursor
//
if (m_CursorVisible && !m_CursorDisabled)
{
//
// check for destination overlap with cursor and turn off cursor if overlaps
// only care if dest is main display surface
//
if (blitParameters->pDst == m_pPrimarySurface)
{
//
// make sure there is a valid prclDst
//
if (blitParameters->prclDst != NULL)
{
//
// if so, use it
//
rectl = *blitParameters->prclDst;
}
else
{
//
// if not, use the Cursor rect - this forces the cursor to be turned off in this case
//
rectl = m_CursorRect;
}
if (m_CursorRect.top < rectl.bottom && m_CursorRect.bottom > rectl.top &&
m_CursorRect.left < rectl.right && m_CursorRect.right > rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
//
// check for source overlap with cursor and turn off cursor if overlaps
// only care if source is main display surface
//
if (blitParameters->pSrc == m_pPrimarySurface)
{
//
// make sure there is a valid prclSrc
//
if (blitParameters->prclSrc != NULL)
{
//
// if so, use it
//
rectl = *blitParameters->prclSrc;
}
else
{
//
// if not, use the CUrsor rect - this forces the cursor to be turned off in this case
//
rectl = m_CursorRect;
}
if (m_CursorRect.top < rectl.bottom && m_CursorRect.bottom > rectl.top &&
m_CursorRect.left < rectl.right && m_CursorRect.right > rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
}
// see if there are any optimized software blits available
EmulatedBltSelect02(blitParameters);
EmulatedBltSelect08(blitParameters);
EmulatedBltSelect16(blitParameters);
return S_OK;
}
//****************************************************************************
// GPEFlat::BltComplete
//****************************************************************************
//
SCODE GPEFlat::BltComplete(GPEBltParms *blitParameters)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEFlat::BltComplete\r\n")));
// see if cursor was forced off because of overlap with source or destination and turn back on
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
return S_OK;
}
//****************************************************************************
// GPEFlat::InVBlank
//****************************************************************************
// We don't have to worry about blanking.
//
INT GPEFlat::InVBlank(void)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEFlat::InVBlank\r\n")));
return 0;
}
//****************************************************************************
// PrintPalette
//****************************************************************************
// Debug routine to print out the current palette
//
//
void PrintPalette()
{
#ifdef DEBUG
ULONG ulEntry;
DEBUGMSG (GPE_ZONE_PALETTE, (L"GPEFLat: 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)
{
DEBUGMSG
(
GPE_ZONE_PALETTE,
(
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
}
//****************************************************************************
// GPEFlat::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 GPEFlat::SetPalette
(
const PALETTEENTRY *source,
USHORT firstEntry,
USHORT numEntries
)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("GPEFlat::SetPalette\r\n")));
ULONG ulEntry;
ULONG ulCount;
if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
{
RETAILMSG(1,(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_INIT, (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;
}
//****************************************************************************
// GPEFlat::GetGraphicsCaps
//****************************************************************************
//
//
ULONG GPEFlat::GetGraphicsCaps()
{
if (m_pMode)
{
//
// if in 16bpp mode, return GCAPS_GRAY16 to denote that we support
// anti-aliased fonts
if (m_pMode->Bpp == 16)
{
return GCAPS_GRAY16;
}
}
return 0;
}
//****************************************************************************
// RegisterDDHALAPI
//****************************************************************************
// no DDHAL support
//
void RegisterDDHALAPI(void)
{
return;
}
ULONG gBitMasks[] = { 0x0001,0x0002,0x0000 };
//****************************************************************************
// DrvGetMasks
//****************************************************************************
//
//
ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
return gBitMasks;
}
//****************************************************************************
// GPEAccel::PowerHandler
//****************************************************************************
// Routine that powers up and down the video clocks.
//
//
VOID GPEFlat::PowerHandler( BOOL bOff)
{
ULONG ulTemp;
//
// Unlock the video attributes register.
//
*RASTER_REALITI_SWLOCK = 0xaa;
//
// See if we are power up the system or shutting down the system.
//
if(bOff)
{
//
// Clear the Sleep signal. This turns off the LCD.
//
if( m_Registry.fSleepSignalActive )
{
ulTemp = *GPIO_PADR;
*GPIO_PADR = ulTemp & ~0x2;
}
*RASTER_VIDEOATTRIBS = ~VIDEOATTRIBS_EN & m_ulVideoAttrib ;
}
else
{
//
// Set the Sleep Signal. This turns on the LCD.
//
if( m_Registry.fSleepSignalActive )
{
ulTemp = *GPIO_PADR;
*GPIO_PADR = ulTemp | 0x2;
}
*RASTER_VIDEOATTRIBS = m_ulVideoAttrib ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -